MCPcopy Create free account
hub / github.com/WheretIB/nullc / ParseArithmetic

Function ParseArithmetic

NULLC/Parser.cpp:2252–2279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2250FastVector<LexemeType> opStack;
2251
2252bool 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
2281bool ParseTernaryExpr(Lexeme** str)
2282{

Callers 1

ParseTernaryExprFunction · 0.85

Calls 5

ParseTerminalFunction · 0.85
AddBinaryCommandNodeFunction · 0.85
ThrowErrorFunction · 0.85
pop_backMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected