[antlr-interest] Getting parse exceptions from a parse run. (topic: Compiler Design workflow)
Raynier van Egmond
rene at c3ismc.com
Wed May 5 12:21:37 PDT 2004
Hi All,
I feel somewhat humbled by the expert advice that cam in reply to my
design workflow question I am not that far in the process yet to play
with the trees and all that.
What I wondered is if there is a way to get some kind of result or
parsing exception thrown my the parser.entryPointMethod() call? I admit
that this may be a typical case of “if all you have is a hammer
everything looks like a nail” but … I’m learning.
Trying to figure out how to build a rather large compiler/evaluator
Content MathML I like to go in little steps. E.g. first doing a large
structure thing proper nesting of the elements… then putting in
attributes, then handling proper data type management… I haven’t figured
out a better way to go through the motions yet.
Now what I would like to do is build my whole suite of UnitTests for the
various rules in my parser/compiler/evaluator:
e.g.
testAPass - Parsing a unary operator apply-element:
<apply><factorial/><cn>4</cn></apply>
testBPass- Parsing a binary operator apply-element:
<apply><plus/><cn>4</cn><cn>3</cn></apply>
testAFail …
..etc..
As I progress the list will grow and as the parser supports more exactly
the properties of the language tests will fail and need to be
re-written.
The typical JUnit patterns I use:
try {
…
assertTrue(“should have thrown exception
XYZ”,false);
} catch (SomeExpectedXYZException e) {
assertTrue(true);
}
try {
…
} catch (SomeUnExpectedException e) {
assertTrue(false);
}
Is there in the parser something that I could ‘hook’ into to get the
status of the parsing process during/after a parse run was executed?
Again many thanks for your support and the good discussions on the list.
Raynier.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.675 / Virus Database: 437 - Release Date: 5/2/2004
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20040505/9ae7041f/attachment.html
More information about the antlr-interest
mailing list