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-18 04:17:05 +00:00
|
|
|
lexical sorts
|
|
|
|
|
|
|
|
STRING_LITERAL
|
|
|
|
|
|
|
|
lexical syntax
|
|
|
|
|
|
|
|
STRING_LITERAL = "'"~[\']*"'"
|
|
|
|
|
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-18 04:17:05 +00:00
|
|
|
Ex.Int = INT
|
|
|
|
Ex.LitString = STRING_LITERAL
|
2021-02-19 03:41:54 +00:00
|
|
|
Ex.EscString = STRING
|
2021-02-18 04:17:05 +00:00
|
|
|
Ex.Stream = <stream>
|
|
|
|
Ex.Sum = <<Ex> + <Ex>> {left}
|
2021-03-13 19:30:23 +00:00
|
|
|
Ex.Concat = <<Ex> ++ <Ex>> {left}
|
2021-02-18 04:17:05 +00:00
|
|
|
Ex.Gets = [[Ex] << [Ex]] {left}
|
2021-02-18 20:18:47 +00:00
|
|
|
Ex.DefGets = [<<< [Ex]]
|
2021-02-18 04:17:05 +00:00
|
|
|
Ex.To = [[Ex] >> [Ex]] {left}
|
2021-02-18 20:18:47 +00:00
|
|
|
Ex.DefTo = [[Ex] >>>]
|
2021-03-13 19:30:23 +00:00
|
|
|
Ex.Emits = <<Ex>!>
|
|
|
|
Ex.DefEmits = <!!>
|
2021-02-06 05:11:41 +00:00
|
|
|
|
2021-02-18 04:17:05 +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-18 20:18:47 +00:00
|
|
|
> Ex.DefTo
|
2021-03-13 19:30:23 +00:00
|
|
|
> {Ex.Sum Ex.Concat}
|
2021-02-18 20:18:47 +00:00
|
|
|
> Ex.DefGets
|
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
|