On Mon, 2009-08-03 at 21:22 +0300, Abdulaziz Ghuloum wrote:
> On Aug 3, 2009, at 12:27 PM, Marco Maggi wrote:
>
> >> Also, is there a test suite for the beast? It seems like it only
> >> comes
> >> with a calc example. I don't think that's enough.
> >
> > Not that I know of.
>
> Darn! The code looks pretty nasty to say the least and refactoring
> it without a decent test suite is no picnic. If I were to use it,
> I'd probably pull up the dragon book and do it from scratch in a way
> that doesn't use a gazillion global variables. (probably not today
> though)
JTMI, I've recently made a functional (no mutation) abstract lexer (with
tests), and upon it I've made an R6RS lexer:
> (import (xitomatl R6RS-lexer))
> (R6RS-lexer "(1\n (two))\n#|lex #|this|# !|#\n\"a\\\"b\"\n;; blah...\n#\\λ")
(#[open-paren-token "(" 0 0 0]
#[number-token "1" 1 0 1]
#[whitespace-token "\n " 2 0 2]
#[open-paren-token "(" 4 1 1]
#[identifier-token "two" 5 1 2]
#[close-paren-token ")" 8 1 5]
#[close-paren-token ")" 9 1 6]
#[whitespace-token "\n" 10 1 7]
#[nested-comment-token "#|lex #|this|# !|#" 11 2 0]
#[whitespace-token "\n" 29 2 18]
#[string-token "\"a\\\"b\"" 30 3 0]
#[whitespace-token "\n" 36 3 6]
#[line-comment-token ";; blah...\n" 37 4 0]
#[character-token "#\\λ" 48 5 0])
Sorry, I can't document it right now. See revision 181.
--
: Derick
----------------------------------------------------------------