[antlr-interest] I got the parseing, now how do I do something useful ?

Andrew Deren andrew at adersoftware.com
Thu Feb 27 19:47:40 PST 2003


I have created a simple parser/lexer that builds AST and a program that
walks AST and pretty-prints it and interpreter that interprets the program.
The language is a simple calculator where you can define your own functions
and use variables.
You can download it from http://www.adersoftware.com/antlr/calc.zip or read
more info at
http://www.adersoftware.com/antlr/readme.txt

I just started it today and it seems with antlr it's pretty easy to do
things. I used this small example as my learning experience for antlr.
Hope this can help you a bit.

Andrew

----- Original Message -----
From: <uiorean at cluj.astral.ro>
To: <antlr-interest at yahoogroups.com>
Sent: Thursday, February 27, 2003 12:16 PM
Subject: [antlr-interest] I got the parseing, now how do I do something
useful ?


> I wrote a lexer and a parser. Now my problem is how do I get the
> parsed tokens stored (for further processing) ?
> My parser looks like:
>
> entry: (
> (insrd dest COMA source)
> |(insdest dest)
> )*;
>
> where I have
>
> protected insrd: ADD_
> |ADC_
> |SUB_
>                 ;
> protected source: REG
> |DOP
> |PORT
> |LDB
> |DST
> ;
> protected dest: REG;
>
> and so on...
>
> i would like to do something like:
>
>
> entry: (
> (i:insrd d:dest COMA s:source
> {somefunction(i.getText(), i.getType(), d.getText(), d.getType());})
> |(i1:insdest d1:dest
> {somefunction(i.getText(), i1.getType(), d1.getText(), d1.getType());})
> )*;
>
> but this does not work.  I don't think I really need to build a tree
> for this, there must be an easyer way.
>
> I am new to this mather so any suggestion is appreciated.
>
> L. Uiorean
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list