[antlr-interest] Problems with Pre-processing instructions of C#

Eduard Ralph hallo at eduard-ralph.de
Sun Sep 20 10:23:42 PDT 2009


Hi community,

I'm fighting with the processing of pre-processing instructions according to C# specs. The BNF is:

Whitespace(opt) '#' Whitespace(opt) 'error' input-characters
Whitespace(opt) '#' Whitespace(opt) 'warning' input-characters
Whitespace(opt) '#' Whitespace(opt) 'line'  ...

where
 Whitespace(opt) can be optionally one or more spaces ('\u0020','\u00A0', and a few more)
 Input-characters is anything except newline ('\n', and a few more)

I wrote in the Lexer, where the other rules are fragments


PP_DIAGNOSTIC      :        (WHITESPACE* HASH WHITESPACE* 'error')=>WHITESPACE* HASH WHITESPACE* ERROR INPUT_CHARACTER*
                            |        (WHITESPACE* HASH WHITESPACE* 'warning')=>WHITESPACE* HASH WHITESPACE* WARNING INPUT_CHARACTER*
                            ;


PP_LINE                 :        (WHITESPACE* HASH WHITESPACE* 'line')=> WHITESPACE* HASH WHITESPACE* LINE PP_LINE_INDICATOR NEWLINE
                            ;

fragment PP_LINE_INDICATOR      :        INTEGER_LITERAL PP_FILE_NAME?
                                               |        IDENTIFIER_OR_KEYWORD
                                               ;

fragment PP_FILE_NAME              :        STRING_LITERAL
                                               ;

fragment HASH                          :        '#';


Unfortunately the DFA in the Lexer doesn't recognize correctly which Lexer rule applies and now I'm wondering why this is so. Some thoughts and help would be greatly appreciated.

Thanks in advance,

Eduard
________________________________
The essential is to excite the spectators. If that means playing Hamlet
on a flying trapeze or in an aquarium, you do it.
- Orson Welles

It is not the strongest of the species that survives, nor the most
intelligent that survives. It is the one that is the most adaptable to change.
- Charles Darwin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090920/1193342e/attachment.html 


More information about the antlr-interest mailing list