[antlr-interest] Help : How to return more values in Parser

Premkumar Rathanavelu rprememail at yahoo.com
Fri Mar 25 03:27:44 PST 2005


HI to all.,
  
 Eg:
// in Parser
tokenStream returns [String result = ""]
:
   (id:RET_ID)  {result = id.getText();}  // RET_ID see in Lexer below 
;
/* Q: here if i add (id:ID)+ to return more values. 
        Then I'm getting unexpected result */
 
// in Parser 
LEX_ID
:
  (ID)+     // ID is an identifier
;
RET_ID
:
  (Whitespace)+   (LEX_ID)
;
 
Here in the parser I used to get only value of the token.
 
For eg: /* beginining comes some "Whitespace" */  
           HERE IS A TEST
 
The result : parser gets only one token ID (= HERE) and 
                 leaving other after a whitespace
Coments : The Whitespace rule in the LEX_ID is must
                 for my construct so i cannot delete it.
 
Please give me some tips to solve the problem ..
 
Thanks.,
PREM
 

		
---------------------------------
Do you Yahoo!?
 Yahoo! Small Business - Try our new resources site! 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050325/0fcd329a/attachment.html


More information about the antlr-interest mailing list