forked from glen/fostr
Glen Whitney
7feddbcfbe
Add the ! postfix operator and !! expression. Also add the ++ string concatenation operator. Also allow specification of standard input in the test scheme. Resolves #7, #18. Co-authored-by: Glen Whitney <glen@studioinfinity.org> Reviewed-on: glen/fostr#25 Co-Authored-By: Glen Whitney <glen@nobody@nowhere.net> Co-Committed-By: Glen Whitney <glen@nobody@nowhere.net>
65 lines
1.2 KiB
Plaintext
65 lines
1.2 KiB
Plaintext
module fostr
|
|
|
|
imports
|
|
|
|
Common
|
|
|
|
context-free start-symbols
|
|
|
|
Start
|
|
|
|
lexical sorts
|
|
|
|
STRING_LITERAL
|
|
|
|
lexical syntax
|
|
|
|
STRING_LITERAL = "'"~[\']*"'"
|
|
|
|
context-free sorts
|
|
|
|
Start LineSeq Line OptTermEx TermExLst TermEx Ex
|
|
|
|
context-free syntax
|
|
|
|
Start.TopLevel = LineSeq
|
|
|
|
LineSeq = Line
|
|
LineSeq.Sequence = sq:Line+ {layout(align-list sq)}
|
|
|
|
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>;>
|
|
|
|
Ex.Int = INT
|
|
Ex.LitString = STRING_LITERAL
|
|
Ex.EscString = STRING
|
|
Ex.Stream = <stream>
|
|
Ex.Sum = <<Ex> + <Ex>> {left}
|
|
Ex.Concat = <<Ex> ++ <Ex>> {left}
|
|
Ex.Gets = [[Ex] << [Ex]] {left}
|
|
Ex.DefGets = [<<< [Ex]]
|
|
Ex.To = [[Ex] >> [Ex]] {left}
|
|
Ex.DefTo = [[Ex] >>>]
|
|
Ex.Emits = <<Ex>!>
|
|
Ex.DefEmits = <!!>
|
|
|
|
Ex = <(<Ex>)> {bracket}
|
|
|
|
context-free priorities
|
|
|
|
Ex.To
|
|
> Ex.DefTo
|
|
> {Ex.Sum Ex.Concat}
|
|
> Ex.DefGets
|
|
> Ex.Gets,
|
|
|
|
// prevent cycle: no singletons
|
|
LineSeq.Sequence <0> .> Line+ = Line
|