Implementation of Hecl

The Hecl scripting language as a programming language isn't something that's pushing programming language design in interesting new directions. However, as a simple, dynamic language that's implemented in Java, it's pretty easy to figure out how it works, so perhaps this article on its design and implementation is of interest to those who aren't quite as advanced or passionate as most of the LtU readership, or who are interested in something to sink their teeth into before wading into something more difficult.

Additionally, because of the very fact that it is small and simple, it has a practical application: the runtime runs on even older, slower J2ME-enabled cell phones.

I originally wrote the article for a European Linux magazine, but didn't like their terms, so I decided to just put it up on my web site:

http://www.dedasys.com/articles/hecl_implementation.html

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Looks like a nice

Looks like a nice introduction. I am promoting this item to the home page.

A few questions about the parser.

1) how does your parser work? is it a recursive descent parser or a table-driven LL/LR/LALR parser?

2) did you write the parser manually or you used a tool? if you used a tool, which tool was that?

3) how does your parser handle errors? does it stop at the first error found or it uses specific symbols as markers for reporting more than one errors?

4) do you tokenize the source code before parsing, or you tokenize as you parse?

5) do you evaluate the code while it is parsed or after the AST is constructed?

I apologise if the questions are already answered in the link provided, but I did not understand a few things which maybe you consider obvious.

Hi - the point of the

Hi - the point of the article is, in some ways, to avoid going too much into technical details like these. I wouldn't expect the target audience to know what things like 'recursive descent', tokenize and 'AST' mean, although I guess I could go into more detail about the mechanisms used.

It's a hand-written (has to be small) parser using a recursive descent strategy, just like Tcl, from which it borrows a number of other things.

When it runs into actual parse errors, it halts.

It's tokenized and parsed at the same time, and then executed afterwards, although it's also lazy in the sense that in this code:

if { = $foo "bar" } {
...
do
something
}

It doesn't really care about the arguments to the 'if' command until the if command is run. At that point it looks at them as code, and goes about parsing them, saving that parsed form, and then running it.

Thanks.

Thanks a lot for replying.

The article is very good for its purpose, i.e. to introduce beginners in the art of making programming languages.

Do you plan to write another article going deeper into the details?

Don't think so

It took me a while to write that one, and I had fun, but I think I'll call it a day with what I've written so far. People interested in Hecl itself can ask after it on the mailing list, and those interested in pursuing language design can find an ample amount of more in-depth material on this and other sites.