[antlr-interest] Building own interpreter

Andreas Stefik stefika at gmail.com
Fri Apr 9 12:18:51 PDT 2010


If it doesn't matter for your particular application at all, then
cliff's suggestion is probably best. Just emit out code that can be
read by a traditional compiler (e.g., gcc). Only design a full
evaluator/interpreter if your application (whatever it is), demands
it.

Stefik

On Fri, Apr 9, 2010 at 2:13 PM, Cliff Hudson <cliff.s.hudson at gmail.com> wrote:
> If you decide to go the compiled route, also consider just writing a
> translator from your language to a compiled one, such as C or C++.  Then you
> don't have to implement a compiler at all which will save you a ton of time.
>
>
> On Fri, Apr 9, 2010 at 12:09 PM, Andreas Stefik <stefika at gmail.com> wrote:
>>
>> That's hard to answer without knowing context. Compilers are tricky
>> things. For example, you might make a simple evaluator that will
>> inevitably run very slowly, but do the job you need. Or, you might
>> make something that generates code that ultimately be compiled into
>> very fast C code to be compiled by a GCC compiler --- or who knows
>> what.
>>
>> That's why I'm saying it depends on context. What problem are you
>> trying to solve with your DSL?
>>
>> Stefik
>>
>> On Fri, Apr 9, 2010 at 1:59 PM, William v Doorn <williamvdoorn at gmail.com>
>> wrote:
>> > Andreas,
>> >
>> > Well, I can already execute some code and evaluate it, but is this
>> > really
>> > the way to do it? e.g. could I use this as interpreter, or do I need a
>> > fully
>> > different approach? (see the file I attached)
>> >
>> > Thanks
>> >
>> > William van Doorn
>> >
>> >
>> >
>> > 2010/4/9 Andreas Stefik <stefika at gmail.com>
>> >>
>> >> William,
>> >>
>> >> This is a complex question to answer, and it really depends on your
>> >> needs. For example, creating a whole compiler from scratch is
>> >> difficult, but possible. We have our own compiler (with an ANTLR front
>> >> end), that integrates our own custom language, called HOP, which is
>> >> basically a novice programming language we distribute to schools for
>> >> the blind. Our implementation is on sourceforge and is under GPL2, so
>> >> you are welcome to look at it (Search for "Sodbeans"). We also
>> >> integrate our custom compiler into NetBeans.
>> >>
>> >> On the other hand, if your needs allow it, you can also do things like
>> >> have your antlr grammar generate java byte code or assembly directly,
>> >> which is sometimes easier, again depending on what you need. And very
>> >> simple interpreters for very simple languages aren't too tough, if you
>> >> know what you are doing, and depending on your requirements.
>> >>
>> >> Hope that gives you some tips, at least. Short answer: Yes, it's
>> >> definitely possible, but it depends on your goals, and it's typically
>> >> not something you would bang out in a weekend.
>> >>
>> >> Andreas Stefik, Ph.D.
>> >> Department of Computer Science
>> >> Southern Illinois University Edwardsville
>> >>
>> >> On Fri, Apr 9, 2010 at 1:44 PM, William v Doorn
>> >> <williamvdoorn at gmail.com>
>> >> wrote:
>> >> > Hello all,
>> >> >
>> >> > I've been reading the The definitive ANTLR book and I've made my own
>> >> > small
>> >> > language using the AST strcuture.
>> >> >
>> >> > Now I was wondering, is it hard to make my own compiler/interpeter
>> >> > for
>> >> > this?
>> >> > I can feed files and such to it, but how would I make my own
>> >> > interpreter/compiler?
>> >> >
>> >> > Thanks,
>> >> >
>> >> > William van Doorn
>> >> >
>> >> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> >> > Unsubscribe:
>> >> >
>> >> > http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>> >> >
>> >
>> >
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>


More information about the antlr-interest mailing list