Comparing version 0.4.2 to 0.4.3
@@ -377,3 +377,3 @@ (function(root, factory) { | ||
type: (group.getType && group.getType(text)) || group.tokenType, | ||
value: (group.value && group.value(text)) || text, | ||
value: group.value ? group.value(text) : text, | ||
text: text, | ||
@@ -380,0 +380,0 @@ toString: tokenToString, |
{ | ||
"name": "moo", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "Optimised tokenizer/lexer generator! π Much performance. Moo!", | ||
@@ -5,0 +5,0 @@ "main": "moo.js", |
@@ -125,4 +125,13 @@ ![](cow.png) | ||
It will track line numbers, as long as you apply the `lineBreaks: true` option to any tokens which might contain newlines. Moo will try to warn you if you forget to do this. | ||
It will track line numbers, as long as you **apply the `lineBreaks: true` option to any rules which might contain newlines**. Moo will try to warn you if you forget to do this. | ||
Note that this is `false` by default, for performance reasons: counting the number of lines in a matched token has a small cost. For optimal performance, only match newlines inside a dedicated token: | ||
```js | ||
newline: {match: '\n', lineBreaks: true}, | ||
``` | ||
### Token Info ### | ||
Token objects (returned from `next()`) have the following attributes: | ||
@@ -181,2 +190,5 @@ | ||
### Why? ### | ||
You need to do this to ensure the **longest match** principle applies, even in edge cases. | ||
@@ -187,4 +199,4 @@ | ||
```js | ||
['keyword', ['class']], | ||
['identifier', /[a-zA-Z]+/], | ||
keyword: ['class'], | ||
identifier: /[a-zA-Z]+/, | ||
``` | ||
@@ -196,2 +208,5 @@ | ||
### Keyword Types ### | ||
Keywords can also have **individual types**. | ||
@@ -214,3 +229,3 @@ | ||
Use [itt](https://github.com/nathan/itt)'s iterator adapters to make constructing keyword objects easier: | ||
You can use [itt](https://github.com/nathan/itt)'s iterator adapters to make constructing keyword objects easier: | ||
@@ -217,0 +232,0 @@ ```js |
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
25996
362