| 2250 | FastVector<LexemeType> opStack; |
| 2251 | |
| 2252 | bool ParseArithmetic(Lexeme** str) |
| 2253 | { |
| 2254 | if(!ParseTerminal(str)) |
| 2255 | return false; |
| 2256 | unsigned int opCount = 0; |
| 2257 | while((*str)->type >= lex_add && (*str)->type <= lex_in) |
| 2258 | { |
| 2259 | LexemeType lType = (*str)->type; |
| 2260 | while(opCount > 0 && opPrecedence[opStack.back() - lex_add] <= opPrecedence[lType - lex_add]) |
| 2261 | { |
| 2262 | AddBinaryCommandNode((*str)->pos, opHandler[opStack.back() - lex_add]); |
| 2263 | opStack.pop_back(); |
| 2264 | opCount--; |
| 2265 | } |
| 2266 | opStack.push_back(lType); |
| 2267 | opCount++; // opStack is global, but we are tracing its local size |
| 2268 | (*str)++; |
| 2269 | if(!ParseTerminal(str)) |
| 2270 | ThrowError((*str)->pos, "ERROR: terminal expression not found after binary operation"); |
| 2271 | } |
| 2272 | while(opCount > 0) |
| 2273 | { |
| 2274 | AddBinaryCommandNode((*str)->pos, opHandler[opStack.back() - lex_add]); |
| 2275 | opStack.pop_back(); |
| 2276 | opCount--; |
| 2277 | } |
| 2278 | return true; |
| 2279 | } |
| 2280 | |
| 2281 | bool ParseTernaryExpr(Lexeme** str) |
| 2282 | { |
no test coverage detected