Comparing version 1.2.0 to 1.3.0
@@ -9,2 +9,3 @@ if (typeof module === "object" && typeof module.exports === "object") module.exports = Lexer; | ||
this.input = input; | ||
return this; | ||
}; | ||
@@ -36,2 +37,4 @@ | ||
}); | ||
return this; | ||
}; | ||
@@ -38,0 +41,0 @@ |
{ | ||
"name": "lex", | ||
"description": "An elegant armor-plated JavaScript lexer modelled after flex. Easily extensible to tailor to your need for perfection.", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"keywords": ["lexer"], | ||
@@ -6,0 +6,0 @@ "author": "Aadit M Shah (http://aaditmshah.github.com/) <aaditmshah@myopera.com>", |
@@ -29,3 +29,3 @@ # Lexer # | ||
After adding rules to the lexer you may set the property `input` of the lexer to any string that you wish to tokenize and then call the method `lex`. The function returns the first non `undefined` value returned by an action. Else it returns `undefined` if it scans the entire input string. On calling `lex` it starts scanning where it last left off. | ||
After adding rules to the lexer you may set the property `input` of the lexer to any string that you wish to tokenize and then call the method `lex`. The function returns the first non `undefined` value returned by an action. Else it returns `undefined` if it scans the entire input string. On calling `lex` it starts scanning where it last left off. The `addRule` and `setInput` methods of the lexer support chaining. | ||
@@ -36,16 +36,8 @@ ```javascript | ||
var lexer = new Lexer; | ||
lexer.addRule(/\n/, function () { | ||
(new Lexer).addRule(/\n/, function () { | ||
lines++; | ||
chars++; | ||
}); | ||
lexer.addRule(/./, function () { | ||
}).addRule(/./, function () { | ||
chars++; | ||
}); | ||
lexer.input = "Hello World!"; | ||
lexer.lex(); | ||
}).setInput("Hello World!").lex(); | ||
``` | ||
@@ -52,0 +44,0 @@ |
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
8349
99
101