Consider the syntax definition
definition module Exp exports sorts Exp context-free syntax "nil" -> Exp lexical syntax [\t\n\r\ ] -> LAYOUT
Representation in AsFix2ME:
appl( prod([lit("nil")], cf(sort("Exp")), no-attrs) , [lit("nil")] )
Representation in AsFix2:
appl( prod([lit("nil")], cf(sort("Exp")), no-attrs) , [ appl( prod( [char-class([110]), char-class([105]), char-class([108])] , lit("nil") , no-attrs ) , [110, 105, 108] ) ] )
Consider the syntax definition
definition module Exp hiddens sorts IntConst exports sorts Exp lexical syntax [\ \t\n] -> LAYOUT [0-9]+ -> IntConst context-free syntax IntConst -> Exp {cons("Int")}
sdf2table -i Exp-tiny.def.def -o Exp-tiny.tbl -m Exp
Stratego Script to extract the tree related to the context-free symbol IntConst:
import simple-traversal ;; oncetd(?appl(prod(_, cf(sort("IntConst")), _), _); ?x) ;; !x ;;
Parse the expression "12" to AsFix2?
echo "1" | sglr -2 -p Exp-tiny.tbl | stratego-shell --script extract-lex.srts | pp-aterm
appl( prod( [lex(sort("IntConst"))] , cf(sort("IntConst")) , no-attrs ) , [ appl( prod( [lex(iter(char-class([range(48, 57)])))] , lex(sort("IntConst")) , no-attrs ) , [ appl( prod( [ lex(iter(char-class([range(48, 57)]))) , lex(iter(char-class([range(48, 57)]))) ] , lex(iter(char-class([range(48, 57)]))) , attrs([assoc(left)]) ) , [ appl( prod( [char-class([range(48, 57)])] , lex(iter(char-class([range(48, 57)]))) , no-attrs ) , [49] ) , appl( prod( [char-class([range(48, 57)])] , lex(iter(char-class([range(48, 57)]))) , no-attrs ) , [50] ) ] ) ] ) ] )
echo "12" | sglr -m -p Exp-tiny.tbl | stratego-shell --script extract-cf.strs | pp-aterm
appl( prod( [lex(sort("IntConst"))] , cf(sort("IntConst")) , no-attrs ) , [ appl( list(iter-star(char-class([range(0, 255)]))) , [49, 50] ) ] )
Now consider the syntax definition:
definition module Exp hiddens sorts DecConst exports sorts Exp lexical syntax [\ \t\n] -> LAYOUT [0-9]+ "." [0-9]+ -> DecConst {cons("DecConst")} context-free syntax DecConst -> Exp
Parsing to AsFix2ME:
echo "13.25" | sglr -m -p Exp-tiny.tbl | stratego-shell --script extract-cf.strs | pp-aterm
appl( prod( [lex(sort("DecConst"))] , cf(sort("DecConst")) , no-attrs ) , [ appl( list(iter-star(char-class([range(0, 255)]))) , [49, 51, 46, 50, 53] ) ] )
Consider the syntax definition
definition module Exp hiddens sorts DecConst exports sorts Exp context-free syntax DecConst -> Exp syntax [0-9]+ "." [0-9]+ -> DecConst {cons("DecConst")} DecConst -> <DecConst-CF> lexical syntax [\t\n\r\ ] -> LAYOUT
In this case the DecConst application is represented as a tree in AsFix2ME, just like in AsFix2.