[antlr-interest] retaining comments
Bogdan Mitu
bogdan_mt at yahoo.com
Fri Oct 11 02:19:09 PDT 2002
Hi ram,
It's usually a good idea to read the documentation first ;-)
See http://www.antlr.org/fieldguide/whitespace/index.html
Cheers,
Bogdan
--- Sriram Durbha <cintyram at yahoo.com> wrote:
> hi,
> 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
>
> eg:
> int a, // comment a
> b,
> c ;// comment c
>
> since a comment can in principle appear any where;
> eg:
>
> int a //
> , //
> b //
> , //
> 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;
>
> thanks
> ram
>
>
>
>
>
>
> __________________________________________________
> Do you Yahoo!?
> Faith Hill - Exclusive Performances, Videos & More
> http://faith.yahoo.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list