Hi.
I have following input: four hex digits, representing 32-bit integer value.
It can be defined:
11 22 AA BB
or undefined:
XX XX XX XX
and here is according rule:
dword_ : BYTE_ BYTE_ BYTE_ BYTE_;
Now i'm trying to construct AST from this rule, which looks like (INT32
0xBBAA2211) or (INT32 UNDEFINED), where INT32 and UNDEFINED - some imaginary
tokens. I'm understand, that i can't just put $text in -> ^(INT32 $text), so
i tried to construct Token object. And here is what i get:
dword_ : BYTE_ BYTE_ BYTE_ BYTE_
{
//this func parses $text and makes new CommonToken
Token t=makeDwordToken($text);
//now i'm popping four BYTE_ tokens from stream_BYTE_
//if i don't do that, i'll get a first byte from dword_ in my tree
stream_BYTE_.nextNode();
stream_BYTE_.nextNode();
stream_BYTE_.nextNode();
stream_BYTE_.nextNode();
//now pushing my handmade token
stream_BYTE_.add(t);
}
-> ^( INT_ {stream_BYTE_.nextNode()})
//and finally make it a tree's child
;
Now i'm doubting in what i have wrote, but still can't find other way to
achieve this goal.
Any ideas?
P.S. Sorry for if my English looks terrible.
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=.
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address