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

Function ParseDoWhileExpr

NULLC/Parser.cpp:1609–1635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1607}
1608
1609bool ParseDoWhileExpr(Lexeme** str)
1610{
1611 if(!ParseLexem(str, lex_do))
1612 return false;
1613
1614 IncreaseCycleDepth();
1615
1616 if(!ParseExpression(str))
1617 ThrowError((*str)->pos, "ERROR: expression expected after 'do'");
1618
1619 if(!ParseLexem(str, lex_while))
1620 ThrowError((*str)->pos, "ERROR: 'while' expected after 'do' statement");
1621 if(!ParseLexem(str, lex_oparen))
1622 ThrowError((*str)->pos, "ERROR: '(' not found after 'while'");
1623
1624 const char *condPos = (*str)->pos;
1625 if(!ParseVaribleSet(str))
1626 ThrowError((*str)->pos, "ERROR: expression expected after 'while('");
1627 if(!ParseLexem(str, lex_cparen))
1628 ThrowError((*str)->pos, "ERROR: closing ')' not found after expression in 'while' statement");
1629
1630 AddDoWhileNode(condPos);
1631
1632 if(!ParseLexem(str, lex_semicolon))
1633 ThrowError((*str)->pos, "ERROR: while(...) should be followed by ';'");
1634 return true;
1635}
1636
1637bool ParseSwitchExpr(Lexeme** str)
1638{

Callers 1

ParseExpressionFunction · 0.85

Calls 6

ParseLexemFunction · 0.85
IncreaseCycleDepthFunction · 0.85
ParseExpressionFunction · 0.85
ThrowErrorFunction · 0.85
ParseVaribleSetFunction · 0.85
AddDoWhileNodeFunction · 0.85

Tested by

no test coverage detected