I have some questions about TeX/LaTeX parser and parsing TeX/LaTeX after reading the following:
Limitations when parsing TeX as a context-free grammar
This is a PEG parser, which means it interprets LaTeX as a context-free language. However, TeX (and therefore LaTeX) is Turing complete, so TeX can only really be parsed by a complete Turing machine. It is not possible to parse the full TeX language with a static parser. See here for some interesting examples.
It is even undecidable whether a TeX program has a parse tree. There has been done some research on the problem of parsing TeX, see here.
Source: https://github.com/michael-brade/LaTeX.js/blob/master/README.md
- What are the parsing rules used in TeX/LaTeX?
- If this is not a context-free grammar what is the type of grammar used?
- What is the parser used in TeX/LaTeX and how does it prase a TeX/LaTeX document?
- How is the parser written/generated?