[antlr-interest] Error Handling in AntLR 3 (beginner)
Rafael C.P.
kurama.youko.br at gmail.com
Wed Jun 11 11:53:31 PDT 2008
Hi! I'm new to AntLR (and, to some extent, to Java as well) and I'd like to
know how to handle errors in AntLR 3. Just an example I'm using to test it:
program
scope {
Scope globalScope;
Scope currentScope;
}
@init {
$program::globalScope = new Scope();
$program::currentScope = $program::globalScope;
System.out.println("program start");
throw new Exception("bla");
}
: declf*
;
But I can't throw any exception here, because there isn't a "throws" header
in the method. The actual piece of code requiring it:
declf
scope {
FunctionSymbol currentFunction;
}
: ftype IDF {
if ($program::currentScope.lookup($IDF.text) == null) {
$declf::currentFunction =
(FunctionSymbol)$program::currentScope.defineFunction($IDF.text,
$ftype.text);
}
else throw new Exception("Duplicated Entry");
} args end_declf
;
Thanks in advance!
=========
Rafael C.P.
=========
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080611/324cc2ed/attachment.html
More information about the antlr-interest
mailing list