similar to Shortening the parse tree
i want to make the parse tree more compact
i have this rule
If {
keyword<"if"> expression
keyword<"then"> expression
keyword<"else"> expression
}
which will parse
if a then b else c
==>
If(if,a,then,b,else,c)
how can i remove the if/then/else keywords from the parse tree?
so that i get
if a then b else c
==>
If(a,b,c)
as workaround im using tokens with lowercase names …
maybe there is a prettier solution?
If {
hiddenKeywordIf expression
hiddenKeywordThen expression
hiddenKeywordElse expression
}
@tokens {
hiddenKeywordIf { "if" }
hiddenKeywordThen { "then" }
hiddenKeywordElse { "else" }
@precedence {
hiddenKeywordIf, hiddenKeywordThen, hiddenKeywordElse,
otherToken1, otherToken2
}
}