Comparing version 0.4.1 to 0.4.2
20
moo.js
@@ -60,6 +60,2 @@ (function(root, factory) { | ||
function compareLength(a, b) { | ||
return b.length - a.length | ||
} | ||
function regexpOrLiteral(obj) { | ||
@@ -195,5 +191,5 @@ if (typeof obj === 'string') { | ||
var flags = hasSticky ? 'ym' : 'gm' | ||
var regexp = new RegExp(reUnion(parts) + suffix, flags) | ||
var combined = new RegExp(reUnion(parts) + suffix, flags) | ||
return {regexp: regexp, groups: groups, error: errorRule} | ||
return {regexp: combined, groups: groups, error: errorRule} | ||
} | ||
@@ -243,2 +239,5 @@ | ||
(byLength[keyword.length] = byLength[keyword.length] || []).push(keyword) | ||
if (typeof keyword !== 'string') { | ||
throw new Error("keyword must be string (in keyword '" + tokenType + "')") | ||
} | ||
reverseMap[keyword] = tokenType | ||
@@ -260,5 +259,2 @@ }) | ||
var tokenType = reverseMap[keyword] | ||
if (typeof tokenType !== 'string') { | ||
throw new Error('keyword type must be string: ' + name) | ||
} | ||
source += 'case ' + str(keyword) + ': return ' + str(tokenType) + '\n' | ||
@@ -455,6 +451,4 @@ }) | ||
if (group.tokenType === tokenType) return true | ||
if (group.keywords) { | ||
for (var k in group.keywords) { | ||
if (group.keywords[k].tokenType === tokenType) return true | ||
} | ||
if (group.keywords && hasOwnProperty.call(group.keywords, tokenType)) { | ||
return true | ||
} | ||
@@ -461,0 +455,0 @@ } |
{ | ||
"name": "moo", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Optimised tokenizer/lexer generator! π Much performance. Moo!", | ||
@@ -5,0 +5,0 @@ "main": "moo.js", |
@@ -343,3 +343,5 @@ ![](cow.png) | ||
Do check the [FAQ](https://github.com/tjvr/moo/issues?q=label%3Aquestion). | ||
Before submitting an issue, [remember...](https://github.com/tjvr/moo/blob/master/.github/CONTRIBUTING.md) | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
347
25684
398