[antlr-interest] ANTLR Python and SemanticException
Klaas Hofstra
antlr at klaashofstra.com
Tue Jun 21 13:31:39 PDT 2005
I think I have found a bug in ANTLR Python.
This rule:
type
: t:ID { isTypeName(#t.getText()) }?
;
generates this python code for the parser:
if not isTypeName(t_AST.getText()) :
raise SemanticException(" isTypeName(t_AST.getText()) ")
This code does not run correctly because the global name 'SemanticException'
is not defined. It needs to be replaced by antlr.SemanticException in order
to work correctly.
I also came across a typo in the file examples/python/tinybasic/basic.g:
global numericUnaryExpression
:
(
p:PLUS^ {#p.setType(UNARY_PLUS);}
| m:MINUS^ {#m.setType(UNARY_PLUS);}
)? numericPrimaryExpression
;
I think the second UNARY_PLUS should be a UNARY_MINUS.
Cheers,
Klaas
More information about the antlr-interest
mailing list