mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Fixes #2359 -- tweak grammar to use new name
This commit is contained in:
parent
1aa57bf24f
commit
fa1ffa66d3
3 changed files with 37 additions and 37 deletions
|
@ -14,7 +14,7 @@
|
|||
action = (match = unwrap.exec(action)) ? match[1] : "(" + action + "())";
|
||||
action = action.replace(/\bnew /g, '$&yy.');
|
||||
action = action.replace(/\b(?:Block\.wrap|extend)\b/g, 'yy.$&');
|
||||
action = action.replace(/\b(Op|Value\.create)\b/g, 'yy.$&');
|
||||
action = action.replace(/\b(Op|Value\.(create|wrap))\b/g, 'yy.$&');
|
||||
return [patternString, "$$ = " + action + ";", options];
|
||||
};
|
||||
|
||||
|
@ -83,12 +83,12 @@
|
|||
],
|
||||
AssignObj: [
|
||||
o('ObjAssignable', function() {
|
||||
return Value.create($1);
|
||||
return Value.wrap($1);
|
||||
}), o('ObjAssignable : Expression', function() {
|
||||
return new Assign(Value.create($1), $3, 'object');
|
||||
return new Assign(Value.wrap($1), $3, 'object');
|
||||
}), o('ObjAssignable :\
|
||||
INDENT Expression OUTDENT', function() {
|
||||
return new Assign(Value.create($1), $4, 'object');
|
||||
return new Assign(Value.wrap($1), $4, 'object');
|
||||
}), o('Comment')
|
||||
],
|
||||
ObjAssignable: [o('Identifier'), o('AlphaNumeric'), o('ThisProperty')],
|
||||
|
@ -149,27 +149,27 @@
|
|||
],
|
||||
SimpleAssignable: [
|
||||
o('Identifier', function() {
|
||||
return Value.create($1);
|
||||
return Value.wrap($1);
|
||||
}), o('Value Accessor', function() {
|
||||
return $1.add($2);
|
||||
}), o('Invocation Accessor', function() {
|
||||
return Value.create($1, [].concat($2));
|
||||
return Value.wrap($1, [].concat($2));
|
||||
}), o('ThisProperty')
|
||||
],
|
||||
Assignable: [
|
||||
o('SimpleAssignable'), o('Array', function() {
|
||||
return Value.create($1);
|
||||
return Value.wrap($1);
|
||||
}), o('Object', function() {
|
||||
return Value.create($1);
|
||||
return Value.wrap($1);
|
||||
})
|
||||
],
|
||||
Value: [
|
||||
o('Assignable'), o('Literal', function() {
|
||||
return Value.create($1);
|
||||
return Value.wrap($1);
|
||||
}), o('Parenthetical', function() {
|
||||
return Value.create($1);
|
||||
return Value.wrap($1);
|
||||
}), o('Range', function() {
|
||||
return Value.create($1);
|
||||
return Value.wrap($1);
|
||||
}), o('This')
|
||||
],
|
||||
Accessor: [
|
||||
|
@ -263,14 +263,14 @@
|
|||
],
|
||||
This: [
|
||||
o('THIS', function() {
|
||||
return Value.create(new Literal('this'));
|
||||
return Value.wrap(new Literal('this'));
|
||||
}), o('@', function() {
|
||||
return Value.create(new Literal('this'));
|
||||
return Value.wrap(new Literal('this'));
|
||||
})
|
||||
],
|
||||
ThisProperty: [
|
||||
o('@ Identifier', function() {
|
||||
return Value.create(new Literal('this'), [new Access($2)], 'this');
|
||||
return Value.wrap(new Literal('this'), [new Access($2)], 'this');
|
||||
})
|
||||
],
|
||||
Array: [
|
||||
|
@ -337,7 +337,7 @@
|
|||
o('CATCH Identifier Block', function() {
|
||||
return [$2, $3];
|
||||
}), o('CATCH Object Block', function() {
|
||||
return [Value.create($2), $3];
|
||||
return [Value.wrap($2), $3];
|
||||
})
|
||||
],
|
||||
Throw: [
|
||||
|
@ -400,7 +400,7 @@
|
|||
ForBody: [
|
||||
o('FOR Range', function() {
|
||||
return {
|
||||
source: Value.create($2)
|
||||
source: Value.wrap($2)
|
||||
};
|
||||
}), o('ForStart ForSource', function() {
|
||||
$2.own = $1.own;
|
||||
|
@ -419,9 +419,9 @@
|
|||
],
|
||||
ForValue: [
|
||||
o('Identifier'), o('ThisProperty'), o('Array', function() {
|
||||
return Value.create($1);
|
||||
return Value.wrap($1);
|
||||
}), o('Object', function() {
|
||||
return Value.create($1);
|
||||
return Value.wrap($1);
|
||||
})
|
||||
],
|
||||
ForVariables: [
|
||||
|
|
|
@ -606,4 +606,4 @@ exports.main = function commonjsMain(args) {
|
|||
if (typeof module !== 'undefined' && require.main === module) {
|
||||
exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ o = (patternString, action, options) ->
|
|||
action = if match = unwrap.exec action then match[1] else "(#{action}())"
|
||||
action = action.replace /\bnew /g, '$&yy.'
|
||||
action = action.replace /\b(?:Block\.wrap|extend)\b/g, 'yy.$&'
|
||||
action = action.replace /\b(Op|Value\.create)\b/g, 'yy.$&'
|
||||
action = action.replace /\b(Op|Value\.(create|wrap))\b/g, 'yy.$&'
|
||||
[patternString, "$$ = #{action};", options]
|
||||
|
||||
# Grammatical Rules
|
||||
|
@ -143,10 +143,10 @@ grammar =
|
|||
# Assignment when it happens within an object literal. The difference from
|
||||
# the ordinary **Assign** is that these allow numbers and strings as keys.
|
||||
AssignObj: [
|
||||
o 'ObjAssignable', -> Value.create $1
|
||||
o 'ObjAssignable : Expression', -> new Assign Value.create($1), $3, 'object'
|
||||
o 'ObjAssignable', -> Value.wrap $1
|
||||
o 'ObjAssignable : Expression', -> new Assign Value.wrap($1), $3, 'object'
|
||||
o 'ObjAssignable :
|
||||
INDENT Expression OUTDENT', -> new Assign Value.create($1), $4, 'object'
|
||||
INDENT Expression OUTDENT', -> new Assign Value.wrap($1), $4, 'object'
|
||||
o 'Comment'
|
||||
]
|
||||
|
||||
|
@ -220,26 +220,26 @@ grammar =
|
|||
|
||||
# Variables and properties that can be assigned to.
|
||||
SimpleAssignable: [
|
||||
o 'Identifier', -> Value.create $1
|
||||
o 'Identifier', -> Value.wrap $1
|
||||
o 'Value Accessor', -> $1.add $2
|
||||
o 'Invocation Accessor', -> Value.create $1, [].concat $2
|
||||
o 'Invocation Accessor', -> Value.wrap $1, [].concat $2
|
||||
o 'ThisProperty'
|
||||
]
|
||||
|
||||
# Everything that can be assigned to.
|
||||
Assignable: [
|
||||
o 'SimpleAssignable'
|
||||
o 'Array', -> Value.create $1
|
||||
o 'Object', -> Value.create $1
|
||||
o 'Array', -> Value.wrap $1
|
||||
o 'Object', -> Value.wrap $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', -> Value.create $1
|
||||
o 'Parenthetical', -> Value.create $1
|
||||
o 'Range', -> Value.create $1
|
||||
o 'Literal', -> Value.wrap $1
|
||||
o 'Parenthetical', -> Value.wrap $1
|
||||
o 'Range', -> Value.wrap $1
|
||||
o 'This'
|
||||
]
|
||||
|
||||
|
@ -314,13 +314,13 @@ grammar =
|
|||
|
||||
# A reference to the *this* current object.
|
||||
This: [
|
||||
o 'THIS', -> Value.create new Literal 'this'
|
||||
o '@', -> Value.create new Literal 'this'
|
||||
o 'THIS', -> Value.wrap new Literal 'this'
|
||||
o '@', -> Value.wrap new Literal 'this'
|
||||
]
|
||||
|
||||
# A reference to a property on *this*.
|
||||
ThisProperty: [
|
||||
o '@ Identifier', -> Value.create new Literal('this'), [new Access($2)], 'this'
|
||||
o '@ Identifier', -> Value.wrap new Literal('this'), [new Access($2)], 'this'
|
||||
]
|
||||
|
||||
# The array literal.
|
||||
|
@ -384,7 +384,7 @@ grammar =
|
|||
# A catch clause names its error and runs a block of code.
|
||||
Catch: [
|
||||
o 'CATCH Identifier Block', -> [$2, $3]
|
||||
o 'CATCH Object Block', -> [Value.create($2), $3]
|
||||
o 'CATCH Object Block', -> [Value.wrap($2), $3]
|
||||
]
|
||||
|
||||
# Throw an exception object.
|
||||
|
@ -433,7 +433,7 @@ grammar =
|
|||
]
|
||||
|
||||
ForBody: [
|
||||
o 'FOR Range', -> source: Value.create($2)
|
||||
o 'FOR Range', -> source: Value.wrap($2)
|
||||
o 'ForStart ForSource', -> $2.own = $1.own; $2.name = $1[0]; $2.index = $1[1]; $2
|
||||
]
|
||||
|
||||
|
@ -447,8 +447,8 @@ grammar =
|
|||
ForValue: [
|
||||
o 'Identifier'
|
||||
o 'ThisProperty'
|
||||
o 'Array', -> Value.create $1
|
||||
o 'Object', -> Value.create $1
|
||||
o 'Array', -> Value.wrap $1
|
||||
o 'Object', -> Value.wrap $1
|
||||
]
|
||||
|
||||
# An array or range comprehension has variables for the current element
|
||||
|
|
Loading…
Reference in a new issue