I'm trying to parse the binary not in and is not Python operators.
I successfully added a check in the scanner in this way:
TokenType concatenatedToken;
switch (scanner.start[0]) {
...
case 'n': {
concatenatedToken = check_kw(s, 1, 2, "ot", Token_NOT);
break;
}
// the same for `is not`.
...
}
if (concatenatedToken == Token_NOT || concatenatedToken == Token_IS) {
skip_whitespace(s);
switch (scanner.current[0]) {
case 'i':
return check_conc_kw(s, 1, 1, "n", Token_NOTIN);
case 'n':
return check_conc_kw(s, 1, 2, "ot", Token_ISNOT);
}
}
check_conc_kw() is the same as checkKeyword() except for the fact that use scanner.current (Not sure if this is the best way, but it works).
Now I'm not sure how to continue in the compiler, should I refactor the advance() function in order to check while parsing or should I make some modification in parsePrecedence()?
Note that I have a token for both not in (Token_NOTIN) and is not (Token_ISNOT).
I'm trying to parse the binary
not in
andis not
Python operators.I successfully added a check in the scanner in this way:
check_conc_kw()
is the same ascheckKeyword()
except for the fact that usescanner.current
(Not sure if this is the best way, but it works).Now I'm not sure how to continue in the compiler, should I refactor the
advance()
function in order to check while parsing or should I make some modification inparsePrecedence()
?Note that I have a token for both
not in
(Token_NOTIN
) andis not
(Token_ISNOT
).