[antlr-interest] Problem of EOS

sebast sebast.65 at gmail.com
Fri Feb 29 09:48:00 PST 2008


hi,
I use antlr 3.0.1
I have a problem with a simple grammar :
grammar gramm;
options {
    k=2;
    output=AST;
    ASTLabelType=CommonTree;
    }
   
tokens {DECL;}

@header {package com.ast;}
@lexer::header {package com.ast;}

programme
    : (localDeclaration EOS)* -> ^(DECL localDeclaration*)
    ;
   
localDeclaration
    :    'def' 'var' Identifier 'as' ('c' | 'l')
    ;

   

// LEXER
   
DOT    
    :    '.' { if (input.LA(1) == ' ' | input.LA(1) == '\n' | 
input.LA(1)== '\t' | input.LA(1)== EOF)} {$type = EOS;}
    ;

fragment EOS : '.' (EOF|WS|NL);


WS  :      (' '|'\t'|'\f') {$channel=HIDDEN;}
    ;

NL     :    ('\r'|'\n') {$channel=HIDDEN;}
    ;
   
Identifier
    :   Letter (Letter)*
    ;

fragment
Letter
    :  '\u0024' |
       '\u0041'..'\u005a' |
       '\u005f' |
       '\u0061'..'\u007a' |
       '\u00c0'..'\u00d6' |
       '\u00d8'..'\u00f6' |
       '\u00f8'..'\u00ff' |
       '\u0100'..'\u1fff' |
       '\u3040'..'\u318f' |
       '\u3300'..'\u337f' |
       '\u3400'..'\u3d2d' |
       '\u4e00'..'\u9fff' |
              '\uf900'..'\ufaff'
    ;

For the test I use this :
    def   var  varbureausrvhndl       as  c.
    def   var vardebug          as l.
  def    var vardebugfic       as c.
  def     var vardebugcrit      as c.
  def    var vardebugtrace     as c.

The dot at the end of the first line should be recognized as an EOS, but 
it is not !

would you have any idea about the source of the problem ?

Thanks a lot.


More information about the antlr-interest mailing list