Skip to content

Commit

Permalink
working on map
Browse files Browse the repository at this point in the history
  • Loading branch information
jweinst1 committed May 10, 2018
1 parent 53db524 commit 9a7e853
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/WindExec.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ int WindExec_push(WindStream* ws);

int WindExec_clr(WindStream* ws);

int WindExec_map(WindStream* ws);

#endif
7 changes: 5 additions & 2 deletions include/WindType.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
typedef enum
{
WindType_None,
WindType_Bool
WindType_Bool,
WindType_Not,
WindType_Sep
} WindType;

// An enum to track the kinds of Wind Commands.
Expand All @@ -15,7 +17,8 @@ typedef enum
WindCommand_null, // abscence of a command
WindCommand_out,
WindCommand_push,
WindCommand_clr
WindCommand_clr,
WindCommand_map
} WindCommand;

#endif
33 changes: 33 additions & 0 deletions src/code/WindRun.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ int WindRun_exec(WindStream* ws, const char** code)
case WindCommand_clr:
WindExec_clr(ws);
break;
case WindCommand_map:
WindExec_map(ws);
break;
}
WindStream_RESET_LOAD(ws);
ws->command = WindCommand_null;
Expand Down Expand Up @@ -45,6 +48,15 @@ int WindRun_load(WindStream* ws, const char** code)
WindStream_write_err(ws, "Expected separator ->, found '-%c'", (*code)[1]);
return 0; // error
}
case '|':
*code += 1;
WindStream_put(ws, BufKey_load, WindType_Sep);
continue;
case '!':
// not :symbol
*code += 1;
WindStream_put(ws, BufKey_load, WindType_Not);
continue;
case 'T':
if((*code)[1] == 'r' && (*code)[2] == 'u' && (*code)[3] == 'e')
{
Expand Down Expand Up @@ -146,6 +158,27 @@ int WindRun_command(WindStream* ws, const char** code)
return 0;
}
break;
case 'm':
switch((*code)[1])
{
case 'a':
switch((*code)[2])
{
case 'p':
// exec out
*code += 3;
ws->command = WindCommand_map;
goto TRANS_TO_LOAD;
default:
WindStream_write_err(ws, "Expected command symbol, found 'ma%c'", *code[2]);
return 0;
}
break;
default:
WindStream_write_err(ws, "Expected command symbol, found 'm%c'", *code[1]);
return 0;
}
break;
case 'o':
switch((*code)[1])
{
Expand Down
12 changes: 12 additions & 0 deletions src/stream/WindExec.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ int WindExec_out(WindStream* ws, BufKey bkey)
i++;
printf(sbuf->data[i] ? "True " : "False ");
break;
case WindType_Not:
printf("! ");
break;
case WindType_Sep:
printf("| ");
break;
default:
WindStream_write_err(ws, "Cannot recognize item with byte %u", sbuf->data[i]);
return 0;
Expand All @@ -37,3 +43,9 @@ int WindExec_clr(WindStream* ws)
WindStream_reset(ws, BufKey_active);
return 1;
}

int WindExec_map(WindStream* ws)
{

return 1;
}
12 changes: 11 additions & 1 deletion src/util/Debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@

void Debug_buf(WindBuf* wb)
{
int count = 1;
puts("......Buf..Data............");
for(size_t i = 0; i < wb->len; i++)
{
printf("Item: %lu\n", i);
printf("Item @: %lu, place:%d\n", i, count++);
switch(wb->data[i])
{
case WindType_None:
puts("None");
break;
case WindType_Not:
puts("!");
break;
case WindType_Sep:
puts("|");
break;
case WindType_Bool:
i++;
printf("%s\n", (wb->data[i] ? "True" : "False"));
Expand All @@ -37,6 +44,9 @@ void Debug_cmd(WindCommand cmd)
case WindCommand_clr:
puts("Command: clr");
break;
case WindCommand_map:
puts("Command: map");
break;
}
}

Expand Down

0 comments on commit 9a7e853

Please sign in to comment.