annotate test/expression.x @ 405:f381cea07fec

merge
author Windel Bouwman
date Thu, 19 Feb 2015 14:10:52 +0100
parents e84047f29c78
children
rev   line source
318
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
1
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
2 %tokens '+' number '(' ')' '*'
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
3 %%
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
4
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
5 input: expression {return $1};
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
6
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
7 expression: term { return $1 }
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
8 | expression '+' term {};
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
9
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
10 term: factor { return $1 }
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
11 | term '*' factor { return $1 * $3 };
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
12
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
13 factor: '(' expression ')'
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
14 | number {return $1.val};
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
15
e84047f29c78 Add burg and yacc initial attempts
Windel Bouwman
parents:
diff changeset
16