ANTLR v3 greedy=false

Amal <akhailtash@gmail.com>
Wed, 5 Dec 2007 14:43:29 -0800 (PST)

          From comp.compilers

Related articles
ANTLR v3 greedy=false akhailtash@gmail.com (Amal) (2007-12-05)
| List of all articles for this month |

From: Amal <akhailtash@gmail.com>
Newsgroups: comp.compilers
Date: Wed, 5 Dec 2007 14:43:29 -0800 (PST)
Organization: Compilers Central
Keywords: parse, question

I need to extract the multi-line comments from a C/C++ source file.
Most grammars deal with throwing out the ML_COMMENT like below:


ML_COMMENT
    : '/*' (options {greedy=false;} : .)* '/*' {skip();}
    ;


How do I keep the comment lines? I need something like this:


comment : '/*' COMMENT_TEXT '*/' ;


I am confused as how to define COMMENT_TEXT in ANTLR v3.


COMMENT_TEXT : ?????? ;


Any hints and pointers are appreciated.
-- Amal



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.