OMeta for Scheme

(This page is a mirrored copy of an article originally posted on the LShift blog; see the archive index here.)

Speaking of OMeta/JS and OMeta in general, I’ve implemented an OMeta for Scheme. Currently it runs in MzScheme, but it should be fairly portable, with dependencies only on a handful of commonly-implemented SRFIs. I intend to properly libraryise it — making it into a proper MzScheme module — and to port it to other schemes, most probably starting with SISC.

One interesting feature of this OMeta is that it implements the error-handling mechanisms suggested by Bryan Ford that I implemented previously in a packrat parsing library for Scheme. The packrat-based error-handling techniques seem to generalise fairly well to an OMeta setting.

  • Browse the code here.
  • Check it out with hg clone

I’m already using it as part of an experimental compiler: the reader, the parser.

Update: Switched from hosting the ometa-scheme code in Darcs to Mercurial.


On 3 July, 2008 at 4:42 am, web design wrote:

For you Lisp2 fans, a common lisp version has been posted to reddit previously:

On 24 July, 2008 at 11:48 am, John Pallister wrote:


Thanks for making your code available. I’m a Lisper interested in OMeta, so between your Scheme code and John Leuner’s Lisp port of the Squeak version (as mentioned above) I hope to get (a) my head around OMeta and (b) some Lisp code of my own that I understand.

I like your mention of extra (any?) error handling stuff, and the fact that your code is 803 lines of Scheme vs. 3000+ lines of Lisp and 5000+ lines of JavaScript… ;)

And now my question: I’ve downloaded the latest MzScheme, but it looks like your code won’t run in version 4 out of the box (not that I’ve used this particular box before).

If I want to study your code interactively, would I be best advised to download a slightly earlier version of MzScheme? Or should I hang on for the next release?

Thanks again,

John :^P

On 25 July, 2008 at 11:03 am, Simon Michael wrote:

Thanks for this, very timely.

I made it work with PLT scheme 4, more or less - using enter! in a command-line mzscheme, at least. (boot) works, (opt (parse-ometa “a ::= ‘a’ => true;”)) works, I haven’t figured out how to parse actual data. See darcs repo at;a=summary

On 27 July, 2008 at 11:30 am, John Pallister wrote:

Thanks for that Simon, I’ll grab the latest code and try again.


John :^P

On 1 August, 2008 at 2:01 pm, tonyg wrote:

John, Simon: Thanks for trying out the code — and thanks for the bug report. I’ve not yet upgraded to mzscheme 4, but will do so and integrate Simon’s patches ASAP.

On 12 December, 2008 at 2:03 am, tonyg wrote:

I’ve switched the repository from darcs to mercurial, and updated the links in the post above. I’ve also incorporated Simon’s fixes for MzScheme 4 — thanks, Simon!

The situation now is that the default branch is the PLT 4 branch, and PLT 3 support is now legacy, and lives on a support branch.