1
0
Fork 0
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:
Jeremy Ashkenas 2013-02-14 16:34:32 +13:00
parent 1aa57bf24f
commit fa1ffa66d3
3 changed files with 37 additions and 37 deletions

View file

@ -14,7 +14,7 @@
action = (match = unwrap.exec(action)) ? match[1] : "(" + action + "())"; action = (match = unwrap.exec(action)) ? match[1] : "(" + action + "())";
action = action.replace(/\bnew /g, '$&yy.'); action = action.replace(/\bnew /g, '$&yy.');
action = action.replace(/\b(?:Block\.wrap|extend)\b/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]; return [patternString, "$$ = " + action + ";", options];
}; };
@ -83,12 +83,12 @@
], ],
AssignObj: [ AssignObj: [
o('ObjAssignable', function() { o('ObjAssignable', function() {
return Value.create($1); return Value.wrap($1);
}), o('ObjAssignable : Expression', function() { }), o('ObjAssignable : Expression', function() {
return new Assign(Value.create($1), $3, 'object'); return new Assign(Value.wrap($1), $3, 'object');
}), o('ObjAssignable :\ }), o('ObjAssignable :\
INDENT Expression OUTDENT', function() { INDENT Expression OUTDENT', function() {
return new Assign(Value.create($1), $4, 'object'); return new Assign(Value.wrap($1), $4, 'object');
}), o('Comment') }), o('Comment')
], ],
ObjAssignable: [o('Identifier'), o('AlphaNumeric'), o('ThisProperty')], ObjAssignable: [o('Identifier'), o('AlphaNumeric'), o('ThisProperty')],
@ -149,27 +149,27 @@
], ],
SimpleAssignable: [ SimpleAssignable: [
o('Identifier', function() { o('Identifier', function() {
return Value.create($1); return Value.wrap($1);
}), o('Value Accessor', function() { }), o('Value Accessor', function() {
return $1.add($2); return $1.add($2);
}), o('Invocation Accessor', function() { }), o('Invocation Accessor', function() {
return Value.create($1, [].concat($2)); return Value.wrap($1, [].concat($2));
}), o('ThisProperty') }), o('ThisProperty')
], ],
Assignable: [ Assignable: [
o('SimpleAssignable'), o('Array', function() { o('SimpleAssignable'), o('Array', function() {
return Value.create($1); return Value.wrap($1);
}), o('Object', function() { }), o('Object', function() {
return Value.create($1); return Value.wrap($1);
}) })
], ],
Value: [ Value: [
o('Assignable'), o('Literal', function() { o('Assignable'), o('Literal', function() {
return Value.create($1); return Value.wrap($1);
}), o('Parenthetical', function() { }), o('Parenthetical', function() {
return Value.create($1); return Value.wrap($1);
}), o('Range', function() { }), o('Range', function() {
return Value.create($1); return Value.wrap($1);
}), o('This') }), o('This')
], ],
Accessor: [ Accessor: [
@ -263,14 +263,14 @@
], ],
This: [ This: [
o('THIS', function() { o('THIS', function() {
return Value.create(new Literal('this')); return Value.wrap(new Literal('this'));
}), o('@', function() { }), o('@', function() {
return Value.create(new Literal('this')); return Value.wrap(new Literal('this'));
}) })
], ],
ThisProperty: [ ThisProperty: [
o('@ Identifier', function() { o('@ Identifier', function() {
return Value.create(new Literal('this'), [new Access($2)], 'this'); return Value.wrap(new Literal('this'), [new Access($2)], 'this');
}) })
], ],
Array: [ Array: [
@ -337,7 +337,7 @@
o('CATCH Identifier Block', function() { o('CATCH Identifier Block', function() {
return [$2, $3]; return [$2, $3];
}), o('CATCH Object Block', function() { }), o('CATCH Object Block', function() {
return [Value.create($2), $3]; return [Value.wrap($2), $3];
}) })
], ],
Throw: [ Throw: [
@ -400,7 +400,7 @@
ForBody: [ ForBody: [
o('FOR Range', function() { o('FOR Range', function() {
return { return {
source: Value.create($2) source: Value.wrap($2)
}; };
}), o('ForStart ForSource', function() { }), o('ForStart ForSource', function() {
$2.own = $1.own; $2.own = $1.own;
@ -419,9 +419,9 @@
], ],
ForValue: [ ForValue: [
o('Identifier'), o('ThisProperty'), o('Array', function() { o('Identifier'), o('ThisProperty'), o('Array', function() {
return Value.create($1); return Value.wrap($1);
}), o('Object', function() { }), o('Object', function() {
return Value.create($1); return Value.wrap($1);
}) })
], ],
ForVariables: [ ForVariables: [

View file

@ -606,4 +606,4 @@ exports.main = function commonjsMain(args) {
if (typeof module !== 'undefined' && require.main === module) { if (typeof module !== 'undefined' && require.main === module) {
exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args); exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
} }
} }

View file

@ -36,7 +36,7 @@ o = (patternString, action, options) ->
action = if match = unwrap.exec action then match[1] else "(#{action}())" action = if match = unwrap.exec action then match[1] else "(#{action}())"
action = action.replace /\bnew /g, '$&yy.' action = action.replace /\bnew /g, '$&yy.'
action = action.replace /\b(?:Block\.wrap|extend)\b/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] [patternString, "$$ = #{action};", options]
# Grammatical Rules # Grammatical Rules
@ -143,10 +143,10 @@ grammar =
# Assignment when it happens within an object literal. The difference from # Assignment when it happens within an object literal. The difference from
# the ordinary **Assign** is that these allow numbers and strings as keys. # the ordinary **Assign** is that these allow numbers and strings as keys.
AssignObj: [ AssignObj: [
o 'ObjAssignable', -> Value.create $1 o 'ObjAssignable', -> Value.wrap $1
o 'ObjAssignable : Expression', -> new Assign Value.create($1), $3, 'object' o 'ObjAssignable : Expression', -> new Assign Value.wrap($1), $3, 'object'
o 'ObjAssignable : o 'ObjAssignable :
INDENT Expression OUTDENT', -> new Assign Value.create($1), $4, 'object' INDENT Expression OUTDENT', -> new Assign Value.wrap($1), $4, 'object'
o 'Comment' o 'Comment'
] ]
@ -220,26 +220,26 @@ grammar =
# Variables and properties that can be assigned to. # Variables and properties that can be assigned to.
SimpleAssignable: [ SimpleAssignable: [
o 'Identifier', -> Value.create $1 o 'Identifier', -> Value.wrap $1
o 'Value Accessor', -> $1.add $2 o 'Value Accessor', -> $1.add $2
o 'Invocation Accessor', -> Value.create $1, [].concat $2 o 'Invocation Accessor', -> Value.wrap $1, [].concat $2
o 'ThisProperty' o 'ThisProperty'
] ]
# Everything that can be assigned to. # Everything that can be assigned to.
Assignable: [ Assignable: [
o 'SimpleAssignable' o 'SimpleAssignable'
o 'Array', -> Value.create $1 o 'Array', -> Value.wrap $1
o 'Object', -> Value.create $1 o 'Object', -> Value.wrap $1
] ]
# The types of things that can be treated as values -- assigned to, invoked # The types of things that can be treated as values -- assigned to, invoked
# as functions, indexed into, named as a class, etc. # as functions, indexed into, named as a class, etc.
Value: [ Value: [
o 'Assignable' o 'Assignable'
o 'Literal', -> Value.create $1 o 'Literal', -> Value.wrap $1
o 'Parenthetical', -> Value.create $1 o 'Parenthetical', -> Value.wrap $1
o 'Range', -> Value.create $1 o 'Range', -> Value.wrap $1
o 'This' o 'This'
] ]
@ -314,13 +314,13 @@ grammar =
# A reference to the *this* current object. # A reference to the *this* current object.
This: [ This: [
o 'THIS', -> Value.create new Literal 'this' o 'THIS', -> Value.wrap new Literal 'this'
o '@', -> Value.create new Literal 'this' o '@', -> Value.wrap new Literal 'this'
] ]
# A reference to a property on *this*. # A reference to a property on *this*.
ThisProperty: [ 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. # The array literal.
@ -384,7 +384,7 @@ grammar =
# A catch clause names its error and runs a block of code. # A catch clause names its error and runs a block of code.
Catch: [ Catch: [
o 'CATCH Identifier Block', -> [$2, $3] 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. # Throw an exception object.
@ -433,7 +433,7 @@ grammar =
] ]
ForBody: [ 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 o 'ForStart ForSource', -> $2.own = $1.own; $2.name = $1[0]; $2.index = $1[1]; $2
] ]
@ -447,8 +447,8 @@ grammar =
ForValue: [ ForValue: [
o 'Identifier' o 'Identifier'
o 'ThisProperty' o 'ThisProperty'
o 'Array', -> Value.create $1 o 'Array', -> Value.wrap $1
o 'Object', -> Value.create $1 o 'Object', -> Value.wrap $1
] ]
# An array or range comprehension has variables for the current element # An array or range comprehension has variables for the current element