Fixing naked chained existential checks -- the associativity recently got reversed.
This commit is contained in:
parent
c90a75ebc5
commit
129e950c59
|
@ -555,6 +555,8 @@
|
||||||
return new OpNode('--', $1, null, true);
|
return new OpNode('--', $1, null, true);
|
||||||
}), o("Expression ++", function() {
|
}), o("Expression ++", function() {
|
||||||
return new OpNode('++', $1, null, true);
|
return new OpNode('++', $1, null, true);
|
||||||
|
}), o("Expression ? Expression", function() {
|
||||||
|
return new OpNode('?', $1, $3);
|
||||||
}), o("Expression + Expression", function() {
|
}), o("Expression + Expression", function() {
|
||||||
return new OpNode('+', $1, $3);
|
return new OpNode('+', $1, $3);
|
||||||
}), o("Expression - Expression", function() {
|
}), o("Expression - Expression", function() {
|
||||||
|
@ -588,7 +590,7 @@
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
operators = [["left", '?'], ["nonassoc", '++', '--'], ["right", 'UNARY'], ["left", 'MATH'], ["left", '+', '-'], ["left", 'SHIFT'], ["left", 'COMPARE'], ["left", 'INSTANCEOF'], ["left", '==', '!='], ["left", 'LOGIC'], ["right", 'COMPOUND_ASSIGN'], ["left", '.'], ["nonassoc", 'INDENT', 'OUTDENT'], ["right", 'WHEN', 'LEADING_WHEN', 'IN', 'OF', 'BY', 'THROW'], ["right", 'IF', 'UNLESS', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'NEW', 'SUPER', 'CLASS', 'EXTENDS'], ["right", '=', ':', 'RETURN'], ["right", '->', '=>', 'UNLESS', 'POST_IF', 'POST_UNLESS']];
|
operators = [["right", '?'], ["nonassoc", '++', '--'], ["right", 'UNARY'], ["left", 'MATH'], ["left", '+', '-'], ["left", 'SHIFT'], ["left", 'COMPARE'], ["left", 'INSTANCEOF'], ["left", '==', '!='], ["left", 'LOGIC'], ["right", 'COMPOUND_ASSIGN'], ["left", '.'], ["nonassoc", 'INDENT', 'OUTDENT'], ["right", 'WHEN', 'LEADING_WHEN', 'IN', 'OF', 'BY', 'THROW'], ["right", 'IF', 'UNLESS', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'NEW', 'SUPER', 'CLASS', 'EXTENDS'], ["right", '=', ':', 'RETURN'], ["right", '->', '=>', 'UNLESS', 'POST_IF', 'POST_UNLESS']];
|
||||||
tokens = [];
|
tokens = [];
|
||||||
_a = grammar;
|
_a = grammar;
|
||||||
for (name in _a) {
|
for (name in _a) {
|
||||||
|
|
|
@ -339,7 +339,7 @@
|
||||||
}
|
}
|
||||||
if (value === ';') {
|
if (value === ';') {
|
||||||
tag = 'TERMINATOR';
|
tag = 'TERMINATOR';
|
||||||
} else if ((value === '?' && spaced) || include(LOGIC, value)) {
|
} else if (include(LOGIC, value)) {
|
||||||
tag = 'LOGIC';
|
tag = 'LOGIC';
|
||||||
} else if (include(MATH, value)) {
|
} else if (include(MATH, value)) {
|
||||||
tag = 'MATH';
|
tag = 'MATH';
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -529,6 +529,7 @@ grammar =
|
||||||
o "Expression --", -> new OpNode '--', $1, null, true
|
o "Expression --", -> new OpNode '--', $1, null, true
|
||||||
o "Expression ++", -> new OpNode '++', $1, null, true
|
o "Expression ++", -> new OpNode '++', $1, null, true
|
||||||
|
|
||||||
|
o "Expression ? Expression", -> new OpNode '?', $1, $3
|
||||||
o "Expression + Expression", -> new OpNode '+', $1, $3
|
o "Expression + Expression", -> new OpNode '+', $1, $3
|
||||||
o "Expression - Expression", -> new OpNode '-', $1, $3
|
o "Expression - Expression", -> new OpNode '-', $1, $3
|
||||||
o "Expression == Expression", -> new OpNode '==', $1, $3
|
o "Expression == Expression", -> new OpNode '==', $1, $3
|
||||||
|
@ -561,7 +562,7 @@ grammar =
|
||||||
#
|
#
|
||||||
# (2 + 3) * 4
|
# (2 + 3) * 4
|
||||||
operators = [
|
operators = [
|
||||||
["left", '?']
|
["right", '?']
|
||||||
["nonassoc", '++', '--']
|
["nonassoc", '++', '--']
|
||||||
["right", 'UNARY']
|
["right", 'UNARY']
|
||||||
["left", 'MATH']
|
["left", 'MATH']
|
||||||
|
|
|
@ -280,13 +280,13 @@ exports.Lexer = class Lexer
|
||||||
if @value() in ['or', 'and']
|
if @value() in ['or', 'and']
|
||||||
@tokens.splice(@tokens.length - 1, 1, ['COMPOUND_ASSIGN', CONVERSIONS[@value()] + '=', @prev()[2]])
|
@tokens.splice(@tokens.length - 1, 1, ['COMPOUND_ASSIGN', CONVERSIONS[@value()] + '=', @prev()[2]])
|
||||||
return true
|
return true
|
||||||
if value is ';' then tag = 'TERMINATOR'
|
if value is ';' then tag = 'TERMINATOR'
|
||||||
else if (value is '?' and spaced) or include(LOGIC, value) then tag = 'LOGIC'
|
else if include(LOGIC, value) then tag = 'LOGIC'
|
||||||
else if include(MATH, value) then tag = 'MATH'
|
else if include(MATH, value) then tag = 'MATH'
|
||||||
else if include(COMPARE, value) then tag = 'COMPARE'
|
else if include(COMPARE, value) then tag = 'COMPARE'
|
||||||
else if include(COMPOUND_ASSIGN, value) then tag = 'COMPOUND_ASSIGN'
|
else if include(COMPOUND_ASSIGN, value) then tag = 'COMPOUND_ASSIGN'
|
||||||
else if include(UNARY, value) then tag = 'UNARY'
|
else if include(UNARY, value) then tag = 'UNARY'
|
||||||
else if include(SHIFT, value) then tag = 'SHIFT'
|
else if include(SHIFT, value) then tag = 'SHIFT'
|
||||||
else if include(CALLABLE, @tag()) and not spaced
|
else if include(CALLABLE, @tag()) and not spaced
|
||||||
if value is '('
|
if value is '('
|
||||||
tag = 'CALL_START'
|
tag = 'CALL_START'
|
||||||
|
|
|
@ -24,6 +24,8 @@ func = -> i += 1
|
||||||
result = func() ? 101
|
result = func() ? 101
|
||||||
ok result is 10
|
ok result is 10
|
||||||
|
|
||||||
|
ok (non ? existent ? variables ? 1) is 1
|
||||||
|
|
||||||
|
|
||||||
# Only evaluate once.
|
# Only evaluate once.
|
||||||
counter = 0
|
counter = 0
|
||||||
|
|
Loading…
Reference in New Issue