[antlr-interest] throws-spec in ANTLR rules -- does nothing?

Joachim Schrod jschrod at acm.org
Sat Nov 13 07:02:12 PST 2010


Hi,

I'm using ANTLR 3.2 with Java code generation.

According to the ANTLR book, p.94, and
http://www.antlr.org/wiki/pages/viewpage.action?pageId=1956, a rule
may have a «throws-spec». But I didn't find an explanation of that
part -- neither in the book nor on the Web site.

If I have a rule that starts with

   remarks throws DiscardPDFException : ...

I would have thought that DiscardPDFException is added to the
throws clause of the generated method; but it isn't done so. ANTLR
expects that clause without error messages, but also without effects.

So my question is:
What's the spec for «throws-spec», syntactically and semantically?

Thanks in advance for any answer,

	Joachim

PS: For now I can make DiscardPDFException a run-time exception,
but I would have preferred to force the caller to declare a catch
clause.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Joachim Schrod				Email: jschrod at acm.org
Roedermark, Germany



More information about the antlr-interest mailing list