feat: Implement enters operator >>
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Also added paranthesization of fostr expressions. Finally managed to cast code generation in terms of bottomup processing of a local strategy. Resolves #1.
This commit is contained in:
parent
527f802793
commit
a564b2274d
8 changed files with 97 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