forked from glen/fostr
Glen Whitney
991976d3a8
feat: sequencing of expressions with newline to same indent Also revised README to reflect greater emphasis on streams. Haskell code generation unsurprisingly required a fairly significant rework. Resolves #3. Co-authored-by: Glen Whitney <glen@studioinfinity.org> Reviewed-on: glen/fostr#11 Co-Authored-By: Glen Whitney <glen@nobody@nowhere.net> Co-Committed-By: Glen Whitney <glen@nobody@nowhere.net>
44 lines
783 B
Plaintext
44 lines
783 B
Plaintext
module fostr
|
|
|
|
imports
|
|
|
|
Common
|
|
|
|
context-free start-symbols
|
|
|
|
Start
|
|
|
|
context-free sorts
|
|
|
|
Start LineSeq Line Ex
|
|
|
|
context-free syntax
|
|
|
|
Start.TopLevel = LineSeq
|
|
|
|
LineSeq = <<ln:Ex>> {layout(offside ln)}
|
|
LineSeq.Sequence = sq:Ex+ {layout(align-list sq)}
|
|
|
|
Ex+ = Ex+ ln:Ex {layout(offside ln)}
|
|
|
|
Ex.Int = INT
|
|
Ex.Stream = <stream>
|
|
Ex.Sum = [[Ex] + [Ex]] {left}
|
|
Ex.Gets = [[Ex] << [Ex]] {left}
|
|
Ex.To = [[Ex] >> [Ex]] {left}
|
|
|
|
Ex = <(<Ex>)> {bracket}
|
|
|
|
context-free priorities
|
|
|
|
Ex.To
|
|
> Ex.Sum
|
|
> Ex.Gets,
|
|
|
|
// prevent cycle: no singletons
|
|
LineSeq.Sequence <0> .> Ex+ = Ex,
|
|
|
|
// flat: No LineSeq immediately in LineSeq
|
|
Ex+ = Ex <0> .> LineSeq.Sequence,
|
|
Ex+ = Ex+ Ex <1> .> LineSeq.Sequence
|