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

Function ParseTerminal

NULLC/Parser.cpp:1948–2247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1946}
1947
1948bool ParseTerminal(Lexeme** str)
1949{
1950 switch((*str)->type)
1951 {
1952 case lex_true:
1953 case lex_false:
1954 CodeInfo::nodeList.push_back(new NodeNumber((*str)->type == lex_true ? 1 : 0, typeBool));
1955 (*str)++;
1956 return true;
1957 break;
1958 case lex_number:
1959 return ParseNumber(str);
1960 break;
1961 case lex_nullptr:
1962 (*str)++;
1963 AddNullPointer();
1964 return true;
1965 break;
1966 case lex_bitand:
1967 (*str)++;
1968 if(!ParseVariable(str))
1969 ThrowError((*str)->pos, "ERROR: variable not found after '&'");
1970 return true;
1971 break;
1972 case lex_lognot:
1973 (*str)++;
1974 if(!ParseTerminal(str))
1975 ThrowError((*str)->pos, "ERROR: expression not found after '!'");
1976 AddLogNotNode((*str)->pos);
1977 return true;
1978 break;
1979 case lex_bitnot:
1980 (*str)++;
1981 if(!ParseTerminal(str))
1982 ThrowError((*str)->pos, "ERROR: expression not found after '~'");
1983 AddBitNotNode((*str)->pos);
1984 return true;
1985 break;
1986 case lex_dec:
1987 (*str)++;
1988 if(!ParseVariable(str))
1989 {
1990 if(!ParseGroup(str))
1991 ThrowError((*str)->pos, "ERROR: variable not found after '--'");
1992 else
1993 UndoDereferceNode((*str)->pos);
1994 }
1995 AddUnaryModifyOpNode((*str)->pos, OP_DECREMENT, OP_PREFIX);
1996 return true;
1997 break;
1998 case lex_inc:
1999 (*str)++;
2000 if(!ParseVariable(str))
2001 {
2002 if(!ParseGroup(str))
2003 ThrowError((*str)->pos, "ERROR: variable not found after '++'");
2004 else
2005 UndoDereferceNode((*str)->pos);

Callers 4

ParseBreakExprFunction · 0.85
ParseContinueExprFunction · 0.85
ParseVariableFunction · 0.85
ParseArithmeticFunction · 0.85

Calls 15

ParseNumberFunction · 0.85
AddNullPointerFunction · 0.85
ParseVariableFunction · 0.85
ThrowErrorFunction · 0.85
AddLogNotNodeFunction · 0.85
AddBitNotNodeFunction · 0.85
ParseGroupFunction · 0.85
UndoDereferceNodeFunction · 0.85
AddUnaryModifyOpNodeFunction · 0.85
ParseLexemFunction · 0.85
AddPositiveNodeFunction · 0.85
AddNegateNodeFunction · 0.85

Tested by

no test coverage detected