view test/expression.x @ 354:5477e499b039

Added some sort of string functionality
author Windel Bouwman
date Thu, 13 Mar 2014 18:59:06 +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};