view test/expression.x @ 348:442fb043d149

Added log option to zcc
author Windel Bouwman
date Sat, 08 Mar 2014 15:32:33 +0100
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};