fostr/syntax/fostr.sdf3

44 lines
783 B
Plaintext
Raw Permalink Normal View History

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