{"_id":"dfa","_rev":"3551641","name":"dfa","description":"A state machine compiler","dist-tags":{"latest":"1.2.0"},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"time":{"modified":"2024-09-19T02:43:36.000Z","created":"2014-07-01T03:26:19.938Z","1.2.0":"2019-06-17T01:49:58.424Z","1.1.0":"2017-05-12T05:24:29.948Z","1.0.0":"2016-10-12T03:50:48.528Z","0.0.0":"2014-07-01T03:26:19.938Z"},"users":{},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/devongovett/dfa.git"},"versions":{"1.2.0":{"name":"dfa","version":"1.2.0","description":"A state machine compiler","main":"index.js","devDependencies":{"@babel/core":"^7.0.0","@babel/preset-env":"^7.0.0","@babel/register":"^7.0.0","mocha":"^3.1.0","pegjs":"^0.10.0","rollup":"^1.5.0","rollup-plugin-babel":"^4.0.1","rollup-plugin-commonjs":"^9.2.1","rollup-plugin-local-resolve":"^1.0.7"},"scripts":{"test":"mocha --require @babel/register","prepublish":"make"},"repository":{"type":"git","url":"git+ssh://git@github.com/devongovett/dfa.git"},"keywords":["state","machine","compiler"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/dfa/issues"},"homepage":"https://github.com/devongovett/dfa#readme","gitHead":"3f5e603e5082caedabefefdf53e8a6ca3111e966","_id":"dfa@1.2.0","_nodeVersion":"12.0.0","_npmVersion":"6.9.0","dist":{"shasum":"96ac3204e2d29c49ea5b57af8d92c2ae12790657","size":29338,"noattachment":false,"key":"/dfa/-/dfa-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/dfa/download/dfa-1.2.0.tgz"},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dfa_1.2.0_1560736198275_0.15129651032467462"},"_hasShrinkwrap":false,"publish_time":1560736198424,"_cnpm_publish_time":1560736198424,"_cnpmcore_publish_time":"2021-12-16T14:47:18.635Z"},"1.1.0":{"name":"dfa","version":"1.1.0","description":"A state machine compiler","main":"index.js","dependencies":{"babel-runtime":"^6.11.6"},"devDependencies":{"babel-core":"^6.17.0","babel-plugin-transform-runtime":"^6.15.0","babel-polyfill":"^6.16.0","babel-preset-es2015":"^6.16.0","babel-register":"^6.16.3","mocha":"^3.1.0","pegjs":"^0.10.0","rollup":"^0.36.1","rollup-plugin-babel":"^2.6.1","rollup-plugin-commonjs":"^5.0.4","rollup-plugin-local-resolve":"^1.0.7"},"scripts":{"test":"mocha --require babel-register --require babel-polyfill","prepublish":"make"},"repository":{"type":"git","url":"git+ssh://git@github.com/devongovett/dfa.git"},"keywords":["state","machine","compiler"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/dfa/issues"},"homepage":"https://github.com/devongovett/dfa#readme","files":["index.js","index.js.map","compile.js","compile.js.map"],"gitHead":"549990f9903e88cb09d2d93359113cf1f556da77","_id":"dfa@1.1.0","_shasum":"d30218bd10d030fa421df3ebbc82285463a31781","_from":".","_npmVersion":"3.10.9","_nodeVersion":"6.9.2","_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"dist":{"shasum":"d30218bd10d030fa421df3ebbc82285463a31781","size":31303,"noattachment":false,"key":"/dfa/-/dfa-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/dfa/download/dfa-1.1.0.tgz"},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/dfa-1.1.0.tgz_1494566669667_0.5800026464276016"},"directories":{},"publish_time":1494566669948,"_hasShrinkwrap":false,"_cnpm_publish_time":1494566669948,"_cnpmcore_publish_time":"2021-12-16T14:47:18.863Z"},"1.0.0":{"name":"dfa","version":"1.0.0","description":"A state machine compiler","main":"index.js","dependencies":{"babel-runtime":"^6.11.6"},"devDependencies":{"babel-core":"^6.17.0","babel-plugin-transform-runtime":"^6.15.0","babel-polyfill":"^6.16.0","babel-preset-es2015":"^6.16.0","babel-register":"^6.16.3","mocha":"^3.1.0","pegjs":"^0.10.0","rollup":"^0.36.1","rollup-plugin-babel":"^2.6.1","rollup-plugin-commonjs":"^5.0.4","rollup-plugin-local-resolve":"^1.0.7"},"scripts":{"test":"mocha --require babel-register --require babel-polyfill","prepublish":"make"},"repository":{"type":"git","url":"git+ssh://git@github.com/devongovett/dfa.git"},"keywords":["state","machine","compiler"],"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/dfa/issues"},"homepage":"https://github.com/devongovett/dfa#readme","files":["index.js","index.js.map","compile.js","compile.js.map"],"gitHead":"ebec316da8370c4a39c4ab2e5febf50387a77418","_id":"dfa@1.0.0","_shasum":"1e8665a345f967bee13a8850f40592ec4fe447df","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"dist":{"shasum":"1e8665a345f967bee13a8850f40592ec4fe447df","size":26112,"noattachment":false,"key":"/dfa/-/dfa-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/dfa/download/dfa-1.0.0.tgz"},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/dfa-1.0.0.tgz_1476244247858_0.509749905904755"},"directories":{},"publish_time":1476244248528,"_hasShrinkwrap":false,"_cnpm_publish_time":1476244248528,"_cnpmcore_publish_time":"2021-12-16T14:47:19.055Z"},"0.0.0":{"name":"dfa","version":"0.0.0","description":"Deterministic Finite Automata","main":"index.js","scripts":{"test":"node test"},"repository":{"type":"git","url":"https://github.com/ben-ng/dfa.git"},"keywords":["finite","automata"],"author":{"name":"Ben Ng","email":"me@benng.me"},"license":"MIT","bugs":{"url":"https://github.com/ben-ng/dfa/issues"},"homepage":"https://github.com/ben-ng/dfa","_id":"dfa@0.0.0","_shasum":"bc92ff7fe4ed796ae78d3653c546dae15f63dc39","_from":".","_npmVersion":"1.4.18","_npmUser":{"name":"benng","email":"me@benng.me"},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"dist":{"shasum":"bc92ff7fe4ed796ae78d3653c546dae15f63dc39","size":347,"noattachment":false,"key":"/dfa/-/dfa-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/dfa/download/dfa-0.0.0.tgz"},"directories":{},"publish_time":1404185179938,"_hasShrinkwrap":false,"_cnpm_publish_time":1404185179938,"_cnpmcore_publish_time":"2021-12-16T14:47:19.246Z"}},"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","_attachments":{},"homepage":"https://github.com/devongovett/dfa#readme","bugs":{"url":"https://github.com/devongovett/dfa/issues"},"license":"MIT"}