Re: Help wanted - getting started writing an interpretter

"Joachim Durchholz" <joachim_d@gmx.de>
25 Sep 2001 00:13:47 -0400

          From comp.compilers

Related articles
Help wanted - getting started writing an interpretter dont@send.me.spam (SynapZ) (2001-09-21)
Re: Help wanted - getting started writing an interpretter monnier+comp.compilers/news/@RUM.cs.yale.edu (Stefan Monnier) (2001-09-25)
Re: Help wanted - getting started writing an interpretter joachim_d@gmx.de (Joachim Durchholz) (2001-09-25)
Re: Help wanted - getting started writing an interpretter anton@mips.complang.tuwien.ac.at (2001-09-26)
| List of all articles for this month |

From: "Joachim Durchholz" <joachim_d@gmx.de>
Newsgroups: comp.compilers
Date: 25 Sep 2001 00:13:47 -0400
Organization: Compilers Central
References: 01-09-098
Keywords: interpreter
Posted-Date: 25 Sep 2001 00:13:47 EDT

SynapZ <dont@send.me.spam> wrote:
>
> I'm writing a simple script language for a game I'm making and I've
> been reading up on the area (never written a compiler before!). I've
> decided to create a compiler with lex/yacc that produces a condense
> bytecode output, to be interpretted by the game. Does this sound like
> a sensible approach (small footprint target so need to keep compiled
> scripts as small as possible) ?


Yes.
Well, modulo the general "Don't Do That"... it's rarely worth the
effort. OTOH your language is so minimal that a specialized interpreter
might indeed be more compact than a general solution... but I'd still
first try with an existing interpreter and look whether it's good
enough.


> I'm fairly confident that I can make the compiler with the help of lex
> and yacc but the interpretter seems to be a completely separate issue.
> Are there any tools out there to help automate this process (i.e.
> generate an interpretter for a lex/yacc'd language)?


You still have to write semantic actions on yacc, I don't think any tool
will help you with that. These actions would either produce a parse
tree, or generate byte code directly, depending on how much in the way
of code transformation etc. you're going to do.


However, the following might help you with writing the bytecode
interpreter:
http://www.complang.tuwien.ac.at/anton/vmgen/
Vmgen will take C code and a bit of metainformation for each
instruction, and generate a VM for you. (At least that's what I
understood from the docs, I haven't used it yet.)


Regards,
Joachim


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.