Update coalesce precedence (#11017)
* refactor: reimplement nullish coalescing precedence tracking Co-authored-by: Toru Nagashima <public@mysticatea.dev> * fix: Coalesce has same precedence with LogicalOR * fix flow errors Co-authored-by: Toru Nagashima <public@mysticatea.dev>
This commit is contained in:
committed by
Nicolò Ribaudo
parent
6648d62f40
commit
45301c5304
@@ -139,22 +139,22 @@ export const types: { [name: string]: TokenType } = {
|
||||
tilde: new TokenType("~", { beforeExpr, prefix, startsExpr }),
|
||||
pipeline: createBinop("|>", 0),
|
||||
nullishCoalescing: createBinop("??", 1),
|
||||
logicalOR: createBinop("||", 2),
|
||||
logicalAND: createBinop("&&", 3),
|
||||
bitwiseOR: createBinop("|", 4),
|
||||
bitwiseXOR: createBinop("^", 5),
|
||||
bitwiseAND: createBinop("&", 6),
|
||||
equality: createBinop("==/!=/===/!==", 7),
|
||||
relational: createBinop("</>/<=/>=", 8),
|
||||
bitShift: createBinop("<</>>/>>>", 9),
|
||||
plusMin: new TokenType("+/-", { beforeExpr, binop: 10, prefix, startsExpr }),
|
||||
logicalOR: createBinop("||", 1),
|
||||
logicalAND: createBinop("&&", 2),
|
||||
bitwiseOR: createBinop("|", 3),
|
||||
bitwiseXOR: createBinop("^", 4),
|
||||
bitwiseAND: createBinop("&", 5),
|
||||
equality: createBinop("==/!=/===/!==", 6),
|
||||
relational: createBinop("</>/<=/>=", 7),
|
||||
bitShift: createBinop("<</>>/>>>", 8),
|
||||
plusMin: new TokenType("+/-", { beforeExpr, binop: 9, prefix, startsExpr }),
|
||||
// startsExpr: required by v8intrinsic plugin
|
||||
modulo: new TokenType("%", { beforeExpr, binop: 11, startsExpr }),
|
||||
star: createBinop("*", 11),
|
||||
slash: createBinop("/", 11),
|
||||
modulo: new TokenType("%", { beforeExpr, binop: 10, startsExpr }),
|
||||
star: createBinop("*", 10),
|
||||
slash: createBinop("/", 10),
|
||||
exponent: new TokenType("**", {
|
||||
beforeExpr,
|
||||
binop: 12,
|
||||
binop: 11,
|
||||
rightAssociative: true,
|
||||
}),
|
||||
|
||||
@@ -189,8 +189,8 @@ export const types: { [name: string]: TokenType } = {
|
||||
_null: createKeyword("null", { startsExpr }),
|
||||
_true: createKeyword("true", { startsExpr }),
|
||||
_false: createKeyword("false", { startsExpr }),
|
||||
_in: createKeyword("in", { beforeExpr, binop: 8 }),
|
||||
_instanceof: createKeyword("instanceof", { beforeExpr, binop: 8 }),
|
||||
_in: createKeyword("in", { beforeExpr, binop: 7 }),
|
||||
_instanceof: createKeyword("instanceof", { beforeExpr, binop: 7 }),
|
||||
_typeof: createKeyword("typeof", { beforeExpr, prefix, startsExpr }),
|
||||
_void: createKeyword("void", { beforeExpr, prefix, startsExpr }),
|
||||
_delete: createKeyword("delete", { beforeExpr, prefix, startsExpr }),
|
||||
|
||||
Reference in New Issue
Block a user