aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/pre_parser.mly
diff options
context:
space:
mode:
authorFrançois Pottier <francois.pottier@inria.fr>2015-10-07 10:42:10 +0200
committerFrançois Pottier <francois.pottier@inria.fr>2015-10-07 10:42:10 +0200
commitc1937e330a3ca6c19ef648e2dcfe4871fc3c2219 (patch)
treee77f33185f3012c9579d7ef3bbff6d130cf80efe /cparser/pre_parser.mly
parente9ba1d3276b0b2fbc37ecb8bd7e4955fd8ec030b (diff)
downloadcompcert-kvx-c1937e330a3ca6c19ef648e2dcfe4871fc3c2219.tar.gz
compcert-kvx-c1937e330a3ca6c19ef648e2dcfe4871fc3c2219.zip
Factorized the productions for several categories of binary operators.
This leads to a small savings in the number of states (which could become greater in the future if we decide to parameterize expressions). If desired, the old automaton could be recovered by marking the binary operators as %inline.
Diffstat (limited to 'cparser/pre_parser.mly')
-rw-r--r--cparser/pre_parser.mly33
1 files changed, 20 insertions, 13 deletions
diff --git a/cparser/pre_parser.mly b/cparser/pre_parser.mly
index 7567b372..497851bf 100644
--- a/cparser/pre_parser.mly
+++ b/cparser/pre_parser.mly
@@ -210,37 +210,44 @@ cast_expression:
| LPAREN type_name RPAREN cast_expression
{}
+multiplicative_operator:
+ STAR | SLASH | PERCENT {}
+
multiplicative_expression:
| cast_expression
-| multiplicative_expression STAR cast_expression
-| multiplicative_expression SLASH cast_expression
-| multiplicative_expression PERCENT cast_expression
+| multiplicative_expression multiplicative_operator cast_expression
{}
+additive_operator:
+ PLUS | MINUS {}
+
additive_expression:
| multiplicative_expression
-| additive_expression PLUS multiplicative_expression
-| additive_expression MINUS multiplicative_expression
+| additive_expression additive_operator multiplicative_expression
{}
+shift_operator:
+ LEFT | RIGHT {}
+
shift_expression:
| additive_expression
-| shift_expression LEFT additive_expression
-| shift_expression RIGHT additive_expression
+| shift_expression shift_operator additive_expression
{}
+relational_operator:
+ LT | GT | LEQ | GEQ {}
+
relational_expression:
| shift_expression
-| relational_expression LT shift_expression
-| relational_expression GT shift_expression
-| relational_expression LEQ shift_expression
-| relational_expression GEQ shift_expression
+| relational_expression relational_operator shift_expression
{}
+equality_operator:
+ EQEQ | NEQ {}
+
equality_expression:
| relational_expression
-| equality_expression EQEQ relational_expression
-| equality_expression NEQ relational_expression
+| equality_expression equality_operator relational_expression
{}
and_expression: