3 ms·
One question here for the more advanced compiler writers.. How do you go about writing a "pre-lexer" for LISP like language where you want to expand sexpr? I.e.
by d0m 10y ago
One question here for the more advanced compiler writers.. How do you go about writing a "pre-lexer" for LISP like language where you want to expand sexpr? I.e. Does the lexer even see `(...), or does it get pre-extracted to (quote ..)? And if so, how does the pre-extraction work exactly? Is it built using regex..? That can be tricky.
- munificent 10y agoThose are handled by the reader. If you Google "Lisp reader" and "Lisp reader macro", you should find a bunch of info.
- kazinator 10y agoLisp dialects usually have an input mechanism called a "reader". It scans the character syntax and produces the equivalent object, combining lexical analysis and parsing. Special notations like 'x denoting the same thing (quote x) are easily handled here. When the reader sees a quote, it consumes it, calls itself recursively to scan the expression which follows to get an object O and then returns the object (quote O).