Skip to content

Commit

Permalink
build: generate dist for v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yuqingc committed May 19, 2019
1 parent 33063e2 commit 16ee71e
Show file tree
Hide file tree
Showing 12 changed files with 265 additions and 189 deletions.
6 changes: 6 additions & 0 deletions dist/fas/combineStateOps.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { StateOp } from './stateOps';
export declare function concatMultipleStates(...states: StateOp[]): StateOp;
export declare function unionMultipleStates({ states, accepted }: {
states: StateOp[];
accepted?: boolean;
}): StateOp;
32 changes: 32 additions & 0 deletions dist/fas/combineStateOps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var stateOps_1 = require("./stateOps");
function concatMultipleStates() {
var states = [];
for (var _i = 0; _i < arguments.length; _i++) {
states[_i] = arguments[_i];
}
if (states.length === 0) {
throw new Error('Argument must be at least one state');
}
if (states.length === 1) {
return states[0];
}
return states.reduce(function (stateA, stateB) {
return new stateOps_1.ConcatState(stateA, stateB);
});
}
exports.concatMultipleStates = concatMultipleStates;
function unionMultipleStates(_a) {
var states = _a.states, _b = _a.accepted, accepted = _b === void 0 ? false : _b;
if (states.length === 0) {
throw new Error('Argument must be at least one state');
}
if (states.length === 1) {
return states[0];
}
return states.reduce(function (stateA, stateB, currentIndex) {
return new stateOps_1.UnionState(stateA, stateB, (currentIndex === states.length - 1) && accepted);
});
}
exports.unionMultipleStates = unionMultipleStates;
3 changes: 2 additions & 1 deletion dist/fas/dfa.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { State, Epsilon } from './state';
import { State } from './state';
import { Epsilon } from './epsilon';
export declare class DFAStatesSet {
states: Set<State>;
private nextStatesSetMap;
Expand Down
4 changes: 4 additions & 0 deletions dist/fas/epsilon.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare class Epsilon {
}
declare const epsilon: Epsilon;
export default epsilon;
10 changes: 10 additions & 0 deletions dist/fas/epsilon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Epsilon = /** @class */ (function () {
function Epsilon() {
}
return Epsilon;
}());
exports.Epsilon = Epsilon;
var epsilon = new Epsilon();
exports.default = epsilon;
2 changes: 1 addition & 1 deletion dist/fas/nfa.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StateOp } from './state';
import { StateOp } from './stateOps';
import { DFA } from './dfa';
export declare class NFA {
private stateOp;
Expand Down
32 changes: 2 additions & 30 deletions dist/fas/state.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export declare class Epsilon {
}
export declare const epsilon: Epsilon;
declare type InputType = string | Epsilon;
import { Epsilon } from './epsilon';
export declare type InputType = string | Epsilon;
export declare class State {
nextStatesMap: Map<InputType, Set<State>>;
private accepted;
Expand All @@ -11,29 +9,3 @@ export declare class State {
isAccepted(): boolean;
epsilonClosure(): Set<State>;
}
export declare class StateOp {
protected start: State | null;
protected end: State | null;
constructor();
getStartState(): State | null;
getEndState(): State | null;
setNext(input: InputType, state: StateOp): void;
}
export declare class SingleInputState extends StateOp {
constructor(input: InputType, accepted?: boolean);
}
export declare class ConcatState extends StateOp {
private a;
private b;
constructor(a: StateOp, b: StateOp);
}
export declare class UnionState extends StateOp {
private a;
private b;
constructor(a: StateOp, b: StateOp, accepted?: boolean);
}
export declare class ClosureState extends StateOp {
private a;
constructor(a: StateOp, accepted?: boolean);
}
export {};
146 changes: 5 additions & 141 deletions dist/fas/state.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __values = (this && this.__values) || function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
Expand All @@ -22,15 +9,12 @@ var __values = (this && this.__values) || function (o) {
}
};
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("../utils");
var Epsilon = /** @class */ (function () {
function Epsilon() {
}
return Epsilon;
}());
exports.Epsilon = Epsilon;
exports.epsilon = new Epsilon();
var epsilon_1 = __importDefault(require("./epsilon"));
var State = /** @class */ (function () {
function State(accepted, alias) {
if (accepted === void 0) { accepted = false; }
Expand All @@ -56,7 +40,7 @@ var State = /** @class */ (function () {
var e_1, _a;
var epsilonSet = new Set();
epsilonSet.add(this);
var epsilonStates = this.nextStatesMap.get(exports.epsilon);
var epsilonStates = this.nextStatesMap.get(epsilon_1.default);
if (epsilonStates) {
utils_1.mergeSetInto(epsilonSet, epsilonStates);
try {
Expand All @@ -78,123 +62,3 @@ var State = /** @class */ (function () {
return State;
}());
exports.State = State;
var StateOp = /** @class */ (function () {
function StateOp() {
this.start = null;
this.end = null;
}
StateOp.prototype.getStartState = function () {
return this.start;
};
StateOp.prototype.getEndState = function () {
return this.end;
};
StateOp.prototype.setNext = function (input, state) {
var start = state.getStartState();
if (start && this.end) {
this.end.setNext(input, start);
}
else if (!start) {
throw new Error('Start state of param state is null');
}
else if (!this.end) {
throw new Error('this.end is null');
}
};
return StateOp;
}());
exports.StateOp = StateOp;
var SingleInputState = /** @class */ (function (_super) {
__extends(SingleInputState, _super);
function SingleInputState(input, accepted) {
if (accepted === void 0) { accepted = false; }
var _this = _super.call(this) || this;
_this.start = new State();
_this.end = new State(accepted);
_this.start.setNext(input, _this.end);
return _this;
}
return SingleInputState;
}(StateOp));
exports.SingleInputState = SingleInputState;
var ConcatState = /** @class */ (function (_super) {
__extends(ConcatState, _super);
function ConcatState(a, b) {
var _this = _super.call(this) || this;
_this.a = a;
_this.b = b;
_this.start = _this.a.getStartState();
_this.a.setNext(exports.epsilon, _this.b);
_this.end = _this.b.getEndState();
return _this;
}
return ConcatState;
}(StateOp));
exports.ConcatState = ConcatState;
var UnionState = /** @class */ (function (_super) {
__extends(UnionState, _super);
function UnionState(a, b, accepted) {
var e_2, _a;
if (accepted === void 0) { accepted = false; }
var _this = _super.call(this) || this;
_this.a = a;
_this.b = b;
_this.start = new State();
_this.end = new State(accepted);
try {
for (var _b = __values([_this.a, _this.b]), _c = _b.next(); !_c.done; _c = _b.next()) {
var arg = _c.value;
var argOpStart = arg.getStartState();
var argOpEnd = arg.getEndState();
if (argOpStart) {
_this.start.setNext(exports.epsilon, argOpStart);
}
else {
throw new Error('start of argOp is null');
}
if (argOpEnd) {
argOpEnd.setNext(exports.epsilon, _this.end);
}
else {
throw new Error('end of argOp is null');
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_2) throw e_2.error; }
}
return _this;
}
return UnionState;
}(StateOp));
exports.UnionState = UnionState;
var ClosureState = /** @class */ (function (_super) {
__extends(ClosureState, _super);
function ClosureState(a, accepted) {
if (accepted === void 0) { accepted = false; }
var _this = _super.call(this) || this;
_this.a = a;
_this.start = new State();
_this.end = new State(accepted);
var aStart = _this.a.getStartState();
var aEnd = _this.a.getEndState();
if (aStart) {
_this.start.setNext(exports.epsilon, aStart);
}
else {
throw new Error('start of a is null');
}
_this.start.setNext(exports.epsilon, _this.end);
if (aEnd) {
aEnd.setNext(exports.epsilon, _this.end);
aEnd.setNext(exports.epsilon, _this.start);
}
return _this;
}
return ClosureState;
}(StateOp));
exports.ClosureState = ClosureState;
26 changes: 26 additions & 0 deletions dist/fas/stateOps.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { State, InputType } from './state';
export declare class StateOp {
protected start: State | null;
protected end: State | null;
constructor();
getStartState(): State | null;
getEndState(): State | null;
setNext(input: InputType, state: StateOp): void;
}
export declare class SingleInputState extends StateOp {
constructor(input: InputType, accepted?: boolean);
}
export declare class ConcatState extends StateOp {
private a;
private b;
constructor(a: StateOp, b: StateOp);
}
export declare class UnionState extends StateOp {
private a;
private b;
constructor(a: StateOp, b: StateOp, accepted?: boolean);
}
export declare class ClosureState extends StateOp {
private a;
constructor(a: StateOp, accepted?: boolean);
}
Loading

0 comments on commit 16ee71e

Please sign in to comment.