reindenting grammar.coffee to the shared column, as much as possible.

This commit is contained in:
Jeremy Ashkenas 2010-11-01 21:37:42 -04:00
parent c17efcf422
commit 749e056618
1 changed files with 41 additions and 41 deletions

View File

@ -144,10 +144,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', -> new Value $1 o 'ObjAssignable', -> new Value $1
o 'ObjAssignable : Expression', -> new Assign new Value($1), $3, 'object' o 'ObjAssignable : Expression', -> new Assign new Value($1), $3, 'object'
o 'ObjAssignable : o 'ObjAssignable :
INDENT Expression OUTDENT', -> new Assign new Value($1), $4, 'object' INDENT Expression OUTDENT', -> new Assign new Value($1), $4, 'object'
o 'ThisProperty' o 'ThisProperty'
o 'Comment' o 'Comment'
] ]
@ -200,9 +200,9 @@ grammar =
# A single parameter in a function definition can be ordinary, or a splat # A single parameter in a function definition can be ordinary, or a splat
# that hoovers up the remaining arguments. # that hoovers up the remaining arguments.
Param: [ Param: [
o 'ParamVar', -> new Param $1 o 'ParamVar', -> new Param $1
o 'ParamVar ...', -> new Param $1, null, on o 'ParamVar ...', -> new Param $1, null, on
o 'ParamVar = Expression', -> new Param $1, $3 o 'ParamVar = Expression', -> new Param $1, $3
] ]
ParamVar: [ ParamVar: [
@ -228,8 +228,8 @@ grammar =
# Everything that can be assigned to. # Everything that can be assigned to.
Assignable: [ Assignable: [
o 'SimpleAssignable' o 'SimpleAssignable'
o 'Array', -> new Value $1 o 'Array', -> new Value $1
o 'Object', -> new Value $1 o 'Object', -> new Value $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
@ -276,17 +276,17 @@ grammar =
# Class definitions have optional bodies of prototype property assignments, # Class definitions have optional bodies of prototype property assignments,
# and optional references to the superclass. # and optional references to the superclass.
Class: [ Class: [
o 'CLASS SimpleAssignable', -> new Class $2 o 'CLASS SimpleAssignable', -> new Class $2
o 'CLASS SimpleAssignable EXTENDS Value', -> new Class $2, $4 o 'CLASS SimpleAssignable EXTENDS Value', -> new Class $2, $4
o 'CLASS SimpleAssignable o 'CLASS SimpleAssignable
INDENT ClassBody OUTDENT', -> new Class $2, null, $4 INDENT ClassBody OUTDENT', -> new Class $2, null, $4
o 'CLASS SimpleAssignable EXTENDS Value o 'CLASS SimpleAssignable EXTENDS Value
INDENT ClassBody OUTDENT', -> new Class $2, $4, $6 INDENT ClassBody OUTDENT', -> new Class $2, $4, $6
o 'CLASS INDENT ClassBody OUTDENT', -> new Class null, null, $3 o 'CLASS INDENT ClassBody OUTDENT', -> new Class null, null, $3
o 'CLASS', -> new Class null, null, new Expressions o 'CLASS', -> new Class null, null, new Expressions
o 'CLASS EXTENDS Value', -> new Class null, $3 , new Expressions o 'CLASS EXTENDS Value', -> new Class null, $3 , new Expressions
o 'CLASS EXTENDS Value o 'CLASS EXTENDS Value
INDENT ClassBody OUTDENT', -> new Class null, $3, $5 INDENT ClassBody OUTDENT', -> new Class null, $3, $5
] ]
# Assignments that can happen directly inside a class declaration. # Assignments that can happen directly inside a class declaration.
@ -340,7 +340,7 @@ grammar =
# A reference to a property on *this*. # A reference to a property on *this*.
ThisProperty: [ ThisProperty: [
o '@ Identifier', -> new Value new Literal('this'), [new Accessor($2)], 'this' o '@ Identifier', -> new Value new Literal('this'), [new Accessor($2)], 'this'
] ]
# The array literal. # The array literal.
@ -418,25 +418,25 @@ grammar =
] ]
Loop: [ Loop: [
o 'LOOP Block', -> new While(new Literal 'true').addBody $2 o 'LOOP Block', -> new While(new Literal 'true').addBody $2
o 'LOOP Expression', -> new While(new Literal 'true').addBody Expressions.wrap [$2] o 'LOOP Expression', -> new While(new Literal 'true').addBody Expressions.wrap [$2]
] ]
# Array, object, and range comprehensions, at the most generic level. # Array, object, and range comprehensions, at the most generic level.
# Comprehensions can either be normal, with a block of expressions to execute, # Comprehensions can either be normal, with a block of expressions to execute,
# or postfix, with a single expression. # or postfix, with a single expression.
For: [ For: [
o 'Statement ForBody', -> new For $1, $2 o 'Statement ForBody', -> new For $1, $2
o 'Expression ForBody', -> new For $1, $2 o 'Expression ForBody', -> new For $1, $2
o 'ForBody Block', -> new For $2, $1 o 'ForBody Block', -> new For $2, $1
] ]
# An array of all accepted values for a variable inside the loop. This # An array of all accepted values for a variable inside the loop. This
# enables support for pattern matching. # enables support for pattern matching.
ForValue: [ ForValue: [
o 'Identifier' o 'Identifier'
o 'Array', -> new Value $1 o 'Array', -> new Value $1
o 'Object', -> new Value $1 o 'Object', -> new Value $1
] ]
ForIn: [ ForIn: [
@ -447,8 +447,8 @@ grammar =
] ]
ForOf: [ ForOf: [
o 'FOROF Expression', -> object: on, source: $2 o 'FOROF Expression', -> object: on, source: $2
o 'FOROF Expression WHEN Expression', -> object: on, source: $2, guard: $4 o 'FOROF Expression WHEN Expression', -> object: on, source: $2, guard: $4
] ]
ForTo: [ ForTo: [
@ -462,13 +462,13 @@ grammar =
# clause. If it's an array comprehension, you can also choose to step through # clause. If it's an array comprehension, you can also choose to step through
# in fixed-size increments. # in fixed-size increments.
ForBody: [ ForBody: [
o 'FOR ForValue ForIn', -> extend $3, name: $2 o 'FOR ForValue ForIn', -> extend $3, name: $2
o 'FOR ForValue , Identifier ForIn', -> extend $5, name: $2, index: $4 o 'FOR ForValue , Identifier ForIn', -> extend $5, name: $2, index: $4
o 'FOR Identifier ForOf', -> extend $3, index: $2 o 'FOR Identifier ForOf', -> extend $3, index: $2
o 'FOR ForValue , ForValue ForOf', -> extend $5, index: $2, name: $4 o 'FOR ForValue , ForValue ForOf', -> extend $5, index: $2, name: $4
o 'FOR ALL Identifier ForOf', -> extend $4, raw: on, index: $3 o 'FOR ALL Identifier ForOf', -> extend $4, raw: on, index: $3
o 'FOR ALL Identifier , ForValue ForOf', -> extend $6, raw: on, index: $3, name: $5 o 'FOR ALL Identifier , ForValue ForOf', -> extend $6, raw: on, index: $3, name: $5
o 'FOR Identifier FROM Expression ForTo', -> extend $5, index: $2, from: $4 o 'FOR Identifier FROM Expression ForTo', -> extend $5, index: $2, from: $4
] ]
Switch: [ Switch: [
@ -493,20 +493,20 @@ grammar =
# if-related rules are broken up along these lines in order to avoid # if-related rules are broken up along these lines in order to avoid
# ambiguity. # ambiguity.
IfBlock: [ IfBlock: [
o 'IF Expression Block', -> new If $2, $3 o 'IF Expression Block', -> new If $2, $3
o 'UNLESS Expression Block', -> new If $2, $3, invert: true o 'UNLESS Expression Block', -> new If $2, $3, invert: true
o 'IfBlock ELSE IF Expression Block', -> $1.addElse new If $4, $5 o 'IfBlock ELSE IF Expression Block', -> $1.addElse new If $4, $5
o 'IfBlock ELSE Block', -> $1.addElse $3 o 'IfBlock ELSE Block', -> $1.addElse $3
] ]
# The full complement of *if* expressions, including postfix one-liner # The full complement of *if* expressions, including postfix one-liner
# *if* and *unless*. # *if* and *unless*.
If: [ If: [
o 'IfBlock' o 'IfBlock'
o 'Statement POST_IF Expression', -> new If $3, Expressions.wrap([$1]), statement: true o 'Statement POST_IF Expression', -> new If $3, Expressions.wrap([$1]), statement: true
o 'Expression POST_IF Expression', -> new If $3, Expressions.wrap([$1]), statement: true o 'Expression POST_IF Expression', -> new If $3, Expressions.wrap([$1]), statement: true
o 'Statement POST_UNLESS Expression', -> new If $3, Expressions.wrap([$1]), statement: true, invert: true o 'Statement POST_UNLESS Expression', -> new If $3, Expressions.wrap([$1]), statement: true, invert: true
o 'Expression POST_UNLESS Expression', -> new If $3, Expressions.wrap([$1]), statement: true, invert: true o 'Expression POST_UNLESS Expression', -> new If $3, Expressions.wrap([$1]), statement: true, invert: true
] ]
# Arithmetic and logical operators, working on one or more operands. # Arithmetic and logical operators, working on one or more operands.