mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
hopefully the last enhancement for my #1380 fix
This commit is contained in:
parent
94fb7e32ea
commit
085874d5f3
5 changed files with 25 additions and 21 deletions
|
@ -617,7 +617,7 @@
|
|||
JS_FORBIDDEN = JS_KEYWORDS.concat(RESERVED);
|
||||
exports.RESERVED = RESERVED.concat(JS_KEYWORDS).concat(COFFEE_KEYWORDS);
|
||||
IDENTIFIER = /^([$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)([^\n\S]*:(?!:))?/;
|
||||
NUMBER = /^0x[\da-f]+|^(?:\d+(\.\d+)?|\.\d+)(?:e[+-]?\d+)?/i;
|
||||
NUMBER = /^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i;
|
||||
HEREDOC = /^("""|''')([\s\S]*?)(?:\n[^\n\S]*)?\1/;
|
||||
OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/;
|
||||
WHITESPACE = /^[^\n\S]+/;
|
||||
|
|
|
@ -589,7 +589,7 @@
|
|||
throw SyntaxError('cannot call super outside of a function.');
|
||||
}
|
||||
name = method.name;
|
||||
if (!name) {
|
||||
if (name == null) {
|
||||
throw SyntaxError('cannot call super on an anonymous function.');
|
||||
}
|
||||
if (method.klass) {
|
||||
|
@ -1140,7 +1140,7 @@
|
|||
return unfoldSoak(o, this, 'variable');
|
||||
};
|
||||
Assign.prototype.compileNode = function(o) {
|
||||
var isValue, match, name, val, _ref2, _ref3, _ref4;
|
||||
var isValue, match, name, val, _ref2, _ref3, _ref4, _ref5;
|
||||
if (isValue = this.variable instanceof Value) {
|
||||
if (this.variable.isArray() || this.variable.isObject()) {
|
||||
return this.compilePatternMatch(o);
|
||||
|
@ -1167,7 +1167,7 @@
|
|||
if (match[1]) {
|
||||
this.value.klass = match[1];
|
||||
}
|
||||
this.value.name = (_ref3 = (_ref4 = match[2]) != null ? _ref4 : match[3]) != null ? _ref3 : match[4];
|
||||
this.value.name = (_ref3 = (_ref4 = (_ref5 = match[2]) != null ? _ref5 : match[3]) != null ? _ref4 : match[4]) != null ? _ref3 : match[5];
|
||||
}
|
||||
val = this.value.compile(o, LEVEL_LIST);
|
||||
if (this.context === 'object') {
|
||||
|
@ -2263,7 +2263,7 @@
|
|||
IDENTIFIER_STR = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*";
|
||||
IDENTIFIER = RegExp("^" + IDENTIFIER_STR + "$");
|
||||
SIMPLENUM = /^[+-]?\d+$/;
|
||||
METHOD_DEF = RegExp("^(?:(" + IDENTIFIER_STR + ")\\.prototype(?:\\.(" + IDENTIFIER_STR + ")|\\[(\"(?:[^\"\\r\\n]|\\\\\")*\"|'(?:[^'\\r\\n]|\\\\')*')\\]))|(" + IDENTIFIER_STR + ")$");
|
||||
METHOD_DEF = RegExp("^(?:(" + IDENTIFIER_STR + ")\\.prototype(?:\\.(" + IDENTIFIER_STR + ")|\\[(\"(?:[^\\\\\"\\r\\n]|\\\\.)*\"|'(?:[^\\\\'\\r\\n]|\\\\.)*')\\]|\\[(0x[\\da-fA-F]+|\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\]))|(" + IDENTIFIER_STR + ")$");
|
||||
IS_STRING = /^['"]/;
|
||||
utility = function(name) {
|
||||
var ref;
|
||||
|
|
|
@ -554,7 +554,7 @@ IDENTIFIER = /// ^
|
|||
|
||||
NUMBER = ///
|
||||
^ 0x[\da-f]+ | # hex
|
||||
^ (?: \d+(\.\d+)? | \.\d+ ) (?:e[+-]?\d+)? # decimal
|
||||
^ \d*\.?\d+ (?:e[+-]?\d+)? # decimal
|
||||
///i
|
||||
|
||||
HEREDOC = /// ^ ("""|''') ([\s\S]*?) (?:\n[^\n\S]*)? \1 ///
|
||||
|
|
|
@ -467,7 +467,7 @@ exports.Call = class Call extends Base
|
|||
{method} = o.scope
|
||||
throw SyntaxError 'cannot call super outside of a function.' unless method
|
||||
{name} = method
|
||||
throw SyntaxError 'cannot call super on an anonymous function.' unless name
|
||||
throw SyntaxError 'cannot call super on an anonymous function.' unless name?
|
||||
if method.klass
|
||||
(new Value (new Literal method.klass), [new Access(new Literal "__super__"), new Access new Literal name]).compile o
|
||||
else
|
||||
|
@ -934,7 +934,7 @@ exports.Assign = class Assign extends Base
|
|||
o.scope.find name
|
||||
if @value instanceof Code and match = METHOD_DEF.exec name
|
||||
@value.klass = match[1] if match[1]
|
||||
@value.name = match[2] ? match[3] ? match[4]
|
||||
@value.name = match[2] ? match[3] ? match[4] ? match[5]
|
||||
val = @value.compile o, LEVEL_LIST
|
||||
return "#{name}: #{val}" if @context is 'object'
|
||||
val = name + " #{ @context or '=' } " + val
|
||||
|
@ -1802,19 +1802,19 @@ IDENTIFIER_STR = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*"
|
|||
IDENTIFIER = /// ^ #{IDENTIFIER_STR} $ ///
|
||||
SIMPLENUM = /^[+-]?\d+$/
|
||||
METHOD_DEF = ///
|
||||
^
|
||||
(?:
|
||||
(#{IDENTIFIER_STR})
|
||||
\.prototype
|
||||
(?:
|
||||
\.(#{IDENTIFIER_STR})
|
||||
|
|
||||
\[("(?:[^"\r\n]|\\")*"|'(?:[^'\r\n]|\\')*')\]
|
||||
)
|
||||
)
|
||||
|
|
||||
(#{IDENTIFIER_STR})
|
||||
$
|
||||
^
|
||||
(?:
|
||||
(#{IDENTIFIER_STR})
|
||||
\.prototype
|
||||
(?:
|
||||
\.(#{IDENTIFIER_STR})
|
||||
| \[("(?:[^\\"\r\n]|\\.)*"|'(?:[^\\'\r\n]|\\.)*')\]
|
||||
| \[(0x[\da-fA-F]+ | \d*\.?\d+ (?:[eE][+-]?\d+)?)\]
|
||||
)
|
||||
)
|
||||
|
|
||||
(#{IDENTIFIER_STR})
|
||||
$
|
||||
///
|
||||
|
||||
# Is a literal value a string?
|
||||
|
|
|
@ -486,3 +486,7 @@ test "#1380: `super` with reserved names", ->
|
|||
class C
|
||||
do: -> super
|
||||
ok C::do
|
||||
|
||||
class B
|
||||
0: -> super
|
||||
ok B::[0]
|
||||
|
|
Loading…
Add table
Reference in a new issue