Skip to content

Commit

Permalink
Update lexer to recognize JS regex literals
Browse files Browse the repository at this point in the history
The parsing code was failing in enyo.Control due to some
embedded regex's we added.  This prevents that failure
by having the lexer properly recognize those as their
own tokens.

Enyo-DCO-1.1-Signed-Off-By: Ben Combee (ben.combee@lge.com)
  • Loading branch information
Ben Combee committed Oct 31, 2013
1 parent 2c900f7 commit 53a4b46
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions analyzer2/Lexer.js
Expand Up @@ -104,7 +104,7 @@ enyo.kind({
},
buildPattern: function() {
// match an inline regex
//var rregex = "/[^*/](?:\\/|[^/])+?/";
var rregex = "\\/[^\/*[](?:[^\\/\\\\\\r\n]|\\\\.)+\\/\\w*";
//
// matches double-quoted string that may contain escaped double-quotes
var rstring1 = '"(?:\\\\"|[^"])*?"';
Expand Down Expand Up @@ -136,9 +136,9 @@ enyo.kind({
//
// these are the patterns to match
// match escape sequences \" and \/ first to help defray confusion
var matches = ["\\\\\"|\\\\/", rstring, rkeys, '\\/\\/', '\\/\\*', rsymbols, "\\s"];
var matches = ["\\\\\"|\\\\/", rregex, rstring, rkeys, '\\/\\/', '\\/\\*', rsymbols, "\\s"];
// these are the matching methods corresponding to the patterns above
this.matchers = ["doSymbol", "doString", "doKeyword", "doLineComment", "doCComment", "doSymbol", "doWhitespace"];
this.matchers = ["doSymbol", "doRegex", "doString", "doKeyword", "doLineComment", "doCComment", "doSymbol", "doWhitespace"];
//
//
// construct the master regex as a union of the patterns above
Expand Down Expand Up @@ -215,5 +215,8 @@ enyo.kind({
},
doString: function() {
this.pushToken("string", this.m[0].length);
},
doRegex: function() {
this.pushToken("regex", this.m[0].length);
}
});

0 comments on commit 53a4b46

Please sign in to comment.