Greetings! On Fri, 2010-03-19 at 17:01 -0400, venkat medhaj wrote: > Hi, > > 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 hope). 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.... -jbb
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
expressions.tgz
Description: application/compressed-tar
-- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
