mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-19 03:44:23 -05:00
added the 'delete' operator
This commit is contained in:
@@ -148,3 +148,6 @@ a_googol: 1e100
|
|||||||
hex: 0xff0000
|
hex: 0xff0000
|
||||||
|
|
||||||
negative: -1.0
|
negative: -1.0
|
||||||
|
|
||||||
|
# Deleting.
|
||||||
|
delete secret.identity
|
||||||
@@ -11,6 +11,7 @@ token BREAK CONTINUE
|
|||||||
token FOR IN WHILE
|
token FOR IN WHILE
|
||||||
token SWITCH CASE
|
token SWITCH CASE
|
||||||
token SUPER
|
token SUPER
|
||||||
|
token DELETE
|
||||||
token NEWLINE
|
token NEWLINE
|
||||||
token JS
|
token JS
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ prechigh
|
|||||||
left '&&' '||' AND OR
|
left '&&' '||' AND OR
|
||||||
left ':'
|
left ':'
|
||||||
right '-=' '+=' '/=' '*=' '||=' '&&='
|
right '-=' '+=' '/=' '*=' '||=' '&&='
|
||||||
|
right DELETE
|
||||||
right RETURN THROW FOR WHILE
|
right RETURN THROW FOR WHILE
|
||||||
left UNLESS
|
left UNLESS
|
||||||
nonassoc IF
|
nonassoc IF
|
||||||
@@ -116,7 +118,6 @@ rule
|
|||||||
| '-' Expression = UMINUS { result = OpNode.new(val[0], val[1]) }
|
| '-' Expression = UMINUS { result = OpNode.new(val[0], val[1]) }
|
||||||
| NOT Expression { result = OpNode.new(val[0], val[1]) }
|
| NOT Expression { result = OpNode.new(val[0], val[1]) }
|
||||||
|
|
||||||
|
|
||||||
| Expression '*' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
| Expression '*' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||||
| Expression '/' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
| Expression '/' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||||
| Expression '%' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
| Expression '%' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||||
@@ -145,6 +146,8 @@ rule
|
|||||||
| Expression '*=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
| Expression '*=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||||
| Expression '||=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
| Expression '||=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||||
| Expression '&&=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
| Expression '&&=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||||
|
|
||||||
|
| DELETE Expression { result = OpNode.new(val[0], val[1]) }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ class Lexer
|
|||||||
"break", "continue",
|
"break", "continue",
|
||||||
"for", "in", "while",
|
"for", "in", "while",
|
||||||
"switch", "case",
|
"switch", "case",
|
||||||
"super"]
|
"super",
|
||||||
|
"delete"]
|
||||||
|
|
||||||
IDENTIFIER = /\A([a-zA-Z$_]\w*)/
|
IDENTIFIER = /\A([a-zA-Z$_]\w*)/
|
||||||
NUMBER = /\A\b((0(x|X)[0-9a-fA-F]+)|([0-9]+(\.[0-9]+)?(e[+\-]?[0-9]+)?))\b/i
|
NUMBER = /\A\b((0(x|X)[0-9a-fA-F]+)|([0-9]+(\.[0-9]+)?(e[+\-]?[0-9]+)?))\b/i
|
||||||
|
|||||||
@@ -252,7 +252,8 @@ class OpNode < Node
|
|||||||
end
|
end
|
||||||
|
|
||||||
def compile_unary(indent, scope)
|
def compile_unary(indent, scope)
|
||||||
"#{@operator}#{@first.compile(indent, scope)}"
|
space = @operator == 'delete' ? ' ' : ''
|
||||||
|
"#{@operator}#{space}#{@first.compile(indent, scope)}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user