{"_id":"dfa","_rev":"14-115c4fbff0a87321f422bfefc0df2080","name":"dfa","dist-tags":{"latest":"2.0.0"},"versions":{"0.0.0":{"name":"dfa","version":"0.0.0","keywords":["finite","automata"],"author":{"name":"Ben Ng","email":"me@benng.me"},"license":"MIT","_id":"dfa@0.0.0","maintainers":[{"name":"benng","email":"me@benng.me"}],"homepage":"https://github.com/ben-ng/dfa","bugs":{"url":"https://github.com/ben-ng/dfa/issues"},"dist":{"shasum":"bc92ff7fe4ed796ae78d3653c546dae15f63dc39","tarball":"https://registry.npmjs.org/dfa/-/dfa-0.0.0.tgz","integrity":"sha512-yChttqIjFp5weQlcKe/Aad53suQq/Tq9glVV2ljSIOGHzSzjSUXwe1U0plDdHoN/3JOWESZmTfngwF6oijZfDw==","signatures":[{"sig":"MEQCIEtapi+9fnZNPBlwgTGb9mwLVAVZ+2cqFxZN4Sfp1/ywAiAejkQmJ6AmL6QqkdYZ4cCB6TvFhPlFeBqeCtuKMOpVbw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"bc92ff7fe4ed796ae78d3653c546dae15f63dc39","scripts":{"test":"node test"},"_npmUser":{"name":"benng","email":"me@benng.me"},"repository":{"url":"https://github.com/ben-ng/dfa.git","type":"git"},"_npmVersion":"1.4.18","description":"Deterministic Finite Automata","directories":{}},"1.0.0":{"name":"dfa","version":"1.0.0","keywords":["state","machine","compiler"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","_id":"dfa@1.0.0","maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"homepage":"https://github.com/devongovett/dfa#readme","bugs":{"url":"https://github.com/devongovett/dfa/issues"},"dist":{"shasum":"1e8665a345f967bee13a8850f40592ec4fe447df","tarball":"https://registry.npmjs.org/dfa/-/dfa-1.0.0.tgz","integrity":"sha512-SFrynaraPi0kMH6PnXaYxDIr4ELL1ar/G5EUfVUsiDqPpdf7+1bUBEBFPXG/oBrIxmdi6CpmssHcBmtX3gwEaw==","signatures":[{"sig":"MEYCIQDUcbrzBZM6l/xP4oIbqr2N+BvqSjT+7xCHcrT4YTy1TgIhAP9jMReg34mUp+3uRDgwIPrgWOoee8xEGKytUYB9AYRg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","files":["index.js","index.js.map","compile.js","compile.js.map"],"_shasum":"1e8665a345f967bee13a8850f40592ec4fe447df","gitHead":"ebec316da8370c4a39c4ab2e5febf50387a77418","scripts":{"test":"mocha --require babel-register --require babel-polyfill","prepublish":"make"},"_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"repository":{"url":"git+ssh://git@github.com/devongovett/dfa.git","type":"git"},"_npmVersion":"3.9.5","description":"A state machine compiler","directories":{},"_nodeVersion":"6.2.2","dependencies":{"babel-runtime":"^6.11.6"},"devDependencies":{"mocha":"^3.1.0","pegjs":"^0.10.0","rollup":"^0.36.1","babel-core":"^6.17.0","babel-polyfill":"^6.16.0","babel-register":"^6.16.3","babel-preset-es2015":"^6.16.0","rollup-plugin-babel":"^2.6.1","rollup-plugin-commonjs":"^5.0.4","rollup-plugin-local-resolve":"^1.0.7","babel-plugin-transform-runtime":"^6.15.0"},"_npmOperationalInternal":{"tmp":"tmp/dfa-1.0.0.tgz_1476244247858_0.509749905904755","host":"packages-16-east.internal.npmjs.com"}},"1.1.0":{"name":"dfa","version":"1.1.0","keywords":["state","machine","compiler"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","_id":"dfa@1.1.0","maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"homepage":"https://github.com/devongovett/dfa#readme","bugs":{"url":"https://github.com/devongovett/dfa/issues"},"dist":{"shasum":"d30218bd10d030fa421df3ebbc82285463a31781","tarball":"https://registry.npmjs.org/dfa/-/dfa-1.1.0.tgz","integrity":"sha512-P8AJYW6FNxAogQAu5evzX1gSDAsLiE1vEs0eqyWPS1pQjS8OcWDghBcKjEIysZ37Oh0wS88pgcWbDByCBzVBCQ==","signatures":[{"sig":"MEUCIQDsc/eBvQHhyAOGmsw5beQIWP+xIJjPTQieqfrQhr0iCQIgedsQKpbDRCX3gUnIaXxMoDQCTlXjmdHg5mYHNZkiizo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","files":["index.js","index.js.map","compile.js","compile.js.map"],"_shasum":"d30218bd10d030fa421df3ebbc82285463a31781","gitHead":"549990f9903e88cb09d2d93359113cf1f556da77","scripts":{"test":"mocha --require babel-register --require babel-polyfill","prepublish":"make"},"_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"repository":{"url":"git+ssh://git@github.com/devongovett/dfa.git","type":"git"},"_npmVersion":"3.10.9","description":"A state machine compiler","directories":{},"_nodeVersion":"6.9.2","dependencies":{"babel-runtime":"^6.11.6"},"devDependencies":{"mocha":"^3.1.0","pegjs":"^0.10.0","rollup":"^0.36.1","babel-core":"^6.17.0","babel-polyfill":"^6.16.0","babel-register":"^6.16.3","babel-preset-es2015":"^6.16.0","rollup-plugin-babel":"^2.6.1","rollup-plugin-commonjs":"^5.0.4","rollup-plugin-local-resolve":"^1.0.7","babel-plugin-transform-runtime":"^6.15.0"},"_npmOperationalInternal":{"tmp":"tmp/dfa-1.1.0.tgz_1494566669667_0.5800026464276016","host":"packages-12-west.internal.npmjs.com"}},"1.2.0":{"name":"dfa","version":"1.2.0","keywords":["state","machine","compiler"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","_id":"dfa@1.2.0","maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"homepage":"https://github.com/devongovett/dfa#readme","bugs":{"url":"https://github.com/devongovett/dfa/issues"},"dist":{"shasum":"96ac3204e2d29c49ea5b57af8d92c2ae12790657","tarball":"https://registry.npmjs.org/dfa/-/dfa-1.2.0.tgz","fileCount":6,"integrity":"sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q==","signatures":[{"sig":"MEUCIQDiUCBfhWBk0/nH846qibtXSviV3c4q7zYwpbyatOezgAIgCel943di30Oy/W4ciR/g2DL/1e8rHzHdOqSZUV0WWMo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137726,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdBvHHCRA9TVsSAnZWagAA3TsP+gJxBBaJpBEkzPko4v2r\nCymaJHmr1xAUePGaaSotnXgjzR4H6SRlob1vxk8gRwccs68XiU71wChXqixG\n2DCQ/cKtOxJmjL1GHbDdpwui2pvQKv2gmeL3O4XZBeKybHQGyUzAlAQuP6Oz\nCZEb2CLBBz81Cea7NIS9JaOgK1mbjd3P462htFLoaCr0AAS+3OXAhDJKEcXD\nnLZ4wgxrWhpV0MNLU4sCcA6gH4KAP5LKOiPnJbRxZmmroXIVqpCzf6KIUYFU\nlttYMLfhICDbMRq09d2Yoi4ARtXQgKMVnsICcR6p0LXPzZiwSnGywntv/uwl\nQttGwjtobjIv4rmFHfk3mF+DgJEHPu1CaaA762hnnLoea18lw68rTvLqdR+U\n3gQrommxFfn8ABpxwjRRf3Bqp7xuVB5W3yNJn/lvVQ1GbwFtEF0CWRkT4SKA\ne74et90vCqTCUcTGLxU6CYL72YE1glnpkErEqnE1f172bYyoOgNxCa+khUAU\nF3xXkmunRNx9GECOTsQrCo8sykvVgr+hVjDmu368Ykd9pCvV41JPmdMdQAlr\n0uJ5Ja0unlBCuQmxUy+J+CtSp/drl9K9IvydX+hq33jJ6TL1t4smLsWnKT47\nXJnd4y+fiF1rKew3czTvfWCbFRCDDHIvmjIqyzHEbZhV87o69dsBw+5ZN4mR\nKNKQ\r\n=ktlT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","gitHead":"3f5e603e5082caedabefefdf53e8a6ca3111e966","scripts":{"test":"mocha --require @babel/register","prepublish":"make"},"_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"repository":{"url":"git+ssh://git@github.com/devongovett/dfa.git","type":"git"},"_npmVersion":"6.9.0","description":"A state machine compiler","directories":{},"_nodeVersion":"12.0.0","_hasShrinkwrap":false,"devDependencies":{"mocha":"^3.1.0","pegjs":"^0.10.0","rollup":"^1.5.0","@babel/core":"^7.0.0","@babel/register":"^7.0.0","@babel/preset-env":"^7.0.0","rollup-plugin-babel":"^4.0.1","rollup-plugin-commonjs":"^9.2.1","rollup-plugin-local-resolve":"^1.0.7"},"_npmOperationalInternal":{"tmp":"tmp/dfa_1.2.0_1560736198275_0.15129651032467462","host":"s3://npm-registry-packages"}},"2.0.0":{"_id":"dfa@2.0.0","bugs":{"url":"https://github.com/devongovett/dfa/issues"},"dist":{"shasum":"42cad47b92e68cfce7958985fae349daaf024f19","tarball":"https://registry.npmjs.org/dfa/-/dfa-2.0.0.tgz","fileCount":6,"integrity":"sha512-4Z/ig4JY/6CyXaPvkjuJu7q5+6SikugixA/1wf/52A9Z+WOJr8NFKd60pv6KCwsdVdDmCCE3JrGwPFYxNcw8xw==","signatures":[{"sig":"MEUCIQDuiyu/I66oZ3O92qr3H6CfrUA0neQYamPZPGZPtN9c6QIgY+0dDl02cBv8/xtsBkjPrINl4h4Fhe/BkmNsZEzZ0us=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGbqiiRAL4sX3iORmA7oAdnqIUJWwEGnsGLI+gwEtbORAiEAoejRy+LXUdNSKdOttbTH49YXFBYnwIKnmTDQaa0kz2o="}],"unpackedSize":141658},"name":"dfa","type":"module","author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"exports":{".":"./dist/index.js","./compile":"./dist/compile.js","./compile.js":"./dist/compile.js"},"gitHead":"0205982a2a4fff76a43ca0b678460925b409e1e9","license":"MIT","scripts":{"test":"mocha","build":"npm run build:grammar && npm run build:index && npm run build:compile","clean":"rm -f dist/index.js dist/index.js.map dist/compile.js dist/compile.js.map src/grammar.js","prepublish":"npm run build","build:index":"rollup -c -m -i src/StateMachine.js -o dist/index.js","build:compile":"rollup -c -m -i src/compile.js -o dist/compile.js","build:grammar":"pegjs src/grammar.peg"},"version":"2.0.0","_npmUser":{"name":"blikblum-dev","email":"camara_luiz@yahoo.com.br"},"homepage":"https://github.com/devongovett/dfa#readme","keywords":["state","machine","compiler"],"repository":{"url":"git+ssh://git@github.com/devongovett/dfa.git","type":"git"},"_npmVersion":"11.6.2","description":"A state machine compiler","directories":{},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"blikblum-dev","email":"camara_luiz@yahoo.com.br"}],"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"devDependencies":{"mocha":"^12.0.3","pegjs":"^0.10.0","rollup":"^4.65.0","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-local-resolve":"^1.0.7"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dfa_2.0.0_1792886509957_0.08094434053543398"}}},"time":{"created":"2014-07-01T03:26:19.938Z","modified":"2026-10-25T00:01:50.265Z","0.0.0":"2014-07-01T03:26:19.938Z","1.0.0":"2016-10-12T03:50:48.528Z","1.1.0":"2017-05-12T05:24:29.948Z","1.2.0":"2019-06-17T01:49:58.424Z","2.0.0":"2026-10-25T00:01:50.050Z"},"bugs":{"url":"https://github.com/devongovett/dfa/issues"},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","homepage":"https://github.com/devongovett/dfa#readme","keywords":["state","machine","compiler"],"repository":{"url":"git+ssh://git@github.com/devongovett/dfa.git","type":"git"},"description":"A state machine compiler","maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"blikblum-dev","email":"camara_luiz@yahoo.com.br"}],"readme":"# dfa\n\nCompiles a regular expression like syntax to fast deterministic finite automata.\nUseful for pattern matching against non-string sequences.\n\n## Example\n\nThis example matches [Hangul](https://en.wikipedia.org/wiki/Hangul) syllables. The symbols defined in the machine are Unicode character categories which could be mapped from code points.\n\nMachine definition:\n\n```coffeescript\n# define symbols\nX   = 0; # Other character\nL   = 1; # Leading consonant\nV   = 2; # Medial vowel\nT   = 3; # Trailing consonant\nLV  = 4; # Composed <LV> syllable\nLVT = 5; # Composed <LVT> syllable\nM   = 6; # Tone mark\n\n# define variables\ndecomposed = L V T?;\npartial = LV T?;\ncomposed = LVT;\n\n# define main state machine pattern\nmain = (decomposed | partial | composed) M?;\n```\n\nVisualized, the machine looks like this (double circles are accepting states):\n\n![dfa](https://cloud.githubusercontent.com/assets/19409/19143719/8fbc6a12-8b5a-11e6-868d-99621644d094.png)\n\nCompiling and using the machine:\n\n```javascript\nimport { compile } from 'dfa/compile';\nimport fs from 'fs';\n\nlet stateMachine = compile(fs.readFileSync('hangul.machine', 'utf8'));\n\n// find matches\nfor (let [startIndex, endIndex] of stateMachine.match([0, 1, 2, 3, 0, 4, 6]) {\n  console.log('match:', startIndex, endIndex);\n}\n```\n\nOutput:\n```\nmatch: 1 3\nmatch: 5 6\n```\n\n## Syntax\n\nA state machine file contains a list of assignment statements. Comments are also allowed\nand are started with the `#` character. Each statement is an assignment of a variable name\nto a value or expression. Assigning a variable to a number produces a symbol, which is\nadded to the state machine's alphabet. Assigning a variable to an expression allows\nfor substitutions into later expressions. The special `main` variable should always be\nassigned to at the end of the file, and is the final expression that will be compiled.\n\nA subset of common regular expression syntax is supported. A list of operators and their\nprecedence is below. Operators with the same precedence are evaluated left to right.\n\n| Precedence | Syntax     | Type          | Meaning                                    |\n| ---------- | ---------- | --------------| ------------------------------------------ |\n| 1          | `a \\| b`   | Alternation   | Matches either `a` or `b`                  |\n| 2          | `a b`      | Concatenation | Matches `a` followed by `b`                |\n| 3          | `a*`       | Repetition    | Matches zero or more occurrences of `a`    |\n| 3          | `a+`       | Repetition    | Matches one ore more occurrences of `a`    |\n| 3          | `a?`       | Optional      | Matches zero or one occurrence of `a`      |\n| 3          | `a{n}`     | Repetition    | Matches exactly n occurrences of `a`       |\n| 3          | `a{n,}`    | Repetition    | Matches n or more occurrences of `a`       |\n| 3          | `a{,n}`    | Repetition    | Matches up to n occurrences of `a`         |\n| 3          | `a{n,m}`   | Repetition    | Matches n to m occurrences of `a`          |\n| 4          | `t:<expr>` | Tag           | Tags the following expression with tag `t` |\n| 5          | `(<expr>)` | Grouping      | Groups an expression                       |\n\n## License\n\nMIT\n","readmeFilename":"README.md"}