[racket] Developing a Recursive Descent Parser in Racket

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Thu Oct 24 00:45:30 EDT 2013

A lex&yacc-like pair of parser tools is included in Racket, and works 
OK.  http://doc.racket-lang.org/parser-tools/

Danny Yoo did some work on higher-level parser specification.  I'm not 
sure what's a good URL, but here are some:
http://planet.racket-lang.org/display.ss?package=autogrammar.plt&owner=dyoo
http://hashcollision.org/ragg/
https://groups.google.com/forum/#!topic/plt-scheme/J5xcIDjesmQ

If you want to write a parser by hand, you can use things like 
"read-char", "peek-char", and regexp-matching to tokenize, and use 
procedures for simple recursive descent.  This is how my old permissive 
HTML parser was implemented.  Or other ways (e.g., if your parser is 
doing heavy backtracking on the input characters/bytes directly rather 
than on an intermediate token stream/list, maybe read the input into a 
big string or byte-string first, rather than port-peeking or file-seeking).

Neil V.


Posted on the users mailing list.