|
32 | 32 |
|
33 | 33 | /* eslint-disable no-console */ |
34 | 34 | /* eslint-disable guard-for-in */ |
35 | | -var composePatterns = require( './compose-patterns.js' ); |
| 35 | +const composePatterns = require( './compose-patterns.js' ); |
| 36 | +const identifyMarkedArea = require( './identify-marked-area.js' ); |
36 | 37 |
|
37 | 38 | const eosTokenN = 2070000; |
38 | 39 | const eosTokenX = '$%^EoS^%$'; |
@@ -172,7 +173,7 @@ var simpleFSM = function ( cache, token2Ignore ) { |
172 | 173 | if ( mark ) { |
173 | 174 | // Update last element of `mark` to simplifies computations during fsm |
174 | 175 | // execution. Update must happen as a deep copy & not directly! |
175 | | - markedStates[ state ] = [ mark[ 0 ], ( length - mark[ 1 ] - 1 ) ]; |
| 176 | + markedStates[ state ] = identifyMarkedArea( mark, length ); |
176 | 177 | } |
177 | 178 |
|
178 | 179 | if ( customProperty !== undefined ) { |
@@ -261,8 +262,14 @@ var simpleFSM = function ( cache, token2Ignore ) { |
261 | 262 |
|
262 | 263 | var customProperty = customPropertyAtStates[ m0 ]; |
263 | 264 | if ( mark ) { |
| 265 | + // `match[ 1 ]` will now point to the index of the token where |
| 266 | + // the entity should end because `match[ 0 ]` is pointing to the index |
| 267 | + // of the token of detected entity's start and by adding `mark[ 1 ]` |
| 268 | + // i.e. the `lastIndex` to it, we get the required value. |
| 269 | + match[ 1 ] = match[ 0 ] + mark[ 1 ]; |
| 270 | + // For `match[ 0 ]`, simply adding `mark[ 0 ]` i.e. `firstIndex` yields |
| 271 | + // the desried value. |
264 | 272 | match[ 0 ] += mark[ 0 ]; |
265 | | - match[ 1 ] -= mark[ 1 ]; |
266 | 273 | } |
267 | 274 |
|
268 | 275 | // Removed `customProperty !== undefined &&` check while coding pos experiment |
|
0 commit comments