annotate test/expression.x @ 389:2ec730e45ea1

Added check for recursive struct
author Windel Bouwman
date Fri, 16 May 2014 12:29:31 +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