adding nice support for fancy implicit hashes

This commit is contained in:
Jeremy Ashkenas 2010-07-24 23:52:02 -07:00
parent d1ffffab04
commit a0b2b78962
6 changed files with 223 additions and 197 deletions

View File

@ -87,6 +87,10 @@
return new AssignNode(new ValueNode($1), $3, 'object');
}), o("AlphaNumeric : Expression", function() {
return new AssignNode(new ValueNode($1), $3, 'object');
}), o("Identifier : INDENT Expression OUTDENT", function() {
return new AssignNode(new ValueNode($1), $4, 'object');
}), o("AlphaNumeric : INDENT Expression OUTDENT", function() {
return new AssignNode(new ValueNode($1), $4, 'object');
}), o("Comment")
],
Return: [

View File

@ -599,7 +599,7 @@
JS_CLEANER = /(^`|`$)/g;
MULTILINER = /\n/g;
STRING_NEWLINES = /\n[ \t]*/g;
NO_NEWLINE = /^([+\*&|\/\-%=<>:!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/;
NO_NEWLINE = /^([+\*&|\/\-%=<>!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/;
HEREDOC_INDENT = /(\n+([ \t]*)|^([ \t]+))/g;
ASSIGNED = /^([a-zA-Z\$_]\w*[ \t]*?[:=][^=])/;
NEXT_CHARACTER = /^\s*(\S)/;

File diff suppressed because one or more lines are too long

View File

@ -149,6 +149,8 @@ grammar = {
o "AlphaNumeric"
o "Identifier : Expression", -> new AssignNode new ValueNode($1), $3, 'object'
o "AlphaNumeric : Expression", -> new AssignNode new ValueNode($1), $3, 'object'
o "Identifier : INDENT Expression OUTDENT", -> new AssignNode new ValueNode($1), $4, 'object'
o "AlphaNumeric : INDENT Expression OUTDENT", -> new AssignNode new ValueNode($1), $4, 'object'
o "Comment"
]

View File

@ -527,7 +527,7 @@ REGEX_ESCAPE = /\\[^\$]/g
JS_CLEANER = /(^`|`$)/g
MULTILINER = /\n/g
STRING_NEWLINES = /\n[ \t]*/g
NO_NEWLINE = /^([+\*&|\/\-%=<>:!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/
NO_NEWLINE = /^([+\*&|\/\-%=<>!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/
HEREDOC_INDENT = /(\n+([ \t]*)|^([ \t]+))/g
ASSIGNED = /^([a-zA-Z\$_]\w*[ \t]*?[:=][^=])/
NEXT_CHARACTER = /^\s*(\S)/

View File

@ -116,3 +116,19 @@ func = ->
this == 'this'
ok func() is false
# New fancy implicit objects:
config =
development:
server: 'localhost'
timeout: 10
production:
server: 'dreamboat'
timeout: 1000
ok config.development.server is 'localhost'
ok config.production.server is 'dreamboat'
ok config.development.timeout is 10
ok config.production.timeout is 1000