Creates a Deterministic Finite Automata (DFA) from regular expressions
npm install regex-to-dfa
npm install regex-to-dfa
`Use examples
$3
Once the DFA is installed one can load it using:
`
var DFA = require('regex-to-dfa').DFA;
`$3
To create a new DFA which accepts any input corresponding to the regular expressions foo+ and ba*r with identifiers A and B respectively:
`
var myDFA = new DFA(new RegExp(/foo+/), 'A');
myDFA.add(new RegExp(/ba*r/), 'B');
`$3
To check whether input is accepted one uses
`
var isAccepted = myDFA.accepts('foo');
console.log(isAccepted);
>>> trueisAccepted = myDFA.accepts('abc');
console.log(isAccepted);
>>> false
`To check what label corresponds to the input one uses
`
var label = myDFA.acceptingID('bar');
console.log(label);
>>> Blabel = myDFA.acceptingID('abc');
console.log(label);
>>> undefined
`Supported expressions
1. All character classes, e.g. ., [\s\S], \w, \W, \d, \D, \s, \S
2. All character sets, e.g. [ABC], [^ABC], [A-Z]
3. All escaped characters, e.g. \n, \+, \uFFFF, \xFF, \000
4. All quantifiers and alternation, e.g. +, *, {1,3}, ?, |Unsupported expressions - expected in future releases
1. Groups, e.g. (abc)`