Skip to content

Commit 16ee71e

Browse files
committed
build: generate dist for v1.0.0
1 parent 33063e2 commit 16ee71e

12 files changed

Lines changed: 265 additions & 189 deletions

dist/fas/combineStateOps.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { StateOp } from './stateOps';
2+
export declare function concatMultipleStates(...states: StateOp[]): StateOp;
3+
export declare function unionMultipleStates({ states, accepted }: {
4+
states: StateOp[];
5+
accepted?: boolean;
6+
}): StateOp;

dist/fas/combineStateOps.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
var stateOps_1 = require("./stateOps");
4+
function concatMultipleStates() {
5+
var states = [];
6+
for (var _i = 0; _i < arguments.length; _i++) {
7+
states[_i] = arguments[_i];
8+
}
9+
if (states.length === 0) {
10+
throw new Error('Argument must be at least one state');
11+
}
12+
if (states.length === 1) {
13+
return states[0];
14+
}
15+
return states.reduce(function (stateA, stateB) {
16+
return new stateOps_1.ConcatState(stateA, stateB);
17+
});
18+
}
19+
exports.concatMultipleStates = concatMultipleStates;
20+
function unionMultipleStates(_a) {
21+
var states = _a.states, _b = _a.accepted, accepted = _b === void 0 ? false : _b;
22+
if (states.length === 0) {
23+
throw new Error('Argument must be at least one state');
24+
}
25+
if (states.length === 1) {
26+
return states[0];
27+
}
28+
return states.reduce(function (stateA, stateB, currentIndex) {
29+
return new stateOps_1.UnionState(stateA, stateB, (currentIndex === states.length - 1) && accepted);
30+
});
31+
}
32+
exports.unionMultipleStates = unionMultipleStates;

dist/fas/dfa.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { State, Epsilon } from './state';
1+
import { State } from './state';
2+
import { Epsilon } from './epsilon';
23
export declare class DFAStatesSet {
34
states: Set<State>;
45
private nextStatesSetMap;

dist/fas/epsilon.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export declare class Epsilon {
2+
}
3+
declare const epsilon: Epsilon;
4+
export default epsilon;

dist/fas/epsilon.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
var Epsilon = /** @class */ (function () {
4+
function Epsilon() {
5+
}
6+
return Epsilon;
7+
}());
8+
exports.Epsilon = Epsilon;
9+
var epsilon = new Epsilon();
10+
exports.default = epsilon;

dist/fas/nfa.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { StateOp } from './state';
1+
import { StateOp } from './stateOps';
22
import { DFA } from './dfa';
33
export declare class NFA {
44
private stateOp;

dist/fas/state.d.ts

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
export declare class Epsilon {
2-
}
3-
export declare const epsilon: Epsilon;
4-
declare type InputType = string | Epsilon;
1+
import { Epsilon } from './epsilon';
2+
export declare type InputType = string | Epsilon;
53
export declare class State {
64
nextStatesMap: Map<InputType, Set<State>>;
75
private accepted;
@@ -11,29 +9,3 @@ export declare class State {
119
isAccepted(): boolean;
1210
epsilonClosure(): Set<State>;
1311
}
14-
export declare class StateOp {
15-
protected start: State | null;
16-
protected end: State | null;
17-
constructor();
18-
getStartState(): State | null;
19-
getEndState(): State | null;
20-
setNext(input: InputType, state: StateOp): void;
21-
}
22-
export declare class SingleInputState extends StateOp {
23-
constructor(input: InputType, accepted?: boolean);
24-
}
25-
export declare class ConcatState extends StateOp {
26-
private a;
27-
private b;
28-
constructor(a: StateOp, b: StateOp);
29-
}
30-
export declare class UnionState extends StateOp {
31-
private a;
32-
private b;
33-
constructor(a: StateOp, b: StateOp, accepted?: boolean);
34-
}
35-
export declare class ClosureState extends StateOp {
36-
private a;
37-
constructor(a: StateOp, accepted?: boolean);
38-
}
39-
export {};

dist/fas/state.js

Lines changed: 5 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
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-
})();
152
var __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+
};
2515
Object.defineProperty(exports, "__esModule", { value: true });
2616
var 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"));
3418
var 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
}());
8064
exports.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;

dist/fas/stateOps.d.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { State, InputType } from './state';
2+
export declare class StateOp {
3+
protected start: State | null;
4+
protected end: State | null;
5+
constructor();
6+
getStartState(): State | null;
7+
getEndState(): State | null;
8+
setNext(input: InputType, state: StateOp): void;
9+
}
10+
export declare class SingleInputState extends StateOp {
11+
constructor(input: InputType, accepted?: boolean);
12+
}
13+
export declare class ConcatState extends StateOp {
14+
private a;
15+
private b;
16+
constructor(a: StateOp, b: StateOp);
17+
}
18+
export declare class UnionState extends StateOp {
19+
private a;
20+
private b;
21+
constructor(a: StateOp, b: StateOp, accepted?: boolean);
22+
}
23+
export declare class ClosureState extends StateOp {
24+
private a;
25+
constructor(a: StateOp, accepted?: boolean);
26+
}

0 commit comments

Comments
 (0)