Hello all,
     I have modified the C++ grammar to support numbers with units.
     float j = 3.0mV;
     I created an action to replace the 3.0mV with 0.003 using the 
following code in the grammar:
@init
{
   string newNum(" ");
}

inside a rule alternative:
     |       un=UNITNUM //EAC here is where we replace the prefix with 
multiplier
                           {
                           ConvertToNum($un, newNum);
                           printf("UnitNum= %s %s\n", $un.text->chars, 
newNum.c_str());
                           $un.text = newNum;
                           } -> {newNum} // this is where I get lost

So how do I create the new pANTLR_BASE_TREE node and assign it the 
string of interest?

I was thinking something like the following, but I don't know how to 
assign the new token to the tree node.

            pANTLR3_COMMON_TOKEN  newTok = new ANTLR3_COMMON_TOKEN(un);
            pANTLR3_STRING newString = new ANTLR3_STRING();
            newString->set(newString, newNum.c_str());
             newTok->setText(newTok, newString);
            pANTLR3_BASE_TREE newNumTree = new ANTLR3_COMMON_TREE(<put 
in the token?>);

Any help would be greatly appreciated!

-- 
Eric Craft
ShibaSoku Co., Ltd.
Software Engineer
848 Wakamatsu-cho
Tokorozawa, Saitama 359-0032 Japan
TEL 81-4-2994-1154
[email protected]


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
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].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to