fostr/syntax/fostr.sdf3

38 lines
610 B
Plaintext
Raw Normal View History

module fostr
imports
Common
context-free start-symbols
Start
context-free sorts
Start Ex
context-free syntax
Start.TopLevel = prog:Ex {layout(offside prog)}
Ex.Int = INT
Ex.Stdio = <stdio>
Ex.Sum = {Ex "+"}+
Ex.Receives = [[Ex] << [Ex]] {left}
Ex.Enters = [[Ex] >> [Ex]] {left}
Ex = <(<Ex>)> {bracket}
context-free priorities
Ex.Enters
> Ex.Sum
> Ex.Receives,
// prevent cycle: no singletons
Ex.Sum <0> .> {Ex "+"}+ = Ex,
// flat: no Sum immediately in Sum:
{Ex "+"}+ = Ex <0> .> Ex.Sum,
{Ex "+"}+ = {Ex "+"}+ "+" Ex <2> .> Ex.Sum