Backus-Naur form context-free grammar in LaTeX

Udgivet 2016-10-09 - Skrevet af

Backus-Naur form context-free grammar in LaTeX

During my fourth semester at Aalborg University I had a course in Languages and Compilers. Within this course we were introduced to context-free grammar using the Backus-Naur form, and in our semester project we had to utilize it. This, of course, required us to describe the grammar within our report, and since we are using the lovely TeX I had to figure out how to do it.

I quickly found the Syntax package from Mdwtools which could be used to display this grammar. You can read about it in this Stack Exchange post. Unfortunately I also quickly found out that using the package within our report caused it to crash for some reason, and merely displaying this odd message:
TeX capacity exceeded, sorry [input stack size=5000]
Okay. What now?

It took me far too long to find a solution. I actually found myself digging up this 8 year old forum post describing a problem with the package. It was not the same issue as mine, but I tried the solution regardless, and IT FUCKING WORKED! Who would have thought?

The code solving the problem:
\usepackage{syntax}\AtBeginDocument{\catcode`\_=8 }
Basically as Enrico (the original poster) describes, the syntax package alters the way underscore is viewed, and if you, like me, have files with underscore it will not compile. The added command returns underscore to its original meaning without maiming the syntax package.

Later I discussed the problem with a friend who also had experienced it and solved it always. His solution was different, and can be seen here:
\usepackage[nounderscore]{syntax}
I hope it helped.


Kommentarer

Der er ingen kommentarer.

Tilføj kommentar