Skip to content

MathParser

donhilion edited this page Nov 1, 2012 · 1 revision

Parts of the generated AST

Nodes

  • Const(int)
  • Plus(exp, exp)
  • Minus(exp, exp)
  • Times(exp, exp)
  • Div(exp, exp)
  • Call(string, list of exp)

Grammar

Exp -> Call | Math

Call -> string + '(' + ListExp + ')'

ListExp -> epsilon | exp + ListExp2

ListExp2 -> epsilon | ',' + exp + ListExp2

Math -> Prod | Prod + '+' + Prod | Prod + '-' + Prod

Sum -> Fact | Fact + '*' + Fact | Fact + '/' + Fact

Fact -> Const | Exp

Clone this wiki locally