moo icon indicating copy to clipboard operation
moo copied to clipboard

Question: implementing read macros

Open jasonsbarr opened this issue 3 years ago • 0 comments

I'm looking to generate a lexer and parser for a Lisp-like language. Generally this should be a pretty simple task, since Lisp is really easy to parse, but there's one thing I'm not sure about.

It's common in Lisps to have read macros that transform the input string before it's tokenized. The simplest and probably most-used example in practice is something like this:

'hello

which is transformed by the reader into

(quote hello)

before being parsed.

Is there any way to do that sort of processing with a Moo lexer, or do I need to do that transformation prior to lexing?

Doing the transformation first should be a trivial exercise, but I'd like to preserve line and column info from the original code, which makes it a bit more sticky.

jasonsbarr avatar Oct 25 '21 02:10 jasonsbarr