[antlr-interest] Problems in upgrading to ANTLR v3.1

David Goldberg david at gohazel.com
Thu Aug 28 12:54:07 PDT 2008


I finally upgraded my ANTLR version from 3.0.1 to 3.1

I'm using ANTLRWorks 1.2b5 and and C# libraries that came with ANTLR v3.1b1 (since I couldn't find any in 3.1)

I have a tree grammar with a line that looks like:
block     :               thelb=LBRACE (blockExprList)? RBRACE -> ^(BLOCK[$thelb] blockExprList?);

In the previous version of ANTLR, this did what I expected - create a BLOCK node with syntax information taken from the LBRACE token. Now, it just gives me a null pointer exception, claiming that thelb is null.

The input is:
{ 1; }

My full grammar consists of the following:

grammar LangTest;

options
{language = 'CSharp2';
output=AST;
ASTLabelType=CommonTree;
}

tokens {
   PROG;
   BLOCK;
}

prog       :               topLevelExprList? -> ^(PROG topLevelExprList?)
                ;

topLevelExprList
                :               (blockExpr)+
                ;
blockExpr
                :               statement
                ;
statement
                :               (block)=>block
                |              emptyStatement
                |              numericLiteral SEMI!
                ;
emptyStatement
                :               emptyExpr SEMI!
                ;
emptyExpr
                :
                ;
block     :               thelb=LBRACE (blockExprList)? RBRACE -> ^(BLOCK[$thelb] blockExprList?);
blockExprList
                :               (blockExpr)+
                ;

numericLiteral
                :               DECIMALLITERAL;
WS :
                (' '
| '\t'
| '\n'
| '\r'
|              '\u000C')
{ $channel = HIDDEN; }
;

LBRACE :               '{';
RBRACE                :               '}';
SEMI      :                ';' ;

DECIMALLITERAL
                :               INT;
fragment
INT
                :               ('0' | '1'..'9' ('0'..'9')*);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080828/3aa31225/attachment.html 


More information about the antlr-interest mailing list