1
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ 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... $\endgroup$
    – user46107
    Commented Feb 22, 2020 at 15:22
  • $\begingroup$ @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? $\endgroup$
    – sesodesa
    Commented Feb 22, 2020 at 16:07
  • 1
    $\begingroup$ 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. $\endgroup$
    – user46107
    Commented Feb 22, 2020 at 16:52
  • 1
    $\begingroup$ @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). $\endgroup$
    – vonbrand
    Commented Feb 23, 2020 at 16:37

1 Answer 1

1
$\begingroup$

Be careful. Even mastering the tools for compiler construction, handling a very complex preexisting language (which LaTeX certainly is) is an arduous task. Add that there is no firm syntax for LaTeX (there are certain overall conventions, but lots of special cases) makes it worse.

But to really be of any guidance, we'd need a whole lot further detail: What kind of documents? Can you define the format, or is it a corpus of preexisting texts? Do they use the same packages? Are they written to some rigid format or "anything goes? What do you want to extract? (If it is e.g. all the "exercise" environments it is very simple ---but the contents will depend on all sorts of external definitions, finding/including that isn't simple. Solution is to require manual fixups, but that negates the "automation" aspect).

Go also to TeX.SE for LaTeX related questions.

Good luck!

$\endgroup$
2
  • $\begingroup$ Currently the idea is to be able to transform LaTeX documents to rST (Sphinx) form. It is all related to this platform: github.com/apluslms/a-plus $\endgroup$
    – sesodesa
    Commented Feb 24, 2020 at 13:40
  • $\begingroup$ @SeSodesa, looking for Sphinx and LaTeX nets a good heap of references in Google, as far as I understand, many tools generate either, or translate between them. Besides, my (limited!) understanding is that Sphinx is much simpler (restricted), translating LaTeX decently will be hard. $\endgroup$
    – vonbrand
    Commented Feb 29, 2020 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.