Fixing issue #676, chained accesses against the super() keyword.
This commit is contained in:
parent
b727245834
commit
a3c224e57a
|
@ -255,7 +255,7 @@
|
|||
})
|
||||
],
|
||||
Call: [
|
||||
o("Invocation"), o("Super"), o("NEW Invocation", function() {
|
||||
o("Invocation"), o("NEW Invocation", function() {
|
||||
return $2.newInstance();
|
||||
}), o("NEW Value", function() {
|
||||
return (new CallNode($2, [])).newInstance();
|
||||
|
@ -271,6 +271,10 @@
|
|||
return new CallNode($1, $3, $2);
|
||||
}), o("Invocation OptFuncExist Arguments", function() {
|
||||
return new CallNode($1, $3, $2);
|
||||
}), o("SUPER", function() {
|
||||
return new CallNode('super', [new SplatNode(new LiteralNode('arguments'))]);
|
||||
}), o("SUPER Arguments", function() {
|
||||
return new CallNode('super', $2);
|
||||
})
|
||||
],
|
||||
OptFuncExist: [
|
||||
|
@ -287,13 +291,6 @@
|
|||
return $2;
|
||||
})
|
||||
],
|
||||
Super: [
|
||||
o("SUPER", function() {
|
||||
return new CallNode('super', [new SplatNode(new LiteralNode('arguments'))]);
|
||||
}), o("SUPER Arguments", function() {
|
||||
return new CallNode('super', $2);
|
||||
})
|
||||
],
|
||||
This: [
|
||||
o("THIS", function() {
|
||||
return new ValueNode(new LiteralNode('this'));
|
||||
|
@ -615,7 +612,7 @@
|
|||
})
|
||||
]
|
||||
};
|
||||
operators = [["right", '?', 'NEW'], ["nonassoc", '++', '--'], ["right", 'UNARY'], ["left", 'MATH'], ["left", '+', '-'], ["left", 'SHIFT'], ["left", 'COMPARE'], ["left", 'INSTANCEOF'], ["left", '==', '!='], ["left", 'LOGIC'], ["right", 'COMPOUND_ASSIGN'], ["left", '.'], ["nonassoc", 'INDENT', 'OUTDENT'], ["right", 'WHEN', 'LEADING_WHEN', 'IN', 'OF', 'BY', 'THROW'], ["right", 'IF', 'UNLESS', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS', 'EXTENDS'], ["right", '=', ':', 'RETURN'], ["right", '->', '=>', 'UNLESS', 'POST_IF', 'POST_UNLESS']];
|
||||
operators = [["right", '?', 'NEW'], ["left", 'CALL_START', 'CALL_END'], ["nonassoc", '++', '--'], ["right", 'UNARY'], ["left", 'MATH'], ["left", '+', '-'], ["left", 'SHIFT'], ["left", 'COMPARE'], ["left", 'INSTANCEOF'], ["left", '==', '!='], ["left", 'LOGIC'], ["right", 'COMPOUND_ASSIGN'], ["left", '.'], ["nonassoc", 'INDENT', 'OUTDENT'], ["right", 'WHEN', 'LEADING_WHEN', 'IN', 'OF', 'BY', 'THROW'], ["right", 'IF', 'UNLESS', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS', 'EXTENDS'], ["right", '=', ':', 'RETURN'], ["right", '->', '=>', 'UNLESS', 'POST_IF', 'POST_UNLESS']];
|
||||
tokens = [];
|
||||
_a = grammar;
|
||||
for (name in _a) {
|
||||
|
|
212
lib/parser.js
212
lib/parser.js
File diff suppressed because one or more lines are too long
|
@ -296,11 +296,9 @@ grammar =
|
|||
o "{ ClassBody }", -> $2
|
||||
]
|
||||
|
||||
# The three flavors of function call: normal, object instantiation with `new`,
|
||||
# and calling `super()`
|
||||
# The two flavors of function call: normal, and object instantiation with `new`.
|
||||
Call: [
|
||||
o "Invocation"
|
||||
o "Super"
|
||||
o "NEW Invocation", -> $2.newInstance()
|
||||
o "NEW Value", -> (new CallNode($2, [])).newInstance()
|
||||
]
|
||||
|
@ -315,6 +313,8 @@ grammar =
|
|||
Invocation: [
|
||||
o "Value OptFuncExist Arguments", -> new CallNode $1, $3, $2
|
||||
o "Invocation OptFuncExist Arguments", -> new CallNode $1, $3, $2
|
||||
o "SUPER", -> new CallNode 'super', [new SplatNode(new LiteralNode('arguments'))]
|
||||
o "SUPER Arguments", -> new CallNode 'super', $2
|
||||
]
|
||||
|
||||
# An optional existence check on a function.
|
||||
|
@ -329,12 +329,6 @@ grammar =
|
|||
o "CALL_START ArgList OptComma CALL_END", -> $2
|
||||
]
|
||||
|
||||
# Calling super.
|
||||
Super: [
|
||||
o "SUPER", -> new CallNode 'super', [new SplatNode(new LiteralNode('arguments'))]
|
||||
o "SUPER Arguments", -> new CallNode 'super', $2
|
||||
]
|
||||
|
||||
# A reference to the *this* current object.
|
||||
This: [
|
||||
o "THIS", -> new ValueNode new LiteralNode 'this'
|
||||
|
@ -584,6 +578,7 @@ grammar =
|
|||
# (2 + 3) * 4
|
||||
operators = [
|
||||
["right", '?', 'NEW']
|
||||
["left", 'CALL_START', 'CALL_END']
|
||||
["nonassoc", '++', '--']
|
||||
["right", 'UNARY']
|
||||
["left", 'MATH']
|
||||
|
|
|
@ -27,6 +27,13 @@ result = (new ThirdChild).func 'four'
|
|||
ok result is 'zero/one/two/three/four'
|
||||
ok Base.static('word') is 'static/word'
|
||||
|
||||
FirstChild::func = (string) ->
|
||||
super('one/').length + string
|
||||
|
||||
result = (new ThirdChild).func 'four'
|
||||
|
||||
ok result is '9two/three/four'
|
||||
|
||||
|
||||
class TopClass
|
||||
constructor: (arg) ->
|
||||
|
|
Loading…
Reference in New Issue