mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
added the instanceof operator to the grammar as an operation node
This commit is contained in:
@@ -10,8 +10,8 @@ token TRY CATCH FINALLY THROW
|
||||
token BREAK CONTINUE
|
||||
token FOR IN WHILE
|
||||
token SWITCH WHEN
|
||||
token DELETE INSTANCEOF
|
||||
token SUPER
|
||||
token DELETE
|
||||
token NEWLINE
|
||||
token COMMENT
|
||||
token JS
|
||||
@@ -27,7 +27,7 @@ prechigh
|
||||
right '==' '!=' IS AINT
|
||||
left '&&' '||' AND OR
|
||||
right '-=' '+=' '/=' '*='
|
||||
right DELETE
|
||||
right DELETE INSTANCEOF
|
||||
left "."
|
||||
right THROW FOR IN WHILE NEW
|
||||
left UNLESS IF ELSE
|
||||
@@ -185,6 +185,7 @@ rule
|
||||
| Expression '&&:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
|
||||
| DELETE Expression { result = OpNode.new(val[0], val[1]) }
|
||||
| Expression INSTANCEOF Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
;
|
||||
|
||||
# Function definition.
|
||||
|
||||
@@ -15,7 +15,7 @@ module CoffeeScript
|
||||
"for", "in", "while",
|
||||
"switch", "when",
|
||||
"super",
|
||||
"delete"]
|
||||
"delete", "instanceof"]
|
||||
|
||||
# Token matching regexes.
|
||||
IDENTIFIER = /\A([a-zA-Z$_]\w*)/
|
||||
|
||||
10
test/fixtures/execution/keyword_operators.cs
vendored
Normal file
10
test/fixtures/execution/keyword_operators.cs
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
a: 5
|
||||
atype: typeof(a)
|
||||
|
||||
b: "hello"
|
||||
btype: typeof(b)
|
||||
|
||||
Klass: => .
|
||||
k: new Klass()
|
||||
|
||||
print(atype is 'number' and btype is 'string' and k instanceof(Klass))
|
||||
10
test/fixtures/execution/keyword_operators.js
vendored
Normal file
10
test/fixtures/execution/keyword_operators.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
(function(){
|
||||
var a = 5;
|
||||
var atype = typeof(a);
|
||||
var b = "hello";
|
||||
var btype = typeof(b);
|
||||
var Klass = function() {
|
||||
};
|
||||
var k = new Klass();
|
||||
print(atype === 'number' && btype === 'string' && k instanceof Klass);
|
||||
})();
|
||||
Reference in New Issue
Block a user