On Fri, Oct 17, 2008 at 2:12 AM,  "Roger Pomeroy" <[EMAIL PROTECTED]> wrote:

> I have completed a grammar for my language, but I am somewhat
> confused by what the next step is.  The intent was to build an
> interpreted language, much like the minibasic example.  However, my
> grammar is more complex in that a has productions for more than
> just simple add subtract, etc..., it allows for full parenthesized
> expressions, etc (much like in Java, C, fortran, etc)   I am not
> sure how to go about which routines I need to actually code up in
> order to make the assignment statments work.   I was wondering if
> anyone else perhaps has an example of how to do a more complicated
> interpreted language?  Essentially, I am confused about the fact
> that I have productions that look as shown below.  I realize I need
> routines to store the computed values in a hash table, and be able
> to look up the identifiers and their values from that, but I am not
> sure if I need to do that for each production alternative (ie
> expression, term, expon, factor...) or if I need only do this at
> the lowest (factor level), etc.
>
> If anyone has any example code I could look at, that would help.  I have 
> looked at both the minibasic and minipascal, but they don't seem to have the 
> same level of complexity as my grammar...
>

Hi Roger,

What I have done in the past was write an a byte code interpreter and
then have my AST traverser generate intermediate bytecode in an Array.
Once the code was generated, I would then pass the Array with the
resulting code to my Byte Code Interpreter. It is like a compiler that
generates some code, but instead of generating it in a file, generate
it in memory. And then the Byte code interpreter reads the code and
executes it.

I don't really have an example, but I will try to digg my archives and
if I find something, I will post the example.

Fidel.

_______________________________________________
SableCC-Discussion mailing list
[email protected]
http://lists.sablecc.org/listinfo/sablecc-discussion

Reply via email to