[antlr-interest] C++ Comments
eric nelson
wirecracker at gmail.com
Thu Oct 27 06:49:50 PDT 2005
I saw this in Todd King's C# grammar file ... its related ... mabye it'll
give you some ideas? Best, - e
// ***** A.1.1 LINE TERMINATORS *****
protected
NEW_LINE
: ( // carriage return character followed by possible line feed character
{ LA(2)=='\u000A' }? '\u000D' '\u000A'
| '\u000D' // line feed character
| '\u000A' // line feed character
| '\u2028' // line separator character
| '\u2029' // paragraph separator character
)
{newline();}
;
protected
NEW_LINE_CHARACTER
: ('\u000D' | '\u000A' | '\u2028' | '\u2029')
;
protected
NOT_NEW_LINE
: ~( '\u000D' | '\u000A' | '\u2028' | '\u2029')
;
....
....
SINGLE_LINE_COMMENT
: "//"
(NOT_NEW_LINE)*
(NEW_LINE)
{_ttype = Token.SKIP;}
;
On 10/27/05, Henry Butowsky <henryb at ntlworld.com> wrote:
>
> Hi Guys I'm using the following rule in my Lexer to skip C++ style
> comments
>
> CPP_COMMENT: ("//" (~'\n')* '\n')
> { newline(); $setType(antlr::Token::SKIP); };
>
> Upon executing this rule the lexer is "aborted" ( in
> CalcLexer::nextToken() )
>
>
> when I use the string ("//" (~'\n')*) it deletes all text to the end-of
> file ? There is some problem with the '\n' -- Any ideas ?
> Many thx Henry
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20051027/8301b02f/attachment-0001.html
More information about the antlr-interest
mailing list