Lambda the Ultimate

inactiveTopic Roll your own with JavaCC
started 1/2/2001; 1:53:50 PM - last post 1/4/2001; 1:52:46 PM
Chris Rathman - Roll your own with JavaCC  blueArrow
1/2/2001; 1:53:50 PM (reads: 924, responses: 4)
Roll your own with JavaCC
For those who want a more accessible Compiler Compiler than Lex and Yacc, the JavaCC looks to be a little simpler to set up and learn.
Posted to "" by Chris Rathman on 1/2/01; 1:54:06 PM

andrew cooke - Re: Roll your own with JavaCC  blueArrow
1/3/2001; 12:22:32 AM (reads: 854, responses: 0)
I used SableCC, which is similar (it's a long time ago, but when I looked at both I thought SableCC was the better designed; I get the impression that it has lost out to JavaCC in the popularity stakes, however).

My notes are here and SableCC is here.

Ehud Lamm - Re: Roll your own with JavaCC  blueArrow
1/4/2001; 4:05:17 AM (reads: 896, responses: 0)
What's the easiest way to build a language interpreter/compiler? Prolog+DCG;Scheme/Lisp (encode language as lists);OOP (the "interpreter pattern")?

I am mainly thinking about producing toy systems, not production quality optimizing compilers...

We should, of course, distinguish between parsing issues and code generation/semantics. Above I was focusing on the former.

pixel - Re: Roll your own with JavaCC  blueArrow
1/4/2001; 7:22:04 AM (reads: 858, responses: 0)
As for me, i've been using Prolog+DCG, Pascal and Ocaml(+camllex&camlyacc).
- Prolog was not typed as so had no compile-time check, sad...
- Pascal was missing pattern matching for further Abstract Syntax Tree modifications. datatypes are not sugared enough (union with tag)
- Ocaml was nice. The best solution IMO.

I don't about the "interpreter pattern" in OOP. Any good link? In any case i wonder if a object hierarchy is a good solution to represent the AST...

Ehud Lamm - Re: Roll your own with JavaCC  blueArrow
1/4/2001; 1:52:46 PM (reads: 967, responses: 0)
I don't about the "interpreter pattern" in OOP. Any good link?

I found this for you on Wiki. Though it is best just to look in the GOF book.


In any case i wonder if a object hierarchy is a good solution to represent the AST...

I am not sure either. It has its advantages and its bad points. I think most problems are not about the AST per se. Most important thing is that if you don't think carefuly about the environment handling (and just use a table) you are likely to create a crippled language (no recursion, closures etc.)

I discussed a bit of this in my paper on application frameworks (currently, like my entire web presence, offline). In that context I discussed some work on what I termed SEPI = Simple Embeddable Parser and Interpretet. Only the interpreter part (in crippled form) was ever written. I was more interested in how to make the framework embeddable inside other applications (it was generic, allowing the client to override primitives etc.)

Btw: I think this question was raised on comp.compilers awhile ago.