Mercurial > lcfOS
diff test/expression.x @ 318:e84047f29c78
Add burg and yacc initial attempts
author | Windel Bouwman |
---|---|
date | Tue, 31 Dec 2013 12:38:15 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/expression.x Tue Dec 31 12:38:15 2013 +0100 @@ -0,0 +1,16 @@ + +%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}; + +