diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-03-06 23:56:41 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-03-07 23:17:51 +0100 |
commit | efe8a0233bea283765443226340fa732cffc9ca6 (patch) | |
tree | 3532b18c9ada2e4bab1ec7d4e89e960067168c3e /include | |
parent | 05bd7edd7a101aa09a54371aa34bc22646b75bee (diff) |
syntax: support add new operators
- Support ES2016 exponentiation (**) and exponentiation assignment (**=)
- Support ES2020 nullish coalescing (??) and logical nullish assignment (??=)
- Support ES2021 logical and assignment (&&=) and logical or assignment (||=)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'include')
-rw-r--r-- | include/ucode/compiler.h | 6 | ||||
-rw-r--r-- | include/ucode/lexer.h | 6 | ||||
-rw-r--r-- | include/ucode/vm.h | 1 |
3 files changed, 11 insertions, 2 deletions
diff --git a/include/ucode/compiler.h b/include/ucode/compiler.h index c112027..ffe7caf 100644 --- a/include/ucode/compiler.h +++ b/include/ucode/compiler.h @@ -37,11 +37,11 @@ typedef enum { P_COMMA, /* , */ - P_ASSIGN, /* = += -= *= /= %= <<= >>= &= ^= |= */ + P_ASSIGN, /* = += -= *= /= %= <<= >>= &= ^= |= ||= &&= **= ??= */ P_TERNARY, /* ?: */ - P_OR, /* || */ + P_OR, /* || ?? */ P_AND, /* && */ P_BOR, /* | */ P_BXOR, /* ^ */ @@ -55,6 +55,8 @@ typedef enum { P_ADD, /* + - */ P_MUL, /* * / % */ + P_EXP, /* ** */ + P_UNARY, /* ! ~ +… -… ++… --… */ P_INC, /* …++ …-- */ diff --git a/include/ucode/lexer.h b/include/ucode/lexer.h index 30849e0..aa5d78b 100644 --- a/include/ucode/lexer.h +++ b/include/ucode/lexer.h @@ -63,6 +63,7 @@ typedef enum { TK_MUL, TK_DIV, TK_MOD, + TK_EXP, TK_NOT, TK_COMPL, TK_INC, @@ -109,6 +110,11 @@ typedef enum { TK_QLBRACK, TK_QLPAREN, TK_QDOT, + TK_ASEXP, + TK_ASAND, + TK_ASOR, + TK_ASNULLISH, + TK_NULLISH, TK_EOF, TK_ERROR diff --git a/include/ucode/vm.h b/include/ucode/vm.h index 4ba4627..24818a1 100644 --- a/include/ucode/vm.h +++ b/include/ucode/vm.h @@ -77,6 +77,7 @@ __insn(SUB) \ __insn(MUL) \ __insn(DIV) \ __insn(MOD) \ +__insn(EXP) \ __insn(NOT) \ __insn(COMPL) \ __insn(PLUS) \ |