Permalink
Browse files

Allow underscores anywhere in identifiers.

  • Loading branch information...
1 parent 1450169 commit 8d2dca7c716a90de8047f3a23221bd8b5211f84d @maryrosecook committed Feb 13, 2013
Showing with 11 additions and 2 deletions.
  1. +8 −0 spec/parser.spec.js
  2. +3 −2 src/grammar.js
View
@@ -397,6 +397,14 @@ describe('parser', function() {
});
});
+ describe('identifier', function() {
+ it('should allow underscores in identifiers', function() {
+ expect(p.extract(astExpression("x _y is 'z'"),
+ 0, "assignee", 0, "object", 1).syntax)
+ .toEqual("attribute");
+ });
+ });
+
describe('attributes', function() {
describe('assignments', function() {
it('should annotate in object assignment', function() {
View
@@ -66,7 +66,7 @@
" = all:string { return nnode('literal', [all], column, 'literal'); }",
"identifier",
- " = !keyword init:[a-zA-Z] rest:identifier_char* { return nnode('identifier', [init + rest.join('')], column); }",
+ " = !keyword init:init_identifier_char rest:identifier_char* { return nnode('identifier', [init + rest.join('')], column); }",
"variable",
" = all:object { return nnode('variable', [all], column); }",
@@ -112,7 +112,8 @@
"to = 'to'",
"from = 'from'",
"_ = [ \\t\\r]+",
- "identifier_char = [a-z0-9]",
+ "identifier_char = [a-zA-Z0-9_]",
+ "init_identifier_char = [a-zA-Z_]",
"string_char_double = [A-Za-z0-9., ']",
"string_char_single = [A-Za-z0-9., \"]"
];

0 comments on commit 8d2dca7

Please sign in to comment.