meta

A recursive-descent parser as described in in a paper by Henry Baker: Pragmatic Parsing in Common Lisp; or, putting defmacro on steroids (ACM Lisp Pointers, vol. IV, no. 2, April--June 1991, pp. 3--15, DOI 10.1145/121983.121984). A few dozen lines of code in Common Lisp. (mirror of the paper.)

The scheme involves building a tiny language, called Meta, on top of Lisp. Whereas it does not handle all possible regular and context-free grammars, it can be used for a surprisingly large fraction of the grammars Lisp programmers encounter.

I think the family of grammars that Meta handles is usually called LL(1) as opposed to LL(k) which some other recursive descent parser generators support. -A. Kjeldaas. Actually the look-ahead limitation to one character is an artefact of using CL streams. The same technique and software can be used with sexprs and strings (and could be used with your own buffering streams if you dared) to provide unlimited look-ahead. -Fare Rideau I also believe that the languages Meta can parse can also be generated by Regular Tree Grammars: a formalism that under-pins xml schema languages like Relax-NG. -M. Swank

The code is packaged in Debian as cl-meta. You can also get it from cCLan (note that the Debian package has bugfixes that aren't in the sources at cCLan).

A simple practical package that uses Meta is Scribble, which you may take as an example.

Download ASDF package from http://fare.tunes.org/asdf-packages/meta-0.1.2.tar.gz

mel-base contains a modified version of cl-meta which uses sexprs instead of the reader. Huh? Baker's META works equally well on objects of type STREAM, STRING or LIST. cl-meta features access to these 3 via WITH-STRING-META, WITH-STREAM-META, WITH-LIST-META: lexical scoping is the solution, via MACROLET and/or LABELS. -Jörg Höhle Also, meta-sexp package is yet another META parser generator using s-expressions.

There's a small problem loading meta under CLISP. CLISP doesn't like umlots and won't load unless you remove the umlot from the last word in the header comment in meta-src.lisp.


Page in this topic: chemical-compounds  


Also linked from: Exscribe   Peter Scott   scribble   text  

CLiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively