[antlr-interest] [C target] [3.1.1] Deriving imaginary nodes from real tokens
antlr at mirality.co.nz
Fri Dec 12 18:40:05 PST 2008
At 01:52 13/12/2008, Sven Van Echelpoel wrote:
>Ah, I wondered why there were two forms of the template. Can you
>really pass constructor arguments to nodes created from token
>references? Why would you want to use the info of another token
>(I can buy the text), as in the following 2 argument call:
>-> $b[ $c, "c" ]
I think you've misinterpreted what I was saying. I'm fairly sure
that what you've posted there is *not* legal (it doesn't make
sense to pass two tokens into one construction expression).
As far as I know, the following are the only valid token
construction expressions (I could be wrong about some of the
Copy existing token FOO, or create imaginary token FOO with no
Copy existing token FOO but give it "bar" as text, or create
imaginary token FOO with "bar" as text and no context.
Copy existing token in $b but change the type to FOO.
-> FOO[$b, "bar"]
Copy existing token in $b but change the type to FOO and the text
Copy existing token in $b.
Copy existing token in $b, but change the text to "bar".
(And unfortunately, the C target can't distinguish between #2 and
#3 because the expression can be such that it can't statically
tell whether it returns a string or a token.)
More information about the antlr-interest