2021-01-30 20:27:10 +00:00
|
|
|
module fostr
|
|
|
|
|
|
|
|
imports
|
|
|
|
|
|
|
|
Common
|
|
|
|
|
|
|
|
context-free start-symbols
|
|
|
|
|
2021-02-01 08:29:00 +00:00
|
|
|
Start
|
2021-01-30 20:27:10 +00:00
|
|
|
|
|
|
|
context-free sorts
|
|
|
|
|
2021-02-06 05:11:41 +00:00
|
|
|
Start LineSeq Line Ex
|
2021-01-30 20:27:10 +00:00
|
|
|
|
|
|
|
context-free syntax
|
|
|
|
|
2021-02-06 05:11:41 +00:00
|
|
|
Start.TopLevel = LineSeq
|
|
|
|
|
|
|
|
LineSeq = <<ln:Ex>> {layout(offside ln)}
|
|
|
|
LineSeq.Sequence = sq:Ex+ {layout(align-list sq)}
|
|
|
|
|
|
|
|
Ex+ = Ex+ ln:Ex {layout(offside ln)}
|
2021-02-01 08:29:00 +00:00
|
|
|
|
2021-01-30 23:37:53 +00:00
|
|
|
Ex.Int = INT
|
2021-02-06 05:11:41 +00:00
|
|
|
Ex.Stream = <stream>
|
|
|
|
Ex.Sum = [[Ex] + [Ex]] {left}
|
|
|
|
Ex.Gets = [[Ex] << [Ex]] {left}
|
|
|
|
Ex.To = [[Ex] >> [Ex]] {left}
|
|
|
|
|
2021-02-01 01:46:31 +00:00
|
|
|
Ex = <(<Ex>)> {bracket}
|
2021-01-30 23:37:53 +00:00
|
|
|
|
|
|
|
context-free priorities
|
|
|
|
|
2021-02-06 05:11:41 +00:00
|
|
|
Ex.To
|
2021-02-01 01:46:31 +00:00
|
|
|
> Ex.Sum
|
2021-02-06 05:11:41 +00:00
|
|
|
> Ex.Gets,
|
2021-01-30 23:37:53 +00:00
|
|
|
|
|
|
|
// prevent cycle: no singletons
|
2021-02-06 05:11:41 +00:00
|
|
|
LineSeq.Sequence <0> .> Ex+ = Ex,
|
2021-01-30 23:37:53 +00:00
|
|
|
|
2021-02-06 05:11:41 +00:00
|
|
|
// flat: No LineSeq immediately in LineSeq
|
|
|
|
Ex+ = Ex <0> .> LineSeq.Sequence,
|
|
|
|
Ex+ = Ex+ Ex <1> .> LineSeq.Sequence
|