Index: trunk/willow/src/willow/expr.cc |
— | — | @@ -87,10 +87,8 @@ |
88 | 88 | const &start(void) const { return top; } |
89 | 89 | |
90 | 90 | rule<scanner, expr_closure::context_t> |
91 | | - add_expr, atom, mod_expr, eq_expr, neq_expr, |
92 | | - mul_expr, div_expr, sub_expr, land_expr, lor_expr, |
93 | | - lt_expr, gt_expr, le_expr, ge_expr, band_expr, |
94 | | - bxor_expr, bor_expr, lsht_expr, rsht_expr, expr; |
| 91 | + add_expr, atom, eq_expr, mul_expr, land_expr, lor_expr, |
| 92 | + lt_expr, band_expr, bxor_expr, bor_expr, lsht_expr, expr; |
95 | 93 | rule<scanner> top, identifier; |
96 | 94 | |
97 | 95 | definition(expression_parser_impl const &self) { |
— | — | @@ -112,48 +110,37 @@ |
113 | 111 | bxor_expr = bor_expr[bxor_expr.val = arg1] |
114 | 112 | >> *('^' >> bor_expr[bxor_expr.val ^= arg1]); |
115 | 113 | |
116 | | -bor_expr = lt_expr[bor_expr.val = arg1] |
117 | | - >> *('|' >> lt_expr[bor_expr.val |= arg1]); |
| 114 | +bor_expr = eq_expr[bor_expr.val = arg1] |
| 115 | + >> *('|' >> eq_expr[bor_expr.val |= arg1]); |
118 | 116 | |
119 | | -lt_expr = gt_expr[lt_expr.val = arg1] |
120 | | - >> *('<' >> gt_expr[lt_expr.val = lt_expr.val < arg1]); |
| 117 | +eq_expr = lt_expr[eq_expr.val = arg1] |
| 118 | + >> *( ("==" >> lt_expr[eq_expr.val = (eq_expr.val == arg1)]) |
| 119 | + | ("!=" >> lt_expr[eq_expr.val = (eq_expr.val != arg1)]) |
| 120 | + ); |
121 | 121 | |
122 | | -gt_expr = le_expr[gt_expr.val = arg1] |
123 | | - >> *('>' >> le_expr[gt_expr.val = gt_expr.val > arg1]); |
| 122 | +lt_expr = lsht_expr[lt_expr.val = arg1] |
| 123 | + >> *( ('<' >> lsht_expr[lt_expr.val = (lt_expr.val < arg1)]) |
| 124 | + | ('>' >> lsht_expr[lt_expr.val = (lt_expr.val > arg1)]) |
| 125 | + | ("<=" >> lsht_expr[lt_expr.val = (lt_expr.val <= arg1)]) |
| 126 | + | (">=" >> lsht_expr[lt_expr.val = (lt_expr.val >= arg1)]) |
| 127 | + ); |
124 | 128 | |
125 | | -le_expr = ge_expr[le_expr.val = arg1] |
126 | | - >> *("<=" >> ge_expr[le_expr.val = le_expr.val <= arg1]); |
| 129 | +lsht_expr = add_expr[lsht_expr.val = arg1] |
| 130 | + >> *( ("<<" >> add_expr[lsht_expr.val <<= arg1]) |
| 131 | + | (">>" >> add_expr[lsht_expr.val >>= arg1]) |
| 132 | + ); |
127 | 133 | |
128 | | -ge_expr = neq_expr[ge_expr.val = arg1] |
129 | | - >> *(">=" >> neq_expr[ge_expr.val = ge_expr.val >= arg1]); |
| 134 | +add_expr = mul_expr[add_expr.val = arg1] |
| 135 | + >> *( ('+' >> mul_expr[add_expr.val += arg1]) |
| 136 | + | ('-' >> mul_expr[add_expr.val -= arg1]) |
| 137 | + ); |
130 | 138 | |
131 | | -neq_expr = eq_expr[neq_expr.val = arg1] |
132 | | - >> *("!=" >> eq_expr[neq_expr.val = neq_expr.val != arg1]); |
| 139 | +mul_expr = atom[mul_expr.val = arg1] |
| 140 | + >> *( ('*' >> atom[mul_expr.val *= arg1]) |
| 141 | + | ('%' >> atom[mul_expr.val %= arg1]) |
| 142 | + | ('/' >> atom[mul_expr.val /= arg1]) |
| 143 | + ); |
133 | 144 | |
134 | | -eq_expr = lsht_expr[eq_expr.val = arg1] |
135 | | - >> *("==" >> lsht_expr[eq_expr.val = eq_expr.val == arg1]); |
136 | | - |
137 | | -lsht_expr = rsht_expr[lsht_expr.val = arg1] |
138 | | - >> *("<<" >> rsht_expr[lsht_expr.val <<= arg1]); |
139 | | - |
140 | | -rsht_expr = add_expr[rsht_expr.val = arg1] |
141 | | - >> *(">>" >> add_expr[rsht_expr.val >>= arg1]); |
142 | | - |
143 | | -add_expr = sub_expr[add_expr.val = arg1] |
144 | | - >> *('+' >> sub_expr[add_expr.val += arg1]); |
145 | | - |
146 | | -sub_expr = mul_expr[sub_expr.val = arg1] |
147 | | - >> *('-' >> mul_expr[sub_expr.val -= arg1]); |
148 | | - |
149 | | -mul_expr = mod_expr[mul_expr.val = arg1] |
150 | | - >> *('*' >> mod_expr[mul_expr.val *= arg1]); |
151 | | - |
152 | | -mod_expr = div_expr[mod_expr.val = arg1] |
153 | | - >> *('%' >> div_expr[mod_expr.val %= arg1]); |
154 | | - |
155 | | -div_expr = atom[div_expr.val = arg1] |
156 | | - >> *('/' >> atom[div_expr.val /= arg1]); |
157 | | - |
158 | 145 | atom = int_p[atom.val = arg1] |
159 | 146 | | ( '(' >> expr[atom.val = arg1] >> ')' ) |
160 | 147 | | ( '-' >> expr[atom.val = -arg1]) |
— | — | @@ -174,18 +161,10 @@ |
175 | 162 | BOOST_SPIRIT_DEBUG_RULE(bxor_expr); |
176 | 163 | BOOST_SPIRIT_DEBUG_RULE(bor_expr); |
177 | 164 | BOOST_SPIRIT_DEBUG_RULE(lt_expr); |
178 | | -BOOST_SPIRIT_DEBUG_RULE(gt_expr); |
179 | | -BOOST_SPIRIT_DEBUG_RULE(le_expr); |
180 | | -BOOST_SPIRIT_DEBUG_RULE(ge_expr); |
181 | | -BOOST_SPIRIT_DEBUG_RULE(neq_expr); |
182 | 165 | BOOST_SPIRIT_DEBUG_RULE(eq_expr); |
183 | 166 | BOOST_SPIRIT_DEBUG_RULE(lsht_expr); |
184 | | -BOOST_SPIRIT_DEBUG_RULE(rsht_expr); |
185 | 167 | BOOST_SPIRIT_DEBUG_RULE(add_expr); |
186 | | -BOOST_SPIRIT_DEBUG_RULE(sub_expr); |
187 | 168 | BOOST_SPIRIT_DEBUG_RULE(mul_expr); |
188 | | -BOOST_SPIRIT_DEBUG_RULE(mod_expr); |
189 | | -BOOST_SPIRIT_DEBUG_RULE(div_expr); |
190 | 169 | BOOST_SPIRIT_DEBUG_RULE(atom); |
191 | 170 | |
192 | 171 | } |