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

Function ParseWhileExpr

NULLC/Parser.cpp:1584–1607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1582}
1583
1584bool ParseWhileExpr(Lexeme** str)
1585{
1586 if(!ParseLexem(str, lex_while))
1587 return false;
1588
1589 IncreaseCycleDepth();
1590 if(!ParseLexem(str, lex_oparen))
1591 ThrowError((*str)->pos, "ERROR: '(' not found after 'while'");
1592
1593 const char *condPos = (*str)->pos;
1594 if(!ParseVaribleSet(str))
1595 ThrowError((*str)->pos, "ERROR: expression expected after 'while('");
1596 if(!ParseLexem(str, lex_cparen))
1597 ThrowError((*str)->pos, "ERROR: closing ')' not found after expression in 'while' statement");
1598
1599 if(!ParseExpression(str))
1600 {
1601 if(!ParseLexem(str, lex_semicolon))
1602 ThrowError((*str)->pos, "ERROR: expression or ';' expected after 'while(...)'");
1603 AddVoidNode();
1604 }
1605 AddWhileNode(condPos);
1606 return true;
1607}
1608
1609bool ParseDoWhileExpr(Lexeme** str)
1610{

Callers 1

ParseExpressionFunction · 0.85

Calls 7

ParseLexemFunction · 0.85
IncreaseCycleDepthFunction · 0.85
ThrowErrorFunction · 0.85
ParseVaribleSetFunction · 0.85
ParseExpressionFunction · 0.85
AddVoidNodeFunction · 0.85
AddWhileNodeFunction · 0.85

Tested by

no test coverage detected