This question is related to the question I asked here How does a TeX engine process the informations within a .tex file?. I want to write a program to parse TeX-LaTeX files. I found libraries to write parser that allow users to describe the langage they target with EBNF grammar.
Can LaTeX-TeX be described with EBNF standard ?
aaa \ifnum\time>600 \catcode\%=12 \fi % is this a comment` for example is or is not a comment depending on the time of day. You can specify a tex-like language grammar and parse that, but not parse arbitrary tex input – David Carlisle Jun 26 '22 at 09:43