Fixing naked chained existential checks -- the associativity recently got reversed.

This commit is contained in:
Jeremy Ashkenas
2010-08-14 16:33:20 -04:00
parent c90a75ebc5
commit 129e950c59
6 changed files with 30 additions and 23 deletions

View File

@@ -529,6 +529,7 @@ grammar =
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
@@ -561,7 +562,7 @@ grammar =
#
# (2 + 3) * 4
operators = [
["left", '?']
["right", '?']
["nonassoc", '++', '--']
["right", 'UNARY']
["left", 'MATH']

View File

@@ -280,13 +280,13 @@ exports.Lexer = class Lexer
if @value() in ['or', 'and']
@tokens.splice(@tokens.length - 1, 1, ['COMPOUND_ASSIGN', CONVERSIONS[@value()] + '=', @prev()[2]])
return true
if value is ';' then tag = 'TERMINATOR'
else if (value is '?' and spaced) or include(LOGIC, value) then tag = 'LOGIC'
else if include(MATH, value) then tag = 'MATH'
else if include(COMPARE, value) then tag = 'COMPARE'
else if include(COMPOUND_ASSIGN, value) then tag = 'COMPOUND_ASSIGN'
else if include(UNARY, value) then tag = 'UNARY'
else if include(SHIFT, value) then tag = 'SHIFT'
if value is ';' then tag = 'TERMINATOR'
else if include(LOGIC, value) then tag = 'LOGIC'
else if include(MATH, value) then tag = 'MATH'
else if include(COMPARE, value) then tag = 'COMPARE'
else if include(COMPOUND_ASSIGN, value) then tag = 'COMPOUND_ASSIGN'
else if include(UNARY, value) then tag = 'UNARY'
else if include(SHIFT, value) then tag = 'SHIFT'
else if include(CALLABLE, @tag()) and not spaced
if value is '('
tag = 'CALL_START'