Added support for the ampersand operator

This commit is contained in:
Tristan B. Velloza Kildaire 2022-04-13 09:49:20 +02:00
parent 15a848756b
commit 1f8f248219
1 changed files with 15 additions and 0 deletions

View File

@ -51,6 +51,7 @@ public enum SymbolType
ADD,
DIVIDE,
STAR,
AMPERSAND,
UNKNOWN
}
@ -399,6 +400,11 @@ public SymbolType getSymbolType(Token tokenIn)
{
return SymbolType.DIVIDE;
}
/* Ampersand `&` operator check */
else if(token[0] == '&')
{
return SymbolType.AMPERSAND;
}
@ -417,6 +423,15 @@ public bool isMathOp(Token token)
tokenStr[0] == '*' || tokenStr[0] == '/';
}
public bool isBinaryOp(Token token)
{
string tokenStr = token.getToken();
return tokenStr[0] == '&' || cmp("&&", tokenStr) == 0 ||
tokenStr[0] == '|' || cmp("||", tokenStr) == 0 ||
tokenStr[0] == '^' || tokenStr[0] == '~';
}
/* Test: Character literal */