Comparing version 0.3.3 to 0.3.4
@@ -496,4 +496,6 @@ var __extends = this.__extends || function (d, b) { | ||
var MachineState = (function () { | ||
function MachineState(iterable) { | ||
function MachineState(iterable, peek_length) { | ||
if (peek_length === void 0) { peek_length = 256; } | ||
this.iterable = iterable; | ||
this.peek_length = peek_length; | ||
} | ||
@@ -507,4 +509,7 @@ // generic callbacks | ||
}; | ||
MachineState.prototype.attachState = function (SubState) { | ||
return new SubState(this.iterable, this.peek_length); | ||
}; | ||
MachineState.prototype.read = function () { | ||
var input = this.iterable.peek(64); | ||
var input = this.iterable.peek(this.peek_length); | ||
for (var i = 0, rule; (rule = this.rules[i]); i++) { | ||
@@ -511,0 +516,0 @@ var match = input.match(rule[0]); |
12
index.ts
@@ -529,2 +529,5 @@ /// <reference path="type_declarations/DefinitelyTyped/node/node.d.ts" /> | ||
} | ||
export interface MachineStateConstructor<T, I> { | ||
new(iterable: StringIterable, peek_length?: number): MachineState<T, I>; | ||
} | ||
@@ -550,3 +553,4 @@ /** | ||
protected rules: MachineRule<T>[]; | ||
constructor(protected iterable: StringIterable) { } | ||
constructor(protected iterable: StringIterable, | ||
protected peek_length: number = 256) { } | ||
@@ -561,4 +565,8 @@ // generic callbacks | ||
attachState<SubT, SubI>(SubState: MachineStateConstructor<SubT, SubI>): MachineState<SubT, SubI> { | ||
return new SubState(this.iterable, this.peek_length); | ||
} | ||
read(): T { | ||
var input = this.iterable.peek(64); | ||
var input = this.iterable.peek(this.peek_length); | ||
@@ -565,0 +573,0 @@ for (var i = 0, rule: MachineRule<T>; (rule = this.rules[i]); i++) { |
@@ -263,2 +263,5 @@ /// <reference path="../../type_declarations/DefinitelyTyped/node/node.d.ts" /> | ||
function MachineRule<T>(regexp: RegExp, callback: MachineCallback<T>): MachineRule<T>; | ||
interface MachineStateConstructor<T, I> { | ||
new (iterable: StringIterable, peek_length?: number): MachineState<T, I>; | ||
} | ||
/** | ||
@@ -282,9 +285,11 @@ Every MachineState has: | ||
protected iterable: StringIterable; | ||
protected peek_length: number; | ||
protected value: I; | ||
protected rules: MachineRule<T>[]; | ||
constructor(iterable: StringIterable); | ||
constructor(iterable: StringIterable, peek_length?: number); | ||
pop(): T; | ||
ignore(): T; | ||
attachState<SubT, SubI>(SubState: MachineStateConstructor<SubT, SubI>): MachineState<SubT, SubI>; | ||
read(): T; | ||
} | ||
} |
{ | ||
"name": "lexing", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Regex-based lexer", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
129335
2904