feat: Implement enters operator >> (#8)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Also adds parenthesization of fostr expressions. Recasts code generation in terms of bottomup processing of a local strategy. Resolves #1. Co-authored-by: Glen Whitney <glen@studioinfinity.org> Reviewed-on: #8 Co-Authored-By: Glen Whitney <glen@nobody@nowhere.net> Co-Committed-By: Glen Whitney <glen@nobody@nowhere.net>
This commit is contained in:
parent
527f802793
commit
2e49065031
8 changed files with 100 additions and 36 deletions
|
@ -71,4 +71,37 @@ stdio << 72 + 87 + 33 << 291
|
|||
/** md
|
||||
```
|
||||
Running this program produces a nice palindromic output: "192291".
|
||||
|
||||
And because sometimes you want to emphasize the value and propagate that
|
||||
instead of the stream, you can also write these expressions "the other way"
|
||||
with `>>`; both forms return the first argument:
|
||||
```fostr
|
||||
**/
|
||||
|
||||
/** md */ test enters_twice [[
|
||||
(7 + 8 >> stdio + 9) >> stdio
|
||||
]]/* **/ parse to
|
||||
Enters(Sum([Int("7"), Enters(Int("8"), Stdio()), Int("9")]), Stdio())
|
||||
/** writes
|
||||
824**/
|
||||
|
||||
/* Extra tests not in the tour */
|
||||
|
||||
test receive_enter [[
|
||||
stdio << (7 + 8 >> stdio + 9)
|
||||
]]/* **/ parse to
|
||||
Receives(Stdio(), Sum([Int("7"), Enters(Int("8"), Stdio()), Int("9")]))
|
||||
/** writes
|
||||
824**/
|
||||
|
||||
test enter_receive [[
|
||||
(7 + 8 >> stdio + 9) >> (stdio << 9 + 2)
|
||||
]]/* **/ parse to
|
||||
Enters(Sum([Int("7"),Enters(Int("8"),Stdio()),Int("9")]),
|
||||
Receives(Stdio(),Sum([Int("9"),Int("2")])))
|
||||
/** writes
|
||||
81124**/
|
||||
|
||||
/** md
|
||||
```
|
||||
**/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue