fostr/syntax/fostr.sdf3
Glen Whitney 5d81316ce2 feat: sequencing of expressions with newline to same indent
Also revised README to reflect greater emphasis on streams.

  Resolves #3.
2021-02-05 20:13:18 -08:00

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