TeX

As part of my ongoing TeX.NET project, I am creating a formal specification of the grammar for the mathematical subset of the TeX language in EBNF notation.

Below is the latest version of the grammar. While I’m working on the project, I’ll try to get around to updating this about once a week.

Last Updated: 07/10/09 (day/month/year)

input = relation expr , ? EOF ? ;
relation expr = fractional expr , [ ? relational op ? , relation expr ] ;
fractional expr = expr [ "\over" , expr ] ;
expr = term , [ expr operator , signed term ] ;
expr operator = "+" | "-" | "\pm" | "\mp" ;
signed term = [ "+" | "-" ] , term ;
term = factorial value , [ term operator , term | term ] ;
term operator = "*" | "/" | "\times" | "\cdot" | "\bmod" ;
factorial value = indexed value , [ "!" ] ;
indexed value = value , indices pair ;
value = raw value | group | bracket expr | factorial | fraction | binomial | root | function | big operator | text ;
raw value = ? number ? | ? letter ? | ? greek letter ? ;
indices pair = ( [ "^" , index ] , [ "_" , index ] ) | ( [ "_" , index ] , [ "^" , index ] ) ;
index = raw value | group ;
group = "{" , fractional expr , "}" ;
bracket expr = "{" , expr , "}" | "(" , expr , ")" | "[" , expr , "]" | "\{" , expr , "\}" ;
fraction = "\frac" , group , group ;
binomial = "\binom" , group , group ;
root = "\sqrt" , [ argument ] , group ;
function = ? function name ? , indices pair , fractional expr ;
argument = "[" , expr , "]" ;
big operator = ? big operator ? , indices pair , fractional expr ;
text =  "{" , { ? letter ? }- , "}" ;

Just to note: please don’t point out “missing rules” – I’m quite aware that the grammar specification is far from complete at the moment, though it is rapidly changing. On the other hand, any corrections or suggestions for improvement to the existing specification are most welcome.

If you are interested in contributing to this grammar specification or the project as a whole (see the Launchpad pages for info), do please drop me a message.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • DotNetKicks
  • Twitter