regexp-tree
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -10,4 +10,2 @@ /** | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
@@ -18,4 +16,2 @@ | ||
var DFAMinimizer = require('./dfa-minimizer'); | ||
var TablePrinter = require('../table-printer'); | ||
var colors = require('colors'); | ||
@@ -358,48 +354,2 @@ var _require = require('../special-symbols'), | ||
/** | ||
* Prints transition table. | ||
*/ | ||
}, { | ||
key: 'printTransitionTable', | ||
value: function printTransitionTable() { | ||
var header = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '\nDFA transition table:\n'; | ||
console.info(colors.bold(header)); | ||
var alphabet = [].concat(_toConsumableArray(this.getAlphabet())); | ||
var printer = new TablePrinter({ | ||
head: [''].concat(alphabet) | ||
}); | ||
var table = this.getTransitionTable(); | ||
var acceptingStates = this.getAcceptingStateNumbers(); | ||
var _loop = function _loop(stateNumber) { | ||
var tableRow = table[stateNumber]; | ||
var stateLabel = acceptingStates.has(Number(stateNumber)) ? colors.bold(colors.green(stateNumber + ' \u2713')) : colors.blue(stateNumber); | ||
if (stateNumber == 1) { | ||
stateLabel += colors.yellow(' >'); | ||
} | ||
var row = _defineProperty({}, stateLabel, []); | ||
alphabet.forEach(function (symbol) { | ||
row[stateLabel].push(tableRow[symbol] || ''); | ||
}); | ||
printer.push(row); | ||
}; | ||
for (var stateNumber in table) { | ||
_loop(stateNumber); | ||
} | ||
console.info(printer.toString()); | ||
console.info(''); | ||
} | ||
/** | ||
* Checks whether this DFA accepts a string. | ||
@@ -406,0 +356,0 @@ */ |
@@ -12,4 +12,2 @@ /** | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
@@ -19,5 +17,2 @@ | ||
var TablePrinter = require('../table-printer'); | ||
var colors = require('colors'); | ||
var _require = require('../special-symbols'), | ||
@@ -236,52 +231,2 @@ EPSILON = _require.EPSILON, | ||
} | ||
/** | ||
* Prints transition table. | ||
*/ | ||
}, { | ||
key: 'printTransitionTable', | ||
value: function printTransitionTable() { | ||
console.info(colors.bold('\nNFA transition table:\n')); | ||
var alphabet = [].concat(_toConsumableArray(this.getAlphabet()), [EPSILON_CLOSURE]); | ||
var printer = new TablePrinter({ | ||
head: [''].concat(alphabet) | ||
}); | ||
var table = this.getTransitionTable(); | ||
var acceptingStates = this.getAcceptingStateNumbers(); | ||
var _loop = function _loop(stateNumber) { | ||
var tableRow = table[stateNumber]; | ||
var stateLabel = acceptingStates.has(Number(stateNumber)) ? colors.bold(colors.green(stateNumber + ' \u2713')) : colors.blue(stateNumber); | ||
if (stateNumber == 1) { | ||
stateLabel += colors.yellow(' >'); | ||
} | ||
var row = _defineProperty({}, stateLabel, []); | ||
alphabet.forEach(function (symbol) { | ||
var entry = ''; | ||
if (Array.isArray(tableRow[symbol])) { | ||
entry = tableRow[symbol].length === 1 ? tableRow[symbol][0] : '{' + tableRow[symbol].join(',') + '}'; | ||
} | ||
row[stateLabel].push(entry); | ||
}); | ||
printer.push(row); | ||
}; | ||
for (var stateNumber in table) { | ||
_loop(stateNumber); | ||
} | ||
console.info(printer.toString()); | ||
console.info(''); | ||
} | ||
}]); | ||
@@ -288,0 +233,0 @@ |
{ | ||
"name": "regexp-tree", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Regular Expressions parser in JavaScript", |
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
250928
5710