# Tools for modelling compilers

I'm a wannabe mathematician, whose master's thesis is (by the looks of it) going to focus on a certain "compiler", used to produce learning materials from a subset of $$\LaTeX$$, in the context of mathematics education. I'm of course going to have to talk about the compilation process in general, and was planning to discuss the mathematical abstractions related to it (this being a master's thesis in mathematics), and then use those to describe the compiler.

I have no experience in the field whatsoever, however, and was wondering whether the concepts of regular expressions and languages, automata and the like are actually used to model (and|or) describe the functionality of compilers in a professional setting. Is it typical (even in the industry) to use these methods of modelling compilers, or are there better alternatives available?

I simply stumbled upon these basic concepts in a certain course handout, and they seem useful, but I want to be certain.

• Compilers have a front end and a back end. The concepts you mention are used in front end stages, lexical analysis and parsing, often via tools like lex/flex and yacc/bison. Back ends, doing optimization and code generation, use less formal methods. Interestingly, I believe Latex, based on Tex, is a macro system and I’m not sure whether it uses a parser at all... Feb 22 '20 at 15:22
• @Daniel No, I suppose it wouldn't. But the result produced by this compiler is not LaTeX (nor TeX macro expansions), so the tokens produced by the lexing stage have to be parsed somehow, no? Feb 22 '20 at 16:07
• If your thesis is focused on a specific compiler (can you share which it is?) it may use very ad-hoc or fully formal techniques - you have to dig into the code. If you can expand discussion to compilation in general, you are on safe ground, as the theory is very much applied in real implementations. Feb 22 '20 at 16:52
• @DanielMGessel, TeX uses an ad hoc hand-written parser (surprisingly, as Knuth did fundamental work in parsing, and his professors were famously miffed that as an undergraduate he did more working on compilers during break than they did in a full year). Feb 23 '20 at 16:37