@webwriter/automaton
Version:
Build, visualize, and interact with different kinds of automata (DFA, NFA, PDA).
521 lines (520 loc) • 20.8 kB
JSON
{
"schemaVersion": "1.0.0",
"readme": "",
"modules": [
{
"kind": "javascript-module",
"path": "src/index.ts",
"declarations": [
{
"kind": "class",
"description": "Represents an Automaton Component.\r\nThis component is responsible for rendering and managing the automaton editor and simulator.",
"name": "AutomatonComponent",
"members": [
{
"kind": "field",
"name": "graphCanvas",
"type": {
"text": "HTMLElement"
},
"privacy": "private"
},
{
"kind": "field",
"name": "toolMenu",
"type": {
"text": "ToolMenu"
},
"privacy": "private"
},
{
"kind": "field",
"name": "simulatorMenu",
"type": {
"text": "SimulatorMenu"
},
"privacy": "private"
},
{
"kind": "field",
"name": "infoMenu",
"type": {
"text": "InfoMenu"
},
"privacy": "private"
},
{
"kind": "field",
"name": "topMenu",
"type": {
"text": "TopMenu"
},
"privacy": "private"
},
{
"kind": "field",
"name": "localize",
"privacy": "protected",
"default": "LOCALIZE"
},
{
"kind": "field",
"name": "nodes",
"type": {
"text": "Node[]"
},
"privacy": "public",
"default": "[]",
"description": "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.",
"attribute": "nodes",
"reflects": true
},
{
"kind": "field",
"name": "transitions",
"type": {
"text": "Transition[]"
},
"privacy": "public",
"default": "[]",
"description": "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`",
"attribute": "transitions",
"reflects": true
},
{
"kind": "field",
"name": "type",
"type": {
"text": "AutomatonType"
},
"privacy": "public",
"default": "\"dfa\"",
"description": "The type of the automaton. Can be `'dfa'`, `'nfa'`, or `'pda'`.",
"attribute": "type",
"reflects": true
},
{
"kind": "field",
"name": "mode",
"type": {
"text": "\"edit\" | \"simulate\""
},
"privacy": "public",
"default": "\"edit\"",
"description": "The current mode. Can be `'edit'`, or `'simulate'`.",
"attribute": "mode",
"reflects": true
},
{
"kind": "field",
"name": "testLanguage",
"type": {
"text": "string"
},
"privacy": "public",
"default": "\"\"",
"description": "A regular expression to check the language of the automaton against.",
"attribute": "testLanguage",
"reflects": true
},
{
"kind": "field",
"name": "forcedAlphabet",
"type": {
"text": "string[]"
},
"privacy": "public",
"default": "[]",
"description": "The alphabet that the automaton is forced to use as characters separated by spaces.",
"attribute": "forcedAlphabet",
"reflects": true
},
{
"kind": "field",
"name": "testWords",
"type": {
"text": "string[]"
},
"privacy": "public",
"default": "[]",
"description": "Words used for automatically testing the automaton as a string separated by spaces.",
"attribute": "testWords",
"reflects": true
},
{
"kind": "field",
"name": "_verbose",
"type": {
"text": "boolean"
},
"privacy": "private",
"default": "false"
},
{
"kind": "field",
"name": "verbose",
"privacy": "public",
"description": "Enables logging of numerous events to the console.",
"type": {
"text": "boolean"
},
"attribute": "verbose",
"reflects": true
},
{
"kind": "field",
"name": "permissions",
"type": {
"text": "string"
},
"privacy": "public",
"default": "\"777\"",
"description": "The encoded permissions for the editor.",
"attribute": "permissions",
"reflects": true
},
{
"kind": "field",
"name": "showHelp",
"type": {
"text": "string"
},
"privacy": "public",
"default": "\"true\"",
"description": "If true, the widget displays automaton error messages.",
"attribute": "showHelp",
"reflects": true
},
{
"kind": "field",
"name": "showFormalDefinition",
"type": {
"text": "string"
},
"privacy": "public",
"default": "\"true\"",
"description": "If true, the widget allows viewing the automaton's formal definition.",
"attribute": "showFormalDefinition",
"reflects": true
},
{
"kind": "field",
"name": "showTransitionsTable",
"type": {
"text": "string"
},
"privacy": "public",
"default": "\"true\"",
"description": "If true, the widget allows viewing the automaton's transition table.",
"attribute": "showTransitionsTable",
"reflects": true
},
{
"kind": "field",
"name": "allowedTypes",
"type": {
"text": "string[]"
},
"privacy": "public",
"default": "[\"dfa\", \"nfa\", \"pda\"]",
"description": "The types of automata that are allowed in the editor.",
"attribute": "allowedTypes",
"reflects": true
},
{
"kind": "field",
"name": "allowedModes",
"type": {
"text": "string[]"
},
"privacy": "public",
"default": "[\"edit\", \"simulate\"]",
"description": "The modes that are allowed in the editor.",
"attribute": "allowedModes",
"reflects": true
},
{
"kind": "field",
"name": "allowedTransformations",
"type": {
"text": "string[]"
},
"privacy": "public",
"default": "[\"sink\"]",
"description": "The transformations that are allowed in the editor.",
"attribute": "allowedTransformations",
"reflects": true
},
{
"kind": "field",
"name": "_graph",
"type": {
"text": "Graph"
},
"privacy": "private"
},
{
"kind": "field",
"name": "graph",
"privacy": "protected"
},
{
"kind": "field",
"name": "_automaton",
"type": {
"text": "Automaton"
},
"privacy": "private",
"default": "new DFA([], [])"
},
{
"kind": "field",
"name": "_helpOverlay",
"type": {
"text": "boolean"
},
"privacy": "private",
"default": "false"
},
{
"kind": "field",
"name": "helpOverlay",
"privacy": "private"
},
{
"kind": "field",
"name": "scopedElements",
"privacy": "protected",
"static": true,
"readonly": true
},
{
"kind": "method",
"name": "renderEditor",
"privacy": "private",
"return": {
"type": {
"text": "TemplateResult"
}
}
},
{
"kind": "method",
"name": "renderSettings",
"privacy": "private",
"return": {
"type": {
"text": "TemplateResult"
}
},
"description": "Renders the settings section of the component."
},
{
"kind": "method",
"name": "renderHelpOverlay",
"privacy": "private",
"return": {
"type": {
"text": "TemplateResult"
}
},
"description": "Renders the help overlay."
},
{
"kind": "method",
"name": "renderModeSwitch",
"privacy": "private",
"return": {
"type": {
"text": "TemplateResult"
}
},
"description": "Renders the mode switch component."
},
{
"kind": "method",
"name": "toggleMode",
"privacy": "private",
"description": "Toggles the mode between 'edit' and 'simulate'."
},
{
"kind": "method",
"name": "setUpListeners",
"privacy": "private",
"parameters": [
{
"name": "a",
"type": {
"text": "Automaton"
},
"description": "The automaton object."
}
],
"description": "Sets up the listeners for the automaton."
}
],
"attributes": [
{
"name": "nodes",
"type": {
"text": "Node[]"
},
"default": "[]",
"description": "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.",
"fieldName": "nodes"
},
{
"name": "transitions",
"type": {
"text": "Transition[]"
},
"default": "[]",
"description": "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`",
"fieldName": "transitions"
},
{
"name": "type",
"type": {
"text": "AutomatonType"
},
"default": "\"dfa\"",
"description": "The type of the automaton. Can be `'dfa'`, `'nfa'`, or `'pda'`.",
"fieldName": "type"
},
{
"name": "mode",
"type": {
"text": "\"edit\" | \"simulate\""
},
"default": "\"edit\"",
"description": "The current mode. Can be `'edit'`, or `'simulate'`.",
"fieldName": "mode"
},
{
"name": "testLanguage",
"type": {
"text": "string"
},
"default": "\"\"",
"description": "A regular expression to check the language of the automaton against.",
"fieldName": "testLanguage"
},
{
"name": "forcedAlphabet",
"type": {
"text": "string[]"
},
"default": "[]",
"description": "The alphabet that the automaton is forced to use as characters separated by spaces.",
"fieldName": "forcedAlphabet"
},
{
"name": "testWords",
"type": {
"text": "string[]"
},
"default": "[]",
"description": "Words used for automatically testing the automaton as a string separated by spaces.",
"fieldName": "testWords"
},
{
"name": "verbose",
"description": "Enables logging of numerous events to the console.",
"type": {
"text": "boolean"
},
"fieldName": "verbose"
},
{
"name": "permissions",
"type": {
"text": "string"
},
"default": "\"777\"",
"description": "The encoded permissions for the editor.",
"fieldName": "permissions"
},
{
"name": "showHelp",
"type": {
"text": "string"
},
"default": "\"true\"",
"description": "If true, the widget displays automaton error messages.",
"fieldName": "showHelp"
},
{
"name": "showFormalDefinition",
"type": {
"text": "string"
},
"default": "\"true\"",
"description": "If true, the widget allows viewing the automaton's formal definition.",
"fieldName": "showFormalDefinition"
},
{
"name": "showTransitionsTable",
"type": {
"text": "string"
},
"default": "\"true\"",
"description": "If true, the widget allows viewing the automaton's transition table.",
"fieldName": "showTransitionsTable"
},
{
"name": "allowedTypes",
"type": {
"text": "string[]"
},
"default": "[\"dfa\", \"nfa\", \"pda\"]",
"description": "The types of automata that are allowed in the editor.",
"fieldName": "allowedTypes"
},
{
"name": "allowedModes",
"type": {
"text": "string[]"
},
"default": "[\"edit\", \"simulate\"]",
"description": "The modes that are allowed in the editor.",
"fieldName": "allowedModes"
},
{
"name": "allowedTransformations",
"type": {
"text": "string[]"
},
"default": "[\"sink\"]",
"description": "The transformations that are allowed in the editor.",
"fieldName": "allowedTransformations"
}
],
"superclass": {
"name": "LitElementWw",
"package": "@webwriter/lit"
},
"tagName": "webwriter-automaton",
"customElement": true
}
],
"exports": [
{
"kind": "js",
"name": "AutomatonComponent",
"declaration": {
"name": "AutomatonComponent",
"module": "src/index.ts"
}
},
{
"kind": "custom-element-definition",
"name": "webwriter-automaton",
"declaration": {
"name": "AutomatonComponent",
"module": "src/index.ts"
}
}
]
}
]
}