mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 03:21:20 -05:00
make equals signs full equals of colons -- you can use them inside of object literals now too
This commit is contained in:
@@ -28,10 +28,10 @@ prechigh
|
||||
left '&&' '||' AND OR
|
||||
right '-=' '+=' '/=' '*=' '%='
|
||||
right DELETE INSTANCEOF TYPEOF
|
||||
left "."
|
||||
left '.'
|
||||
right THROW FOR IN WHILE NEW SUPER
|
||||
left UNLESS IF ELSE EXTENDS
|
||||
left ':' '=' '||=' '&&='
|
||||
left ASSIGN '||=' '&&='
|
||||
right RETURN
|
||||
preclow
|
||||
|
||||
@@ -115,14 +115,13 @@ rule
|
||||
|
||||
# Assignment to a variable.
|
||||
Assign:
|
||||
Value ":" Expression { result = AssignNode.new(val[0], val[2]) }
|
||||
| Value "=" Expression { result = AssignNode.new(val[0], val[2]) }
|
||||
Value ASSIGN Expression { result = AssignNode.new(val[0], val[2]) }
|
||||
;
|
||||
|
||||
# Assignment within an object literal.
|
||||
AssignObj:
|
||||
IDENTIFIER ":" Expression { result = AssignNode.new(val[0], val[2], :object) }
|
||||
| STRING ":" Expression { result = AssignNode.new(val[0], val[2], :object) }
|
||||
IDENTIFIER ASSIGN Expression { result = AssignNode.new(val[0], val[2], :object) }
|
||||
| STRING ASSIGN Expression { result = AssignNode.new(val[0], val[2], :object) }
|
||||
| Comment { result = val[0] }
|
||||
;
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ module CoffeeScript
|
||||
# Tokens that always constitute the end of an expression.
|
||||
EXP_END = ['}', ')', ']']
|
||||
|
||||
# Assignment tokens.
|
||||
ASSIGN = [':', '=']
|
||||
|
||||
# Scan by attempting to match tokens one character at a time. Slow and steady.
|
||||
def tokenize(code)
|
||||
@code = code.chomp # Cleanup code by remove extra line breaks
|
||||
@@ -139,7 +142,8 @@ module CoffeeScript
|
||||
value ||= @chunk[0,1]
|
||||
skip_following_newlines if EXP_START.include?(value)
|
||||
remove_leading_newlines if EXP_END.include?(value)
|
||||
token(value, value)
|
||||
tag = ASSIGN.include?(value) ? :ASSIGN : value
|
||||
token(tag, value)
|
||||
@i += value.length
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user