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
|
|
|
|
2021-02-11 18:02:43 +00:00
|
|
|
lexical sorts
|
|
|
|
|
|
|
|
STRING_LITERAL
|
|
|
|
|
|
|
|
lexical syntax
|
|
|
|
|
2021-02-16 17:46:12 +00:00
|
|
|
STRING_LITERAL = "'"~[\']*"'"
|
2021-02-11 18:02:43 +00:00
|
|
|
|
2021-01-30 20:27:10 +00:00
|
|
|
context-free sorts
|
|
|
|
|
2021-02-10 20:47:34 +00:00
|
|
|
Start LineSeq Line OptTermEx TermExLst TermEx Ex
|
2021-01-30 20:27:10 +00:00
|
|
|
|
|
|
|
context-free syntax
|
|
|
|
|
2021-02-06 05:11:41 +00:00
|
|
|
Start.TopLevel = LineSeq
|
|
|
|
|
2021-02-10 20:47:34 +00:00
|
|
|
LineSeq = Line
|
|
|
|
LineSeq.Sequence = sq:Line+ {layout(align-list sq)}
|
2021-02-06 05:11:41 +00:00
|
|
|
|
2021-02-10 20:47:34 +00:00
|
|
|
Line = OptTermEx
|
|
|
|
Line.ISequence = TermExLst OptTermEx {layout(0.first.line == 1.first.line)}
|
|
|
|
|
|
|
|
TermExLst.Prior = TermEx+
|
|
|
|
|
|
|
|
OptTermEx = ex:Ex {layout(offside ex)}
|
|
|
|
OptTermEx = te:TermEx {layout(offside te)}
|
|
|
|
|
|
|
|
TermEx.Terminate = <<Ex>;>
|
2021-02-01 08:29:00 +00:00
|
|
|
|
2021-02-11 18:02:43 +00:00
|
|
|
Ex.Int = INT
|
2021-02-16 17:46:12 +00:00
|
|
|
Ex.LitString = STRING_LITERAL
|
2021-02-11 18:02:43 +00:00
|
|
|
Ex.Stream = <stream>
|
|
|
|
Ex.Sum = <<Ex> + <Ex>> {left}
|
|
|
|
Ex.Gets = [[Ex] << [Ex]] {left}
|
|
|
|
Ex.To = [[Ex] >> [Ex]] {left}
|
2021-02-06 05:11:41 +00:00
|
|
|
|
2021-02-11 18:02:43 +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-10 20:47:34 +00:00
|
|
|
LineSeq.Sequence <0> .> Line+ = Line
|