mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 02:51:25 -05:00
Allowing @[property] syntax.
This commit is contained in:
@@ -343,6 +343,8 @@
|
|||||||
return new ValueNode(new LiteralNode('this'));
|
return new ValueNode(new LiteralNode('this'));
|
||||||
}), o("@ Identifier", function() {
|
}), o("@ Identifier", function() {
|
||||||
return new ValueNode(new LiteralNode('this'), [new AccessorNode($2)]);
|
return new ValueNode(new LiteralNode('this'), [new AccessorNode($2)]);
|
||||||
|
}), o("@ Index", function() {
|
||||||
|
return new ValueNode(new LiteralNode('this'), [$2]);
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
// The range literal.
|
// The range literal.
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
// See: http://www.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions
|
// See: http://www.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions
|
||||||
NOT_REGEX = ['IDENTIFIER', 'NUMBER', 'REGEX', 'STRING', ')', '++', '--', ']', '}', 'FALSE', 'NULL', 'TRUE'];
|
NOT_REGEX = ['IDENTIFIER', 'NUMBER', 'REGEX', 'STRING', ')', '++', '--', ']', '}', 'FALSE', 'NULL', 'TRUE'];
|
||||||
// Tokens which could legitimately be invoked or indexed.
|
// Tokens which could legitimately be invoked or indexed.
|
||||||
CALLABLE = ['IDENTIFIER', 'SUPER', ')', ']', '}', 'STRING'];
|
CALLABLE = ['IDENTIFIER', 'SUPER', ')', ']', '}', 'STRING', '@'];
|
||||||
// Tokens that indicate an access -- keywords immediately following will be
|
// Tokens that indicate an access -- keywords immediately following will be
|
||||||
// treated as identifiers.
|
// treated as identifiers.
|
||||||
ACCESSORS = ['PROPERTY_ACCESS', 'PROTOTYPE_ACCESS', 'SOAK_ACCESS', '@'];
|
ACCESSORS = ['PROPERTY_ACCESS', 'PROTOTYPE_ACCESS', 'SOAK_ACCESS', '@'];
|
||||||
|
|||||||
@@ -300,6 +300,7 @@ grammar: {
|
|||||||
This: [
|
This: [
|
||||||
o "@", -> new ValueNode(new LiteralNode('this'))
|
o "@", -> new ValueNode(new LiteralNode('this'))
|
||||||
o "@ Identifier", -> new ValueNode(new LiteralNode('this'), [new AccessorNode($2)])
|
o "@ Identifier", -> new ValueNode(new LiteralNode('this'), [new AccessorNode($2)])
|
||||||
|
o "@ Index", -> new ValueNode(new LiteralNode('this'), [$2])
|
||||||
]
|
]
|
||||||
|
|
||||||
# The range literal.
|
# The range literal.
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ NOT_REGEX: [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# Tokens which could legitimately be invoked or indexed.
|
# Tokens which could legitimately be invoked or indexed.
|
||||||
CALLABLE: ['IDENTIFIER', 'SUPER', ')', ']', '}', 'STRING']
|
CALLABLE: ['IDENTIFIER', 'SUPER', ')', ']', '}', 'STRING', '@']
|
||||||
|
|
||||||
# Tokens that indicate an access -- keywords immediately following will be
|
# Tokens that indicate an access -- keywords immediately following will be
|
||||||
# treated as identifiers.
|
# treated as identifiers.
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ bob: {
|
|||||||
greet: (salutation) ->
|
greet: (salutation) ->
|
||||||
salutation + " " + @name
|
salutation + " " + @name
|
||||||
hello: ->
|
hello: ->
|
||||||
@greet "Hello"
|
@['greet'] "Hello"
|
||||||
10: 'number'
|
10: 'number'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user