[antlr-interest] semantic analysis
John B. Brodie
jbb at acm.org
Fri Mar 19 17:35:27 PDT 2010
On Fri, 2010-03-19 at 17:01 -0400, venkat medhaj wrote:
> I have a simple grammar for which I was able to walk through the AST and
> printout the input text to the console. I learned that we need to put the
> information in the symbol table and do the semantic analysis from there on.
> How , what information should I put into the symbol table and how do I check
> for type errors ?
> Let say, I have something like a + b, given that I am able to walk through
> the AST, how do I do the type checking for this little case?
> Any simple code snippets would be appreciated.
Attached please find an example Expression parsing suite for ANTLRv3. I
intended for this to be a simple tutorial example for tree rewriting. It
is complete, but not documented. So, as is, it is not a very good
example, but hopefully you can see one possibility for your solution (i
It has 4 phases: 1) parsing, 2) type checking, 3) instruction selection,
and 4) evaluation. There is a grammar that drives each phase. Probably
start by looking at the Main.java and try to figure out where we go from
there... (sorry for the lack of commentary/documentation)
Hope this helps....
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 8571 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20100319/984caea2/attachment.bin
More information about the antlr-interest