{
  "_id": "dfa",
  "maintainers": [
    {
      "name": "devongovett",
      "email": "devongovett@gmail.com"
    }
  ],
  "keywords": [
    "state",
    "machine",
    "compiler"
  ],
  "dist-tags": {
    "latest": "1.2.0"
  },
  "author": {
    "name": "Devon Govett",
    "email": "devongovett@gmail.com"
  },
  "_rev": "11-afbf89ee75d99441de76ee8c74bb2cae",
  "description": "A state machine compiler",
  "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",
  "repository": {
    "type": "git",
    "url": "git+ssh://git@github.com/devongovett/dfa.git"
  },
  "bugs": {
    "url": "https://github.com/devongovett/dfa/issues"
  },
  "license": "MIT",
  "versions": {
    "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": "benng",
          "email": "me@benng.me"
        }
      ],
      "dist": {
        "shasum": "bc92ff7fe4ed796ae78d3653c546dae15f63dc39",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/dfa/-/dfa-0.0.0.tgz",
        "integrity": "sha512-yChttqIjFp5weQlcKe/Aad53suQq/Tq9glVV2ljSIOGHzSzjSUXwe1U0plDdHoN/3JOWESZmTfngwF6oijZfDw==",
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEQCIEtapi+9fnZNPBlwgTGb9mwLVAVZ+2cqFxZN4Sfp1/ywAiAejkQmJ6AmL6QqkdYZ4cCB6TvFhPlFeBqeCtuKMOpVbw=="
          }
        ]
      },
      "directories": {}
    },
    "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",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/dfa/-/dfa-1.0.0.tgz",
        "integrity": "sha512-SFrynaraPi0kMH6PnXaYxDIr4ELL1ar/G5EUfVUsiDqPpdf7+1bUBEBFPXG/oBrIxmdi6CpmssHcBmtX3gwEaw==",
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEYCIQDUcbrzBZM6l/xP4oIbqr2N+BvqSjT+7xCHcrT4YTy1TgIhAP9jMReg34mUp+3uRDgwIPrgWOoee8xEGKytUYB9AYRg"
          }
        ]
      },
      "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": {}
    },
    "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",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/dfa/-/dfa-1.1.0.tgz",
        "integrity": "sha512-P8AJYW6FNxAogQAu5evzX1gSDAsLiE1vEs0eqyWPS1pQjS8OcWDghBcKjEIysZ37Oh0wS88pgcWbDByCBzVBCQ==",
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEUCIQDsc/eBvQHhyAOGmsw5beQIWP+xIJjPTQieqfrQhr0iCQIgedsQKpbDRCX3gUnIaXxMoDQCTlXjmdHg5mYHNZkiizo="
          }
        ]
      },
      "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": {}
    },
    "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": {
        "integrity": "sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q==",
        "shasum": "96ac3204e2d29c49ea5b57af8d92c2ae12790657",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/dfa/-/dfa-1.2.0.tgz",
        "fileCount": 6,
        "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",
        "signatures": [
          {
            "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
            "sig": "MEUCIQDiUCBfhWBk0/nH846qibtXSviV3c4q7zYwpbyatOezgAIgCel943di30Oy/W4ciR/g2DL/1e8rHzHdOqSZUV0WWMo="
          }
        ]
      },
      "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
    }
  },
  "name": "dfa",
  "time": {
    "modified": "2026-05-20T19:28:00.664Z",
    "created": "2014-07-01T03:26:19.938Z",
    "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"
  },
  "readmeFilename": "README.md",
  "homepage": "https://github.com/devongovett/dfa#readme"
}