full site update

This commit is contained in:
2025-07-24 18:46:24 +02:00
parent bfe2b90d8d
commit 37a6e0ab31
6912 changed files with 540482 additions and 361712 deletions

83
node_modules/dfa/README.md generated vendored Normal file
View File

@@ -0,0 +1,83 @@
# dfa
Compiles a regular expression like syntax to fast deterministic finite automata.
Useful for pattern matching against non-string sequences.
## Example
This 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.
Machine definition:
```coffeescript
# define symbols
X = 0; # Other character
L = 1; # Leading consonant
V = 2; # Medial vowel
T = 3; # Trailing consonant
LV = 4; # Composed <LV> syllable
LVT = 5; # Composed <LVT> syllable
M = 6; # Tone mark
# define variables
decomposed = L V T?;
partial = LV T?;
composed = LVT;
# define main state machine pattern
main = (decomposed | partial | composed) M?;
```
Visualized, the machine looks like this (double circles are accepting states):
![dfa](https://cloud.githubusercontent.com/assets/19409/19143719/8fbc6a12-8b5a-11e6-868d-99621644d094.png)
Compiling and using the machine:
```javascript
import compile from 'dfa/compile';
import fs from 'fs';
let stateMachine = compile(fs.readFileSync('hangul.machine', 'utf8'));
// find matches
for (let [startIndex, endIndex] of stateMachine.match([0, 1, 2, 3, 0, 4, 6]) {
console.log('match:', startIndex, endIndex);
}
```
Output:
```
match: 1 3
match: 5 6
```
## Syntax
A state machine file contains a list of assignment statements. Comments are also allowed
and are started with the `#` character. Each statement is an assignment of a variable name
to a value or expression. Assigning a variable to a number produces a symbol, which is
added to the state machine's alphabet. Assigning a variable to an expression allows
for substitutions into later expressions. The special `main` variable should always be
assigned to at the end of the file, and is the final expression that will be compiled.
A subset of common regular expression syntax is supported. A list of operators and their
precedence is below. Operators with the same precedence are evaluated left to right.
| Precedence | Syntax | Type | Meaning |
| ---------- | ---------- | --------------| ------------------------------------------ |
| 1 | `a \| b` | Alternation | Matches either `a` or `b` |
| 2 | `a b` | Concatenation | Matches `a` followed by `b` |
| 3 | `a*` | Repetition | Matches zero or more occurrences of `a` |
| 3 | `a+` | Repetition | Matches one ore more occurrences of `a` |
| 3 | `a?` | Optional | Matches zero or one occurrence of `a` |
| 3 | `a{n}` | Repetition | Matches exactly n occurrences of `a` |
| 3 | `a{n,}` | Repetition | Matches n or more occurrences of `a` |
| 3 | `a{,n}` | Repetition | Matches up to n occurrences of `a` |
| 3 | `a{n,m}` | Repetition | Matches n to m occurrences of `a` |
| 4 | `t:<expr>` | Tag | Tags the following expression with tag `t` |
| 5 | `(<expr>)` | Grouping | Groups an expression |
## License
MIT

1834
node_modules/dfa/compile.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/dfa/compile.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

91
node_modules/dfa/index.js generated vendored Normal file
View File

@@ -0,0 +1,91 @@
'use strict';
var INITIAL_STATE = 1;
var FAIL_STATE = 0;
/**
* A StateMachine represents a deterministic finite automaton.
* It can perform matches over a sequence of values, similar to a regular expression.
*/
class StateMachine {
constructor(dfa) {
this.stateTable = dfa.stateTable;
this.accepting = dfa.accepting;
this.tags = dfa.tags;
}
/**
* Returns an iterable object that yields pattern matches over the input sequence.
* Matches are of the form [startIndex, endIndex, tags].
*/
match(str) {
var self = this;
return {
*[Symbol.iterator]() {
var state = INITIAL_STATE;
var startRun = null;
var lastAccepting = null;
var lastState = null;
for (var p = 0; p < str.length; p++) {
var c = str[p];
lastState = state;
state = self.stateTable[state][c];
if (state === FAIL_STATE) {
// yield the last match if any
if (startRun != null && lastAccepting != null && lastAccepting >= startRun) {
yield [startRun, lastAccepting, self.tags[lastState]];
} // reset the state as if we started over from the initial state
state = self.stateTable[INITIAL_STATE][c];
startRun = null;
} // start a run if not in the failure state
if (state !== FAIL_STATE && startRun == null) {
startRun = p;
} // if accepting, mark the potential match end
if (self.accepting[state]) {
lastAccepting = p;
} // reset the state to the initial state if we get into the failure state
if (state === FAIL_STATE) {
state = INITIAL_STATE;
}
} // yield the last match if any
if (startRun != null && lastAccepting != null && lastAccepting >= startRun) {
yield [startRun, lastAccepting, self.tags[state]];
}
}
};
}
/**
* For each match over the input sequence, action functions matching
* the tag definitions in the input pattern are called with the startIndex,
* endIndex, and sub-match sequence.
*/
apply(str, actions) {
for (var [start, end, tags] of this.match(str)) {
for (var tag of tags) {
if (typeof actions[tag] === 'function') {
actions[tag](start, end, str.slice(start, end + 1));
}
}
}
}
}
module.exports = StateMachine;
//# sourceMappingURL=index.js.map

1
node_modules/dfa/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["src/StateMachine.js"],"sourcesContent":["const INITIAL_STATE = 1;\nconst FAIL_STATE = 0;\n\n/**\n * A StateMachine represents a deterministic finite automaton.\n * It can perform matches over a sequence of values, similar to a regular expression.\n */\nexport default class StateMachine {\n constructor(dfa) {\n this.stateTable = dfa.stateTable;\n this.accepting = dfa.accepting;\n this.tags = dfa.tags;\n }\n\n /**\n * Returns an iterable object that yields pattern matches over the input sequence.\n * Matches are of the form [startIndex, endIndex, tags].\n */\n match(str) {\n let self = this;\n return {\n *[Symbol.iterator]() {\n let state = INITIAL_STATE;\n let startRun = null;\n let lastAccepting = null;\n let lastState = null;\n\n for (let p = 0; p < str.length; p++) {\n let c = str[p];\n\n lastState = state;\n state = self.stateTable[state][c];\n\n if (state === FAIL_STATE) {\n // yield the last match if any\n if (startRun != null && lastAccepting != null && lastAccepting >= startRun) {\n yield [startRun, lastAccepting, self.tags[lastState]];\n }\n\n // reset the state as if we started over from the initial state\n state = self.stateTable[INITIAL_STATE][c];\n startRun = null;\n }\n\n // start a run if not in the failure state\n if (state !== FAIL_STATE && startRun == null) {\n startRun = p;\n }\n\n // if accepting, mark the potential match end\n if (self.accepting[state]) {\n lastAccepting = p;\n }\n\n // reset the state to the initial state if we get into the failure state\n if (state === FAIL_STATE) {\n state = INITIAL_STATE;\n }\n }\n\n // yield the last match if any\n if (startRun != null && lastAccepting != null && lastAccepting >= startRun) {\n yield [startRun, lastAccepting, self.tags[state]];\n }\n }\n };\n }\n\n /**\n * For each match over the input sequence, action functions matching\n * the tag definitions in the input pattern are called with the startIndex,\n * endIndex, and sub-match sequence.\n */\n apply(str, actions) {\n for (let [start, end, tags] of this.match(str)) {\n for (let tag of tags) {\n if (typeof actions[tag] === 'function') {\n actions[tag](start, end, str.slice(start, end + 1));\n }\n }\n }\n }\n}\n"],"names":["INITIAL_STATE","FAIL_STATE","StateMachine","constructor","dfa","stateTable","accepting","tags","match","str","self","Symbol","iterator","state","startRun","lastAccepting","lastState","p","length","c","apply","actions","start","end","tag","slice"],"mappings":";;AAAA,IAAMA,aAAa,GAAG,CAAtB;AACA,IAAMC,UAAU,GAAG,CAAnB;;;;;;AAMA,AAAe,MAAMC,YAAN,CAAmB;EAChCC,WAAW,CAACC,GAAD,EAAM;SACVC,UAAL,GAAkBD,GAAG,CAACC,UAAtB;SACKC,SAAL,GAAiBF,GAAG,CAACE,SAArB;SACKC,IAAL,GAAYH,GAAG,CAACG,IAAhB;;;;;;;;EAOFC,KAAK,CAACC,GAAD,EAAM;QACLC,IAAI,GAAG,IAAX;WACO;QACHC,MAAM,CAACC,QAAT,IAAqB;YACfC,KAAK,GAAGb,aAAZ;YACIc,QAAQ,GAAG,IAAf;YACIC,aAAa,GAAG,IAApB;YACIC,SAAS,GAAG,IAAhB;;aAEK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGR,GAAG,CAACS,MAAxB,EAAgCD,CAAC,EAAjC,EAAqC;cAC/BE,CAAC,GAAGV,GAAG,CAACQ,CAAD,CAAX;UAEAD,SAAS,GAAGH,KAAZ;UACAA,KAAK,GAAGH,IAAI,CAACL,UAAL,CAAgBQ,KAAhB,EAAuBM,CAAvB,CAAR;;cAEIN,KAAK,KAAKZ,UAAd,EAA0B;;gBAEpBa,QAAQ,IAAI,IAAZ,IAAoBC,aAAa,IAAI,IAArC,IAA6CA,aAAa,IAAID,QAAlE,EAA4E;oBACpE,CAACA,QAAD,EAAWC,aAAX,EAA0BL,IAAI,CAACH,IAAL,CAAUS,SAAV,CAA1B,CAAN;aAHsB;;;YAOxBH,KAAK,GAAGH,IAAI,CAACL,UAAL,CAAgBL,aAAhB,EAA+BmB,CAA/B,CAAR;YACAL,QAAQ,GAAG,IAAX;WAdiC;;;cAkB/BD,KAAK,KAAKZ,UAAV,IAAwBa,QAAQ,IAAI,IAAxC,EAA8C;YAC5CA,QAAQ,GAAGG,CAAX;WAnBiC;;;cAuB/BP,IAAI,CAACJ,SAAL,CAAeO,KAAf,CAAJ,EAA2B;YACzBE,aAAa,GAAGE,CAAhB;WAxBiC;;;cA4B/BJ,KAAK,KAAKZ,UAAd,EAA0B;YACxBY,KAAK,GAAGb,aAAR;;SAnCe;;;YAwCfc,QAAQ,IAAI,IAAZ,IAAoBC,aAAa,IAAI,IAArC,IAA6CA,aAAa,IAAID,QAAlE,EAA4E;gBACpE,CAACA,QAAD,EAAWC,aAAX,EAA0BL,IAAI,CAACH,IAAL,CAAUM,KAAV,CAA1B,CAAN;;;;KA1CN;;;;;;;;;EAqDFO,KAAK,CAACX,GAAD,EAAMY,OAAN,EAAe;SACb,IAAI,CAACC,KAAD,EAAQC,GAAR,EAAahB,IAAb,CAAT,IAA+B,KAAKC,KAAL,CAAWC,GAAX,CAA/B,EAAgD;WACzC,IAAIe,GAAT,IAAgBjB,IAAhB,EAAsB;YAChB,OAAOc,OAAO,CAACG,GAAD,CAAd,KAAwB,UAA5B,EAAwC;UACtCH,OAAO,CAACG,GAAD,CAAP,CAAaF,KAAb,EAAoBC,GAApB,EAAyBd,GAAG,CAACgB,KAAJ,CAAUH,KAAV,EAAiBC,GAAG,GAAG,CAAvB,CAAzB;;;;;;;;;;"}

42
node_modules/dfa/package.json generated vendored Normal file
View File

@@ -0,0 +1,42 @@
{
"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": "Devon Govett <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"
]
}