fixing some implicit object parses for issue #541

This commit is contained in:
Jeremy Ashkenas 2010-07-25 17:46:08 -07:00
parent 6b0418a74a
commit 27e5c42023
6 changed files with 193 additions and 180 deletions

View File

@ -78,6 +78,8 @@
Assign: [
o("Assignable = Expression", function() {
return new AssignNode($1, $3);
}), o("Assignable = INDENT Expression OUTDENT", function() {
return new AssignNode($1, $4);
})
],
AssignObj: [

View File

@ -568,7 +568,7 @@
Lexer.prototype.unfinished = function() {
var prev;
prev = this.prev(2);
return this.value() && this.value().match && this.value().match(NO_NEWLINE) && prev && (prev[0] !== '.') && !this.value().match(CODE);
return this.value() && this.value().match && this.value().match(NO_NEWLINE) && prev && (prev[0] !== '.') && !this.value().match(CODE) && !this.chunk.match(ASSIGNED);
};
return Lexer;
})();
@ -597,7 +597,7 @@
STRING_NEWLINES = /\n[ \t]*/g;
NO_NEWLINE = /^([+\*&|\/\-%=<>!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/;
HEREDOC_INDENT = /(\n+([ \t]*)|^([ \t]+))/g;
ASSIGNED = /^([a-zA-Z\$_]\w*[ \t]*?[:=][^=])/;
ASSIGNED = /^\s*([a-zA-Z\$_@]\w*[ \t]*?[:=][^=])/;
NEXT_CHARACTER = /^\s*(\S)/;
NOT_REGEX = ['NUMBER', 'REGEX', '++', '--', 'FALSE', 'NULL', 'TRUE', ']'];
CALLABLE = ['IDENTIFIER', 'SUPER', ')', ']', '}', 'STRING', '@', 'THIS', '?', '::'];

File diff suppressed because one or more lines are too long

View File

@ -140,6 +140,7 @@ grammar = {
# Assignment of a variable, property, or index to a value.
Assign: [
o "Assignable = Expression", -> new AssignNode $1, $3
o "Assignable = INDENT Expression OUTDENT", -> new AssignNode $1, $4
]
# Assignment when it happens within an object literal. The difference from

View File

@ -464,7 +464,8 @@ exports.Lexer = class Lexer
unfinished: ->
prev = @prev(2)
@value() and @value().match and @value().match(NO_NEWLINE) and
prev and (prev[0] isnt '.') and not @value().match(CODE)
prev and (prev[0] isnt '.') and not @value().match(CODE) and
not @chunk.match ASSIGNED
# Constants
# ---------
@ -529,7 +530,7 @@ MULTILINER = /\n/g
STRING_NEWLINES = /\n[ \t]*/g
NO_NEWLINE = /^([+\*&|\/\-%=<>!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/
HEREDOC_INDENT = /(\n+([ \t]*)|^([ \t]+))/g
ASSIGNED = /^([a-zA-Z\$_]\w*[ \t]*?[:=][^=])/
ASSIGNED = /^\s*([a-zA-Z\$_@]\w*[ \t]*?[:=][^=])/
NEXT_CHARACTER = /^\s*(\S)/
# Tokens which a regular expression will never immediately follow, but which

View File

@ -131,4 +131,11 @@ config =
ok config.development.server is 'localhost'
ok config.production.server is 'dreamboat'
ok config.development.timeout is 10
ok config.production.timeout is 1000
ok config.production.timeout is 1000
obj =
a: 1
b: 2
ok obj.a is 1
ok obj.b is 2