view test/expression.x @ 398:c0d9837acde8

x86 target refactor
author Windel Bouwman
date Thu, 29 May 2014 12:13:37 +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};