Add support for left/right shift operator

This commit is contained in:
yuanchuan 2021-10-29 17:18:49 +08:00
parent e6ed6ed6e0
commit f91f8da978
1 changed files with 5 additions and 2 deletions

View File

@ -24,7 +24,8 @@ const operator = {
'*': 6, '/': 6, '÷': 6, '%': 6,
'&': 5, '|': 5,
'+': 4, '-': 4,
'<': 3, '>': 3,
'<': 3, '<<': 3,
'>': 3, '>>': 3,
'=': 3, '==': 3,
'≤': 3, '<=': 3,
'≥': 3, '>=': 3,
@ -110,7 +111,7 @@ function get_tokens(input) {
if (c == '=' && last_token && /^[!<>=]$/.test(last_token.value)) {
last_token.value += c;
}
else if (/^[|&]$/.test(c) && last_token && last_token.value == c) {
else if (/^[|&<>]$/.test(c) && last_token && last_token.value == c) {
last_token.value += c;
}
else if (c == '-' && expr[i - 1] == 'e') {
@ -255,6 +256,8 @@ function compute(op, a, b) {
case '≠': case '!=': return a != b;
case '∧': case '&&': return a && b;
case '': case '||': return a || b;
case '<<': return a << b;
case '>>': return a >> b;
}
}