forked from glen/fostr
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
|