[antlr-interest] text associated with production

mzukowski at yci.com mzukowski at yci.com
Wed Apr 16 08:02:56 PDT 2003


Tokens by default store the line and column of the start of the token.  So
keep your original file around and then when you have the first and last
tokens of the section you want to reproduce, simply use the line and column
to index into your file to get that region.

Monty


-----Original Message-----
From: Nitin Gupta [mailto:nitin_bitkmc at yahoo.com]
Sent: Tuesday, April 15, 2003 10:56 PM
To: antlr-interest at yahoogroups.com
Subject: RE: [antlr-interest] text associated with production


Yes, i want white spaces also, because i want the entire text of the
production. But i cud not understand the approach which wud give me the text
without white spaces. Please give some more information on that.

mzukowski at yci.com wrote: 
Either way will work with different results. It's not clear whether the
original poster really wanted to preserve whitespace or not.

Monty

-----Original Message-----
From: Albert Huh [mailto:albert.huh at embarcadero-ca.com]
Sent: Tuesday, April 15, 2003 9:32 AM
To: antlr-interest at yahoogroups.com
Subject: RE: [antlr-interest] text associated with production


Stripped tokens shouldn't really be a problem. The original problem was to
get the text of the production, not the original stream. We ONLY want the
text of the matched tokens (or terminal nodes) for a rule.

Tokens that are skipped in the lexer will never be matched in the parser.
What does it matter if they are skipped?



-----Original Message-----
From: Andrew Deren [mailto:andrew at adersoftware.com]
Sent: Tuesday, April 15, 2003 12:02 PM
To: antlr-interest at yahoogroups.com
Subject: RE: [antlr-interest] text associated with production


But I think the problem with that approach would be that you will have some
things stripped out (like white space if you have that skipped)

One possible solution I think would be to get position of the first token
and position and length of the last token in a group, and then using that
information get the text data from the input.

-----Original Message-----
From: mzukowski at yci.com [mailto:mzukowski at yci.com] 
Sent: Tuesday, April 15, 2003 9:13 AM
To: antlr-interest at yahoogroups.com

Antlr doesn't do this for you. You need to collect the tokens and get the
text out of them yourself. Or build a tree in that rule and get the text
from the nodes in the tree.

Monty

-----Original Message-----
From: Nitin Gupta [mailto:nitin_bitkmc at yahoo.com]
Sent: Tuesday, April 15, 2003 6:02 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] text associated with production


Hi all
i want to get complete text associated with productions as we can do for
tokens. lets say following is a production
forStatement: forKeyword LPAREN initial semiColon 
final semiColon step RPAREN StatementBlock ;
i want to get the complete text associated with forStatement as we can do
for LPAREN and RPAREN.
Is there any such option in antlr.
Thanks and regards
Nitin Gupta





Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo. 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 






Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 





Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




Your use of Yahoo! Groups is subject to htt




Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo. 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list