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

Function ParseVariable

NULLC/Parser.cpp:1817–1852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1815}
1816
1817bool ParseVariable(Lexeme** str, bool *lastIsFunctionCall = NULL)
1818{
1819 if(ParseLexem(str, lex_mul))
1820 {
1821 if(!ParseTerminal(str))
1822 ThrowError((*str)->pos, "ERROR: variable name not found after '*'");
1823 AddGetVariableNode((*str)->pos, true);
1824 return true;
1825 }
1826
1827 if((*str)->type != lex_string || (*str)[1].type == lex_oparen)
1828 return false;
1829
1830 NamespaceInfo* lastNS = GetCurrentNamespace();
1831 SetCurrentNamespace(NULL);
1832 NamespaceInfo* ns = NULL;
1833 while((*str)->type == lex_string && (*str + 1)->type == lex_point && (ns = IsNamespace(InplaceStr((*str)->pos, (*str)->length))) != NULL)
1834 {
1835 (*str)++;
1836 if(!ParseLexem(str, lex_point))
1837 ThrowError((*str)->pos, "ERROR: '.' not found after namespace name");
1838 SetCurrentNamespace(ns);
1839 }
1840
1841 if((*str)->length >= NULLC_MAX_VARIABLE_NAME_LENGTH)
1842 ThrowError((*str)->pos, "ERROR: variable name length is limited to 2048 symbols");
1843 AddGetAddressNode((*str)->pos, InplaceStr((*str)->pos, (*str)->length));
1844 (*str)++;
1845 SetCurrentNamespace(lastNS);
1846
1847 bool isFuncCall = false;
1848 while(ParsePostExpression(str, &isFuncCall));
1849 if(lastIsFunctionCall)
1850 *lastIsFunctionCall = isFuncCall;
1851 return true;
1852}
1853
1854bool ParsePostExpression(Lexeme** str, bool *isFunctionCall = NULL)
1855{

Callers 1

ParseTerminalFunction · 0.85

Calls 10

ParseLexemFunction · 0.85
ParseTerminalFunction · 0.85
ThrowErrorFunction · 0.85
AddGetVariableNodeFunction · 0.85
GetCurrentNamespaceFunction · 0.85
SetCurrentNamespaceFunction · 0.85
IsNamespaceFunction · 0.85
InplaceStrClass · 0.85
AddGetAddressNodeFunction · 0.85
ParsePostExpressionFunction · 0.85

Tested by

no test coverage detected