Restricted class and extends values to simple assignments.
This commit is contained in:
parent
7b9a8998cf
commit
6df50399a9
|
@ -187,12 +187,7 @@
|
|||
return new SplatNode($1);
|
||||
})
|
||||
],
|
||||
// Everything that can be assigned to.
|
||||
Assignable: [o("Identifier", function() {
|
||||
return new ValueNode($1);
|
||||
}), o("Array", function() {
|
||||
return new ValueNode($1);
|
||||
}), o("Object", function() {
|
||||
SimpleAssignable: [o("Identifier", function() {
|
||||
return new ValueNode($1);
|
||||
}), o("Value Accessor", function() {
|
||||
return $1.push($2);
|
||||
|
@ -200,6 +195,13 @@
|
|||
return new ValueNode($1, [$2]);
|
||||
}), o("ThisProperty")
|
||||
],
|
||||
// Everything that can be assigned to.
|
||||
Assignable: [o("SimpleAssignable"), o("Array", function() {
|
||||
return new ValueNode($1);
|
||||
}), o("Object", function() {
|
||||
return new ValueNode($1);
|
||||
})
|
||||
],
|
||||
// The types of things that can be treated as values -- assigned to, invoked
|
||||
// as functions, indexed into, named as a class, etc.
|
||||
Value: [o("Assignable"), o("Literal", function() {
|
||||
|
@ -246,13 +248,13 @@
|
|||
],
|
||||
// Class definitions have optional bodies of prototype property assignments,
|
||||
// and optional references to the superclass.
|
||||
Class: [o("CLASS Identifier", function() {
|
||||
Class: [o("CLASS SimpleAssignable", function() {
|
||||
return new ClassNode($2);
|
||||
}), o("CLASS Identifier EXTENDS Value", function() {
|
||||
}), o("CLASS SimpleAssignable EXTENDS Value", function() {
|
||||
return new ClassNode($2, $4);
|
||||
}), o("CLASS Identifier IndentedAssignList", function() {
|
||||
}), o("CLASS SimpleAssignable IndentedAssignList", function() {
|
||||
return new ClassNode($2, null, $3);
|
||||
}), o("CLASS Identifier EXTENDS Value IndentedAssignList", function() {
|
||||
}), o("CLASS SimpleAssignable EXTENDS Value IndentedAssignList", function() {
|
||||
return new ClassNode($2, $4, $5);
|
||||
})
|
||||
],
|
||||
|
@ -289,7 +291,7 @@
|
|||
],
|
||||
// Extending an object by setting its prototype chain to reference a parent
|
||||
// object.
|
||||
Extends: [o("Value EXTENDS Value", function() {
|
||||
Extends: [o("SimpleAssignable EXTENDS Value", function() {
|
||||
return new ExtendsNode($1, $3);
|
||||
})
|
||||
],
|
||||
|
|
272
lib/parser.js
272
lib/parser.js
File diff suppressed because one or more lines are too long
|
@ -195,15 +195,19 @@ grammar: {
|
|||
o "Expression . . .", -> new SplatNode $1
|
||||
]
|
||||
|
||||
# Everything that can be assigned to.
|
||||
Assignable: [
|
||||
SimpleAssignable: [
|
||||
o "Identifier", -> new ValueNode $1
|
||||
o "Array", -> new ValueNode $1
|
||||
o "Object", -> new ValueNode $1
|
||||
o "Value Accessor", -> $1.push $2
|
||||
o "Invocation Accessor", -> new ValueNode $1, [$2]
|
||||
o "ThisProperty"
|
||||
]
|
||||
|
||||
# Everything that can be assigned to.
|
||||
Assignable: [
|
||||
o "SimpleAssignable"
|
||||
o "Array", -> new ValueNode $1
|
||||
o "Object", -> new ValueNode $1
|
||||
]
|
||||
|
||||
# The types of things that can be treated as values -- assigned to, invoked
|
||||
# as functions, indexed into, named as a class, etc.
|
||||
|
@ -244,10 +248,10 @@ grammar: {
|
|||
# Class definitions have optional bodies of prototype property assignments,
|
||||
# and optional references to the superclass.
|
||||
Class: [
|
||||
o "CLASS Identifier", -> new ClassNode $2
|
||||
o "CLASS Identifier EXTENDS Value", -> new ClassNode $2, $4
|
||||
o "CLASS Identifier IndentedAssignList", -> new ClassNode $2, null, $3
|
||||
o "CLASS Identifier EXTENDS Value IndentedAssignList", -> new ClassNode $2, $4, $5
|
||||
o "CLASS SimpleAssignable", -> new ClassNode $2
|
||||
o "CLASS SimpleAssignable EXTENDS Value", -> new ClassNode $2, $4
|
||||
o "CLASS SimpleAssignable IndentedAssignList", -> new ClassNode $2, null, $3
|
||||
o "CLASS SimpleAssignable EXTENDS Value IndentedAssignList", -> new ClassNode $2, $4, $5
|
||||
]
|
||||
|
||||
# Assignment of properties within an object literal can be separated by
|
||||
|
@ -281,7 +285,7 @@ grammar: {
|
|||
# Extending an object by setting its prototype chain to reference a parent
|
||||
# object.
|
||||
Extends: [
|
||||
o "Value EXTENDS Value", -> new ExtendsNode $1, $3
|
||||
o "SimpleAssignable EXTENDS Value", -> new ExtendsNode $1, $3
|
||||
]
|
||||
|
||||
# Ordinary function invocation, or a chained series of calls.
|
||||
|
|
Loading…
Reference in New Issue