Search code examples
elisp

Formal grammar for Emacs Lisp


Where can I find a formal specification (in EBNF, or some other standard notation -- the source code for the "read" function doesn't count!) for the Emacs Lisp grammar?

I'd even be happy with a .y file; unfortunately, emacs's own parser does not use yacc.


Solution

  • There is a tree-sitter grammar for Emacs Lisp at https://github.com/Wilfred/tree-sitter-elisp/blob/4b0e4a3891337514126ec72c7af394c0ff2cf48c/src/grammar.json This is a machine-readable grammar specification which is then used to generate a C parser.