[antlr-interest] retaining comments
cintyram at yahoo.com
Thu Oct 10 12:25:43 PDT 2002
im writing a translator from language A to language B ;
most of the statements in A which when written are finished within one
line and are optionally followed but a comment can be translated as is
to the target ; eg:
int a,b,c ;// comment <===> a,b,c : INTEGER ; # comment
but for mor ethan one line , retaining comments has become an issue
int a, // comment a
c ;// comment c
since a comment can in principle appear any where;
int a //
for the other productions which are more complex, it appears like
rule : ( CMNT)? sub_1 ( CMNT)? sub_2 (CMNT)?
hope you get the picture.. so i decided to write my own parser and
process the source line by line ;
bu tnow it looks like i have to use a tool the code is already a few
hundred lines and does a beautiful job of translating but after two
days when i look at the code i find it difficult to go thru . so i cant
deliver it to the client !!!
and now im considering using antlr again.. but ho9w and wehre do i get
to an example which can show how to retian comments?
since the retaining comments problem is with yacc also, but antlr
offers some cool features.. i opt antlr.. but now im stuck !!
any pointers or links to examples showing how to retain comments will
be appreciated.. mean while im trying to understand what hidden token
streams are all about;
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest