0

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 ?

Elyo
  • 386
  • 1
    No. ------------ – user202729 Jun 26 '22 at 09:18
  • 1
    No try this valid plain tex file as a test case http://mirrors.ctan.org/macros/plain/contrib/xii/xii.tex – David Carlisle Jun 26 '22 at 09:29
  • Note that tex itself at no point parses a tex document to any kind of parse tree. It simply processes the input character by character with reading input characters and evaluation of commands completely inter-mingled – David Carlisle Jun 26 '22 at 09:33
  • @David Carlisle Yes I read that, but I thought I could intercept this process – Elyo Jun 26 '22 at 09:35
  • 1
    @Elyo you can not even get a lexical analysis into tokens, far less a parse tree without a full tex typesetting engine 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
  • 1
    Well, you can get a lexical analysis into tokens in general case but that requires modifying the TeX program to output that content. As I mentioned before in most cases what you want to do is to make your program parse a "small" supported subset of LaTeX. For things like "what are the arguments this function take" it's complex... (learn TeX programming for more details.) – user202729 Jun 26 '22 at 10:19

0 Answers0