view test/expression.x @ 400:0374c65cb437

Move compiler to seperate repo
author Windel Bouwman
date Mon, 14 Jul 2014 22:23:55 +0200
parents e84047f29c78
children
line wrap: on
line source


%tokens '+' number '(' ')' '*'
%%

input: expression {return $1};

expression: term { return $1 }
          | expression '+' term {};

term: factor { return $1 }
    | term '*' factor { return $1 * $3 };

factor: '(' expression ')'
      | number {return $1.val};