parent
2e49065031
commit
eaa06e62eb
9 changed files with 58 additions and 33 deletions
|
@ -14,7 +14,8 @@ that writes the sum of the ASCII codes for 'H', 'W', and '!' to standard output:
|
|||
|
||||
/** md */ test emit_sum [[
|
||||
stdio << 72 + 87 + 33
|
||||
]]/* **/ parse to Receives(Stdio(), Sum([Int("72"), Int("87"), Int("33")]))
|
||||
]]/* **/ parse to TopLevel(Receives(Stdio(),
|
||||
Sum([Int("72"), Int("87"), Int("33")])))
|
||||
/** writes
|
||||
192**/
|
||||
|
||||
|
@ -62,9 +63,9 @@ left-associative, so that way we can chain insertions into a stream:
|
|||
|
||||
/** md */ test emit_twice [[
|
||||
stdio << 72 + 87 + 33 << 291
|
||||
]]/* **/ parse to Receives(
|
||||
Receives(Stdio(), Sum([Int("72"), Int("87"), Int("33")])),
|
||||
Int("291"))
|
||||
]]/* **/ parse to TopLevel(
|
||||
Receives(Receives(Stdio(), Sum([Int("72"), Int("87"), Int("33")])),
|
||||
Int("291")))
|
||||
/** writes
|
||||
192291**/
|
||||
|
||||
|
@ -80,25 +81,48 @@ with `>>`; both forms return the first argument:
|
|||
|
||||
/** md */ test enters_twice [[
|
||||
(7 + 8 >> stdio + 9) >> stdio
|
||||
]]/* **/ parse to
|
||||
Enters(Sum([Int("7"), Enters(Int("8"), Stdio()), Int("9")]), Stdio())
|
||||
]]/* **/ parse to TopLevel(
|
||||
Enters(Sum([Int("7"), Enters(Int("8"), Stdio()), Int("9")]), Stdio()))
|
||||
/** writes
|
||||
824**/
|
||||
|
||||
/** md
|
||||
```
|
||||
|
||||
### Layout in fostr
|
||||
|
||||
Expressions may be laid out onto multiple lines, as long as all continuation
|
||||
lines are indented from the start of the initial line:
|
||||
```fostr
|
||||
**/
|
||||
|
||||
/** md */ test receive_enter_break [[
|
||||
stdio <<
|
||||
7
|
||||
+ 8 >> stdio
|
||||
+ 9
|
||||
]]/* **/ parse to TopLevel(
|
||||
Receives(Stdio(), Sum([Int("7"), Enters(Int("8"), Stdio()), Int("9")])))
|
||||
/** writes
|
||||
824**/
|
||||
|
||||
/** md
|
||||
```
|
||||
(So for example you will get a parse error with something like this:)
|
||||
```fostr
|
||||
**/
|
||||
|
||||
/** md */ test enter_receive_bad_break [[
|
||||
(7 + 8 >> stdio + 9)
|
||||
>> (stdio << 9 + 2)
|
||||
]] /* **/ parse fails
|
||||
|
||||
/* 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
|
||||
]]/* **/ parse to TopLevel(
|
||||
Enters(Sum([Int("7"),Enters(Int("8"),Stdio()),Int("9")]),
|
||||
Receives(Stdio(),Sum([Int("9"),Int("2")])))
|
||||
Receives(Stdio(),Sum([Int("9"),Int("2")]))))
|
||||
/** writes
|
||||
81124**/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue