Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #28

Merged
merged 14 commits into from
Jun 14, 2018
Prev Previous commit
Next Next commit
start reduce, adds WindComp_get_body() function
  • Loading branch information
jweinst1 committed Jun 12, 2018
commit 6c33f074ea2cdcd1fbaae14fc6d56f9c8597086e
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,41 @@ wind> exit
```
At any time in the repl, typing `exit`, will close the program.

#### `-c`:

The `-c` flag allows you to run a string of `Wind` code, like this

```
$ Wind -c "push 5 -> out -> clr"
[ ]
```

#### `-d`:

The `-d` flag allows you to run a string of `Wind` code and also get debug information

```
$ Wind -d "push 5 6 77 44 -> out -> filter > 10 -> out -> filter < 76 -> out"
[ 5 6 77 44 ]
[ 77 44 ]
[ 44 ]
_____Wind___Debug_______
..........State.........
Has Error: false
Mode: Command
Command: null
..........Data.........
Load Buffer: -> [ ]
Active Buffer: -> [ 44 ]
Inactive Buffer: -> [ 77 44 ]
________________________
```

#### `-t`:

The `-t` flag allows for a string of `Wind` code to be run and timed.


## Stage

`Wind` is currently in the alpha development stage, the first release version is still in progress.
2 changes: 2 additions & 0 deletions include/WindComp.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ void WindComp_set_len(unsigned length);

// Returns head byte marker of comp buffer.
unsigned char WindComp_get_head(void);
// Returns the body portion of the comp buffer.
unsigned char* WindComp_get_body(void);

void WindComp_clear(void);
// Writes amount of length bytes from item
Expand Down
3 changes: 2 additions & 1 deletion include/WindType.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ typedef enum
WindCommand_push,
WindCommand_clr,
WindCommand_map,
WindCommand_filter
WindCommand_filter,
WindCommand_reduce
} WindCommand;

const char* WindType_get_str(WindType type);
Expand Down
17 changes: 17 additions & 0 deletions src/code/WindRun.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ int WindRun_exec(const char** code)
case WindCommand_filter:
WindExec_filter();
break;
case WindCommand_reduce:
// handle reduce
break;
}
WindData_load_reset(); // Resets load buf.
WindState_set_cmd(WindCommand_null);
Expand Down Expand Up @@ -318,6 +321,20 @@ int WindRun_command(const char** code)
}
break;

case 'r':
// Due to only one command that starts with f, this does not use static trie
if((*code)[1] == 'e' && (*code)[2] == 'd' && (*code)[3] == 'u' && (*code)[4] == 'c' && (*code)[5] == 'e')
{
*code += 6;
WindState_set_cmd(WindCommand_reduce);
goto TRANS_TO_LOAD;
}
else
{
WindState_write_err("Expected command symbol, found 'r%c%c%c'", *code[1], *code[2], *code[3]);
return 0;
}
break;
case '\0':
goto TRANS_TO_LOAD;
default:
Expand Down
5 changes: 5 additions & 0 deletions src/flow/WindComp.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ unsigned char WindComp_get_head(void)
return WindComp_BUF[0];
}

unsigned char* WindComp_get_body(void)
{
return WindComp_BODY;
}

void WindComp_clear(void)
{
WindComp_ITEM_LEN = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/flow/WindState.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,8 @@ void WindState_print_cmd(void)
case WindCommand_filter:
printf("filter");
break;
case WindCommand_reduce:
printf("reduce");
break;
}
}