addPosInfo adds position information to an AsFix2ME parse tree.
The following syntax definition defines a tiny language of assignments and expressions.
definition module Main exports context-free start-symbols Stm* sorts Id IntConst lexical syntax [\ \t\n] -> LAYOUT [a-zA-Z]+ -> Id [0-9]+ -> IntConst sorts Stm context-free syntax Id ":=" Exp -> Stm {cons("Assign")} sorts Exp context-free syntax Id -> Exp {cons("Var")} IntConst -> Exp {cons("Int")} Exp "+" Exp -> Exp {left, cons("Plus")}
Generate a parse table:
> sdf2table -i Foo.def -o Foo.tbl
Input file:
x := 5 y := x + 4 z := x + y
Parse the input and have a look at the result in abstract syntax:
> sglr -i foo.txt -p Foo.tbl | addPosInfo -p ./foo.txt -m | implodePT | pp-aterm
Notes:
-p
) of the input file.
-2
argument.