11"use strict" ;
2- var __extends = ( this && this . __extends ) || ( function ( ) {
3- var extendStatics = function ( d , b ) {
4- extendStatics = Object . setPrototypeOf ||
5- ( { __proto__ : [ ] } instanceof Array && function ( d , b ) { d . __proto__ = b ; } ) ||
6- function ( d , b ) { for ( var p in b ) if ( b . hasOwnProperty ( p ) ) d [ p ] = b [ p ] ; } ;
7- return extendStatics ( d , b ) ;
8- } ;
9- return function ( d , b ) {
10- extendStatics ( d , b ) ;
11- function __ ( ) { this . constructor = d ; }
12- d . prototype = b === null ? Object . create ( b ) : ( __ . prototype = b . prototype , new __ ( ) ) ;
13- } ;
14- } ) ( ) ;
152var __values = ( this && this . __values ) || function ( o ) {
163 var m = typeof Symbol === "function" && o [ Symbol . iterator ] , i = 0 ;
174 if ( m ) return m . call ( o ) ;
@@ -22,15 +9,12 @@ var __values = (this && this.__values) || function (o) {
229 }
2310 } ;
2411} ;
12+ var __importDefault = ( this && this . __importDefault ) || function ( mod ) {
13+ return ( mod && mod . __esModule ) ? mod : { "default" : mod } ;
14+ } ;
2515Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
2616var utils_1 = require ( "../utils" ) ;
27- var Epsilon = /** @class */ ( function ( ) {
28- function Epsilon ( ) {
29- }
30- return Epsilon ;
31- } ( ) ) ;
32- exports . Epsilon = Epsilon ;
33- exports . epsilon = new Epsilon ( ) ;
17+ var epsilon_1 = __importDefault ( require ( "./epsilon" ) ) ;
3418var State = /** @class */ ( function ( ) {
3519 function State ( accepted , alias ) {
3620 if ( accepted === void 0 ) { accepted = false ; }
@@ -56,7 +40,7 @@ var State = /** @class */ (function () {
5640 var e_1 , _a ;
5741 var epsilonSet = new Set ( ) ;
5842 epsilonSet . add ( this ) ;
59- var epsilonStates = this . nextStatesMap . get ( exports . epsilon ) ;
43+ var epsilonStates = this . nextStatesMap . get ( epsilon_1 . default ) ;
6044 if ( epsilonStates ) {
6145 utils_1 . mergeSetInto ( epsilonSet , epsilonStates ) ;
6246 try {
@@ -78,123 +62,3 @@ var State = /** @class */ (function () {
7862 return State ;
7963} ( ) ) ;
8064exports . State = State ;
81- var StateOp = /** @class */ ( function ( ) {
82- function StateOp ( ) {
83- this . start = null ;
84- this . end = null ;
85- }
86- StateOp . prototype . getStartState = function ( ) {
87- return this . start ;
88- } ;
89- StateOp . prototype . getEndState = function ( ) {
90- return this . end ;
91- } ;
92- StateOp . prototype . setNext = function ( input , state ) {
93- var start = state . getStartState ( ) ;
94- if ( start && this . end ) {
95- this . end . setNext ( input , start ) ;
96- }
97- else if ( ! start ) {
98- throw new Error ( 'Start state of param state is null' ) ;
99- }
100- else if ( ! this . end ) {
101- throw new Error ( 'this.end is null' ) ;
102- }
103- } ;
104- return StateOp ;
105- } ( ) ) ;
106- exports . StateOp = StateOp ;
107- var SingleInputState = /** @class */ ( function ( _super ) {
108- __extends ( SingleInputState , _super ) ;
109- function SingleInputState ( input , accepted ) {
110- if ( accepted === void 0 ) { accepted = false ; }
111- var _this = _super . call ( this ) || this ;
112- _this . start = new State ( ) ;
113- _this . end = new State ( accepted ) ;
114- _this . start . setNext ( input , _this . end ) ;
115- return _this ;
116- }
117- return SingleInputState ;
118- } ( StateOp ) ) ;
119- exports . SingleInputState = SingleInputState ;
120- var ConcatState = /** @class */ ( function ( _super ) {
121- __extends ( ConcatState , _super ) ;
122- function ConcatState ( a , b ) {
123- var _this = _super . call ( this ) || this ;
124- _this . a = a ;
125- _this . b = b ;
126- _this . start = _this . a . getStartState ( ) ;
127- _this . a . setNext ( exports . epsilon , _this . b ) ;
128- _this . end = _this . b . getEndState ( ) ;
129- return _this ;
130- }
131- return ConcatState ;
132- } ( StateOp ) ) ;
133- exports . ConcatState = ConcatState ;
134- var UnionState = /** @class */ ( function ( _super ) {
135- __extends ( UnionState , _super ) ;
136- function UnionState ( a , b , accepted ) {
137- var e_2 , _a ;
138- if ( accepted === void 0 ) { accepted = false ; }
139- var _this = _super . call ( this ) || this ;
140- _this . a = a ;
141- _this . b = b ;
142- _this . start = new State ( ) ;
143- _this . end = new State ( accepted ) ;
144- try {
145- for ( var _b = __values ( [ _this . a , _this . b ] ) , _c = _b . next ( ) ; ! _c . done ; _c = _b . next ( ) ) {
146- var arg = _c . value ;
147- var argOpStart = arg . getStartState ( ) ;
148- var argOpEnd = arg . getEndState ( ) ;
149- if ( argOpStart ) {
150- _this . start . setNext ( exports . epsilon , argOpStart ) ;
151- }
152- else {
153- throw new Error ( 'start of argOp is null' ) ;
154- }
155- if ( argOpEnd ) {
156- argOpEnd . setNext ( exports . epsilon , _this . end ) ;
157- }
158- else {
159- throw new Error ( 'end of argOp is null' ) ;
160- }
161- }
162- }
163- catch ( e_2_1 ) { e_2 = { error : e_2_1 } ; }
164- finally {
165- try {
166- if ( _c && ! _c . done && ( _a = _b . return ) ) _a . call ( _b ) ;
167- }
168- finally { if ( e_2 ) throw e_2 . error ; }
169- }
170- return _this ;
171- }
172- return UnionState ;
173- } ( StateOp ) ) ;
174- exports . UnionState = UnionState ;
175- var ClosureState = /** @class */ ( function ( _super ) {
176- __extends ( ClosureState , _super ) ;
177- function ClosureState ( a , accepted ) {
178- if ( accepted === void 0 ) { accepted = false ; }
179- var _this = _super . call ( this ) || this ;
180- _this . a = a ;
181- _this . start = new State ( ) ;
182- _this . end = new State ( accepted ) ;
183- var aStart = _this . a . getStartState ( ) ;
184- var aEnd = _this . a . getEndState ( ) ;
185- if ( aStart ) {
186- _this . start . setNext ( exports . epsilon , aStart ) ;
187- }
188- else {
189- throw new Error ( 'start of a is null' ) ;
190- }
191- _this . start . setNext ( exports . epsilon , _this . end ) ;
192- if ( aEnd ) {
193- aEnd . setNext ( exports . epsilon , _this . end ) ;
194- aEnd . setNext ( exports . epsilon , _this . start ) ;
195- }
196- return _this ;
197- }
198- return ClosureState ;
199- } ( StateOp ) ) ;
200- exports . ClosureState = ClosureState ;
0 commit comments