Skip to content

Instantly share code, notes, and snippets.

@StanAngeloff
Created April 3, 2010 15:50
Show Gist options
  • Save StanAngeloff/354610 to your computer and use it in GitHub Desktop.
Save StanAngeloff/354610 to your computer and use it in GitHub Desktop.
diff --git a/src/grammar.coffee b/src/grammar.coffee
index 81d5b04..69df6d8 100644
--- a/src/grammar.coffee
+++ b/src/grammar.coffee
@@ -135,12 +135,25 @@ grammar: {
o "Assignable ASSIGN Expression", -> new AssignNode $1, $3
]
- # Assignment when it happens within an object literal. The difference from
- # the ordinary **Assign** is that these allow numbers and strings as keys.
- AssignObj: [
+ # A control level applied to an assignment. This can be either a getter or a
+ # setter within an object literal or a class body.
+ AssignControl: [
+ o "GET", -> new LiteralNode yytext
+ o "SET", -> new LiteralNode yytext
+ ]
+
+ # Assignment with no control. See **AssignControl**.
+ SimpleAssignObj: [
o "Identifier ASSIGN Expression", -> new AssignNode new ValueNode($1), $3, 'object'
o "AlphaNumeric ASSIGN Expression", -> new AssignNode new ValueNode($1), $3, 'object'
o "ThisProperty ASSIGN Expression", -> new AssignNode new ValueNode($1), $3, 'this'
+ ]
+
+ # 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 "SimpleAssignObj"
+ o "AssignControl SimpleAssignObj" -> $2.control: $1; $2
o "Comment"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment