Any blogs to help orient me re the reference implementation? contrasting with F#

Graydon Hoare graydon at
Wed Mar 19 15:01:22 PDT 2008

ToolmakerSteve98 wrote:

> Wondering if there is any info beyond the source itself that would give me a 
> "big picture" view of what is there, before I start wandering around in the 
> depths of the code.

Not a lot, though I've posted some notes to this list in the past; I'm 
happy to discuss it further. It wasn't clear after the last round of 
discussion on this topic whether new readers would be better served by 
"abstract" notes on implementing the language -- implementation-language 
agnostic -- rather than an explicit tour guide for the ML 
implementation. But I can provide pointers on the latter if you like.

> I'm especially interested in the parser. Maybe will be obvious once I start 
> looking, but might as well learn what I can the easy way. Bottom-up? 
> top-down? grammar notation used? Based on some pre-existing parser 
> combinator library?

It's a hand-rolled unicode lexer that produces token lists, and a 
top-down parser over those token lists, with variable lookahead and a 
minor bit of feedback from the parser to the lexer (for mode switching 
on things like /, that contextually means either "leading edge of 
regular-expression"  or "lone division operator"). No grammar formalism 
is used in the code, though it's quite regular in structure. It uses ML 
data pattern matching on the current list head, for the most part.

There is a companion excel spreadsheet kept in the source repository 
that documents the grammar in BNF. There is no mechanical connection 
between that spreadsheet and the ML code. They are kept in sync by hand. 
Jeff Dyer wrote much of the parser.

> My immediate goal is to attempt to translate from the preliminary ES4 into 
> F#, using an extended-PEG metacompiler similar to Rats!. I want to get a 
> grasp on precisely where this dynamic language deviates in semantics from a 
> statically typed language using type inference. Well, that will depend on 
> test sources fed in, but attempting this translation will tell me a lot.

Good luck! I am not sure how far the similarity will carry, but it 
sounds like an interesting experiment.


More information about the Es4-discuss mailing list