annotate test/expression.x @ 396:fb3c1f029b30

Added baselexer into c3 lexer
author Windel Bouwman
date Tue, 27 May 2014 22:19:32 +0200
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