Releases: RunDevelopment/refa
Releases · RunDevelopment/refa
v0.12.1
Added
- Generally added some documentation.
- Added
CharMap#{size,entryCount}to get the size of a map. - Added
CharMap#copyto create a (mapped) copy of a map. - Added
StringSet#{is{Proper,}{Subset,Superset}Of,isDisjointWith}for set relations. - Added
UnicodeSet#{is{Proper,}{Subset,Superset}Of,isDisjointWith}for set relations. - Added
UnicodeSet#{wordSets,maximum}for a more ergonomic API. UnicodeSet#{equals,union,intersect,without}allowCharSets.
Fixed
- Made
StringSet#wordsprivate. This should have never been public in the first place. - Made
StringSet.emptyreadonly. - Removed ignored
rangeparameter fromCharMap#entries. - Fixed some bugs in
StringSet#{equals,union}. - Removed
StringSet#{filter,map}. These methods should have never been public in the first place.
v0.12.0
Breaking changes
- Added support for the
vflag.- This significantly changes the interfaces and types around the parser.
- There are now 2 never classes
JS.UnicodeSetandJS.StringSetto represent a Unicode set with strings. - Much more.
combineTransformershas been deprecated. UseCombinedTransformerinstead.
Added
JS.parseCharSetandJS.parseUnicodeSethave been added to easily parse a character AST into aCharSetorUnicodeSet.JS.toLiteralnow supports thevflag.- Added
CharSet#fromCharacterto easily create a character set from a single character. - Allow string argument for
JS.Parser.fromLiteral. - Added
CombinedTransformerclass to combine multiple transformers into one. - Added transform events which allows the caller to observe the transformation.
- Added
Transformers.makeGreedyto make quantifiers greedy whenever possible. - Added
Transformers.simplifyas a stable way to get the best combination of transformers to simplify a regex.
Changed
- Transformers can now have an optional name.
- Major internal improvements to some transformers, especially
applyAssertions.
Fixed
isEmptyhas been fixed.Transformers.moveUpEmptyshould now work correctly.- Transformers are now guaranteed to be called with the correct
thisargument.
v0.11.0
Breaking changes
- Upgraded to
@eslint-community/regexppv4.5.0 and dropregexpp. - Drop support for NodeJS 10.
- Changed default character-set-to-string function of
{DFA,ENFA,NFA}#toDottoCharSet#toUnicodeString. - Changed character-set-to-string function of
{DFA,ENFA,NFA}#toStringtoCharSet#toUnicodeString. - Renamed
ToDotInfotoNodeInfo. - Removed
createSimpleToDotOptions.
Added
- Added
toMermaidas part of theFAIteratorsnamespace andFiniteAutomatoninterface. - Added a unified interface for the namespaced
toDotandtoMermaidfunctions. - Many DFA, ENFA, and NFA operations now take optional node factory arguments to control the number of nodes created. All operations that create nodes no take factory arguments.
{DFA,ENFA,NFA}.emptyWordwill create a new FA that makes exactly the empty word.- Added
withInitial,withGetOut, andwithIsFinalto more easily derive new FA iterators. - Added
assertions: "ignore"to JS parser,ENFA.fromRegex, andNFA.fromRegex. This is mostly for convenience and performance. The same behavior could previously be achieved using transformers. - Added
CharSet#toUnicodeStringto provide an easy way to convert a character set into a human-readable string. - Added
CharSet#isProper{Subset,Superset}Of. CharSet#equalsnow supportsCharRanges.
Fixed
- Fixed
ENFA#isEmptyfor non-normalized graphs.
Changed
{DFA,NFA}.fromCharSetand{ENFA,NFA}.allnow use constructions with fewer states.approximateRejectingWordSetwill now returnundefinedinstead of throwing an error if the input character set is empty.- Changed behavior of
ENFA#countNodesto be consistent with NFA and DFA. - Upgraded from Unicode 13.0.0 to Unicode 15.0.0.
- Generally added and improved documentation.
0.10.0
Breaking changes
CharSet: Theintersectandwithoutmethods now only takeCharSets andCharRanges as arguments.{DFA,ENFA,NFA}#{isDisjointWith,getIntersectionWords,getIntersectionWordSets}were removed.- Removed
NodeListAPI for all FA implements. This is a very significant change as to how FAs are implemented but doesn't affect the main FA APIs too much. This change gives users a lot more control over FA implements. - Removed
{DFA,ENFA,NFA}.CreationOptionsinterfaces. Use the newNodeFactoryAPI instead. - Removed
{DFA,ENFA,NFA}#options. Just pass the FA as is instead. - Removed
FACreationOptionsinterface. getIntersection{Iterator,Words,WordSets},isDisjointWith: Replaced optionalFACreationOptionsparameter with optionalmaxNodesparameter.- DFA nodes can now only be linked using
CharSets. Linking withChars andCharRanges is no longer supported. - Removed
ENFA'sunorderedResolveEpsilon. UseresolveEpsiloninstead. FAIterator.MapFABuilder: Removed optionalkindargument.
Added
NodeFactoryinterface. This new interface is the basis of allFABuilders and FA implemented.{DFA,ENFA,NFA}.nodeFactory: This is an unlimited node factory.{DFA,ENFA,NFA}.LimitedNodeFactory: This node factory can be used to limit the number of nodes an FA operation is allowed to create.CharSet#resizeCharSet.fromRangeFAIterator.fromWordswill create a new iterator from a list of words.FAIterator.fromWordSetswill create a new iterator from a list of word sets.{DFA,ENFA,NFA}.fromCharSetwill create new FAs from a givenCharSet.{DFA,ENFA,NFA}.fromWordSetswill create new FAs from a list of word sets.{DFA,ENFA,NFA}#countNodeswill return the number of nodes in the FA.{DFA,ENFA,NFA}#nodeswill iterate through all nodes in the FA.ENFA.withoutEmptyWordENFA#{append,prepend,union}Intowill move the nodes of the given ENFA instead of copying them. This can be used to improve performance.
Changed
JS.toLiteral: Settingunicode: falsein theflagsoption will now always succeed.
Improved
CharMapis now implemented using a sorted array instead of an AVL tree. This is significantly faster. Most DFA operation are now 10% faster.FAIterators.iterateWordSetswill now use the natural iteration order of the given FAIterator for words of the same length. This makesENFA#wordSetsa lot more logical.ENFA'sresolveEpsilonis now implemented non-recursively.- The docs now have a dark mode thanks to TypeDoc v0.22.0.
0.9.1
Fixed
- Fixed that some ENFA operations created unnecessary states.
- Fixed internal functions used to traverse graphs. This fixes the bug that some
FAIteratorsfunctions had trouble with falsy state values.
Improved
JS.toLiteral: The heuristic used to decide flags has been improved to prevent unnecessaryiflags.
0.9.0
Breaking changes
FAIterators.intersectionno longer accepts options.- Removed the
IntersectionOptionsinterface. Use the newFACreationOptionsinterface or any of the FA-specific interfaces instead. - Removed custom equality functions for
CharMap. - The constructor of
FAIterators.MapFABuilderchanged slightly. It now accepts arguments as parameters instead of as an object. - Some renaming:
FAIterator#deterministicOut->FAIterator#stableOutFAIterators.ensureDeterministicOut->FAIterators.ensureStableOutCharMap#{delete,set}Every->CharMap#{delete,set}Range
Added
- Added support for the new JS RegExp
hasIndicesflag. - New
WordSetandReadonlyWordSettypes. - New
CharBaseclass. This provides methods to remap alphabets. - Added
CharMap#clear. - Added
CharMap#filter. - Added
CharMap#invertto convertCharMaps toMaps. - Added
CharMap#setCharSetto more efficiently set many ranges. - Added
CharSet#charactersto iterate over all characters in a set. - Added
CharSet#toRangesStringto print only the ranges of a set. - Added
CharSet.fromCharactersto create a set from a collection of characters. FAIterators.shortestAcceptingPathreturns the shortest accepting path of arbitrary iterators.FAIterators.shortestWordSetreturns the shortest accepted word set of an iterator.FAIterators.makeInitialFinalandFAIterators.makeInitialNonFinalchanges whether the initial state is also a final state.FAIterators.approximateRejectingWordSettries to find a rejected word set.FAIterators.makeDeterministicbuilds a deterministic version of an iterator. This is a general DFA construction.Words.wordSetsToWordsconverts a collections of word sets into a collection of words.
Changed
- refa is now allowed to assume all given
Chars andCharRanges conform to the guarantees given by the interface. This includes guarantees that cannot be verified at compile time (e.g.min <= maxforCharRange). Words.pickMostReadableWordwill now always return a word.{DFA,ENFA,NFA}#{isDisjointWith,getIntersectionWords,getIntersectionWordSets}are now deprecated and will be removed in future releases.Words.wordSetToWordsis now deprecated. UseWords.wordSetsToWordsinstead (mind the s).
Fixed
ReadonlyCharMap#isEmptyis now a readonly property.- Fixed
JS.Parserincorrectly caching parsed characters. - Fixed
JS.Parserincorrectly canonicalizing Unicode property escapes. - Fixed
DFA.NodeList#removeUnreachableremoving reachable states sometimes.
Improved
- Many, many minor improvements (code quality, documentation, etc.).
- 10x faster
wordSetToWords. All methods iterating words will now be faster. - Pretty much all DFA operations will be faster. DFA minimization is up to 20x faster.
- Faster NFA creation.
0.8.0
Breaking changes
- New RE AST node:
Unknown. This node is used to represent parts of a regex that cannot be represented using RE AST. - Removed
JS.ParseOptions.disableOptimizations. UseJS.ParseOptions.simplifyinstead. - Removed
TransitionIterableFAinterface. TransitionIterableis now generic over the state type.- Renamed
{DFA,NFA}.intersectionWordSetstogetIntersectionWordSets. - Renamed
{DFA,NFA}.intersectionWordstogetIntersectionWords.
Added
- ENFA - a non-deterministic finite automaton with epsilon transitions.
- FAIterators - a new namespace containing methods can consume and produce FA iterators.
- New
toDotmethod for finite automata. This will make it easier to visualize the state machines. - New
isDisjointWith,getIntersectionWordSets, andgetIntersectionWordsfunctions. These free functions can be used with any FA types. - New
JS.ParseOptions.simplifyoption. - New
FAIterator.deterministicOutproperty. - New
TransitionIterator. (This only gives an already commonly used type a name.) - New
MaxCharacterErrorfor incompatible finite automata. - New
FABuilderinterface to allow algorithms to construct FA without knowing the actual FA implementation. {DFA,ENFA,NFA}.NodeList: Added staticwithLimitmethod to be able to limit the number of nodes aNodeListis allowed to create.
Changed
JS.Parser.parseElementnow accepts more parsable elements.JS.toLiteralnow accepts any RE AST node.NFA.fromRegexnow accepts any RE AST node.{DFA,ENFA,NFA}.NodeListnow implement theFABuilderinterface.- Many, many internal changes that do not affect the API.
Fixed
DFA.fromIntersectionnow correctly computes the intersection for non-DFA arguments.getBaseSets(a util function) now guarantees O(n*log n) run time. I accidentally implemented this in O(n^2) before which caused some DFA operations to be extremely slow.iterateWordSets(a util function) now correctly eliminates dead states. This fixes the bug that some FA with infinite languages only yielded finitely many words when iterating over them.
0.7.1
0.7.0
Breaking changes
FiniteAutomaton.testnow requires aReadonlyArrayinstead of anIterable.Words.wordSetToWordsnow returns anIterableinstead of anIterableIterator.- Removed
toPatternStringfunction. - Removed
NFA.FromRegexOptions.disableLookarounds. UseNFA.FromRegexOptions.assertionsinstead. - AST format: Quantifier nodes now have a lazy property to enable non-greedy quantifiers.
JS.Parserno longer implementsJS.Literal. Use theJS.Parser.literalproperty instead.JS.Parsernow resolves backreferences differently. It now supports resolving capturing groups with finite small languages. How small the language is required to be can be controlled via the newJS.ParseOptions.maxBackreferenceWordsoption (defaults to 100 words).JS.ParseOptions.backreferencesalso works differently now. See theJS.ParseOptionsdocumentation for more details.- Some renaming:
JS.ParseOptions.lookarounds->JS.ParseOptions.assertionsToRegexOptions.maximumNodes->ToRegexOptions.maxNodesToRegexOptions.maximumOptimizationPasses->ToRegexOptions.maxOptimizationPasses
Fixed
Words.fromStringToUTF16now works properly.JS.toLiteralwill now properly detect predefined character sets in character classes. This didn't work properly before.
Added
- Documentation. A lot of code documentation and a TypeDoc-generated website have been added.
- New
Char,Word, andReadonlyWordtypes replace the old plain number and iterable types. - AST transformers. They can efficiently modify a given AST and are used to e.g. apply assertions.
JS.ParseOptionsnow has amaxNodesoption to limit the size of the parsed AST.JS.Parsernow has amaxCharacterproperty.
Changed
NFA.testnow implements Thompson's algorithm which guarantees efficient execution.- The
toRegexmethods of the DFA and NFA classes now use AST transformers under the hood to produce smaller ASTs. - The default value of
ToRegexOptions.maxOptimizationPassesis now implementation-defined.
0.6.0
Breaking changes
DFA#clonehas been renamed toDFA#copyto be compatible withNFA#copy.- The
sourceproperty of RE AST nodes is now optional. This results in the removal/change of several types and functions. TheSimpletype has been removed; useNoParentinstead.
Added
JS.toLiteralnow has aflagsoptions to force/disallow certain flags and afastCharactersoptions for up to 10x better performance.JS.toLiteralnow detects builtin assertions.
Changed
- All DFA and NFA creation methods now have safe defaults and will throw if the FA that is being created is too large. The limit can be controlled using the
maxNodesoption.