Glen Whitney
904f651897
All checks were successful
continuous-integration/drone/push Build is passing
Also rudimentary code generation. The difficulty is that for Haskell generation, we need to know whether an expression is a string or in to send it to standard output. So we will need to begin implementation of a type system for fostr.
57 lines
1.0 KiB
Plaintext
57 lines
1.0 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.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> .> Line+ = Line
|