Skip to content

Commit 2c57130

Browse files
committed
Change attribute format from JSON to custom format, use integers instead of UUIDs
1 parent 41b8f49 commit 2c57130

File tree

18 files changed

+1149
-910
lines changed

18 files changed

+1149
-910
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Automaton (`@webwriter/automaton@2.1.0`)
2-
[License: MIT](LICENSE) | Version: 2.1.0
1+
# Automaton (`@webwriter/automaton@2.1.1`)
2+
[License: MIT](LICENSE) | Version: 2.1.1
33

44
Build, visualize, and interact with different kinds of automata (DFA, NFA, PDA).
55

@@ -45,21 +45,21 @@ npm install @webwriter/automaton
4545
## Fields
4646
| Name (Attribute Name) | Type | Description | Default | Reflects |
4747
| :-------------------: | :--: | :---------: | :-----: | :------: |
48-
| `nodes` (`nodes`) | `Node[]` | The nodes representing the states of the automaton. | `[]` ||
49-
| `transitions` (`transitions`) | `Transition[]` | The transitions of the automaton. | `[]` ||
50-
| `type` (`type`) | `AutomatonType` | The type of the automaton. Can be `'dfa'`, `'nfa'`, or `'pda'`. | `'dfa'` ||
51-
| `mode` (`mode`) | `'edit' \| 'simulate'` | The current mode. Can be `'edit'`, or `'simulate'`. | `'edit'` ||
52-
| `testLanguage` (`testLanguage`) | `string` | A regular expression to check the language of the automaton against. | `''` ||
53-
| `forcedAlphabet` (`forcedAlphabet`) | `string[]` | The alphabet that the automaton is forced to use. | `[]` ||
54-
| `testWords` (`testWords`) | `string[]` | Words used for automatically testing the automaton. | `[]` ||
48+
| `nodes` (`nodes`) | `Node[]` | Each automaton state is encoded as a string using the following format:<br>`[#][%]<id>[<label>](<x>\|<y>)`<br><br>Regex:<br>`^(#)?(%)?(\d+)(?:\[([^\]]*(?:\\.[^\]]*)*)\])?\((-?\d+)\\|(-?\d+)\)$`<br><br>Explanation:<br>`#`: Optional - marks the initial state.<br>`%`: Optional - marks the final (accepting) state.<br>`<id>`: Required non-negative integer - unique state ID.<br>`[<label>]`: Optional - URI-encoded label. Defaults to `q<id>` if omitted.<br>`(<x>\|<y>)`: Required coordinates - signed integers representing the node's position.<br><br>Multiple nodes are separated by semicolons (`;`). Example:<br>`#0(-150\|0);%1[accept](0\|0);2[sink](150\|0)`<br><br>Requirements:<br>Coordinates are mandatory, and there must be at least 150 units of distance between any two nodes.<br>In the case of DFAs, an explicit sink state must be explicitly defined if needed. It should be non-final and have self-loops on all inputs. | `[]` ||
49+
| `transitions` (`transitions`) | `Transition[]` | Each automaton transition is encoded as:<br>`<from>-<to>[<symbolsOrStackOps>][~<roundness>][@<angle>]`<br>Multiple transitions are separated by semicolons (`;`).<br><br>Regex:<br>`^(?:;\d+-\d+(?:\[(?:[^,\{\]\\|]+(?:,[^,\{\]\\|]+)*\|[^,\{\]\\|]*\{(?:p\|o\|e\|n)\\|[^,\{\]\\|]*\\|[^,\{\]\\|]*\}(?:,[^,\{\]\\|]*\{(?:p\|o\|e\|n)\\|[^,\{\]\\|]*\\|[^,\{\]\\|]*\})*)\])?(?:~(-?)(\d+(?:\.\d+)?))?(?:@(-?\d+))?)*$`<br><br>Explanation:<br>`<from>-<to>`: Required - origin and destination state IDs (non-negative integers).<br>`[<symbolsOrStackOps>]`: Required - DFA or NFA -> Symbols only: one or more URI-encoded symbols, separated by commas. PDA -> Stack operations: <symbol>{<op>\|<stackSymbol>\|<condition>}, with <op> one of: p (push), o (pop), e (empty check), or n (no-op); <stackSymbol> being the optional symbol to push or pop, and <condition> being an optional symbol the stack must have on top.<br>`~<roundness>`: Optional - curvature of the arc, negative sign means counter-clockwise. 0.2 is recommended if there is a circle between two states.<br>`@<angle>`: Optional - integer degrees for self-loop placement. Defaults to 45°.<br><br>Multiple transitions must be separated by semicolons, no trailing `;`.<br><br>Examples:<br>`0-1[a]`<br>`1-2[a,b]~0.5`<br>`2-2[a{p\|X\|},b{o\|\|}]@45;0-1[c]~1.2` | `[]` | ✓ |
50+
| `type` (`type`) | `AutomatonType` | The type of the automaton. Can be `'dfa'`, `'nfa'`, or `'pda'`. | `"dfa"` ||
51+
| `mode` (`mode`) | `"edit" \| "simulate"` | The current mode. Can be `'edit'`, or `'simulate'`. | `"edit"` ||
52+
| `testLanguage` (`testLanguage`) | `string` | A regular expression to check the language of the automaton against. | `""` ||
53+
| `forcedAlphabet` (`forcedAlphabet`) | `string[]` | The alphabet that the automaton is forced to use as characters separated by spaces. | `[]` ||
54+
| `testWords` (`testWords`) | `string[]` | Words used for automatically testing the automaton as a string separated by spaces. | `[]` ||
5555
| `verbose` (`verbose`) | `boolean` | Enables logging of numerous events to the console. | - ||
56-
| `permissions` (`permissions`) | `string` | The encoded permissions for the editor. | `'777'` ||
57-
| `showHelp` (`showHelp`) | `string` | If true, the widget displays automaton error messages. | `'true'` ||
58-
| `showFormalDefinition` (`showFormalDefinition`) | `string` | If true, the widget allows viewing the automaton's formal definition. | `'true'` ||
59-
| `showTransitionsTable` (`showTransitionsTable`) | `string` | If true, the widget allows viewing the automaton's transition table. | `'true'` ||
60-
| `allowedTypes` (`allowedTypes`) | `string[]` | The types of automata that are allowed in the editor. | `['dfa', 'nfa', 'pda']` ||
61-
| `allowedModes` (`allowedModes`) | `string[]` | The modes that are allowed in the editor. | `['edit', 'simulate']` ||
62-
| `allowedTransformations` (`allowedTransformations`) | `string[]` | The transformations that are allowed in the editor. | `['sink']` ||
56+
| `permissions` (`permissions`) | `string` | The encoded permissions for the editor. | `"777"` ||
57+
| `showHelp` (`showHelp`) | `string` | If true, the widget displays automaton error messages. | `"true"` ||
58+
| `showFormalDefinition` (`showFormalDefinition`) | `string` | If true, the widget allows viewing the automaton's formal definition. | `"true"` ||
59+
| `showTransitionsTable` (`showTransitionsTable`) | `string` | If true, the widget allows viewing the automaton's transition table. | `"true"` ||
60+
| `allowedTypes` (`allowedTypes`) | `string[]` | The types of automata that are allowed in the editor. | `["dfa", "nfa", "pda"]` ||
61+
| `allowedModes` (`allowedModes`) | `string[]` | The modes that are allowed in the editor. | `["edit", "simulate"]` ||
62+
| `allowedTransformations` (`allowedTransformations`) | `string[]` | The transformations that are allowed in the editor. | `["sink"]` ||
6363

6464
*Fields including [properties](https://developer.mozilla.org/en-US/docs/Glossary/Property/JavaScript) and [attributes](https://developer.mozilla.org/en-US/docs/Glossary/Attribute) define the current state of the widget and offer customization options.*
6565

0 commit comments

Comments
 (0)