diff --git a/README.md b/README.md index aa7d844f..2e58dac0 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,14 @@ A Javascript state machine with a simple API. Well tested, and typed with Flowt ## TL;DR Specify finite state machines with a brief syntax. Run them. Derive charts from them. Save and load states. Make factories. Impress friends and loved ones. Cure corns and callouses. +```javascript +const traffic_light = sm` + Red 'Proceed' -> Green 'Proceed' -> Yellow 'Proceed' -> Red; +`; +``` + +You could also write that as a piece of data, for when you're generating. That's ... a bit more verbose. + ```javascript const traffic_light = new jssm.machine({ @@ -34,7 +42,11 @@ const traffic_light = new jssm.machine({ ] }); +``` + +In either case, you'll build an executable state machine. +```javascript // use with actions traffic_light.state(); // 'Red' traffic_light.action('Proceed'); // true @@ -61,9 +73,47 @@ Which you can see being hand-executed in the console here:

-## Quick Start ## Why -## How To +### Why state machines +### Why this implementation + +## Quick Start +### Terminology + +## Features +### DSL +### States +### Transitions +#### Legal, main, and forced +### Validators +### State history +### Automatic visualization + +## How to think in state machines + +## Example Machines +### Door lock +### Traffic lights +#### Basic three-state +#### RYG, Off, Flash-red, Flash-yellow +#### RYG, Off, Flash-red, Flash-yellow, Green-left, Yellow-left +#### Heirarchal intersection +### [ATM](https://people.engr.ncsu.edu/efg/210/s99/Notes/fsm/atm.gif) +### [HTTP](https://www.w3.org/Library/User/Architecture/HTTP.gif) +#### Better HTTP +### [TCP](http://www.texample.net/media/tikz/examples/PNG/tcp-state-machine.png) +### Coin-op vending machine (data) +### Video games +#### Pac-man Ghost (sensors) +#### Weather (probabilistics) +#### Roguelike monster (interface satisfaction) +### Candy crush clone game flow (practical large use) +### React SPA website (practical large use) +### [BGP](https://upload.wikimedia.org/wikipedia/commons/thumb/a/a8/BGP_FSM.svg/549px-BGP_FSM.svg.png) +### [LibGCrypt FIPS mode FSM](https://www.gnupg.org/documentation/manuals/gcrypt/fips-fsm.png) + +## How to debug + ## Notation Comparison ### Their notations, one by one ### Apples to Apples - Traffic Light diff --git a/dist/jssm.es5.cjs.js b/dist/jssm.es5.cjs.js index 4800d271..80cf969a 100644 --- a/dist/jssm.es5.cjs.js +++ b/dist/jssm.es5.cjs.js @@ -138,268 +138,303 @@ function peg$parse(input, options) { peg$c4 = peg$literalExpectation("rectangle", false), peg$c5 = "circle", peg$c6 = peg$literalExpectation("circle", false), - peg$c7 = peg$otherExpectation("forward light arrow"), + peg$c7 = peg$otherExpectation("forward light arrow ->"), peg$c8 = "->", peg$c9 = peg$literalExpectation("->", false), - peg$c10 = peg$otherExpectation("two way light arrow"), + peg$c10 = peg$otherExpectation("two way light arrow <->"), peg$c11 = "<->", peg$c12 = peg$literalExpectation("<->", false), - peg$c13 = peg$otherExpectation("forward fat arrow"), - peg$c14 = "=>", - peg$c15 = peg$literalExpectation("=>", false), - peg$c16 = peg$otherExpectation("two way fat arrow"), - peg$c17 = "<=>", - peg$c18 = peg$literalExpectation("<=>", false), - peg$c19 = peg$otherExpectation("forward tilde arrow"), - peg$c20 = "~>", - peg$c21 = peg$literalExpectation("~>", false), - peg$c22 = peg$otherExpectation("two way tilde arrow"), - peg$c23 = "<~>", - peg$c24 = peg$literalExpectation("<~>", false), - peg$c25 = peg$otherExpectation("light arrow"), - peg$c26 = peg$otherExpectation("fat arrow"), - peg$c27 = peg$otherExpectation("tilde arrow"), - peg$c28 = peg$otherExpectation("arrow"), - peg$c29 = /^[0-9a-fA-F]/, - peg$c30 = peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false), - peg$c31 = "\"", - peg$c32 = peg$literalExpectation("\"", false), - peg$c33 = "\\", - peg$c34 = peg$literalExpectation("\\", false), - peg$c35 = "/", - peg$c36 = peg$literalExpectation("/", false), - peg$c37 = "b", - peg$c38 = peg$literalExpectation("b", false), - peg$c39 = function peg$c39() { + peg$c13 = peg$otherExpectation("back light arrow <-"), + peg$c14 = "<-", + peg$c15 = peg$literalExpectation("<-", false), + peg$c16 = peg$otherExpectation("forward fat arrow =>"), + peg$c17 = "=>", + peg$c18 = peg$literalExpectation("=>", false), + peg$c19 = peg$otherExpectation("two way fat arrow <=>"), + peg$c20 = "<=>", + peg$c21 = peg$literalExpectation("<=>", false), + peg$c22 = peg$otherExpectation("back fat arrow <="), + peg$c23 = "<=", + peg$c24 = peg$literalExpectation("<=", false), + peg$c25 = peg$otherExpectation("forward tilde arrow ~>"), + peg$c26 = "~>", + peg$c27 = peg$literalExpectation("~>", false), + peg$c28 = peg$otherExpectation("two way tilde arrow <~>"), + peg$c29 = "<~>", + peg$c30 = peg$literalExpectation("<~>", false), + peg$c31 = peg$otherExpectation("back tilde arrow <~"), + peg$c32 = "<~", + peg$c33 = peg$literalExpectation("<~", false), + peg$c34 = peg$otherExpectation("light fat arrow <-=>"), + peg$c35 = "<-=>", + peg$c36 = peg$literalExpectation("<-=>", false), + peg$c37 = peg$otherExpectation("light tilde arrow <-~>"), + peg$c38 = "<-~>", + peg$c39 = peg$literalExpectation("<-~>", false), + peg$c40 = peg$otherExpectation("fat light arrow <=->"), + peg$c41 = "<=->", + peg$c42 = peg$literalExpectation("<=->", false), + peg$c43 = peg$otherExpectation("fat tilde arrow <=~>"), + peg$c44 = "<=~>", + peg$c45 = peg$literalExpectation("<=~>", false), + peg$c46 = peg$otherExpectation("tilde light arrow <~->"), + peg$c47 = "<~->", + peg$c48 = peg$literalExpectation("<~->", false), + peg$c49 = peg$otherExpectation("tilde fat arrow <~=>"), + peg$c50 = "<~=>", + peg$c51 = peg$literalExpectation("<~=>", false), + peg$c52 = peg$otherExpectation("light arrow"), + peg$c53 = peg$otherExpectation("fat arrow"), + peg$c54 = peg$otherExpectation("tilde arrow"), + peg$c55 = peg$otherExpectation("mixed arrow"), + peg$c56 = peg$otherExpectation("arrow"), + peg$c57 = /^[0-9a-fA-F]/, + peg$c58 = peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false), + peg$c59 = "\"", + peg$c60 = peg$literalExpectation("\"", false), + peg$c61 = "\\", + peg$c62 = peg$literalExpectation("\\", false), + peg$c63 = "/", + peg$c64 = peg$literalExpectation("/", false), + peg$c65 = "b", + peg$c66 = peg$literalExpectation("b", false), + peg$c67 = function peg$c67() { return "\b"; }, - peg$c40 = "f", - peg$c41 = peg$literalExpectation("f", false), - peg$c42 = function peg$c42() { + peg$c68 = "f", + peg$c69 = peg$literalExpectation("f", false), + peg$c70 = function peg$c70() { return "\f"; }, - peg$c43 = "n", - peg$c44 = peg$literalExpectation("n", false), - peg$c45 = function peg$c45() { + peg$c71 = "n", + peg$c72 = peg$literalExpectation("n", false), + peg$c73 = function peg$c73() { return "\n"; }, - peg$c46 = "r", - peg$c47 = peg$literalExpectation("r", false), - peg$c48 = function peg$c48() { + peg$c74 = "r", + peg$c75 = peg$literalExpectation("r", false), + peg$c76 = function peg$c76() { return "\r"; }, - peg$c49 = "t", - peg$c50 = peg$literalExpectation("t", false), - peg$c51 = function peg$c51() { + peg$c77 = "t", + peg$c78 = peg$literalExpectation("t", false), + peg$c79 = function peg$c79() { return "\t"; }, - peg$c52 = "v", - peg$c53 = peg$literalExpectation("v", false), - peg$c54 = function peg$c54() { + peg$c80 = "v", + peg$c81 = peg$literalExpectation("v", false), + peg$c82 = function peg$c82() { return "\v"; }, - peg$c55 = "u", - peg$c56 = peg$literalExpectation("u", false), - peg$c57 = function peg$c57(digits) { + peg$c83 = "u", + peg$c84 = peg$literalExpectation("u", false), + peg$c85 = function peg$c85(digits) { return String.fromCharCode(parseInt(digits, 16)); }, - peg$c58 = function peg$c58(Sequence) { + peg$c86 = function peg$c86(Sequence) { return Sequence; }, - peg$c59 = /^[ -!#-[\]-\u10FFFF]/, - peg$c60 = peg$classExpectation([[" ", "!"], ["#", "["], ["]", "\u10FF"], "F", "F"], false, false), - peg$c61 = "`", - peg$c62 = peg$literalExpectation("`", false), - peg$c63 = /^[ -[\]-_a-\u10FFFF]/, - peg$c64 = peg$classExpectation([[" ", "["], ["]", "_"], ["a", "\u10FF"], "F", "F"], false, false), - peg$c65 = peg$otherExpectation("action label"), - peg$c66 = function peg$c66(chars) { + peg$c87 = /^[ -!#-[\]-\u10FFFF]/, + peg$c88 = peg$classExpectation([[" ", "!"], ["#", "["], ["]", "\u10FF"], "F", "F"], false, false), + peg$c89 = "'", + peg$c90 = peg$literalExpectation("'", false), + peg$c91 = /^[ -&(-[\]-\u10FFFF]/, + peg$c92 = peg$classExpectation([[" ", "&"], ["(", "["], ["]", "\u10FF"], "F", "F"], false, false), + peg$c93 = peg$otherExpectation("action label"), + peg$c94 = function peg$c94(chars) { return chars.join(""); }, - peg$c67 = peg$otherExpectation("whitespace"), - peg$c68 = /^[ \t\n\r\x0B]/, - peg$c69 = peg$classExpectation([" ", "\t", "\n", "\r", "\x0B"], false, false), - peg$c70 = peg$otherExpectation("string"), - peg$c71 = peg$otherExpectation("atom"), - peg$c72 = /^[0-9a-zA-Z.+_&()%$#@!?,']/, - peg$c73 = peg$classExpectation([["0", "9"], ["a", "z"], ["A", "Z"], ".", "+", "_", "&", "(", ")", "%", "$", "#", "@", "!", "?", ",", "'"], false, false), - peg$c74 = function peg$c74(text) { + peg$c95 = /^[\n\r\u2028\u2029]/, + peg$c96 = peg$classExpectation(["\n", "\r", "\u2028", "\u2029"], false, false), + peg$c97 = peg$otherExpectation("whitespace"), + peg$c98 = /^[ \t\n\r\x0B]/, + peg$c99 = peg$classExpectation([" ", "\t", "\n", "\r", "\x0B"], false, false), + peg$c100 = peg$otherExpectation("string"), + peg$c101 = peg$otherExpectation("atom"), + peg$c102 = /^[0-9a-zA-Z.+_&()%$#@!?,']/, + peg$c103 = peg$classExpectation([["0", "9"], ["a", "z"], ["A", "Z"], ".", "+", "_", "&", "(", ")", "%", "$", "#", "@", "!", "?", ",", "'"], false, false), + peg$c104 = function peg$c104(text) { return text.join(''); }, - peg$c75 = peg$otherExpectation("label"), - peg$c76 = peg$otherExpectation("color"), - peg$c77 = "red", - peg$c78 = peg$literalExpectation("red", false), - peg$c79 = "green", - peg$c80 = peg$literalExpectation("green", false), - peg$c81 = "blue", - peg$c82 = peg$literalExpectation("blue", false), - peg$c83 = "arc_label", - peg$c84 = peg$literalExpectation("arc_label", false), - peg$c85 = "head_label", - peg$c86 = peg$literalExpectation("head_label", false), - peg$c87 = "tail_label", - peg$c88 = peg$literalExpectation("tail_label", false), - peg$c89 = ":", - peg$c90 = peg$literalExpectation(":", false), - peg$c91 = ";", - peg$c92 = peg$literalExpectation(";", false), - peg$c93 = function peg$c93(key, value) { + peg$c105 = peg$otherExpectation("label"), + peg$c106 = peg$otherExpectation("color"), + peg$c107 = "red", + peg$c108 = peg$literalExpectation("red", false), + peg$c109 = "green", + peg$c110 = peg$literalExpectation("green", false), + peg$c111 = "blue", + peg$c112 = peg$literalExpectation("blue", false), + peg$c113 = "arc_label", + peg$c114 = peg$literalExpectation("arc_label", false), + peg$c115 = "head_label", + peg$c116 = peg$literalExpectation("head_label", false), + peg$c117 = "tail_label", + peg$c118 = peg$literalExpectation("tail_label", false), + peg$c119 = ":", + peg$c120 = peg$literalExpectation(":", false), + peg$c121 = ";", + peg$c122 = peg$literalExpectation(";", false), + peg$c123 = function peg$c123(key, value) { return { key: key, value: value }; }, - peg$c94 = peg$otherExpectation("single edge color"), - peg$c95 = "edge_color", - peg$c96 = peg$literalExpectation("edge_color", false), - peg$c97 = function peg$c97(value) { + peg$c124 = peg$otherExpectation("single edge color"), + peg$c125 = "edge_color", + peg$c126 = peg$literalExpectation("edge_color", false), + peg$c127 = function peg$c127(value) { return { key: 'single_edge_color', value: value }; }, - peg$c98 = "{", - peg$c99 = peg$literalExpectation("{", false), - peg$c100 = "}", - peg$c101 = peg$literalExpectation("}", false), - peg$c102 = function peg$c102(items) { + peg$c128 = "{", + peg$c129 = peg$literalExpectation("{", false), + peg$c130 = "}", + peg$c131 = peg$literalExpectation("}", false), + peg$c132 = function peg$c132(items) { return items; }, - peg$c103 = "[", - peg$c104 = peg$literalExpectation("[", false), - peg$c105 = "]", - peg$c106 = peg$literalExpectation("]", false), - peg$c107 = function peg$c107(names) { + peg$c133 = "[", + peg$c134 = peg$literalExpectation("[", false), + peg$c135 = "]", + peg$c136 = peg$literalExpectation("]", false), + peg$c137 = function peg$c137(names) { return names.map(function (i) { return i[0]; }); }, - peg$c108 = function peg$c108(lactl, ldesc, arrow, rdesc, ractl, label, tail) { + peg$c138 = function peg$c138(r_action, l_desc, arrow, r_desc, l_action, label, tail) { + var base = { kind: arrow, to: label }; if (tail && tail !== []) { base.se = tail; } - if (ldesc) { - base.ldesc = ldesc; + if (l_desc) { + base.l_desc = l_desc; + } + if (r_desc) { + base.r_desc = r_desc; } - if (rdesc) { - base.rdesc = rdesc; + if (l_action) { + base.l_action = l_action; + } + if (r_action) { + base.r_action = r_action; } return base; }, - peg$c109 = function peg$c109(label, se) { - var base = { from: label }; + peg$c139 = function peg$c139(label, se) { + var base = { key: 'transition', from: label }; if (se && se !== []) { base.se = se; } return base; }, - peg$c110 = "whargarbl", - peg$c111 = peg$literalExpectation("whargarbl", false), - peg$c112 = "todo", - peg$c113 = peg$literalExpectation("todo", false), - peg$c114 = function peg$c114(validationkey, value) { + peg$c140 = "whargarbl", + peg$c141 = peg$literalExpectation("whargarbl", false), + peg$c142 = "todo", + peg$c143 = peg$literalExpectation("todo", false), + peg$c144 = function peg$c144(validationkey, value) { return { key: validationkey, value: value }; }, - peg$c115 = "validation", - peg$c116 = peg$literalExpectation("validation", false), - peg$c117 = "};", - peg$c118 = peg$literalExpectation("};", false), - peg$c119 = function peg$c119(validation_items) { + peg$c145 = "validation", + peg$c146 = peg$literalExpectation("validation", false), + peg$c147 = "};", + peg$c148 = peg$literalExpectation("};", false), + peg$c149 = function peg$c149(validation_items) { return { config_kind: "validation", config_items: validation_items || [] }; }, - peg$c120 = "dot", - peg$c121 = peg$literalExpectation("dot", false), - peg$c122 = "circo", - peg$c123 = peg$literalExpectation("circo", false), - peg$c124 = "in_shape", - peg$c125 = peg$literalExpectation("in_shape", false), - peg$c126 = "out_shape", - peg$c127 = peg$literalExpectation("out_shape", false), - peg$c128 = "node_shape", - peg$c129 = peg$literalExpectation("node_shape", false), - peg$c130 = "graph_layout", - peg$c131 = peg$literalExpectation("graph_layout", false), - peg$c132 = function peg$c132(value) { - return { key: "graph_layout", value: value }; - }, - peg$c133 = "state", - peg$c134 = peg$literalExpectation("state", false), - peg$c135 = function peg$c135(state_items) { + peg$c150 = "dot", + peg$c151 = peg$literalExpectation("dot", false), + peg$c152 = "circo", + peg$c153 = peg$literalExpectation("circo", false), + peg$c154 = "fdp", + peg$c155 = peg$literalExpectation("fdp", false), + peg$c156 = "neato", + peg$c157 = peg$literalExpectation("neato", false), + peg$c158 = "in_shape", + peg$c159 = peg$literalExpectation("in_shape", false), + peg$c160 = "out_shape", + peg$c161 = peg$literalExpectation("out_shape", false), + peg$c162 = "node_shape", + peg$c163 = peg$literalExpectation("node_shape", false), + peg$c164 = "state", + peg$c165 = peg$literalExpectation("state", false), + peg$c166 = function peg$c166(state_items) { return { config_kind: "state", config_items: state_items || [] }; }, - peg$c136 = function peg$c136(actionkey, value) { + peg$c167 = function peg$c167(actionkey, value) { return { key: actionkey, value: value }; }, - peg$c137 = "action", - peg$c138 = peg$literalExpectation("action", false), - peg$c139 = function peg$c139(action_items) { + peg$c168 = "action", + peg$c169 = peg$literalExpectation("action", false), + peg$c170 = function peg$c170(action_items) { return { config_kind: "action", config_items: action_items || [] }; }, - peg$c140 = function peg$c140(transitionkey, value) { + peg$c171 = function peg$c171(transitionkey, value) { return { key: transitionkey, value: value }; }, - peg$c141 = peg$otherExpectation("graph default edge color"), - peg$c142 = function peg$c142(value) { + peg$c172 = peg$otherExpectation("graph default edge color"), + peg$c173 = function peg$c173(value) { return { key: 'graph_default_edge_color', value: value }; }, - peg$c143 = "transition", - peg$c144 = peg$literalExpectation("transition", false), - peg$c145 = function peg$c145(transition_items) { + peg$c174 = "transition", + peg$c175 = peg$literalExpectation("transition", false), + peg$c176 = function peg$c176(transition_items) { return { config_kind: "transition", config_items: transition_items || [] }; }, - peg$c146 = "graph_bg", - peg$c147 = peg$literalExpectation("graph_bg", false), - peg$c148 = function peg$c148(value) { - return { key: "graph_bg", value: value }; - }, - peg$c149 = "min_transitions_per_state", - peg$c150 = peg$literalExpectation("min_transitions_per_state", false), - peg$c151 = function peg$c151(value) { - return { key: "min_transitions_per_state", value: value }; - }, - peg$c152 = "max_transitions_per_state", - peg$c153 = peg$literalExpectation("max_transitions_per_state", false), - peg$c154 = function peg$c154(value) { - return { key: "max_transitions_per_state", value: value }; - }, - peg$c155 = "inputs", - peg$c156 = peg$literalExpectation("inputs", false), - peg$c157 = function peg$c157(value) { - return { key: "inputs", value: value }; - }, - peg$c158 = "outputs", - peg$c159 = peg$literalExpectation("outputs", false), - peg$c160 = function peg$c160(value) { - return { key: "outputs", value: value }; + peg$c177 = "graph_layout", + peg$c178 = peg$literalExpectation("graph_layout", false), + peg$c179 = function peg$c179(value) { + return { key: "graph_layout", value: value }; }, - peg$c161 = "start_nodes", - peg$c162 = peg$literalExpectation("start_nodes", false), - peg$c163 = function peg$c163(value) { + peg$c180 = "start_nodes", + peg$c181 = peg$literalExpectation("start_nodes", false), + peg$c182 = function peg$c182(value) { return { key: "start_nodes", value: value }; }, - peg$c164 = "end_nodes", - peg$c165 = peg$literalExpectation("end_nodes", false), - peg$c166 = function peg$c166(value) { + peg$c183 = "end_nodes", + peg$c184 = peg$literalExpectation("end_nodes", false), + peg$c185 = function peg$c185(value) { return { key: "end_nodes", value: value }; }, - peg$c167 = peg$otherExpectation("graph configuration"), - peg$c168 = "graph", - peg$c169 = peg$literalExpectation("graph", false), - peg$c170 = function peg$c170(graph_items) { - return { config_kind: "graph", config_items: graph_items || [] }; + peg$c186 = "graph_bg_color", + peg$c187 = peg$literalExpectation("graph_bg_color", false), + peg$c188 = function peg$c188(value) { + return { key: "graph_bg_color", value: value }; }, - peg$c171 = peg$otherExpectation("configuration"), - peg$c172 = "color", - peg$c173 = peg$literalExpectation("color", false), - peg$c174 = function peg$c174(value) { + peg$c189 = peg$otherExpectation("configuration"), + peg$c190 = "color", + peg$c191 = peg$literalExpectation("color", false), + peg$c192 = function peg$c192(value) { return { key: "state color", value: value }; }, - peg$c175 = peg$otherExpectation("state quality"), - peg$c176 = function peg$c176(name, value) { + peg$c193 = peg$otherExpectation("state quality"), + peg$c194 = function peg$c194(name, value) { return { key: "state quality", name: name, value: value }; }, - peg$c177 = peg$otherExpectation("state definition"), - peg$c178 = function peg$c178(name, sq) { + peg$c195 = peg$otherExpectation("state definition"), + peg$c196 = function peg$c196(name, sq) { return { key: "State qualities", value: sq }; }, + peg$c197 = "machine name", + peg$c198 = peg$literalExpectation("machine name", false), + peg$c199 = function peg$c199(name) { + return { key: "Machine name", value: name }; + }, + peg$c200 = "group", + peg$c201 = peg$literalExpectation("group", false), + peg$c202 = function peg$c202(name, nl) { + return { key: "group definition", value: { name: name, list: nl } }; + }, + peg$c203 = "/*", + peg$c204 = peg$literalExpectation("/*", false), + peg$c205 = "*/", + peg$c206 = peg$literalExpectation("*/", false), + peg$c207 = peg$anyExpectation(), + peg$c208 = function peg$c208() { + return { key: 'comment' }; + }, + peg$c209 = "//", + peg$c210 = peg$literalExpectation("//", false), peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], @@ -644,7 +679,7 @@ function peg$parse(input, options) { return s0; } - function peg$parseForwardFatArrow() { + function peg$parseBackLightArrow() { var s0, s1; peg$silentFails++; @@ -668,13 +703,13 @@ function peg$parse(input, options) { return s0; } - function peg$parseTwoWayFatArrow() { + function peg$parseForwardFatArrow() { var s0, s1; peg$silentFails++; - if (input.substr(peg$currPos, 3) === peg$c17) { + if (input.substr(peg$currPos, 2) === peg$c17) { s0 = peg$c17; - peg$currPos += 3; + peg$currPos += 2; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { @@ -692,13 +727,13 @@ function peg$parse(input, options) { return s0; } - function peg$parseForwardTildeArrow() { + function peg$parseTwoWayFatArrow() { var s0, s1; peg$silentFails++; - if (input.substr(peg$currPos, 2) === peg$c20) { + if (input.substr(peg$currPos, 3) === peg$c20) { s0 = peg$c20; - peg$currPos += 2; + peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { @@ -716,13 +751,13 @@ function peg$parse(input, options) { return s0; } - function peg$parseTwoWayTildeArrow() { + function peg$parseBackFatArrow() { var s0, s1; peg$silentFails++; - if (input.substr(peg$currPos, 3) === peg$c23) { + if (input.substr(peg$currPos, 2) === peg$c23) { s0 = peg$c23; - peg$currPos += 3; + peg$currPos += 2; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { @@ -740,6 +775,222 @@ function peg$parse(input, options) { return s0; } + function peg$parseForwardTildeArrow() { + var s0, s1; + + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c26) { + s0 = peg$c26; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c27); + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c25); + } + } + + return s0; + } + + function peg$parseTwoWayTildeArrow() { + var s0, s1; + + peg$silentFails++; + if (input.substr(peg$currPos, 3) === peg$c29) { + s0 = peg$c29; + peg$currPos += 3; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c30); + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c28); + } + } + + return s0; + } + + function peg$parseBackTildeArrow() { + var s0, s1; + + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c32) { + s0 = peg$c32; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c33); + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c31); + } + } + + return s0; + } + + function peg$parseLightFatArrow() { + var s0, s1; + + peg$silentFails++; + if (input.substr(peg$currPos, 4) === peg$c35) { + s0 = peg$c35; + peg$currPos += 4; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c36); + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c34); + } + } + + return s0; + } + + function peg$parseLightTildeArrow() { + var s0, s1; + + peg$silentFails++; + if (input.substr(peg$currPos, 4) === peg$c38) { + s0 = peg$c38; + peg$currPos += 4; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c39); + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c37); + } + } + + return s0; + } + + function peg$parseFatLightArrow() { + var s0, s1; + + peg$silentFails++; + if (input.substr(peg$currPos, 4) === peg$c41) { + s0 = peg$c41; + peg$currPos += 4; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c42); + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c40); + } + } + + return s0; + } + + function peg$parseFatTildeArrow() { + var s0, s1; + + peg$silentFails++; + if (input.substr(peg$currPos, 4) === peg$c44) { + s0 = peg$c44; + peg$currPos += 4; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c45); + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c43); + } + } + + return s0; + } + + function peg$parseTildeLightArrow() { + var s0, s1; + + peg$silentFails++; + if (input.substr(peg$currPos, 4) === peg$c47) { + s0 = peg$c47; + peg$currPos += 4; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c48); + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c46); + } + } + + return s0; + } + + function peg$parseTildeFatArrow() { + var s0, s1; + + peg$silentFails++; + if (input.substr(peg$currPos, 4) === peg$c50) { + s0 = peg$c50; + peg$currPos += 4; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c51); + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c49); + } + } + + return s0; + } + function peg$parseLightArrow() { var s0, s1; @@ -747,12 +998,15 @@ function peg$parse(input, options) { s0 = peg$parseForwardLightArrow(); if (s0 === peg$FAILED) { s0 = peg$parseTwoWayLightArrow(); + if (s0 === peg$FAILED) { + s0 = peg$parseBackLightArrow(); + } } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c25); + peg$fail(peg$c52); } } @@ -766,12 +1020,15 @@ function peg$parse(input, options) { s0 = peg$parseForwardFatArrow(); if (s0 === peg$FAILED) { s0 = peg$parseTwoWayFatArrow(); + if (s0 === peg$FAILED) { + s0 = peg$parseBackFatArrow(); + } } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c26); + peg$fail(peg$c53); } } @@ -785,12 +1042,46 @@ function peg$parse(input, options) { s0 = peg$parseForwardTildeArrow(); if (s0 === peg$FAILED) { s0 = peg$parseTwoWayTildeArrow(); + if (s0 === peg$FAILED) { + s0 = peg$parseBackTildeArrow(); + } } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c27); + peg$fail(peg$c54); + } + } + + return s0; + } + + function peg$parseMixedArrow() { + var s0, s1; + + peg$silentFails++; + s0 = peg$parseLightFatArrow(); + if (s0 === peg$FAILED) { + s0 = peg$parseLightTildeArrow(); + if (s0 === peg$FAILED) { + s0 = peg$parseFatLightArrow(); + if (s0 === peg$FAILED) { + s0 = peg$parseFatTildeArrow(); + if (s0 === peg$FAILED) { + s0 = peg$parseTildeLightArrow(); + if (s0 === peg$FAILED) { + s0 = peg$parseTildeFatArrow(); + } + } + } + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c55); } } @@ -801,18 +1092,21 @@ function peg$parse(input, options) { var s0, s1; peg$silentFails++; - s0 = peg$parseLightArrow(); + s0 = peg$parseMixedArrow(); if (s0 === peg$FAILED) { - s0 = peg$parseFatArrow(); + s0 = peg$parseLightArrow(); if (s0 === peg$FAILED) { - s0 = peg$parseTildeArrow(); + s0 = peg$parseFatArrow(); + if (s0 === peg$FAILED) { + s0 = peg$parseTildeArrow(); + } } } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c28); + peg$fail(peg$c56); } } @@ -822,13 +1116,13 @@ function peg$parse(input, options) { function peg$parseHexDigit() { var s0; - if (peg$c29.test(input.charAt(peg$currPos))) { + if (peg$c57.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c30); + peg$fail(peg$c58); } } @@ -844,139 +1138,139 @@ function peg$parse(input, options) { s1 = peg$parseEscape(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s2 = peg$c31; + s2 = peg$c59; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c32); + peg$fail(peg$c60); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { - s2 = peg$c33; + s2 = peg$c61; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c34); + peg$fail(peg$c62); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 47) { - s2 = peg$c35; + s2 = peg$c63; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c36); + peg$fail(peg$c64); } } if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 98) { - s3 = peg$c37; + s3 = peg$c65; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c38); + peg$fail(peg$c66); } } if (s3 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c39(); + s3 = peg$c67(); } s2 = s3; if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 102) { - s3 = peg$c40; + s3 = peg$c68; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c41); + peg$fail(peg$c69); } } if (s3 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c42(); + s3 = peg$c70(); } s2 = s3; if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 110) { - s3 = peg$c43; + s3 = peg$c71; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c44); + peg$fail(peg$c72); } } if (s3 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c45(); + s3 = peg$c73(); } s2 = s3; if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 114) { - s3 = peg$c46; + s3 = peg$c74; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c47); + peg$fail(peg$c75); } } if (s3 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c48(); + s3 = peg$c76(); } s2 = s3; if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 116) { - s3 = peg$c49; + s3 = peg$c77; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c50); + peg$fail(peg$c78); } } if (s3 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c51(); + s3 = peg$c79(); } s2 = s3; if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 118) { - s3 = peg$c52; + s3 = peg$c80; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c53); + peg$fail(peg$c81); } } if (s3 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c54(); + s3 = peg$c82(); } s2 = s3; if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 117) { - s3 = peg$c55; + s3 = peg$c83; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c56); + peg$fail(peg$c84); } } if (s3 !== peg$FAILED) { @@ -1015,7 +1309,7 @@ function peg$parse(input, options) { } if (s4 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c57(s4); + s3 = peg$c85(s4); s2 = s3; } else { peg$currPos = s2; @@ -1036,7 +1330,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c58(s2); + s1 = peg$c86(s2); s0 = s1; } else { peg$currPos = s0; @@ -1055,12 +1349,12 @@ function peg$parse(input, options) { var s0; if (input.charCodeAt(peg$currPos) === 92) { - s0 = peg$c33; + s0 = peg$c61; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c34); + peg$fail(peg$c62); } } @@ -1071,12 +1365,12 @@ function peg$parse(input, options) { var s0; if (input.charCodeAt(peg$currPos) === 34) { - s0 = peg$c31; + s0 = peg$c59; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c32); + peg$fail(peg$c60); } } @@ -1086,13 +1380,13 @@ function peg$parse(input, options) { function peg$parseUnescaped() { var s0; - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c87.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c60); + peg$fail(peg$c88); } } @@ -1107,140 +1401,140 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parseEscape(); if (s1 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 96) { - s2 = peg$c61; + if (input.charCodeAt(peg$currPos) === 39) { + s2 = peg$c89; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c62); + peg$fail(peg$c90); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { - s2 = peg$c33; + s2 = peg$c61; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c34); + peg$fail(peg$c62); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 47) { - s2 = peg$c35; + s2 = peg$c63; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c36); + peg$fail(peg$c64); } } if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 98) { - s3 = peg$c37; + s3 = peg$c65; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c38); + peg$fail(peg$c66); } } if (s3 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c39(); + s3 = peg$c67(); } s2 = s3; if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 102) { - s3 = peg$c40; + s3 = peg$c68; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c41); + peg$fail(peg$c69); } } if (s3 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c42(); + s3 = peg$c70(); } s2 = s3; if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 110) { - s3 = peg$c43; + s3 = peg$c71; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c44); + peg$fail(peg$c72); } } if (s3 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c45(); + s3 = peg$c73(); } s2 = s3; if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 114) { - s3 = peg$c46; + s3 = peg$c74; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c47); + peg$fail(peg$c75); } } if (s3 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c48(); + s3 = peg$c76(); } s2 = s3; if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 116) { - s3 = peg$c49; + s3 = peg$c77; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c50); + peg$fail(peg$c78); } } if (s3 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c51(); + s3 = peg$c79(); } s2 = s3; if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 118) { - s3 = peg$c52; + s3 = peg$c80; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c53); + peg$fail(peg$c81); } } if (s3 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c54(); + s3 = peg$c82(); } s2 = s3; if (s2 === peg$FAILED) { s2 = peg$currPos; if (input.charCodeAt(peg$currPos) === 117) { - s3 = peg$c55; + s3 = peg$c83; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c56); + peg$fail(peg$c84); } } if (s3 !== peg$FAILED) { @@ -1279,7 +1573,7 @@ function peg$parse(input, options) { } if (s4 !== peg$FAILED) { peg$savedPos = s2; - s3 = peg$c57(s4); + s3 = peg$c85(s4); s2 = s3; } else { peg$currPos = s2; @@ -1300,7 +1594,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c58(s2); + s1 = peg$c86(s2); s0 = s1; } else { peg$currPos = s0; @@ -1318,13 +1612,13 @@ function peg$parse(input, options) { function peg$parseActionLabelQuoteMark() { var s0; - if (input.charCodeAt(peg$currPos) === 96) { - s0 = peg$c61; + if (input.charCodeAt(peg$currPos) === 39) { + s0 = peg$c89; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c62); + peg$fail(peg$c90); } } @@ -1334,13 +1628,13 @@ function peg$parse(input, options) { function peg$parseActionLabelUnescaped() { var s0; - if (peg$c63.test(input.charAt(peg$currPos))) { + if (peg$c91.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c64); + peg$fail(peg$c92); } } @@ -1364,7 +1658,7 @@ function peg$parse(input, options) { s3 = peg$parseActionLabelQuoteMark(); if (s3 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c66(s2); + s1 = peg$c94(s2); s0 = s1; } else { peg$currPos = s0; @@ -1382,7 +1676,23 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c65); + peg$fail(peg$c93); + } + } + + return s0; + } + + function peg$parseLineTerminator() { + var s0; + + if (peg$c95.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c96); } } @@ -1394,24 +1704,24 @@ function peg$parse(input, options) { peg$silentFails++; s0 = []; - if (peg$c68.test(input.charAt(peg$currPos))) { + if (peg$c98.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c69); + peg$fail(peg$c99); } } while (s1 !== peg$FAILED) { s0.push(s1); - if (peg$c68.test(input.charAt(peg$currPos))) { + if (peg$c98.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c69); + peg$fail(peg$c99); } } } @@ -1419,7 +1729,7 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c67); + peg$fail(peg$c97); } } @@ -1443,7 +1753,7 @@ function peg$parse(input, options) { s3 = peg$parseQuoteMark(); if (s3 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c66(s2); + s1 = peg$c94(s2); s0 = s1; } else { peg$currPos = s0; @@ -1461,7 +1771,7 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c70); + peg$fail(peg$c100); } } @@ -1474,25 +1784,25 @@ function peg$parse(input, options) { peg$silentFails++; s0 = peg$currPos; s1 = []; - if (peg$c72.test(input.charAt(peg$currPos))) { + if (peg$c102.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c73); + peg$fail(peg$c103); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); - if (peg$c72.test(input.charAt(peg$currPos))) { + if (peg$c102.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c73); + peg$fail(peg$c103); } } } @@ -1501,14 +1811,14 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c74(s1); + s1 = peg$c104(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c71); + peg$fail(peg$c101); } } @@ -1527,7 +1837,7 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c75); + peg$fail(peg$c105); } } @@ -1538,33 +1848,33 @@ function peg$parse(input, options) { var s0, s1; peg$silentFails++; - if (input.substr(peg$currPos, 3) === peg$c77) { - s0 = peg$c77; + if (input.substr(peg$currPos, 3) === peg$c107) { + s0 = peg$c107; peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c78); + peg$fail(peg$c108); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 5) === peg$c79) { - s0 = peg$c79; + if (input.substr(peg$currPos, 5) === peg$c109) { + s0 = peg$c109; peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c80); + peg$fail(peg$c110); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c81) { - s0 = peg$c81; + if (input.substr(peg$currPos, 4) === peg$c111) { + s0 = peg$c111; peg$currPos += 4; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c82); + peg$fail(peg$c112); } } } @@ -1573,7 +1883,7 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c76); + peg$fail(peg$c106); } } @@ -1583,33 +1893,33 @@ function peg$parse(input, options) { function peg$parseArrowItemKey() { var s0; - if (input.substr(peg$currPos, 9) === peg$c83) { - s0 = peg$c83; + if (input.substr(peg$currPos, 9) === peg$c113) { + s0 = peg$c113; peg$currPos += 9; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c84); + peg$fail(peg$c114); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 10) === peg$c85) { - s0 = peg$c85; + if (input.substr(peg$currPos, 10) === peg$c115) { + s0 = peg$c115; peg$currPos += 10; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c86); + peg$fail(peg$c116); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 10) === peg$c87) { - s0 = peg$c87; + if (input.substr(peg$currPos, 10) === peg$c117) { + s0 = peg$c117; peg$currPos += 10; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c88); + peg$fail(peg$c118); } } } @@ -1629,12 +1939,12 @@ function peg$parse(input, options) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { @@ -1645,19 +1955,19 @@ function peg$parse(input, options) { s7 = peg$parseWhitespace(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; + s8 = peg$c121; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c93(s2, s6); + s1 = peg$c123(s2, s6); s0 = s1; } else { peg$currPos = s0; @@ -1706,25 +2016,25 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 10) === peg$c95) { - s2 = peg$c95; + if (input.substr(peg$currPos, 10) === peg$c125) { + s2 = peg$c125; peg$currPos += 10; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c96); + peg$fail(peg$c126); } } if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { @@ -1735,19 +2045,19 @@ function peg$parse(input, options) { s7 = peg$parseWhitespace(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; + s8 = peg$c121; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c97(s6); + s1 = peg$c127(s6); s0 = s1; } else { peg$currPos = s0; @@ -1789,7 +2099,7 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c94); + peg$fail(peg$c124); } } @@ -1821,12 +2131,12 @@ function peg$parse(input, options) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 123) { - s1 = peg$c98; + s1 = peg$c128; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c99); + peg$fail(peg$c129); } } if (s1 !== peg$FAILED) { @@ -1840,17 +2150,17 @@ function peg$parse(input, options) { s4 = peg$parseWhitespace(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { - s5 = peg$c100; + s5 = peg$c130; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c101); + peg$fail(peg$c131); } } if (s5 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c102(s3); + s1 = peg$c132(s3); s0 = s1; } else { peg$currPos = s0; @@ -1881,12 +2191,12 @@ function peg$parse(input, options) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 91) { - s1 = peg$c103; + s1 = peg$c133; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c104); + peg$fail(peg$c134); } } if (s1 !== peg$FAILED) { @@ -1928,17 +2238,17 @@ function peg$parse(input, options) { } if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 93) { - s4 = peg$c105; + s4 = peg$c135; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c106); + peg$fail(peg$c136); } } if (s4 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c107(s3); + s1 = peg$c137(s3); s0 = s1; } else { peg$currPos = s0; @@ -2019,7 +2329,7 @@ function peg$parse(input, options) { } if (s14 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c108(s2, s4, s6, s8, s10, s12, s14); + s1 = peg$c138(s2, s4, s6, s8, s10, s12, s14); s0 = s1; } else { peg$currPos = s0; @@ -2092,19 +2402,19 @@ function peg$parse(input, options) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s4 = peg$c91; + s4 = peg$c121; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c109(s1, s2); + s1 = peg$c139(s1, s2); s0 = s1; } else { peg$currPos = s0; @@ -2133,23 +2443,23 @@ function peg$parse(input, options) { function peg$parseValidationKey() { var s0; - if (input.substr(peg$currPos, 9) === peg$c110) { - s0 = peg$c110; + if (input.substr(peg$currPos, 9) === peg$c140) { + s0 = peg$c140; peg$currPos += 9; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c111); + peg$fail(peg$c141); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c112) { - s0 = peg$c112; + if (input.substr(peg$currPos, 4) === peg$c142) { + s0 = peg$c142; peg$currPos += 4; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c113); + peg$fail(peg$c143); } } } @@ -2164,29 +2474,29 @@ function peg$parse(input, options) { s1 = peg$parseValidationKey(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s2 = peg$c89; + s2 = peg$c119; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s2 !== peg$FAILED) { s3 = peg$parseLabel(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s4 = peg$c91; + s4 = peg$c121; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s4 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c114(s1, s3); + s1 = peg$c144(s1, s3); s0 = s1; } else { peg$currPos = s0; @@ -2231,37 +2541,37 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 10) === peg$c115) { - s2 = peg$c115; + if (input.substr(peg$currPos, 10) === peg$c145) { + s2 = peg$c145; peg$currPos += 10; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c116); + peg$fail(peg$c146); } } if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 123) { - s6 = peg$c98; + s6 = peg$c128; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c99); + peg$fail(peg$c129); } } if (s6 !== peg$FAILED) { @@ -2274,20 +2584,20 @@ function peg$parse(input, options) { if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c117) { - s10 = peg$c117; + if (input.substr(peg$currPos, 2) === peg$c147) { + s10 = peg$c147; peg$currPos += 2; } else { s10 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c118); + peg$fail(peg$c148); } } if (s10 !== peg$FAILED) { s11 = peg$parseWhitespace(); if (s11 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c119(s8); + s1 = peg$c149(s8); s0 = s1; } else { peg$currPos = s0; @@ -2340,23 +2650,45 @@ function peg$parse(input, options) { function peg$parseGvizLayout() { var s0; - if (input.substr(peg$currPos, 3) === peg$c120) { - s0 = peg$c120; + if (input.substr(peg$currPos, 3) === peg$c150) { + s0 = peg$c150; peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c121); + peg$fail(peg$c151); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 5) === peg$c122) { - s0 = peg$c122; + if (input.substr(peg$currPos, 5) === peg$c152) { + s0 = peg$c152; peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c123); + peg$fail(peg$c153); + } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 3) === peg$c154) { + s0 = peg$c154; + peg$currPos += 3; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c155); + } + } + if (s0 === peg$FAILED) { + if (input.substr(peg$currPos, 5) === peg$c156) { + s0 = peg$c156; + peg$currPos += 5; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c157); + } + } } } } @@ -2367,33 +2699,33 @@ function peg$parse(input, options) { function peg$parseStateItemShapeKey() { var s0; - if (input.substr(peg$currPos, 8) === peg$c124) { - s0 = peg$c124; + if (input.substr(peg$currPos, 8) === peg$c158) { + s0 = peg$c158; peg$currPos += 8; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c125); + peg$fail(peg$c159); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 9) === peg$c126) { - s0 = peg$c126; + if (input.substr(peg$currPos, 9) === peg$c160) { + s0 = peg$c160; peg$currPos += 9; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c127); + peg$fail(peg$c161); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 10) === peg$c128) { - s0 = peg$c128; + if (input.substr(peg$currPos, 10) === peg$c162) { + s0 = peg$c162; peg$currPos += 10; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c129); + peg$fail(peg$c163); } } } @@ -2413,12 +2745,12 @@ function peg$parse(input, options) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { @@ -2429,108 +2761,19 @@ function peg$parse(input, options) { s7 = peg$parseWhitespace(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c92); - } - } - if (s8 !== peg$FAILED) { - s9 = peg$parseWhitespace(); - if (s9 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c93(s2, s6); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseStateItemGraphLayout() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseWhitespace(); - if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 12) === peg$c130) { - s2 = peg$c130; - peg$currPos += 12; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c131); - } - } - if (s2 !== peg$FAILED) { - s3 = peg$parseWhitespace(); - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c90); - } - } - if (s4 !== peg$FAILED) { - s5 = peg$parseWhitespace(); - if (s5 !== peg$FAILED) { - s6 = peg$parseGvizLayout(); - if (s6 !== peg$FAILED) { - s7 = peg$parseWhitespace(); - if (s7 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; + s8 = peg$c121; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c132(s6); + s1 = peg$c123(s2, s6); s0 = s1; } else { peg$currPos = s0; @@ -2572,26 +2815,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseStateItem() { - var s0; - - s0 = peg$parseStateItemShape(); - if (s0 === peg$FAILED) { - s0 = peg$parseStateItemGraphLayout(); - } - - return s0; - } - function peg$parseStateItems() { var s0, s1; s0 = []; - s1 = peg$parseStateItem(); + s1 = peg$parseStateItemShape(); if (s1 !== peg$FAILED) { while (s1 !== peg$FAILED) { s0.push(s1); - s1 = peg$parseStateItem(); + s1 = peg$parseStateItemShape(); } } else { s0 = peg$FAILED; @@ -2606,37 +2838,37 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 5) === peg$c133) { - s2 = peg$c133; + if (input.substr(peg$currPos, 5) === peg$c164) { + s2 = peg$c164; peg$currPos += 5; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c134); + peg$fail(peg$c165); } } if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 123) { - s6 = peg$c98; + s6 = peg$c128; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c99); + peg$fail(peg$c129); } } if (s6 !== peg$FAILED) { @@ -2649,20 +2881,20 @@ function peg$parse(input, options) { if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c117) { - s10 = peg$c117; + if (input.substr(peg$currPos, 2) === peg$c147) { + s10 = peg$c147; peg$currPos += 2; } else { s10 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c118); + peg$fail(peg$c148); } } if (s10 !== peg$FAILED) { s11 = peg$parseWhitespace(); if (s11 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c135(s8); + s1 = peg$c166(s8); s0 = s1; } else { peg$currPos = s0; @@ -2715,23 +2947,23 @@ function peg$parse(input, options) { function peg$parseActionKey() { var s0; - if (input.substr(peg$currPos, 9) === peg$c110) { - s0 = peg$c110; + if (input.substr(peg$currPos, 9) === peg$c140) { + s0 = peg$c140; peg$currPos += 9; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c111); + peg$fail(peg$c141); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c112) { - s0 = peg$c112; + if (input.substr(peg$currPos, 4) === peg$c142) { + s0 = peg$c142; peg$currPos += 4; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c113); + peg$fail(peg$c143); } } } @@ -2746,29 +2978,29 @@ function peg$parse(input, options) { s1 = peg$parseActionKey(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s2 = peg$c89; + s2 = peg$c119; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s2 !== peg$FAILED) { s3 = peg$parseLabel(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s4 = peg$c91; + s4 = peg$c121; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s4 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c136(s1, s3); + s1 = peg$c167(s1, s3); s0 = s1; } else { peg$currPos = s0; @@ -2813,37 +3045,37 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 6) === peg$c137) { - s2 = peg$c137; + if (input.substr(peg$currPos, 6) === peg$c168) { + s2 = peg$c168; peg$currPos += 6; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c138); + peg$fail(peg$c169); } } if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 123) { - s6 = peg$c98; + s6 = peg$c128; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c99); + peg$fail(peg$c129); } } if (s6 !== peg$FAILED) { @@ -2856,20 +3088,20 @@ function peg$parse(input, options) { if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c117) { - s10 = peg$c117; + if (input.substr(peg$currPos, 2) === peg$c147) { + s10 = peg$c147; peg$currPos += 2; } else { s10 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c118); + peg$fail(peg$c148); } } if (s10 !== peg$FAILED) { s11 = peg$parseWhitespace(); if (s11 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c139(s8); + s1 = peg$c170(s8); s0 = s1; } else { peg$currPos = s0; @@ -2922,23 +3154,23 @@ function peg$parse(input, options) { function peg$parseTransitionKey() { var s0; - if (input.substr(peg$currPos, 9) === peg$c110) { - s0 = peg$c110; + if (input.substr(peg$currPos, 9) === peg$c140) { + s0 = peg$c140; peg$currPos += 9; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c111); + peg$fail(peg$c141); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c112) { - s0 = peg$c112; + if (input.substr(peg$currPos, 4) === peg$c142) { + s0 = peg$c142; peg$currPos += 4; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c113); + peg$fail(peg$c143); } } } @@ -2953,29 +3185,29 @@ function peg$parse(input, options) { s1 = peg$parseTransitionKey(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s2 = peg$c89; + s2 = peg$c119; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s2 !== peg$FAILED) { s3 = peg$parseLabel(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s4 = peg$c91; + s4 = peg$c121; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s4 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c140(s1, s3); + s1 = peg$c171(s1, s3); s0 = s1; } else { peg$currPos = s0; @@ -3024,25 +3256,25 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 10) === peg$c95) { - s2 = peg$c95; + if (input.substr(peg$currPos, 10) === peg$c125) { + s2 = peg$c125; peg$currPos += 10; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c96); + peg$fail(peg$c126); } } if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { @@ -3053,19 +3285,19 @@ function peg$parse(input, options) { s7 = peg$parseWhitespace(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; + s8 = peg$c121; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c142(s6); + s1 = peg$c173(s6); s0 = s1; } else { peg$currPos = s0; @@ -3107,7 +3339,7 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c141); + peg$fail(peg$c172); } } @@ -3120,37 +3352,37 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 10) === peg$c143) { - s2 = peg$c143; + if (input.substr(peg$currPos, 10) === peg$c174) { + s2 = peg$c174; peg$currPos += 10; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c144); + peg$fail(peg$c175); } } if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 123) { - s6 = peg$c98; + s6 = peg$c128; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c99); + peg$fail(peg$c129); } } if (s6 !== peg$FAILED) { @@ -3163,20 +3395,20 @@ function peg$parse(input, options) { if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c117) { - s10 = peg$c117; + if (input.substr(peg$currPos, 2) === peg$c147) { + s10 = peg$c147; peg$currPos += 2; } else { s10 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c118); + peg$fail(peg$c148); } } if (s10 !== peg$FAILED) { s11 = peg$parseWhitespace(); if (s11 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c145(s8); + s1 = peg$c176(s8); s0 = s1; } else { peg$currPos = s0; @@ -3226,54 +3458,54 @@ function peg$parse(input, options) { return s0; } - function peg$parseGraphBg() { + function peg$parseConfigGraphLayout() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 8) === peg$c146) { - s2 = peg$c146; - peg$currPos += 8; + if (input.substr(peg$currPos, 12) === peg$c177) { + s2 = peg$c177; + peg$currPos += 12; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c147); + peg$fail(peg$c178); } } if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { - s6 = peg$parseGvizShape(); + s6 = peg$parseGvizLayout(); if (s6 !== peg$FAILED) { s7 = peg$parseWhitespace(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; + s8 = peg$c121; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c148(s6); + s1 = peg$c179(s6); s0 = s1; } else { peg$currPos = s0; @@ -3315,54 +3547,54 @@ function peg$parse(input, options) { return s0; } - function peg$parseMinTransitionsPerState() { + function peg$parseConfigStartNodes() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 25) === peg$c149) { - s2 = peg$c149; - peg$currPos += 25; + if (input.substr(peg$currPos, 11) === peg$c180) { + s2 = peg$c180; + peg$currPos += 11; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c150); + peg$fail(peg$c181); } } if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { - s6 = peg$parseLabel(); + s6 = peg$parseLabelList(); if (s6 !== peg$FAILED) { s7 = peg$parseWhitespace(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; + s8 = peg$c121; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c151(s6); + s1 = peg$c182(s6); s0 = s1; } else { peg$currPos = s0; @@ -3404,54 +3636,54 @@ function peg$parse(input, options) { return s0; } - function peg$parseMaxTransitionsPerState() { + function peg$parseConfigEndNodes() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 25) === peg$c152) { - s2 = peg$c152; - peg$currPos += 25; + if (input.substr(peg$currPos, 9) === peg$c183) { + s2 = peg$c183; + peg$currPos += 9; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c153); + peg$fail(peg$c184); } } if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { - s6 = peg$parseLabel(); + s6 = peg$parseLabelList(); if (s6 !== peg$FAILED) { s7 = peg$parseWhitespace(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; + s8 = peg$c121; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c154(s6); + s1 = peg$c185(s6); s0 = s1; } else { peg$currPos = s0; @@ -3493,54 +3725,54 @@ function peg$parse(input, options) { return s0; } - function peg$parseGraphInputs() { + function peg$parseConfigGraphBgColor() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 6) === peg$c155) { - s2 = peg$c155; - peg$currPos += 6; + if (input.substr(peg$currPos, 14) === peg$c186) { + s2 = peg$c186; + peg$currPos += 14; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c156); + peg$fail(peg$c187); } } if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { - s6 = peg$parseLabelList(); + s6 = peg$parseColor(); if (s6 !== peg$FAILED) { s7 = peg$parseWhitespace(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; + s8 = peg$c121; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c157(s6); + s1 = peg$c188(s6); s0 = s1; } else { peg$currPos = s0; @@ -3582,54 +3814,91 @@ function peg$parse(input, options) { return s0; } - function peg$parseGraphOutputs() { + function peg$parseConfig() { + var s0, s1; + + peg$silentFails++; + s0 = peg$parseConfigGraphLayout(); + if (s0 === peg$FAILED) { + s0 = peg$parseConfigStartNodes(); + if (s0 === peg$FAILED) { + s0 = peg$parseConfigEndNodes(); + if (s0 === peg$FAILED) { + s0 = peg$parseConfigTransition(); + if (s0 === peg$FAILED) { + s0 = peg$parseConfigAction(); + if (s0 === peg$FAILED) { + s0 = peg$parseConfigState(); + if (s0 === peg$FAILED) { + s0 = peg$parseConfigValidation(); + if (s0 === peg$FAILED) { + s0 = peg$parseConfigGraphBgColor(); + } + } + } + } + } + } + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c189); + } + } + + return s0; + } + + function peg$parseStateColor() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 7) === peg$c158) { - s2 = peg$c158; - peg$currPos += 7; + if (input.substr(peg$currPos, 5) === peg$c190) { + s2 = peg$c190; + peg$currPos += 5; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c159); + peg$fail(peg$c191); } } if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { - s6 = peg$parseLabelList(); + s6 = peg$parseColor(); if (s6 !== peg$FAILED) { s7 = peg$parseWhitespace(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; + s8 = peg$c121; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c160(s6); + s1 = peg$c192(s6); s0 = s1; } else { peg$currPos = s0; @@ -3671,54 +3940,47 @@ function peg$parse(input, options) { return s0; } - function peg$parseGraphStartNodes() { + function peg$parseArbitraryStateQuality() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + peg$silentFails++; s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 11) === peg$c161) { - s2 = peg$c161; - peg$currPos += 11; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c162); - } - } + s2 = peg$parseLabel(); if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { - s6 = peg$parseLabelList(); + s6 = peg$parseLabel(); if (s6 !== peg$FAILED) { s7 = peg$parseWhitespace(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; + s8 = peg$c121; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c163(s6); + s1 = peg$c194(s2, s6); s0 = s1; } else { peg$currPos = s0; @@ -3756,19 +4018,38 @@ function peg$parse(input, options) { peg$currPos = s0; s0 = peg$FAILED; } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c193); + } + } return s0; } - function peg$parseGraphEndNodes() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + function peg$parseStateQuality() { + var s0; + + s0 = peg$parseStateColor(); + if (s0 === peg$FAILED) { + s0 = peg$parseArbitraryStateQuality(); + } + + return s0; + } + + function peg$parseStateDef() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; + peg$silentFails++; s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 9) === peg$c164) { + if (input.substr(peg$currPos, 5) === peg$c164) { s2 = peg$c164; - peg$currPos += 9; + peg$currPos += 5; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { @@ -3778,185 +4059,66 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c90); - } - } + s4 = peg$parseLabel(); if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { - s6 = peg$parseLabelList(); + if (input.charCodeAt(peg$currPos) === 91) { + s6 = peg$c133; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c134); + } + } if (s6 !== peg$FAILED) { s7 = peg$parseWhitespace(); if (s7 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c92); - } + s8 = []; + s9 = peg$parseStateQuality(); + while (s9 !== peg$FAILED) { + s8.push(s9); + s9 = peg$parseStateQuality(); } if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c166(s6); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseGraphItem() { - var s0; - - s0 = peg$parseGraphBg(); - if (s0 === peg$FAILED) { - s0 = peg$parseMinTransitionsPerState(); - if (s0 === peg$FAILED) { - s0 = peg$parseMaxTransitionsPerState(); - if (s0 === peg$FAILED) { - s0 = peg$parseGraphStartNodes(); - if (s0 === peg$FAILED) { - s0 = peg$parseGraphEndNodes(); - if (s0 === peg$FAILED) { - s0 = peg$parseGraphInputs(); - if (s0 === peg$FAILED) { - s0 = peg$parseGraphOutputs(); - } - } - } - } - } - } - - return s0; - } - - function peg$parseGraphItems() { - var s0, s1; - - s0 = []; - s1 = peg$parseGraphItem(); - if (s1 !== peg$FAILED) { - while (s1 !== peg$FAILED) { - s0.push(s1); - s1 = peg$parseGraphItem(); - } - } else { - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseConfigGraph() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - peg$silentFails++; - s0 = peg$currPos; - s1 = peg$parseWhitespace(); - if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 5) === peg$c168) { - s2 = peg$c168; - peg$currPos += 5; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c169); - } - } - if (s2 !== peg$FAILED) { - s3 = peg$parseWhitespace(); - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c90); - } - } - if (s4 !== peg$FAILED) { - s5 = peg$parseWhitespace(); - if (s5 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 123) { - s6 = peg$c98; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c99); - } - } - if (s6 !== peg$FAILED) { - s7 = peg$parseWhitespace(); - if (s7 !== peg$FAILED) { - s8 = peg$parseGraphItems(); - if (s8 === peg$FAILED) { - s8 = null; - } - if (s8 !== peg$FAILED) { - s9 = peg$parseWhitespace(); - if (s9 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c117) { - s10 = peg$c117; - peg$currPos += 2; + if (input.charCodeAt(peg$currPos) === 93) { + s10 = peg$c135; + peg$currPos++; } else { s10 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c118); + peg$fail(peg$c136); } } if (s10 !== peg$FAILED) { s11 = peg$parseWhitespace(); if (s11 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c170(s8); - s0 = s1; + if (input.charCodeAt(peg$currPos) === 59) { + s12 = peg$c121; + peg$currPos++; + } else { + s12 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c122); + } + } + if (s12 !== peg$FAILED) { + s13 = peg$parseWhitespace(); + if (s13 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c196(s4, s8); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4005,89 +4167,61 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c167); - } - } - - return s0; - } - - function peg$parseConfig() { - var s0, s1; - - peg$silentFails++; - s0 = peg$parseConfigGraph(); - if (s0 === peg$FAILED) { - s0 = peg$parseConfigTransition(); - if (s0 === peg$FAILED) { - s0 = peg$parseConfigAction(); - if (s0 === peg$FAILED) { - s0 = peg$parseConfigState(); - if (s0 === peg$FAILED) { - s0 = peg$parseConfigValidation(); - } - } - } - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c171); + peg$fail(peg$c195); } } return s0; } - function peg$parseStateColor() { + function peg$parseMachineName() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 5) === peg$c172) { - s2 = peg$c172; - peg$currPos += 5; + if (input.substr(peg$currPos, 12) === peg$c197) { + s2 = peg$c197; + peg$currPos += 12; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c173); + peg$fail(peg$c198); } } if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; + s4 = peg$c119; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c90); + peg$fail(peg$c120); } } if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { - s6 = peg$parseColor(); + s6 = peg$parseLabel(); if (s6 !== peg$FAILED) { s7 = peg$parseWhitespace(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; + s8 = peg$c121; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c92); + peg$fail(peg$c122); } } if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c174(s6); + s1 = peg$c199(s6); s0 = s1; } else { peg$currPos = s0; @@ -4129,48 +4263,67 @@ function peg$parse(input, options) { return s0; } - function peg$parseArbitraryStateQuality() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + function peg$parseStateGroupDef() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - peg$silentFails++; s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - s2 = peg$parseLabel(); + if (input.substr(peg$currPos, 5) === peg$c200) { + s2 = peg$c200; + peg$currPos += 5; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c201); + } + } if (s2 !== peg$FAILED) { s3 = peg$parseWhitespace(); if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 58) { - s4 = peg$c89; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c90); - } - } + s4 = peg$parseLabel(); if (s4 !== peg$FAILED) { s5 = peg$parseWhitespace(); if (s5 !== peg$FAILED) { - s6 = peg$parseLabel(); + if (input.charCodeAt(peg$currPos) === 58) { + s6 = peg$c119; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c120); + } + } if (s6 !== peg$FAILED) { s7 = peg$parseWhitespace(); if (s7 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s8 = peg$c91; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c92); - } - } + s8 = peg$parseLabelOrLabelList(); if (s8 !== peg$FAILED) { s9 = peg$parseWhitespace(); if (s9 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c176(s2, s6); - s0 = s1; + if (input.charCodeAt(peg$currPos) === 59) { + s10 = peg$c121; + peg$currPos++; + } else { + s10 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c122); + } + } + if (s10 !== peg$FAILED) { + s11 = peg$parseWhitespace(); + if (s11 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c202(s4, s8); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4207,131 +4360,233 @@ function peg$parse(input, options) { peg$currPos = s0; s0 = peg$FAILED; } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c175); - } - } - - return s0; - } - - function peg$parseStateQuality() { - var s0; - - s0 = peg$parseStateColor(); - if (s0 === peg$FAILED) { - s0 = peg$parseArbitraryStateQuality(); - } return s0; } - function peg$parseStateDef() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; + function peg$parseComment() { + var s0, s1, s2, s3, s4, s5, s6; - peg$silentFails++; s0 = peg$currPos; s1 = peg$parseWhitespace(); if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 5) === peg$c133) { - s2 = peg$c133; - peg$currPos += 5; + if (input.substr(peg$currPos, 2) === peg$c203) { + s2 = peg$c203; + peg$currPos += 2; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c134); + peg$fail(peg$c204); + } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$currPos; + s5 = peg$currPos; + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c205) { + s6 = peg$c205; + peg$currPos += 2; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c206); + } + } + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = void 0; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + if (input.length > peg$currPos) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c207); + } + } + if (s6 !== peg$FAILED) { + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$currPos; + s5 = peg$currPos; + peg$silentFails++; + if (input.substr(peg$currPos, 2) === peg$c205) { + s6 = peg$c205; + peg$currPos += 2; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c206); + } + } + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = void 0; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + if (input.length > peg$currPos) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c207); + } + } + if (s6 !== peg$FAILED) { + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + if (s3 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c205) { + s4 = peg$c205; + peg$currPos += 2; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c206); + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseWhitespace(); + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c208(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - if (s2 !== peg$FAILED) { - s3 = peg$parseWhitespace(); - if (s3 !== peg$FAILED) { - s4 = peg$parseLabel(); - if (s4 !== peg$FAILED) { - s5 = peg$parseWhitespace(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseWhitespace(); + if (s1 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c209) { + s2 = peg$c209; + peg$currPos += 2; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c210); + } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$currPos; + s5 = peg$currPos; + peg$silentFails++; + s6 = peg$parseLineTerminator(); + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = void 0; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + if (input.length > peg$currPos) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { + peg$fail(peg$c207); + } + } + if (s6 !== peg$FAILED) { + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$currPos; + s5 = peg$currPos; + peg$silentFails++; + s6 = peg$parseLineTerminator(); + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = void 0; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } if (s5 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 91) { - s6 = peg$c103; + if (input.length > peg$currPos) { + s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$c104); + peg$fail(peg$c207); } } if (s6 !== peg$FAILED) { - s7 = peg$parseWhitespace(); - if (s7 !== peg$FAILED) { - s8 = []; - s9 = peg$parseStateQuality(); - while (s9 !== peg$FAILED) { - s8.push(s9); - s9 = peg$parseStateQuality(); - } - if (s8 !== peg$FAILED) { - s9 = peg$parseWhitespace(); - if (s9 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s10 = peg$c105; - peg$currPos++; - } else { - s10 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c106); - } - } - if (s10 !== peg$FAILED) { - s11 = peg$parseWhitespace(); - if (s11 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s12 = peg$c91; - peg$currPos++; - } else { - s12 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c92); - } - } - if (s12 !== peg$FAILED) { - s13 = peg$parseWhitespace(); - if (s13 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c178(s4, s8); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s5 = [s5, s6]; + s4 = s5; } else { - peg$currPos = s0; - s0 = peg$FAILED; + peg$currPos = s4; + s4 = peg$FAILED; } + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + if (s3 !== peg$FAILED) { + s4 = peg$parseWhitespace(); + if (s4 !== peg$FAILED) { + s1 = [s1, s2, s3, s4]; + s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4348,16 +4603,6 @@ function peg$parse(input, options) { peg$currPos = s0; s0 = peg$FAILED; } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$c177); - } } return s0; @@ -4370,7 +4615,16 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s0 = peg$parseStateDef(); if (s0 === peg$FAILED) { - s0 = peg$parseConfig(); + s0 = peg$parseMachineName(); + if (s0 === peg$FAILED) { + s0 = peg$parseStateGroupDef(); + if (s0 === peg$FAILED) { + s0 = peg$parseConfig(); + if (s0 === peg$FAILED) { + s0 = peg$parseComment(); + } + } + } } } @@ -4483,36 +4737,223 @@ exports.weighted_sample_select = weighted_sample_select; Object.defineProperty(exports, "__esModule", { value: true }); -exports.weighted_histo_key = exports.weighted_sample_select = exports.histograph = exports.weighted_rand_select = exports.seq = exports.parse = exports.machine = exports.version = undefined; +exports.weighted_histo_key = exports.weighted_sample_select = exports.histograph = exports.weighted_rand_select = exports.seq = exports.arrow_right_kind = exports.arrow_left_kind = exports.arrow_direction = exports.sm = exports.compile = exports.parse = exports.make = exports.Machine = exports.version = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _jssmUtil = require('./jssm-util.js'); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +// whargarbl lots of these return arrays could/should be sets -var version = '3.9.3'; // replaced from package.js in build +var parse = require('./jssm-dot.js').parse; // eslint-disable-line flowtype/no-weak-types // todo whargarbl remove any +var version = '4.4.2'; // replaced from package.js in build -// whargarbl lots of these return arrays could/should be sets -var parse = require('./jssm-dot.js').parse; // todo burn out any +function arrow_direction(arrow) { + + switch (String(arrow)) { + + case '->':case '=>':case '~>': + return 'right'; + + case '<-':case '<=':case '<~': + return 'left'; + + case '<->':case '<-=>':case '<-~>': + case '<=>':case '<=->':case '<=~>': + case '<~>':case '<~->':case '<~=>': + return 'both'; + + default: + throw new Error('arrow_direction: unknown arrow type ' + arrow); + + } +} + +function arrow_left_kind(arrow) { + + switch (String(arrow)) { + + case '->':case '=>':case '~>': + return 'none'; + + case '<-':case '<->':case '<-=>':case '<-~>': + return 'legal'; + + case '<=':case '<=>':case '<=->':case '<=~>': + return 'main'; + + case '<~':case '<~>':case '<~->':case '<~=>': + return 'forced'; + + default: + throw new Error('arrow_direction: unknown arrow type ' + arrow); + + } +} + +function arrow_right_kind(arrow) { + + switch (String(arrow)) { + + case '<-':case '<=':case '<~': + return 'none'; + + case '->':case '<->':case '<=->':case '<~->': + return 'legal'; + + case '=>':case '<=>':case '<-=>':case '<~=>': + return 'main'; + + case '~>':case '<~>':case '<-~>':case '<=~>': + return 'forced'; + + default: + throw new Error('arrow_direction: unknown arrow type ' + arrow); + + } +} + +function compile_rule_transition_step(acc, from, to, this_se, next_se) { + // todo flow describe the parser representation of a transition step extension + + var edges = []; + + var uFrom = Array.isArray(from) ? from : [from], + uTo = Array.isArray(to) ? to : [to]; + + uFrom.map(function (f) { + uTo.map(function (t) { + + var rk = arrow_right_kind(this_se.kind), + lk = arrow_left_kind(this_se.kind); + + var right = { + from: f, + to: t, + kind: rk, + forced_only: rk === 'forced', + main_path: rk === 'main' + }; + + if (this_se.r_action) { + right.action = this_se.r_action; + } + if (right.kind !== 'none') { + edges.push(right); + } + + var left = { + from: t, + to: f, + kind: lk, + forced_only: lk === 'forced', + main_path: lk === 'main' + }; + + if (this_se.l_action) { + left.action = this_se.l_action; + } + if (left.kind !== 'none') { + edges.push(left); + } + }); + }); + + var new_acc = acc.concat(edges); + + if (next_se) { + return compile_rule_transition_step(new_acc, to, next_se.to, next_se, next_se.se); + } else { + return new_acc; + } +} + +function compile_rule_handle_transition(rule) { + // todo flow describe the parser representation of a transition + return compile_rule_transition_step([], rule.from, rule.se.to, rule.se, rule.se.se); +} + +function compile_rule_handler(rule) { + // todo flow describe the output of the parser + + if (rule.key === 'transition') { + return { agg_as: 'transition', val: compile_rule_handle_transition(rule) }; + } + + var tautologies = ['graph_layout', 'start_nodes', 'end_nodes']; + if (tautologies.includes(rule.key)) { + return { agg_as: rule.key, val: rule.value }; + } + + throw new Error('compile_rule_handler: Unknown rule: ' + JSON.stringify(rule)); +} + +function compile(tree) { + var _ref; + // todo flow describe the output of the parser -var machine = function () { + var results = { + graph_layout: [], + transition: [], + start_nodes: [], + end_nodes: [], + initial_state: [] + }; + + tree.map(function (tr) { + + var rule = compile_rule_handler(tr), + agg_as = rule.agg_as, + val = rule.val; // todo better types + + results[agg_as] = results[agg_as].concat(val); + }); + + ['graph_layout', 'initial_state'].map(function (oneOnlyKey) { + if (results[oneOnlyKey].length > 1) { + throw new Error('May only have one ' + oneOnlyKey + ' statement maximum: ' + JSON.stringify(results[oneOnlyKey])); + } + }); + + var assembled_transitions = (_ref = []).concat.apply(_ref, _toConsumableArray(results['transition'])); + + var result_cfg = { + initial_state: results.start_nodes.length ? results.start_nodes[0] : assembled_transitions[0].from, + transitions: assembled_transitions + }; + + if (results.graph_layout.length) { + result_cfg.layout = results.graph_layout[0]; + } + + return result_cfg; +} + +function make(plan) { + return compile(parse(plan)); +} + +var Machine = function () { // whargarbl this badly needs to be broken up, monolith master - function machine(_ref) { + function Machine(_ref2) { var _this = this; - var initial_state = _ref.initial_state, - _ref$complete = _ref.complete, - complete = _ref$complete === undefined ? [] : _ref$complete, - transitions = _ref.transitions; + var initial_state = _ref2.initial_state, + _ref2$complete = _ref2.complete, + complete = _ref2$complete === undefined ? [] : _ref2$complete, + transitions = _ref2.transitions, + _ref2$layout = _ref2.layout, + layout = _ref2$layout === undefined ? 'dot' : _ref2$layout; - _classCallCheck(this, machine); + _classCallCheck(this, Machine); this._state = initial_state; this._states = new Map(); @@ -4523,8 +4964,9 @@ var machine = function () { this._reverse_actions = new Map(); this._reverse_action_targets = new Map(); // todo + this._layout = layout; + transitions.map(function (tr) { - // whargarbl burn out any if (tr.from === undefined) { throw new Error('transition must define \'from\': ' + JSON.stringify(tr)); @@ -4534,21 +4976,21 @@ var machine = function () { } // get the cursors. what a mess - var cursor_from = _this._states.get(tr.from); - if (cursor_from === undefined) { - _this._new_state({ name: tr.from, from: [], to: [], complete: complete.includes(tr.from) }); - cursor_from = _this._states.get(tr.from); + var cursor_from = _this._states.get(tr.from) || { name: tr.from, from: [], to: [], complete: complete.includes(tr.from) }; + + if (!_this._states.has(tr.from)) { + _this._new_state(cursor_from); } - var cursor_to = _this._states.get(tr.to); - if (cursor_to === undefined) { - _this._new_state({ name: tr.to, from: [], to: [], complete: complete.includes(tr.to) }); - cursor_to = _this._states.get(tr.to); + var cursor_to = _this._states.get(tr.to) || { name: tr.to, from: [], to: [], complete: complete.includes(tr.to) }; + + if (!_this._states.has(tr.to)) { + _this._new_state(cursor_to); } // guard against existing connections being re-added if (cursor_from.to.includes(tr.to)) { - throw new Error('already has ' + tr.from + ' to ' + tr.to); + throw new Error('already has ' + JSON.stringify(tr.from) + ' to ' + JSON.stringify(tr.to)); } else { cursor_from.to.push(tr.to); cursor_to.from.push(tr.from); @@ -4561,17 +5003,16 @@ var machine = function () { // guard against repeating a transition name if (tr.name) { if (_this._named_transitions.has(tr.name)) { - throw new Error('named transition "' + tr.name + '" already created'); + throw new Error('named transition "' + JSON.stringify(tr.name) + '" already created'); } else { _this._named_transitions.set(tr.name, thisEdgeId); } } // set up the mapping, so that edges can be looked up by endpoint pairs - var from_mapping = _this._edge_map.get(tr.from); - if (from_mapping === undefined) { - _this._edge_map.set(tr.from, new Map()); - from_mapping = _this._edge_map.get(tr.from); // whargarbl burn out uses of any + var from_mapping = _this._edge_map.get(tr.from) || new Map(); + if (!_this._edge_map.has(tr.from)) { + _this._edge_map.set(tr.from, from_mapping); } // const to_mapping = from_mapping.get(tr.to); @@ -4588,7 +5029,7 @@ var machine = function () { } if (actionMap.has(tr.from)) { - throw new Error('action ' + tr.action + ' already attached to origin ' + tr.from); + throw new Error('action ' + JSON.stringify(tr.action) + ' already attached to origin ' + JSON.stringify(tr.from)); } else { actionMap.set(tr.from, thisEdgeId); } @@ -4626,13 +5067,13 @@ var machine = function () { }); } - _createClass(machine, [{ + _createClass(Machine, [{ key: '_new_state', value: function _new_state(state_config) { // whargarbl get that state_config any under control if (this._states.has(state_config.name)) { - throw new Error('state ' + state_config.name + ' already exists'); + throw new Error('state ' + JSON.stringify(state_config.name) + ' already exists'); } this._states.set(state_config.name, state_config); @@ -4663,6 +5104,11 @@ var machine = function () { // return ((!this.is_changing()) && this.state_is_final(this.state())); return this.state_is_final(this.state()); } + }, { + key: 'layout', + value: function layout() { + return String(this._layout); + } }, { key: 'machine_state', value: function machine_state() { @@ -4720,13 +5166,20 @@ var machine = function () { }, { key: 'get_transition_by_state_names', value: function get_transition_by_state_names(from, to) { - return this._edge_map.has(from) ? this._edge_map.get(from).get(to) : undefined; + + var emg = this._edge_map.get(from); + + if (emg) { + return emg.get(to); + } else { + return undefined; + } } }, { key: 'lookup_transition_for', value: function lookup_transition_for(from, to) { var id = this.get_transition_by_state_names(from, to); - return id === undefined ? undefined : this._edges[id]; + return id === undefined || id === null ? undefined : this._edges[id]; } }, { key: 'list_transitions', @@ -4762,12 +5215,9 @@ var machine = function () { var wstate_to = wstate.to, wtf = wstate_to.map(function (ws) { return _this2.lookup_transition_for(_this2.state(), ws); - }).filter(function (defined) { - return defined; - }); + }).filter(Boolean); - return wtf; // :any because it can't see that .filter(d => d) removes - // the undefineds, and l_t_f returns ?jt, but this returns jt + return wtf; } }, { key: 'probabilistic_transition', @@ -4830,7 +5280,7 @@ var machine = function () { var _this4 = this; var whichState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state(); - // these are mNT + // these are mNT, not ?mNT var ra_base = this._reverse_actions.get(whichState); if (!ra_base) { throw new Error('No such state ' + JSON.stringify(whichState)); @@ -4952,21 +5402,21 @@ var machine = function () { } } - /* whargarbl reintroduce after valid_force_transition is re-enabled - // can leave machine in inconsistent state. generally do not use - force_transition(newState : mNT, newData? : mDT) : boolean { - // todo whargarbl implement hooks - // todo whargarbl implement data stuff - // todo major incomplete whargarbl comeback - if (this.valid_force_transition(newState, newData)) { - this._state = newState; - return true; - } else { - return false; - } - } - */ + // can leave machine in inconsistent state. generally do not use + }, { + key: 'force_transition', + value: function force_transition(newState, newData) { + // todo whargarbl implement hooks + // todo whargarbl implement data stuff + // todo major incomplete whargarbl comeback + if (this.valid_force_transition(newState, newData)) { + this._state = newState; + return true; + } else { + return false; + } + } }, { key: 'current_action_for', value: function current_action_for(action) { @@ -4977,7 +5427,7 @@ var machine = function () { key: 'current_action_edge_for', value: function current_action_edge_for(action) { var idx = this.current_action_for(action); - if (idx === undefined) { + if (idx === undefined || idx === null) { throw new Error('No such action ' + JSON.stringify(action)); } return this._edges[idx]; @@ -4997,24 +5447,65 @@ var machine = function () { // todo comeback unignore newData // todo whargarbl implement hooks // todo whargarbl implement data stuff - // todo major incomplete whargarbl comeback - return this.lookup_transition_for(this.state(), newState) !== undefined; - } + var transition_for = this.lookup_transition_for(this.state(), newState); - /* todo whargarbl re-enable force_transition/1 after implementing this - valid_force_transition(newState : mNT, newData? : mDT) : boolean { - return false; // major todo whargarbl + if (!transition_for) { + return false; + } + if (transition_for.forced_only) { + return false; } - */ + return true; + } + }, { + key: 'valid_force_transition', + value: function valid_force_transition(newState, _newData) { + // todo comeback unignore newData + // todo whargarbl implement hooks + // todo whargarbl implement data stuff + // todo major incomplete whargarbl comeback + return this.lookup_transition_for(this.state(), newState) !== undefined; + } }]); - return machine; + return Machine; }(); +function sm(template_strings /* , arguments */) { + var _arguments = arguments; + + + // foo`a${1}b${2}c` will come in as (['a','b','c'],1,2) + // this includes when a and c are empty strings + // therefore template_strings will always have one more el than template_args + // therefore map the smaller container and toss the last one on on the way out + + return new Machine(make(template_strings.reduce( + + // in general avoiding `arguments` is smart. however with the template + // string notation, as designed, it's not really worth the hassle + + /* eslint-disable fp/no-arguments */ + /* eslint-disable prefer-rest-params */ + function (acc, val, idx) { + return '' + acc + _arguments[idx] + val; + } // arguments[0] is never loaded, so args doesn't need to be gated + /* eslint-enable prefer-rest-params */ + /* eslint-enable fp/no-arguments */ + + ))); +} + exports.version = version; -exports.machine = machine; +exports.Machine = Machine; +exports.make = make; exports.parse = parse; +exports.compile = compile; +exports.sm = sm; +exports.arrow_direction = arrow_direction; +exports.arrow_left_kind = arrow_left_kind; +exports.arrow_right_kind = arrow_right_kind; exports.seq = _jssmUtil.seq; exports.weighted_rand_select = _jssmUtil.weighted_rand_select; exports.histograph = _jssmUtil.histograph; diff --git a/dist/jssm.es5.cjs.min.js b/dist/jssm.es5.cjs.min.js index ec378911..663750b2 100644 --- a/dist/jssm.es5.cjs.min.js +++ b/dist/jssm.es5.cjs.min.js @@ -1 +1 @@ -require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n||e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o0){for(i=1,j=1;ipeg$maxFailPos&&(peg$maxFailPos=peg$currPos,peg$maxFailExpected=[]),peg$maxFailExpected.push(expected))}function peg$buildStructuredError(expected,found,location){return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected,found),expected,found,location)}function peg$parseDocument(){var s0,s2;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED&&(s2=peg$parseTermList())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c0(s2)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseGvizShape(){var s0;return input.substr(peg$currPos,6)===peg$c1?(s0=peg$c1,peg$currPos+=6):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c2)),s0===peg$FAILED&&(input.substr(peg$currPos,9)===peg$c3?(s0=peg$c3,peg$currPos+=9):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c4)),s0===peg$FAILED&&(input.substr(peg$currPos,6)===peg$c5?(s0=peg$c5,peg$currPos+=6):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c6)))),s0}function peg$parseForwardLightArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,2)===peg$c8?(s0=peg$c8,peg$currPos+=2):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c9)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c7),s0}function peg$parseTwoWayLightArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,3)===peg$c11?(s0=peg$c11,peg$currPos+=3):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c12)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c10),s0}function peg$parseForwardFatArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,2)===peg$c14?(s0=peg$c14,peg$currPos+=2):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c15)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c13),s0}function peg$parseTwoWayFatArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,3)===peg$c17?(s0=peg$c17,peg$currPos+=3):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c18)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c16),s0}function peg$parseForwardTildeArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,2)===peg$c20?(s0=peg$c20,peg$currPos+=2):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c21)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c19),s0}function peg$parseTwoWayTildeArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,3)===peg$c23?(s0=peg$c23,peg$currPos+=3):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c24)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c22),s0}function peg$parseLightArrow(){var s0;return peg$silentFails++,(s0=peg$parseForwardLightArrow())===peg$FAILED&&(s0=peg$parseTwoWayLightArrow()),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c25),s0}function peg$parseFatArrow(){var s0;return peg$silentFails++,(s0=peg$parseForwardFatArrow())===peg$FAILED&&(s0=peg$parseTwoWayFatArrow()),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c26),s0}function peg$parseTildeArrow(){var s0;return peg$silentFails++,(s0=peg$parseForwardTildeArrow())===peg$FAILED&&(s0=peg$parseTwoWayTildeArrow()),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c27),s0}function peg$parseArrow(){var s0;return peg$silentFails++,(s0=peg$parseLightArrow())===peg$FAILED&&(s0=peg$parseFatArrow())===peg$FAILED&&(s0=peg$parseTildeArrow()),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c28),s0}function peg$parseHexDigit(){var s0;return peg$c29.test(input.charAt(peg$currPos))?(s0=input.charAt(peg$currPos),peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c30)),s0}function peg$parseChar(){var s0,s2,s3,s4,s5,s6,s7,s8,s9;return(s0=peg$parseUnescaped())===peg$FAILED&&(s0=peg$currPos,peg$parseEscape()!==peg$FAILED?(34===input.charCodeAt(peg$currPos)?(s2=peg$c31,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c32)),s2===peg$FAILED&&(92===input.charCodeAt(peg$currPos)?(s2=peg$c33,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c34)),s2===peg$FAILED&&(47===input.charCodeAt(peg$currPos)?(s2=peg$c35,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c36)),s2===peg$FAILED&&(s2=peg$currPos,98===input.charCodeAt(peg$currPos)?(s3=peg$c37,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c38)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c39()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,102===input.charCodeAt(peg$currPos)?(s3=peg$c40,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c41)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c42()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,110===input.charCodeAt(peg$currPos)?(s3=peg$c43,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c44)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c45()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,114===input.charCodeAt(peg$currPos)?(s3=peg$c46,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c47)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c48()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,116===input.charCodeAt(peg$currPos)?(s3=peg$c49,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c50)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c51()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,118===input.charCodeAt(peg$currPos)?(s3=peg$c52,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c53)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c54()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,117===input.charCodeAt(peg$currPos)?(s3=peg$c55,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c56)),s3!==peg$FAILED?(s4=peg$currPos,s5=peg$currPos,(s6=peg$parseHexDigit())!==peg$FAILED&&(s7=peg$parseHexDigit())!==peg$FAILED&&(s8=peg$parseHexDigit())!==peg$FAILED&&(s9=peg$parseHexDigit())!==peg$FAILED?s5=s6=[s6,s7,s8,s9]:(peg$currPos=s5,s5=peg$FAILED),(s4=s5!==peg$FAILED?input.substring(s4,peg$currPos):s5)!==peg$FAILED?(peg$savedPos=s2,s2=s3=peg$c57(s4)):(peg$currPos=s2,s2=peg$FAILED)):(peg$currPos=s2,s2=peg$FAILED)))))))))),s2!==peg$FAILED?(peg$savedPos=s0,s0=peg$c58(s2)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)),s0}function peg$parseEscape(){var s0;return 92===input.charCodeAt(peg$currPos)?(s0=peg$c33,peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c34)),s0}function peg$parseQuoteMark(){var s0;return 34===input.charCodeAt(peg$currPos)?(s0=peg$c31,peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c32)),s0}function peg$parseUnescaped(){var s0;return peg$c59.test(input.charAt(peg$currPos))?(s0=input.charAt(peg$currPos),peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c60)),s0}function peg$parseActionLabelChar(){var s0,s2,s3,s4,s5,s6,s7,s8,s9;return(s0=peg$parseActionLabelUnescaped())===peg$FAILED&&(s0=peg$currPos,peg$parseEscape()!==peg$FAILED?(96===input.charCodeAt(peg$currPos)?(s2=peg$c61,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c62)),s2===peg$FAILED&&(92===input.charCodeAt(peg$currPos)?(s2=peg$c33,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c34)),s2===peg$FAILED&&(47===input.charCodeAt(peg$currPos)?(s2=peg$c35,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c36)),s2===peg$FAILED&&(s2=peg$currPos,98===input.charCodeAt(peg$currPos)?(s3=peg$c37,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c38)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c39()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,102===input.charCodeAt(peg$currPos)?(s3=peg$c40,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c41)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c42()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,110===input.charCodeAt(peg$currPos)?(s3=peg$c43,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c44)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c45()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,114===input.charCodeAt(peg$currPos)?(s3=peg$c46,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c47)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c48()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,116===input.charCodeAt(peg$currPos)?(s3=peg$c49,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c50)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c51()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,118===input.charCodeAt(peg$currPos)?(s3=peg$c52,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c53)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c54()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,117===input.charCodeAt(peg$currPos)?(s3=peg$c55,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c56)),s3!==peg$FAILED?(s4=peg$currPos,s5=peg$currPos,(s6=peg$parseHexDigit())!==peg$FAILED&&(s7=peg$parseHexDigit())!==peg$FAILED&&(s8=peg$parseHexDigit())!==peg$FAILED&&(s9=peg$parseHexDigit())!==peg$FAILED?s5=s6=[s6,s7,s8,s9]:(peg$currPos=s5,s5=peg$FAILED),(s4=s5!==peg$FAILED?input.substring(s4,peg$currPos):s5)!==peg$FAILED?(peg$savedPos=s2,s2=s3=peg$c57(s4)):(peg$currPos=s2,s2=peg$FAILED)):(peg$currPos=s2,s2=peg$FAILED)))))))))),s2!==peg$FAILED?(peg$savedPos=s0,s0=peg$c58(s2)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)),s0}function peg$parseActionLabelQuoteMark(){var s0;return 96===input.charCodeAt(peg$currPos)?(s0=peg$c61,peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c62)),s0}function peg$parseActionLabelUnescaped(){var s0;return peg$c63.test(input.charAt(peg$currPos))?(s0=input.charAt(peg$currPos),peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c64)),s0}function peg$parseActionLabel(){var s0,s2,s3;if(peg$silentFails++,s0=peg$currPos,peg$parseActionLabelQuoteMark()!==peg$FAILED){for(s2=[],s3=peg$parseActionLabelChar();s3!==peg$FAILED;)s2.push(s3),s3=peg$parseActionLabelChar();s2!==peg$FAILED&&(s3=peg$parseActionLabelQuoteMark())!==peg$FAILED?(peg$savedPos=s0,s0=peg$c66(s2)):(peg$currPos=s0,s0=peg$FAILED)}else peg$currPos=s0,s0=peg$FAILED;return peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c65),s0}function peg$parseWhitespace(){var s0,s1;for(peg$silentFails++,s0=[],peg$c68.test(input.charAt(peg$currPos))?(s1=input.charAt(peg$currPos),peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c69));s1!==peg$FAILED;)s0.push(s1),peg$c68.test(input.charAt(peg$currPos))?(s1=input.charAt(peg$currPos),peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c69));return peg$silentFails--,s0===peg$FAILED&&(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c67)),s0}function peg$parseString(){var s0,s2,s3;if(peg$silentFails++,s0=peg$currPos,peg$parseQuoteMark()!==peg$FAILED){for(s2=[],s3=peg$parseChar();s3!==peg$FAILED;)s2.push(s3),s3=peg$parseChar();s2!==peg$FAILED&&(s3=peg$parseQuoteMark())!==peg$FAILED?(peg$savedPos=s0,s0=peg$c66(s2)):(peg$currPos=s0,s0=peg$FAILED)}else peg$currPos=s0,s0=peg$FAILED;return peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c70),s0}function peg$parseAtom(){var s0,s1,s2;if(peg$silentFails++,s0=peg$currPos,s1=[],peg$c72.test(input.charAt(peg$currPos))?(s2=input.charAt(peg$currPos),peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c73)),s2!==peg$FAILED)for(;s2!==peg$FAILED;)s1.push(s2),peg$c72.test(input.charAt(peg$currPos))?(s2=input.charAt(peg$currPos),peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c73));else s1=peg$FAILED;return s1!==peg$FAILED&&(peg$savedPos=s0,s1=peg$c74(s1)),s0=s1,peg$silentFails--,s0===peg$FAILED&&(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c71)),s0}function peg$parseLabel(){var s0;return peg$silentFails++,(s0=peg$parseAtom())===peg$FAILED&&(s0=peg$parseString()),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c75),s0}function peg$parseColor(){var s0;return peg$silentFails++,input.substr(peg$currPos,3)===peg$c77?(s0=peg$c77,peg$currPos+=3):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c78)),s0===peg$FAILED&&(input.substr(peg$currPos,5)===peg$c79?(s0=peg$c79,peg$currPos+=5):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c80)),s0===peg$FAILED&&(input.substr(peg$currPos,4)===peg$c81?(s0=peg$c81,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c82)))),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c76),s0}function peg$parseArrowItemKey(){var s0;return input.substr(peg$currPos,9)===peg$c83?(s0=peg$c83,peg$currPos+=9):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c84)),s0===peg$FAILED&&(input.substr(peg$currPos,10)===peg$c85?(s0=peg$c85,peg$currPos+=10):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c86)),s0===peg$FAILED&&(input.substr(peg$currPos,10)===peg$c87?(s0=peg$c87,peg$currPos+=10):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c88)))),s0}function peg$parseArrowItem(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED&&(s2=peg$parseArrowItemKey())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseLabel())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c93(s2,s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseSingleEdgeColor(){var s0,s2,s4,s6,s8;return peg$silentFails++,s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,10)===peg$c95?(s2=peg$c95,peg$currPos+=10):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c96)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseColor())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c97(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c94),s0}function peg$parseArrowItems(){var s0,s1;if((s0=peg$parseSingleEdgeColor())===peg$FAILED)if(s0=[],(s1=peg$parseArrowItem())!==peg$FAILED)for(;s1!==peg$FAILED;)s0.push(s1),s1=peg$parseArrowItem();else s0=peg$FAILED;return s0}function peg$parseArrowDesc(){var s0,s1,s3,s5;return s0=peg$currPos,123===input.charCodeAt(peg$currPos)?(s1=peg$c98,peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c99)),s1!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s3=peg$parseArrowItems())===peg$FAILED&&(s3=null),s3!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(125===input.charCodeAt(peg$currPos)?(s5=peg$c100,peg$currPos++):(s5=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c101)),s5!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c102(s3)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseLabelList(){var s0,s1,s3,s4,s5,s6;if(s0=peg$currPos,91===input.charCodeAt(peg$currPos)?(s1=peg$c103,peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c104)),s1!==peg$FAILED)if(peg$parseWhitespace()!==peg$FAILED){for(s3=[],s4=peg$currPos,(s5=peg$parseLabel())!==peg$FAILED&&(s6=peg$parseWhitespace())!==peg$FAILED?s4=s5=[s5,s6]:(peg$currPos=s4,s4=peg$FAILED);s4!==peg$FAILED;)s3.push(s4),s4=peg$currPos,(s5=peg$parseLabel())!==peg$FAILED&&(s6=peg$parseWhitespace())!==peg$FAILED?s4=s5=[s5,s6]:(peg$currPos=s4,s4=peg$FAILED);s3!==peg$FAILED?(93===input.charCodeAt(peg$currPos)?(s4=peg$c105,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c106)),s4!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c107(s3)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)}else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;return s0}function peg$parseLabelOrLabelList(){var s0;return(s0=peg$parseLabelList())===peg$FAILED&&(s0=peg$parseLabel()),s0}function peg$parseSubexp(){var s0,s2,s4,s6,s8,s10,s12,s14;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?((s2=peg$parseActionLabel())===peg$FAILED&&(s2=null),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s4=peg$parseArrowDesc())===peg$FAILED&&(s4=null),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseArrow())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s8=peg$parseArrowDesc())===peg$FAILED&&(s8=null),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s10=peg$parseActionLabel())===peg$FAILED&&(s10=null),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s12=peg$parseLabelOrLabelList())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s14=peg$parseSubexp())===peg$FAILED&&(s14=null),s14!==peg$FAILED?(peg$savedPos=s0,s0=peg$c108(s2,s4,s6,s8,s10,s12,s14)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseExp(){var s0,s1,s2,s4;return s0=peg$currPos,(s1=peg$parseLabelOrLabelList())!==peg$FAILED&&(s2=peg$parseSubexp())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s4=peg$c91,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c109(s1,s2)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseValidationKey(){var s0;return input.substr(peg$currPos,9)===peg$c110?(s0=peg$c110,peg$currPos+=9):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c111)),s0===peg$FAILED&&(input.substr(peg$currPos,4)===peg$c112?(s0=peg$c112,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c113))),s0}function peg$parseValidationItem(){var s0,s1,s2,s3,s4;return s0=peg$currPos,(s1=peg$parseValidationKey())!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s2=peg$c89,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s2!==peg$FAILED&&(s3=peg$parseLabel())!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s4=peg$c91,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s4!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c114(s1,s3)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseValidationItems(){var s0,s1;if(s0=[],(s1=peg$parseValidationItem())!==peg$FAILED)for(;s1!==peg$FAILED;)s0.push(s1),s1=peg$parseValidationItem();else s0=peg$FAILED;return s0}function peg$parseConfigValidation(){var s0,s2,s4,s6,s8,s10;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,10)===peg$c115?(s2=peg$c115,peg$currPos+=10):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c116)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(123===input.charCodeAt(peg$currPos)?(s6=peg$c98,peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c99)),s6!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s8=peg$parseValidationItems())===peg$FAILED&&(s8=null),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,2)===peg$c117?(s10=peg$c117,peg$currPos+=2):(s10=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c118)),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c119(s8)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseGvizLayout(){var s0;return input.substr(peg$currPos,3)===peg$c120?(s0=peg$c120,peg$currPos+=3):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c121)),s0===peg$FAILED&&(input.substr(peg$currPos,5)===peg$c122?(s0=peg$c122,peg$currPos+=5):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c123))),s0}function peg$parseStateItemShapeKey(){var s0;return input.substr(peg$currPos,8)===peg$c124?(s0=peg$c124,peg$currPos+=8):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c125)),s0===peg$FAILED&&(input.substr(peg$currPos,9)===peg$c126?(s0=peg$c126,peg$currPos+=9):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c127)),s0===peg$FAILED&&(input.substr(peg$currPos,10)===peg$c128?(s0=peg$c128,peg$currPos+=10):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c129)))),s0}function peg$parseStateItemShape(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED&&(s2=peg$parseStateItemShapeKey())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseGvizShape())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c93(s2,s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseStateItemGraphLayout(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,12)===peg$c130?(s2=peg$c130,peg$currPos+=12):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c131)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseGvizLayout())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c132(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseStateItem(){var s0;return(s0=peg$parseStateItemShape())===peg$FAILED&&(s0=peg$parseStateItemGraphLayout()),s0}function peg$parseStateItems(){var s0,s1;if(s0=[],(s1=peg$parseStateItem())!==peg$FAILED)for(;s1!==peg$FAILED;)s0.push(s1),s1=peg$parseStateItem();else s0=peg$FAILED;return s0}function peg$parseConfigState(){var s0,s2,s4,s6,s8,s10;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,5)===peg$c133?(s2=peg$c133,peg$currPos+=5):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c134)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(123===input.charCodeAt(peg$currPos)?(s6=peg$c98,peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c99)),s6!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s8=peg$parseStateItems())===peg$FAILED&&(s8=null),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,2)===peg$c117?(s10=peg$c117,peg$currPos+=2):(s10=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c118)),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c135(s8)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseActionKey(){var s0;return input.substr(peg$currPos,9)===peg$c110?(s0=peg$c110,peg$currPos+=9):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c111)),s0===peg$FAILED&&(input.substr(peg$currPos,4)===peg$c112?(s0=peg$c112,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c113))),s0}function peg$parseActionItem(){var s0,s1,s2,s3,s4;return s0=peg$currPos,(s1=peg$parseActionKey())!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s2=peg$c89,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s2!==peg$FAILED&&(s3=peg$parseLabel())!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s4=peg$c91,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s4!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c136(s1,s3)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseActionItems(){var s0,s1;if(s0=[],(s1=peg$parseActionItem())!==peg$FAILED)for(;s1!==peg$FAILED;)s0.push(s1),s1=peg$parseActionItem();else s0=peg$FAILED;return s0}function peg$parseConfigAction(){var s0,s2,s4,s6,s8,s10;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,6)===peg$c137?(s2=peg$c137,peg$currPos+=6):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c138)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(123===input.charCodeAt(peg$currPos)?(s6=peg$c98,peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c99)),s6!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s8=peg$parseActionItems())===peg$FAILED&&(s8=null),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,2)===peg$c117?(s10=peg$c117,peg$currPos+=2):(s10=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c118)),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c139(s8)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseTransitionKey(){var s0;return input.substr(peg$currPos,9)===peg$c110?(s0=peg$c110,peg$currPos+=9):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c111)),s0===peg$FAILED&&(input.substr(peg$currPos,4)===peg$c112?(s0=peg$c112,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c113))),s0}function peg$parseTransitionItem(){var s0,s1,s2,s3,s4;return s0=peg$currPos,(s1=peg$parseTransitionKey())!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s2=peg$c89,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s2!==peg$FAILED&&(s3=peg$parseLabel())!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s4=peg$c91,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s4!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c140(s1,s3)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseTransitionItems(){var s0,s1;if((s0=peg$parseGraphDefaultEdgeColor())===peg$FAILED)if(s0=[],(s1=peg$parseTransitionItem())!==peg$FAILED)for(;s1!==peg$FAILED;)s0.push(s1),s1=peg$parseTransitionItem();else s0=peg$FAILED;return s0}function peg$parseGraphDefaultEdgeColor(){var s0,s2,s4,s6,s8;return peg$silentFails++,s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,10)===peg$c95?(s2=peg$c95,peg$currPos+=10):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c96)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseColor())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c142(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c141),s0}function peg$parseConfigTransition(){var s0,s2,s4,s6,s8,s10;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,10)===peg$c143?(s2=peg$c143,peg$currPos+=10):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c144)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(123===input.charCodeAt(peg$currPos)?(s6=peg$c98,peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c99)),s6!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s8=peg$parseTransitionItems())===peg$FAILED&&(s8=null),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,2)===peg$c117?(s10=peg$c117,peg$currPos+=2):(s10=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c118)),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c145(s8)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseGraphBg(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,8)===peg$c146?(s2=peg$c146,peg$currPos+=8):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c147)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseGvizShape())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c148(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseMinTransitionsPerState(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,25)===peg$c149?(s2=peg$c149,peg$currPos+=25):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c150)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseLabel())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c151(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseMaxTransitionsPerState(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,25)===peg$c152?(s2=peg$c152,peg$currPos+=25):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c153)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseLabel())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c154(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseGraphInputs(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,6)===peg$c155?(s2=peg$c155,peg$currPos+=6):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c156)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseLabelList())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c157(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseGraphOutputs(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,7)===peg$c158?(s2=peg$c158,peg$currPos+=7):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c159)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseLabelList())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c160(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseGraphStartNodes(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,11)===peg$c161?(s2=peg$c161,peg$currPos+=11):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c162)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseLabelList())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c163(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseGraphEndNodes(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,9)===peg$c164?(s2=peg$c164,peg$currPos+=9):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c165)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseLabelList())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c166(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseGraphItem(){var s0;return(s0=peg$parseGraphBg())===peg$FAILED&&(s0=peg$parseMinTransitionsPerState())===peg$FAILED&&(s0=peg$parseMaxTransitionsPerState())===peg$FAILED&&(s0=peg$parseGraphStartNodes())===peg$FAILED&&(s0=peg$parseGraphEndNodes())===peg$FAILED&&(s0=peg$parseGraphInputs())===peg$FAILED&&(s0=peg$parseGraphOutputs()),s0}function peg$parseGraphItems(){var s0,s1;if(s0=[],(s1=peg$parseGraphItem())!==peg$FAILED)for(;s1!==peg$FAILED;)s0.push(s1),s1=peg$parseGraphItem();else s0=peg$FAILED;return s0}function peg$parseConfigGraph(){var s0,s2,s4,s6,s8,s10;return peg$silentFails++,s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,5)===peg$c168?(s2=peg$c168,peg$currPos+=5):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c169)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(123===input.charCodeAt(peg$currPos)?(s6=peg$c98,peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c99)),s6!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s8=peg$parseGraphItems())===peg$FAILED&&(s8=null),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,2)===peg$c117?(s10=peg$c117,peg$currPos+=2):(s10=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c118)),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c170(s8)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c167),s0}function peg$parseConfig(){var s0;return peg$silentFails++,(s0=peg$parseConfigGraph())===peg$FAILED&&(s0=peg$parseConfigTransition())===peg$FAILED&&(s0=peg$parseConfigAction())===peg$FAILED&&(s0=peg$parseConfigState())===peg$FAILED&&(s0=peg$parseConfigValidation()),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c171),s0}function peg$parseStateColor(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,5)===peg$c172?(s2=peg$c172,peg$currPos+=5):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c173)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseColor())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c174(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseArbitraryStateQuality(){var s0,s2,s4,s6,s8;return peg$silentFails++,s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED&&(s2=peg$parseLabel())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c89,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseLabel())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c91,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c176(s2,s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c175),s0}function peg$parseStateQuality(){var s0;return(s0=peg$parseStateColor())===peg$FAILED&&(s0=peg$parseArbitraryStateQuality()),s0}function peg$parseStateDef(){var s0,s2,s4,s6,s8,s9,s10,s12;if(peg$silentFails++,s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED)if(input.substr(peg$currPos,5)===peg$c133?(s2=peg$c133,peg$currPos+=5):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c134)),s2!==peg$FAILED)if(peg$parseWhitespace()!==peg$FAILED)if((s4=peg$parseLabel())!==peg$FAILED)if(peg$parseWhitespace()!==peg$FAILED)if(91===input.charCodeAt(peg$currPos)?(s6=peg$c103,peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c104)),s6!==peg$FAILED)if(peg$parseWhitespace()!==peg$FAILED){for(s8=[],s9=peg$parseStateQuality();s9!==peg$FAILED;)s8.push(s9),s9=peg$parseStateQuality();s8!==peg$FAILED&&(s9=peg$parseWhitespace())!==peg$FAILED?(93===input.charCodeAt(peg$currPos)?(s10=peg$c105,peg$currPos++):(s10=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c106)),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s12=peg$c91,peg$currPos++):(s12=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s12!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c178(s4,s8)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)}else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;return peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c177),s0}function peg$parseTerm(){var s0;return(s0=peg$parseExp())===peg$FAILED&&(s0=peg$parseStateDef())===peg$FAILED&&(s0=peg$parseConfig()),s0}function peg$parseTermList(){var s0,s1;for(s0=[],s1=peg$parseTerm();s1!==peg$FAILED;)s0.push(s1),s1=peg$parseTerm();return s0}options=void 0!==options?options:{};var peg$result,peg$FAILED={},peg$startRuleFunctions={Document:peg$parseDocument},peg$startRuleFunction=peg$parseDocument,peg$c0=function(e){return e},peg$c1="square",peg$c2=peg$literalExpectation("square",!1),peg$c3="rectangle",peg$c4=peg$literalExpectation("rectangle",!1),peg$c5="circle",peg$c6=peg$literalExpectation("circle",!1),peg$c7=peg$otherExpectation("forward light arrow"),peg$c8="->",peg$c9=peg$literalExpectation("->",!1),peg$c10=peg$otherExpectation("two way light arrow"),peg$c11="<->",peg$c12=peg$literalExpectation("<->",!1),peg$c13=peg$otherExpectation("forward fat arrow"),peg$c14="=>",peg$c15=peg$literalExpectation("=>",!1),peg$c16=peg$otherExpectation("two way fat arrow"),peg$c17="<=>",peg$c18=peg$literalExpectation("<=>",!1),peg$c19=peg$otherExpectation("forward tilde arrow"),peg$c20="~>",peg$c21=peg$literalExpectation("~>",!1),peg$c22=peg$otherExpectation("two way tilde arrow"),peg$c23="<~>",peg$c24=peg$literalExpectation("<~>",!1),peg$c25=peg$otherExpectation("light arrow"),peg$c26=peg$otherExpectation("fat arrow"),peg$c27=peg$otherExpectation("tilde arrow"),peg$c28=peg$otherExpectation("arrow"),peg$c29=/^[0-9a-fA-F]/,peg$c30=peg$classExpectation([["0","9"],["a","f"],["A","F"]],!1,!1),peg$c31='"',peg$c32=peg$literalExpectation('"',!1),peg$c33="\\",peg$c34=peg$literalExpectation("\\",!1),peg$c35="/",peg$c36=peg$literalExpectation("/",!1),peg$c37="b",peg$c38=peg$literalExpectation("b",!1),peg$c39=function(){return"\b"},peg$c40="f",peg$c41=peg$literalExpectation("f",!1),peg$c42=function(){return"\f"},peg$c43="n",peg$c44=peg$literalExpectation("n",!1),peg$c45=function(){return"\n"},peg$c46="r",peg$c47=peg$literalExpectation("r",!1),peg$c48=function(){return"\r"},peg$c49="t",peg$c50=peg$literalExpectation("t",!1),peg$c51=function(){return"\t"},peg$c52="v",peg$c53=peg$literalExpectation("v",!1),peg$c54=function(){return"\v"},peg$c55="u",peg$c56=peg$literalExpectation("u",!1),peg$c57=function(digits){return String.fromCharCode(parseInt(digits,16))},peg$c58=function(Sequence){return Sequence},peg$c59=/^[ -!#-[\]-\u10FFFF]/,peg$c60=peg$classExpectation([[" ","!"],["#","["],["]","ჿ"],"F","F"],!1,!1),peg$c61="`",peg$c62=peg$literalExpectation("`",!1),peg$c63=/^[ -[\]-_a-\u10FFFF]/,peg$c64=peg$classExpectation([[" ","["],["]","_"],["a","ჿ"],"F","F"],!1,!1),peg$c65=peg$otherExpectation("action label"),peg$c66=function(chars){return chars.join("")},peg$c67=peg$otherExpectation("whitespace"),peg$c68=/^[ \t\n\r\x0B]/,peg$c69=peg$classExpectation([" ","\t","\n","\r","\v"],!1,!1),peg$c70=peg$otherExpectation("string"),peg$c71=peg$otherExpectation("atom"),peg$c72=/^[0-9a-zA-Z.+_&()%$#@!?,']/,peg$c73=peg$classExpectation([["0","9"],["a","z"],["A","Z"],".","+","_","&","(",")","%","$","#","@","!","?",",","'"],!1,!1),peg$c74=function(text){return text.join("")},peg$c75=peg$otherExpectation("label"),peg$c76=peg$otherExpectation("color"),peg$c77="red",peg$c78=peg$literalExpectation("red",!1),peg$c79="green",peg$c80=peg$literalExpectation("green",!1),peg$c81="blue",peg$c82=peg$literalExpectation("blue",!1),peg$c83="arc_label",peg$c84=peg$literalExpectation("arc_label",!1),peg$c85="head_label",peg$c86=peg$literalExpectation("head_label",!1),peg$c87="tail_label",peg$c88=peg$literalExpectation("tail_label",!1),peg$c89=":",peg$c90=peg$literalExpectation(":",!1),peg$c91=";",peg$c92=peg$literalExpectation(";",!1),peg$c93=function(key,value){return{key:key,value:value}},peg$c94=peg$otherExpectation("single edge color"),peg$c95="edge_color",peg$c96=peg$literalExpectation("edge_color",!1),peg$c97=function(value){return{key:"single_edge_color",value:value}},peg$c98="{",peg$c99=peg$literalExpectation("{",!1),peg$c100="}",peg$c101=peg$literalExpectation("}",!1),peg$c102=function(items){return items},peg$c103="[",peg$c104=peg$literalExpectation("[",!1),peg$c105="]",peg$c106=peg$literalExpectation("]",!1),peg$c107=function(names){return names.map(function(i){return i[0]})},peg$c108=function(lactl,ldesc,arrow,rdesc,ractl,label,tail){var base={kind:arrow,to:label};return tail&&tail!==[]&&(base.se=tail),ldesc&&(base.ldesc=ldesc),rdesc&&(base.rdesc=rdesc),base},peg$c109=function(label,se){var base={from:label};return se&&se!==[]&&(base.se=se),base},peg$c110="whargarbl",peg$c111=peg$literalExpectation("whargarbl",!1),peg$c112="todo",peg$c113=peg$literalExpectation("todo",!1),peg$c114=function(validationkey,value){return{key:validationkey,value:value}},peg$c115="validation",peg$c116=peg$literalExpectation("validation",!1),peg$c117="};",peg$c118=peg$literalExpectation("};",!1),peg$c119=function(validation_items){return{config_kind:"validation",config_items:validation_items||[]}},peg$c120="dot",peg$c121=peg$literalExpectation("dot",!1),peg$c122="circo",peg$c123=peg$literalExpectation("circo",!1),peg$c124="in_shape",peg$c125=peg$literalExpectation("in_shape",!1),peg$c126="out_shape",peg$c127=peg$literalExpectation("out_shape",!1),peg$c128="node_shape",peg$c129=peg$literalExpectation("node_shape",!1),peg$c130="graph_layout",peg$c131=peg$literalExpectation("graph_layout",!1),peg$c132=function(value){return{key:"graph_layout",value:value}},peg$c133="state",peg$c134=peg$literalExpectation("state",!1),peg$c135=function(state_items){return{config_kind:"state",config_items:state_items||[]}},peg$c136=function(actionkey,value){return{key:actionkey,value:value}},peg$c137="action",peg$c138=peg$literalExpectation("action",!1),peg$c139=function(action_items){return{config_kind:"action",config_items:action_items||[]}},peg$c140=function(transitionkey,value){return{key:transitionkey,value:value}},peg$c141=peg$otherExpectation("graph default edge color"),peg$c142=function(value){return{key:"graph_default_edge_color",value:value}},peg$c143="transition",peg$c144=peg$literalExpectation("transition",!1),peg$c145=function(transition_items){return{config_kind:"transition",config_items:transition_items||[]}},peg$c146="graph_bg",peg$c147=peg$literalExpectation("graph_bg",!1),peg$c148=function(value){return{key:"graph_bg",value:value}},peg$c149="min_transitions_per_state",peg$c150=peg$literalExpectation("min_transitions_per_state",!1),peg$c151=function(value){return{key:"min_transitions_per_state",value:value}},peg$c152="max_transitions_per_state",peg$c153=peg$literalExpectation("max_transitions_per_state",!1),peg$c154=function(value){return{key:"max_transitions_per_state",value:value}},peg$c155="inputs",peg$c156=peg$literalExpectation("inputs",!1),peg$c157=function(value){return{key:"inputs",value:value}},peg$c158="outputs",peg$c159=peg$literalExpectation("outputs",!1),peg$c160=function(value){return{key:"outputs",value:value}},peg$c161="start_nodes",peg$c162=peg$literalExpectation("start_nodes",!1),peg$c163=function(value){return{key:"start_nodes",value:value}},peg$c164="end_nodes",peg$c165=peg$literalExpectation("end_nodes",!1),peg$c166=function(value){return{key:"end_nodes",value:value}},peg$c167=peg$otherExpectation("graph configuration"),peg$c168="graph",peg$c169=peg$literalExpectation("graph",!1),peg$c170=function(graph_items){return{config_kind:"graph",config_items:graph_items||[]}},peg$c171=peg$otherExpectation("configuration"),peg$c172="color",peg$c173=peg$literalExpectation("color",!1),peg$c174=function(value){return{key:"state color",value:value}},peg$c175=peg$otherExpectation("state quality"),peg$c176=function(name,value){return{key:"state quality",name:name,value:value}},peg$c177=peg$otherExpectation("state definition"),peg$c178=function(name,sq){return{key:"State qualities",value:sq}},peg$currPos=0,peg$savedPos=0,peg$posDetailsCache=[{line:1,column:1}],peg$maxFailPos=0,peg$maxFailExpected=[],peg$silentFails=0;if("startRule"in options){if(!(options.startRule in peg$startRuleFunctions))throw new Error("Can't start parsing from rule \""+options.startRule+'".');peg$startRuleFunction=peg$startRuleFunctions[options.startRule]}if((peg$result=peg$startRuleFunction())!==peg$FAILED&&peg$currPos===input.length)return peg$result;throw peg$result!==peg$FAILED&&peg$currPos1&&void 0!==arguments[1]?arguments[1]:"probability";if(!Array.isArray(options))throw new TypeError("options must be a non-empty array of objects");if("object"!==_typeof(options[0]))throw new TypeError("options must be a non-empty array of objects");for(var or_one=function(item){return void 0===item?1:item},rnd=function(cap){return Math.random()*cap}(options.reduce(function(acc,val){return acc+or_one(val[probability_property])},0)),cursor=0,cursor_sum=0;(cursor_sum+=options[cursor++][probability_property])<=rnd;);return options[cursor-1]},seq=function(n){return new Array(n).fill(!0).map(function(_,i){return i})},histograph=function(a){return a.sort().reduce(function(m,v){return m.set(v,m.has(v)?m.get(v)+1:1),m},new Map)},weighted_sample_select=function(n,options,probability_property){return seq(n).map(function(i){return weighted_rand_select(options,probability_property)})};exports.seq=seq,exports.histograph=histograph,exports.weighted_histo_key=function(n,options,probability_property,extract){return histograph(weighted_sample_select(n,options,probability_property).map(function(s){return s[extract]}))},exports.weighted_rand_select=weighted_rand_select,exports.weighted_sample_select=weighted_sample_select},{}],jssm:[function(require,module,exports){"use strict";function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i0&&void 0!==arguments[0]?arguments[0]:this.state();return{entrances:this.list_entrances(whichState),exits:this.list_exits(whichState)}}},{key:"list_entrances",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return(this._states.get(whichState)||{}).from||[]}},{key:"list_exits",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return(this._states.get(whichState)||{}).to||[]}},{key:"probable_exits_for",value:function(whichState){var _this2=this,wstate=this._states.get(whichState);if(!wstate)throw new Error("No such state "+JSON.stringify(whichState)+" in probable_exits_for");return wstate.to.map(function(ws){return _this2.lookup_transition_for(_this2.state(),ws)}).filter(function(defined){return defined})}},{key:"probabilistic_transition",value:function(){var selected=(0,_jssmUtil.weighted_rand_select)(this.probable_exits_for(this.state()));return this.transition(selected.to)}},{key:"probabilistic_walk",value:function(n){var _this3=this;return(0,_jssmUtil.seq)(n).map(function(){var state_was=_this3.state();return _this3.probabilistic_transition(),state_was}).concat([this.state()])}},{key:"probabilistic_histo_walk",value:function(n){return(0,_jssmUtil.histograph)(this.probabilistic_walk(n))}},{key:"actions",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state(),wstate=this._reverse_actions.get(whichState);if(wstate)return[].concat(_toConsumableArray(wstate.keys()));throw new Error("No such state "+JSON.stringify(whichState))}},{key:"list_states_having_action",value:function(whichState){var wstate=this._actions.get(whichState);if(wstate)return[].concat(_toConsumableArray(wstate.keys()));throw new Error("No such state "+JSON.stringify(whichState))}},{key:"list_exit_actions",value:function(){var _this4=this,whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state(),ra_base=this._reverse_actions.get(whichState);if(!ra_base)throw new Error("No such state "+JSON.stringify(whichState));return[].concat(_toConsumableArray(ra_base.values())).map(function(edgeId){return _this4._edges[edgeId]}).filter(function(o){return o.from===whichState}).map(function(filtered){return filtered.action})}},{key:"probable_action_exits",value:function(){var _this5=this,whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state(),ra_base=this._reverse_actions.get(whichState);if(!ra_base)throw new Error("No such state "+JSON.stringify(whichState));return[].concat(_toConsumableArray(ra_base.values())).map(function(edgeId){return _this5._edges[edgeId]}).filter(function(o){return o.from===whichState}).map(function(filtered){return{action:filtered.action,probability:filtered.probability}})}},{key:"is_unenterable",value:function(whichState){return 0===this.list_entrances(whichState).length}},{key:"has_unenterables",value:function(){var _this6=this;return this.states().some(function(x){return _this6.is_unenterable(x)})}},{key:"is_terminal",value:function(){return this.state_is_terminal(this.state())}},{key:"state_is_terminal",value:function(whichState){return 0===this.list_exits(whichState).length}},{key:"has_terminals",value:function(){var _this7=this;return this.states().some(function(x){return _this7.state_is_terminal(x)})}},{key:"is_complete",value:function(){return this.state_is_complete(this.state())}},{key:"state_is_complete",value:function(whichState){var wstate=this._states.get(whichState);if(wstate)return wstate.complete;throw new Error("No such state "+JSON.stringify(whichState))}},{key:"has_completes",value:function(){var _this8=this;return this.states().some(function(x){return _this8.state_is_complete(x)})}},{key:"action",value:function(name,newData){if(this.valid_action(name,newData)){var edge=this.current_action_edge_for(name);return this._state=edge.to,!0}return!1}},{key:"transition",value:function(newState,newData){return!!this.valid_transition(newState,newData)&&(this._state=newState,!0)}},{key:"current_action_for",value:function(action){var action_base=this._actions.get(action);return action_base?action_base.get(this.state()):void 0}},{key:"current_action_edge_for",value:function(action){var idx=this.current_action_for(action);if(void 0===idx)throw new Error("No such action "+JSON.stringify(action));return this._edges[idx]}},{key:"valid_action",value:function(action,_newData){return void 0!==this.current_action_for(action)}},{key:"valid_transition",value:function(newState,_newData){return void 0!==this.lookup_transition_for(this.state(),newState)}}]),machine}();exports.version="3.9.3",exports.machine=machine,exports.parse=parse,exports.seq=_jssmUtil.seq,exports.weighted_rand_select=_jssmUtil.weighted_rand_select,exports.histograph=_jssmUtil.histograph,exports.weighted_sample_select=_jssmUtil.weighted_sample_select,exports.weighted_histo_key=_jssmUtil.weighted_histo_key},{"./jssm-dot.js":1,"./jssm-util.js":2}]},{},[]); \ No newline at end of file +require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n||e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o0){for(i=1,j=1;ipeg$maxFailPos&&(peg$maxFailPos=peg$currPos,peg$maxFailExpected=[]),peg$maxFailExpected.push(expected))}function peg$buildStructuredError(expected,found,location){return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected,found),expected,found,location)}function peg$parseDocument(){var s0,s2;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED&&(s2=peg$parseTermList())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c0(s2)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseGvizShape(){var s0;return input.substr(peg$currPos,6)===peg$c1?(s0=peg$c1,peg$currPos+=6):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c2)),s0===peg$FAILED&&(input.substr(peg$currPos,9)===peg$c3?(s0=peg$c3,peg$currPos+=9):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c4)),s0===peg$FAILED&&(input.substr(peg$currPos,6)===peg$c5?(s0=peg$c5,peg$currPos+=6):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c6)))),s0}function peg$parseForwardLightArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,2)===peg$c8?(s0=peg$c8,peg$currPos+=2):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c9)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c7),s0}function peg$parseTwoWayLightArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,3)===peg$c11?(s0=peg$c11,peg$currPos+=3):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c12)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c10),s0}function peg$parseBackLightArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,2)===peg$c14?(s0=peg$c14,peg$currPos+=2):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c15)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c13),s0}function peg$parseForwardFatArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,2)===peg$c17?(s0=peg$c17,peg$currPos+=2):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c18)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c16),s0}function peg$parseTwoWayFatArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,3)===peg$c20?(s0=peg$c20,peg$currPos+=3):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c21)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c19),s0}function peg$parseBackFatArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,2)===peg$c23?(s0=peg$c23,peg$currPos+=2):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c24)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c22),s0}function peg$parseForwardTildeArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,2)===peg$c26?(s0=peg$c26,peg$currPos+=2):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c27)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c25),s0}function peg$parseTwoWayTildeArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,3)===peg$c29?(s0=peg$c29,peg$currPos+=3):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c30)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c28),s0}function peg$parseBackTildeArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,2)===peg$c32?(s0=peg$c32,peg$currPos+=2):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c33)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c31),s0}function peg$parseLightFatArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,4)===peg$c35?(s0=peg$c35,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c36)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c34),s0}function peg$parseLightTildeArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,4)===peg$c38?(s0=peg$c38,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c39)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c37),s0}function peg$parseFatLightArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,4)===peg$c41?(s0=peg$c41,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c42)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c40),s0}function peg$parseFatTildeArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,4)===peg$c44?(s0=peg$c44,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c45)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c43),s0}function peg$parseTildeLightArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,4)===peg$c47?(s0=peg$c47,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c48)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c46),s0}function peg$parseTildeFatArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,4)===peg$c50?(s0=peg$c50,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c51)),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c49),s0}function peg$parseLightArrow(){var s0;return peg$silentFails++,(s0=peg$parseForwardLightArrow())===peg$FAILED&&(s0=peg$parseTwoWayLightArrow())===peg$FAILED&&(s0=peg$parseBackLightArrow()),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c52),s0}function peg$parseFatArrow(){var s0;return peg$silentFails++,(s0=peg$parseForwardFatArrow())===peg$FAILED&&(s0=peg$parseTwoWayFatArrow())===peg$FAILED&&(s0=peg$parseBackFatArrow()),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c53),s0}function peg$parseTildeArrow(){var s0;return peg$silentFails++,(s0=peg$parseForwardTildeArrow())===peg$FAILED&&(s0=peg$parseTwoWayTildeArrow())===peg$FAILED&&(s0=peg$parseBackTildeArrow()),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c54),s0}function peg$parseMixedArrow(){var s0;return peg$silentFails++,(s0=peg$parseLightFatArrow())===peg$FAILED&&(s0=peg$parseLightTildeArrow())===peg$FAILED&&(s0=peg$parseFatLightArrow())===peg$FAILED&&(s0=peg$parseFatTildeArrow())===peg$FAILED&&(s0=peg$parseTildeLightArrow())===peg$FAILED&&(s0=peg$parseTildeFatArrow()),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c55),s0}function peg$parseArrow(){var s0;return peg$silentFails++,(s0=peg$parseMixedArrow())===peg$FAILED&&(s0=peg$parseLightArrow())===peg$FAILED&&(s0=peg$parseFatArrow())===peg$FAILED&&(s0=peg$parseTildeArrow()),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c56),s0}function peg$parseHexDigit(){var s0;return peg$c57.test(input.charAt(peg$currPos))?(s0=input.charAt(peg$currPos),peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c58)),s0}function peg$parseChar(){var s0,s2,s3,s4,s5,s6,s7,s8,s9;return(s0=peg$parseUnescaped())===peg$FAILED&&(s0=peg$currPos,peg$parseEscape()!==peg$FAILED?(34===input.charCodeAt(peg$currPos)?(s2=peg$c59,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c60)),s2===peg$FAILED&&(92===input.charCodeAt(peg$currPos)?(s2=peg$c61,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c62)),s2===peg$FAILED&&(47===input.charCodeAt(peg$currPos)?(s2=peg$c63,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c64)),s2===peg$FAILED&&(s2=peg$currPos,98===input.charCodeAt(peg$currPos)?(s3=peg$c65,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c66)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c67()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,102===input.charCodeAt(peg$currPos)?(s3=peg$c68,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c69)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c70()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,110===input.charCodeAt(peg$currPos)?(s3=peg$c71,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c72)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c73()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,114===input.charCodeAt(peg$currPos)?(s3=peg$c74,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c75)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c76()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,116===input.charCodeAt(peg$currPos)?(s3=peg$c77,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c78)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c79()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,118===input.charCodeAt(peg$currPos)?(s3=peg$c80,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c81)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c82()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,117===input.charCodeAt(peg$currPos)?(s3=peg$c83,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c84)),s3!==peg$FAILED?(s4=peg$currPos,s5=peg$currPos,(s6=peg$parseHexDigit())!==peg$FAILED&&(s7=peg$parseHexDigit())!==peg$FAILED&&(s8=peg$parseHexDigit())!==peg$FAILED&&(s9=peg$parseHexDigit())!==peg$FAILED?s5=s6=[s6,s7,s8,s9]:(peg$currPos=s5,s5=peg$FAILED),(s4=s5!==peg$FAILED?input.substring(s4,peg$currPos):s5)!==peg$FAILED?(peg$savedPos=s2,s2=s3=peg$c85(s4)):(peg$currPos=s2,s2=peg$FAILED)):(peg$currPos=s2,s2=peg$FAILED)))))))))),s2!==peg$FAILED?(peg$savedPos=s0,s0=peg$c86(s2)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)),s0}function peg$parseEscape(){var s0;return 92===input.charCodeAt(peg$currPos)?(s0=peg$c61,peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c62)),s0}function peg$parseQuoteMark(){var s0;return 34===input.charCodeAt(peg$currPos)?(s0=peg$c59,peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c60)),s0}function peg$parseUnescaped(){var s0;return peg$c87.test(input.charAt(peg$currPos))?(s0=input.charAt(peg$currPos),peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c88)),s0}function peg$parseActionLabelChar(){var s0,s2,s3,s4,s5,s6,s7,s8,s9;return(s0=peg$parseActionLabelUnescaped())===peg$FAILED&&(s0=peg$currPos,peg$parseEscape()!==peg$FAILED?(39===input.charCodeAt(peg$currPos)?(s2=peg$c89,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s2===peg$FAILED&&(92===input.charCodeAt(peg$currPos)?(s2=peg$c61,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c62)),s2===peg$FAILED&&(47===input.charCodeAt(peg$currPos)?(s2=peg$c63,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c64)),s2===peg$FAILED&&(s2=peg$currPos,98===input.charCodeAt(peg$currPos)?(s3=peg$c65,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c66)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c67()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,102===input.charCodeAt(peg$currPos)?(s3=peg$c68,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c69)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c70()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,110===input.charCodeAt(peg$currPos)?(s3=peg$c71,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c72)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c73()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,114===input.charCodeAt(peg$currPos)?(s3=peg$c74,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c75)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c76()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,116===input.charCodeAt(peg$currPos)?(s3=peg$c77,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c78)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c79()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,118===input.charCodeAt(peg$currPos)?(s3=peg$c80,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c81)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c82()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,117===input.charCodeAt(peg$currPos)?(s3=peg$c83,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c84)),s3!==peg$FAILED?(s4=peg$currPos,s5=peg$currPos,(s6=peg$parseHexDigit())!==peg$FAILED&&(s7=peg$parseHexDigit())!==peg$FAILED&&(s8=peg$parseHexDigit())!==peg$FAILED&&(s9=peg$parseHexDigit())!==peg$FAILED?s5=s6=[s6,s7,s8,s9]:(peg$currPos=s5,s5=peg$FAILED),(s4=s5!==peg$FAILED?input.substring(s4,peg$currPos):s5)!==peg$FAILED?(peg$savedPos=s2,s2=s3=peg$c85(s4)):(peg$currPos=s2,s2=peg$FAILED)):(peg$currPos=s2,s2=peg$FAILED)))))))))),s2!==peg$FAILED?(peg$savedPos=s0,s0=peg$c86(s2)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)),s0}function peg$parseActionLabelQuoteMark(){var s0;return 39===input.charCodeAt(peg$currPos)?(s0=peg$c89,peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c90)),s0}function peg$parseActionLabelUnescaped(){var s0;return peg$c91.test(input.charAt(peg$currPos))?(s0=input.charAt(peg$currPos),peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c92)),s0}function peg$parseActionLabel(){var s0,s2,s3;if(peg$silentFails++,s0=peg$currPos,peg$parseActionLabelQuoteMark()!==peg$FAILED){for(s2=[],s3=peg$parseActionLabelChar();s3!==peg$FAILED;)s2.push(s3),s3=peg$parseActionLabelChar();s2!==peg$FAILED&&(s3=peg$parseActionLabelQuoteMark())!==peg$FAILED?(peg$savedPos=s0,s0=peg$c94(s2)):(peg$currPos=s0,s0=peg$FAILED)}else peg$currPos=s0,s0=peg$FAILED;return peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c93),s0}function peg$parseLineTerminator(){var s0;return peg$c95.test(input.charAt(peg$currPos))?(s0=input.charAt(peg$currPos),peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c96)),s0}function peg$parseWhitespace(){var s0,s1;for(peg$silentFails++,s0=[],peg$c98.test(input.charAt(peg$currPos))?(s1=input.charAt(peg$currPos),peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c99));s1!==peg$FAILED;)s0.push(s1),peg$c98.test(input.charAt(peg$currPos))?(s1=input.charAt(peg$currPos),peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c99));return peg$silentFails--,s0===peg$FAILED&&(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c97)),s0}function peg$parseString(){var s0,s2,s3;if(peg$silentFails++,s0=peg$currPos,peg$parseQuoteMark()!==peg$FAILED){for(s2=[],s3=peg$parseChar();s3!==peg$FAILED;)s2.push(s3),s3=peg$parseChar();s2!==peg$FAILED&&(s3=peg$parseQuoteMark())!==peg$FAILED?(peg$savedPos=s0,s0=peg$c94(s2)):(peg$currPos=s0,s0=peg$FAILED)}else peg$currPos=s0,s0=peg$FAILED;return peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c100),s0}function peg$parseAtom(){var s0,s1,s2;if(peg$silentFails++,s0=peg$currPos,s1=[],peg$c102.test(input.charAt(peg$currPos))?(s2=input.charAt(peg$currPos),peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c103)),s2!==peg$FAILED)for(;s2!==peg$FAILED;)s1.push(s2),peg$c102.test(input.charAt(peg$currPos))?(s2=input.charAt(peg$currPos),peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c103));else s1=peg$FAILED;return s1!==peg$FAILED&&(peg$savedPos=s0,s1=peg$c104(s1)),s0=s1,peg$silentFails--,s0===peg$FAILED&&(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c101)),s0}function peg$parseLabel(){var s0;return peg$silentFails++,(s0=peg$parseAtom())===peg$FAILED&&(s0=peg$parseString()),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c105),s0}function peg$parseColor(){var s0;return peg$silentFails++,input.substr(peg$currPos,3)===peg$c107?(s0=peg$c107,peg$currPos+=3):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c108)),s0===peg$FAILED&&(input.substr(peg$currPos,5)===peg$c109?(s0=peg$c109,peg$currPos+=5):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c110)),s0===peg$FAILED&&(input.substr(peg$currPos,4)===peg$c111?(s0=peg$c111,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c112)))),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c106),s0}function peg$parseArrowItemKey(){var s0;return input.substr(peg$currPos,9)===peg$c113?(s0=peg$c113,peg$currPos+=9):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c114)),s0===peg$FAILED&&(input.substr(peg$currPos,10)===peg$c115?(s0=peg$c115,peg$currPos+=10):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c116)),s0===peg$FAILED&&(input.substr(peg$currPos,10)===peg$c117?(s0=peg$c117,peg$currPos+=10):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c118)))),s0}function peg$parseArrowItem(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED&&(s2=peg$parseArrowItemKey())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseLabel())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c121,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c123(s2,s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseSingleEdgeColor(){var s0,s2,s4,s6,s8;return peg$silentFails++,s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,10)===peg$c125?(s2=peg$c125,peg$currPos+=10):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c126)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseColor())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c121,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c127(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c124),s0}function peg$parseArrowItems(){var s0,s1;if((s0=peg$parseSingleEdgeColor())===peg$FAILED)if(s0=[],(s1=peg$parseArrowItem())!==peg$FAILED)for(;s1!==peg$FAILED;)s0.push(s1),s1=peg$parseArrowItem();else s0=peg$FAILED;return s0}function peg$parseArrowDesc(){var s0,s1,s3,s5;return s0=peg$currPos,123===input.charCodeAt(peg$currPos)?(s1=peg$c128,peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c129)),s1!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s3=peg$parseArrowItems())===peg$FAILED&&(s3=null),s3!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(125===input.charCodeAt(peg$currPos)?(s5=peg$c130,peg$currPos++):(s5=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c131)),s5!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c132(s3)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseLabelList(){var s0,s1,s3,s4,s5,s6;if(s0=peg$currPos,91===input.charCodeAt(peg$currPos)?(s1=peg$c133,peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c134)),s1!==peg$FAILED)if(peg$parseWhitespace()!==peg$FAILED){for(s3=[],s4=peg$currPos,(s5=peg$parseLabel())!==peg$FAILED&&(s6=peg$parseWhitespace())!==peg$FAILED?s4=s5=[s5,s6]:(peg$currPos=s4,s4=peg$FAILED);s4!==peg$FAILED;)s3.push(s4),s4=peg$currPos,(s5=peg$parseLabel())!==peg$FAILED&&(s6=peg$parseWhitespace())!==peg$FAILED?s4=s5=[s5,s6]:(peg$currPos=s4,s4=peg$FAILED);s3!==peg$FAILED?(93===input.charCodeAt(peg$currPos)?(s4=peg$c135,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c136)),s4!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c137(s3)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)}else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;return s0}function peg$parseLabelOrLabelList(){var s0;return(s0=peg$parseLabelList())===peg$FAILED&&(s0=peg$parseLabel()),s0}function peg$parseSubexp(){var s0,s2,s4,s6,s8,s10,s12,s14;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?((s2=peg$parseActionLabel())===peg$FAILED&&(s2=null),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s4=peg$parseArrowDesc())===peg$FAILED&&(s4=null),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseArrow())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s8=peg$parseArrowDesc())===peg$FAILED&&(s8=null),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s10=peg$parseActionLabel())===peg$FAILED&&(s10=null),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s12=peg$parseLabelOrLabelList())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s14=peg$parseSubexp())===peg$FAILED&&(s14=null),s14!==peg$FAILED?(peg$savedPos=s0,s0=peg$c138(s2,s4,s6,s8,s10,s12,s14)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseExp(){var s0,s1,s2,s4;return s0=peg$currPos,(s1=peg$parseLabelOrLabelList())!==peg$FAILED&&(s2=peg$parseSubexp())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s4=peg$c121,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c139(s1,s2)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseValidationKey(){var s0;return input.substr(peg$currPos,9)===peg$c140?(s0=peg$c140,peg$currPos+=9):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c141)),s0===peg$FAILED&&(input.substr(peg$currPos,4)===peg$c142?(s0=peg$c142,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c143))),s0}function peg$parseValidationItem(){var s0,s1,s2,s3,s4;return s0=peg$currPos,(s1=peg$parseValidationKey())!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s2=peg$c119,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s2!==peg$FAILED&&(s3=peg$parseLabel())!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s4=peg$c121,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s4!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c144(s1,s3)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseValidationItems(){var s0,s1;if(s0=[],(s1=peg$parseValidationItem())!==peg$FAILED)for(;s1!==peg$FAILED;)s0.push(s1),s1=peg$parseValidationItem();else s0=peg$FAILED;return s0}function peg$parseConfigValidation(){var s0,s2,s4,s6,s8,s10;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,10)===peg$c145?(s2=peg$c145,peg$currPos+=10):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c146)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(123===input.charCodeAt(peg$currPos)?(s6=peg$c128,peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c129)),s6!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s8=peg$parseValidationItems())===peg$FAILED&&(s8=null),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,2)===peg$c147?(s10=peg$c147,peg$currPos+=2):(s10=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c148)),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c149(s8)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseGvizLayout(){var s0;return input.substr(peg$currPos,3)===peg$c150?(s0=peg$c150,peg$currPos+=3):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c151)),s0===peg$FAILED&&(input.substr(peg$currPos,5)===peg$c152?(s0=peg$c152,peg$currPos+=5):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c153)),s0===peg$FAILED&&(input.substr(peg$currPos,3)===peg$c154?(s0=peg$c154,peg$currPos+=3):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c155)),s0===peg$FAILED&&(input.substr(peg$currPos,5)===peg$c156?(s0=peg$c156,peg$currPos+=5):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c157))))),s0}function peg$parseStateItemShapeKey(){var s0;return input.substr(peg$currPos,8)===peg$c158?(s0=peg$c158,peg$currPos+=8):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c159)),s0===peg$FAILED&&(input.substr(peg$currPos,9)===peg$c160?(s0=peg$c160,peg$currPos+=9):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c161)),s0===peg$FAILED&&(input.substr(peg$currPos,10)===peg$c162?(s0=peg$c162,peg$currPos+=10):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c163)))),s0}function peg$parseStateItemShape(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED&&(s2=peg$parseStateItemShapeKey())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseGvizShape())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c121,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c123(s2,s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseStateItems(){var s0,s1;if(s0=[],(s1=peg$parseStateItemShape())!==peg$FAILED)for(;s1!==peg$FAILED;)s0.push(s1),s1=peg$parseStateItemShape();else s0=peg$FAILED;return s0}function peg$parseConfigState(){var s0,s2,s4,s6,s8,s10;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,5)===peg$c164?(s2=peg$c164,peg$currPos+=5):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c165)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(123===input.charCodeAt(peg$currPos)?(s6=peg$c128,peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c129)),s6!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s8=peg$parseStateItems())===peg$FAILED&&(s8=null),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,2)===peg$c147?(s10=peg$c147,peg$currPos+=2):(s10=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c148)),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c166(s8)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseActionKey(){var s0;return input.substr(peg$currPos,9)===peg$c140?(s0=peg$c140,peg$currPos+=9):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c141)),s0===peg$FAILED&&(input.substr(peg$currPos,4)===peg$c142?(s0=peg$c142,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c143))),s0}function peg$parseActionItem(){var s0,s1,s2,s3,s4;return s0=peg$currPos,(s1=peg$parseActionKey())!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s2=peg$c119,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s2!==peg$FAILED&&(s3=peg$parseLabel())!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s4=peg$c121,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s4!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c167(s1,s3)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseActionItems(){var s0,s1;if(s0=[],(s1=peg$parseActionItem())!==peg$FAILED)for(;s1!==peg$FAILED;)s0.push(s1),s1=peg$parseActionItem();else s0=peg$FAILED;return s0}function peg$parseConfigAction(){var s0,s2,s4,s6,s8,s10;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,6)===peg$c168?(s2=peg$c168,peg$currPos+=6):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c169)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(123===input.charCodeAt(peg$currPos)?(s6=peg$c128,peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c129)),s6!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s8=peg$parseActionItems())===peg$FAILED&&(s8=null),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,2)===peg$c147?(s10=peg$c147,peg$currPos+=2):(s10=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c148)),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c170(s8)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseTransitionKey(){var s0;return input.substr(peg$currPos,9)===peg$c140?(s0=peg$c140,peg$currPos+=9):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c141)),s0===peg$FAILED&&(input.substr(peg$currPos,4)===peg$c142?(s0=peg$c142,peg$currPos+=4):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c143))),s0}function peg$parseTransitionItem(){var s0,s1,s2,s3,s4;return s0=peg$currPos,(s1=peg$parseTransitionKey())!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s2=peg$c119,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s2!==peg$FAILED&&(s3=peg$parseLabel())!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s4=peg$c121,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s4!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c171(s1,s3)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseTransitionItems(){var s0,s1;if((s0=peg$parseGraphDefaultEdgeColor())===peg$FAILED)if(s0=[],(s1=peg$parseTransitionItem())!==peg$FAILED)for(;s1!==peg$FAILED;)s0.push(s1),s1=peg$parseTransitionItem();else s0=peg$FAILED;return s0}function peg$parseGraphDefaultEdgeColor(){var s0,s2,s4,s6,s8;return peg$silentFails++,s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,10)===peg$c125?(s2=peg$c125,peg$currPos+=10):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c126)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseColor())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c121,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c173(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c172),s0}function peg$parseConfigTransition(){var s0,s2,s4,s6,s8,s10;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,10)===peg$c174?(s2=peg$c174,peg$currPos+=10):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c175)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(123===input.charCodeAt(peg$currPos)?(s6=peg$c128,peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c129)),s6!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s8=peg$parseTransitionItems())===peg$FAILED&&(s8=null),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,2)===peg$c147?(s10=peg$c147,peg$currPos+=2):(s10=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c148)),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c176(s8)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseConfigGraphLayout(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,12)===peg$c177?(s2=peg$c177,peg$currPos+=12):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c178)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseGvizLayout())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c121,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c179(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseConfigStartNodes(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,11)===peg$c180?(s2=peg$c180,peg$currPos+=11):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c181)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseLabelList())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c121,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c182(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseConfigEndNodes(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,9)===peg$c183?(s2=peg$c183,peg$currPos+=9):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c184)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseLabelList())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c121,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c185(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseConfigGraphBgColor(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,14)===peg$c186?(s2=peg$c186,peg$currPos+=14):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c187)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseColor())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c121,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c188(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseConfig(){var s0;return peg$silentFails++,(s0=peg$parseConfigGraphLayout())===peg$FAILED&&(s0=peg$parseConfigStartNodes())===peg$FAILED&&(s0=peg$parseConfigEndNodes())===peg$FAILED&&(s0=peg$parseConfigTransition())===peg$FAILED&&(s0=peg$parseConfigAction())===peg$FAILED&&(s0=peg$parseConfigState())===peg$FAILED&&(s0=peg$parseConfigValidation())===peg$FAILED&&(s0=peg$parseConfigGraphBgColor()),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c189),s0}function peg$parseStateColor(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,5)===peg$c190?(s2=peg$c190,peg$currPos+=5):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c191)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseColor())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c121,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c192(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseArbitraryStateQuality(){var s0,s2,s4,s6,s8;return peg$silentFails++,s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED&&(s2=peg$parseLabel())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseLabel())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c121,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c194(s2,s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c193),s0}function peg$parseStateQuality(){var s0;return(s0=peg$parseStateColor())===peg$FAILED&&(s0=peg$parseArbitraryStateQuality()),s0}function peg$parseStateDef(){var s0,s2,s4,s6,s8,s9,s10,s12;if(peg$silentFails++,s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED)if(input.substr(peg$currPos,5)===peg$c164?(s2=peg$c164,peg$currPos+=5):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c165)),s2!==peg$FAILED)if(peg$parseWhitespace()!==peg$FAILED)if((s4=peg$parseLabel())!==peg$FAILED)if(peg$parseWhitespace()!==peg$FAILED)if(91===input.charCodeAt(peg$currPos)?(s6=peg$c133,peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c134)),s6!==peg$FAILED)if(peg$parseWhitespace()!==peg$FAILED){for(s8=[],s9=peg$parseStateQuality();s9!==peg$FAILED;)s8.push(s9),s9=peg$parseStateQuality();s8!==peg$FAILED&&(s9=peg$parseWhitespace())!==peg$FAILED?(93===input.charCodeAt(peg$currPos)?(s10=peg$c135,peg$currPos++):(s10=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c136)),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s12=peg$c121,peg$currPos++):(s12=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s12!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c196(s4,s8)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)}else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;return peg$silentFails--,s0===peg$FAILED&&0===peg$silentFails&&peg$fail(peg$c195),s0}function peg$parseMachineName(){var s0,s2,s4,s6,s8;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,12)===peg$c197?(s2=peg$c197,peg$currPos+=12):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c198)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s4=peg$c119,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s6=peg$parseLabel())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s8=peg$c121,peg$currPos++):(s8=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s8!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c199(s6)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseStateGroupDef(){var s0,s2,s4,s6,s8,s10;return s0=peg$currPos,peg$parseWhitespace()!==peg$FAILED?(input.substr(peg$currPos,5)===peg$c200?(s2=peg$c200,peg$currPos+=5):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c201)),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s4=peg$parseLabel())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s6=peg$c119,peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c120)),s6!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s8=peg$parseLabelOrLabelList())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s10=peg$c121,peg$currPos++):(s10=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c122)),s10!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=peg$c202(s4,s8)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseComment(){var s0,s1,s2,s3,s4,s5,s6;if(s0=peg$currPos,(s1=peg$parseWhitespace())!==peg$FAILED)if(input.substr(peg$currPos,2)===peg$c203?(s2=peg$c203,peg$currPos+=2):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c204)),s2!==peg$FAILED){for(s3=[],s4=peg$currPos,s5=peg$currPos,peg$silentFails++,input.substr(peg$currPos,2)===peg$c205?(s6=peg$c205,peg$currPos+=2):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c206)),peg$silentFails--,s6===peg$FAILED?s5=void 0:(peg$currPos=s5,s5=peg$FAILED),s5!==peg$FAILED?(input.length>peg$currPos?(s6=input.charAt(peg$currPos),peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c207)),s6!==peg$FAILED?s4=s5=[s5,s6]:(peg$currPos=s4,s4=peg$FAILED)):(peg$currPos=s4,s4=peg$FAILED);s4!==peg$FAILED;)s3.push(s4),s4=peg$currPos,s5=peg$currPos,peg$silentFails++,input.substr(peg$currPos,2)===peg$c205?(s6=peg$c205,peg$currPos+=2):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c206)),peg$silentFails--,s6===peg$FAILED?s5=void 0:(peg$currPos=s5,s5=peg$FAILED),s5!==peg$FAILED?(input.length>peg$currPos?(s6=input.charAt(peg$currPos),peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c207)),s6!==peg$FAILED?s4=s5=[s5,s6]:(peg$currPos=s4,s4=peg$FAILED)):(peg$currPos=s4,s4=peg$FAILED);s3!==peg$FAILED?(input.substr(peg$currPos,2)===peg$c205?(s4=peg$c205,peg$currPos+=2):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c206)),s4!==peg$FAILED&&(s5=peg$parseWhitespace())!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c208()):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)}else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;if(s0===peg$FAILED)if(s0=peg$currPos,(s1=peg$parseWhitespace())!==peg$FAILED)if(input.substr(peg$currPos,2)===peg$c209?(s2=peg$c209,peg$currPos+=2):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c210)),s2!==peg$FAILED){for(s3=[],s4=peg$currPos,s5=peg$currPos,peg$silentFails++,s6=peg$parseLineTerminator(),peg$silentFails--,s6===peg$FAILED?s5=void 0:(peg$currPos=s5,s5=peg$FAILED),s5!==peg$FAILED?(input.length>peg$currPos?(s6=input.charAt(peg$currPos),peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c207)),s6!==peg$FAILED?s4=s5=[s5,s6]:(peg$currPos=s4,s4=peg$FAILED)):(peg$currPos=s4,s4=peg$FAILED);s4!==peg$FAILED;)s3.push(s4),s4=peg$currPos,s5=peg$currPos,peg$silentFails++,s6=peg$parseLineTerminator(),peg$silentFails--,s6===peg$FAILED?s5=void 0:(peg$currPos=s5,s5=peg$FAILED),s5!==peg$FAILED?(input.length>peg$currPos?(s6=input.charAt(peg$currPos),peg$currPos++):(s6=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c207)),s6!==peg$FAILED?s4=s5=[s5,s6]:(peg$currPos=s4,s4=peg$FAILED)):(peg$currPos=s4,s4=peg$FAILED);s3!==peg$FAILED&&(s4=peg$parseWhitespace())!==peg$FAILED?s0=s1=[s1,s2,s3,s4]:(peg$currPos=s0,s0=peg$FAILED)}else peg$currPos=s0,s0=peg$FAILED;else peg$currPos=s0,s0=peg$FAILED;return s0}function peg$parseTerm(){var s0;return(s0=peg$parseExp())===peg$FAILED&&(s0=peg$parseStateDef())===peg$FAILED&&(s0=peg$parseMachineName())===peg$FAILED&&(s0=peg$parseStateGroupDef())===peg$FAILED&&(s0=peg$parseConfig())===peg$FAILED&&(s0=peg$parseComment()),s0}function peg$parseTermList(){var s0,s1;for(s0=[],s1=peg$parseTerm();s1!==peg$FAILED;)s0.push(s1),s1=peg$parseTerm();return s0}options=void 0!==options?options:{};var peg$result,peg$FAILED={},peg$startRuleFunctions={Document:peg$parseDocument},peg$startRuleFunction=peg$parseDocument,peg$c0=function(e){return e},peg$c1="square",peg$c2=peg$literalExpectation("square",!1),peg$c3="rectangle",peg$c4=peg$literalExpectation("rectangle",!1),peg$c5="circle",peg$c6=peg$literalExpectation("circle",!1),peg$c7=peg$otherExpectation("forward light arrow ->"),peg$c8="->",peg$c9=peg$literalExpectation("->",!1),peg$c10=peg$otherExpectation("two way light arrow <->"),peg$c11="<->",peg$c12=peg$literalExpectation("<->",!1),peg$c13=peg$otherExpectation("back light arrow <-"),peg$c14="<-",peg$c15=peg$literalExpectation("<-",!1),peg$c16=peg$otherExpectation("forward fat arrow =>"),peg$c17="=>",peg$c18=peg$literalExpectation("=>",!1),peg$c19=peg$otherExpectation("two way fat arrow <=>"),peg$c20="<=>",peg$c21=peg$literalExpectation("<=>",!1),peg$c22=peg$otherExpectation("back fat arrow <="),peg$c23="<=",peg$c24=peg$literalExpectation("<=",!1),peg$c25=peg$otherExpectation("forward tilde arrow ~>"),peg$c26="~>",peg$c27=peg$literalExpectation("~>",!1),peg$c28=peg$otherExpectation("two way tilde arrow <~>"),peg$c29="<~>",peg$c30=peg$literalExpectation("<~>",!1),peg$c31=peg$otherExpectation("back tilde arrow <~"),peg$c32="<~",peg$c33=peg$literalExpectation("<~",!1),peg$c34=peg$otherExpectation("light fat arrow <-=>"),peg$c35="<-=>",peg$c36=peg$literalExpectation("<-=>",!1),peg$c37=peg$otherExpectation("light tilde arrow <-~>"),peg$c38="<-~>",peg$c39=peg$literalExpectation("<-~>",!1),peg$c40=peg$otherExpectation("fat light arrow <=->"),peg$c41="<=->",peg$c42=peg$literalExpectation("<=->",!1),peg$c43=peg$otherExpectation("fat tilde arrow <=~>"),peg$c44="<=~>",peg$c45=peg$literalExpectation("<=~>",!1),peg$c46=peg$otherExpectation("tilde light arrow <~->"),peg$c47="<~->",peg$c48=peg$literalExpectation("<~->",!1),peg$c49=peg$otherExpectation("tilde fat arrow <~=>"),peg$c50="<~=>",peg$c51=peg$literalExpectation("<~=>",!1),peg$c52=peg$otherExpectation("light arrow"),peg$c53=peg$otherExpectation("fat arrow"),peg$c54=peg$otherExpectation("tilde arrow"),peg$c55=peg$otherExpectation("mixed arrow"),peg$c56=peg$otherExpectation("arrow"),peg$c57=/^[0-9a-fA-F]/,peg$c58=peg$classExpectation([["0","9"],["a","f"],["A","F"]],!1,!1),peg$c59='"',peg$c60=peg$literalExpectation('"',!1),peg$c61="\\",peg$c62=peg$literalExpectation("\\",!1),peg$c63="/",peg$c64=peg$literalExpectation("/",!1),peg$c65="b",peg$c66=peg$literalExpectation("b",!1),peg$c67=function(){return"\b"},peg$c68="f",peg$c69=peg$literalExpectation("f",!1),peg$c70=function(){return"\f"},peg$c71="n",peg$c72=peg$literalExpectation("n",!1),peg$c73=function(){return"\n"},peg$c74="r",peg$c75=peg$literalExpectation("r",!1),peg$c76=function(){return"\r"},peg$c77="t",peg$c78=peg$literalExpectation("t",!1),peg$c79=function(){return"\t"},peg$c80="v",peg$c81=peg$literalExpectation("v",!1),peg$c82=function(){return"\v"},peg$c83="u",peg$c84=peg$literalExpectation("u",!1),peg$c85=function(digits){return String.fromCharCode(parseInt(digits,16))},peg$c86=function(Sequence){return Sequence},peg$c87=/^[ -!#-[\]-\u10FFFF]/,peg$c88=peg$classExpectation([[" ","!"],["#","["],["]","ჿ"],"F","F"],!1,!1),peg$c89="'",peg$c90=peg$literalExpectation("'",!1),peg$c91=/^[ -&(-[\]-\u10FFFF]/,peg$c92=peg$classExpectation([[" ","&"],["(","["],["]","ჿ"],"F","F"],!1,!1),peg$c93=peg$otherExpectation("action label"),peg$c94=function(chars){return chars.join("")},peg$c95=/^[\n\r\u2028\u2029]/,peg$c96=peg$classExpectation(["\n","\r","\u2028","\u2029"],!1,!1),peg$c97=peg$otherExpectation("whitespace"),peg$c98=/^[ \t\n\r\x0B]/,peg$c99=peg$classExpectation([" ","\t","\n","\r","\v"],!1,!1),peg$c100=peg$otherExpectation("string"),peg$c101=peg$otherExpectation("atom"),peg$c102=/^[0-9a-zA-Z.+_&()%$#@!?,']/,peg$c103=peg$classExpectation([["0","9"],["a","z"],["A","Z"],".","+","_","&","(",")","%","$","#","@","!","?",",","'"],!1,!1),peg$c104=function(text){return text.join("")},peg$c105=peg$otherExpectation("label"),peg$c106=peg$otherExpectation("color"),peg$c107="red",peg$c108=peg$literalExpectation("red",!1),peg$c109="green",peg$c110=peg$literalExpectation("green",!1),peg$c111="blue",peg$c112=peg$literalExpectation("blue",!1),peg$c113="arc_label",peg$c114=peg$literalExpectation("arc_label",!1),peg$c115="head_label",peg$c116=peg$literalExpectation("head_label",!1),peg$c117="tail_label",peg$c118=peg$literalExpectation("tail_label",!1),peg$c119=":",peg$c120=peg$literalExpectation(":",!1),peg$c121=";",peg$c122=peg$literalExpectation(";",!1),peg$c123=function(key,value){return{key:key,value:value}},peg$c124=peg$otherExpectation("single edge color"),peg$c125="edge_color",peg$c126=peg$literalExpectation("edge_color",!1),peg$c127=function(value){return{key:"single_edge_color",value:value}},peg$c128="{",peg$c129=peg$literalExpectation("{",!1),peg$c130="}",peg$c131=peg$literalExpectation("}",!1),peg$c132=function(items){return items},peg$c133="[",peg$c134=peg$literalExpectation("[",!1),peg$c135="]",peg$c136=peg$literalExpectation("]",!1),peg$c137=function(names){return names.map(function(i){return i[0]})},peg$c138=function(r_action,l_desc,arrow,r_desc,l_action,label,tail){var base={kind:arrow,to:label};return tail&&tail!==[]&&(base.se=tail),l_desc&&(base.l_desc=l_desc),r_desc&&(base.r_desc=r_desc),l_action&&(base.l_action=l_action),r_action&&(base.r_action=r_action),base},peg$c139=function(label,se){var base={key:"transition",from:label};return se&&se!==[]&&(base.se=se),base},peg$c140="whargarbl",peg$c141=peg$literalExpectation("whargarbl",!1),peg$c142="todo",peg$c143=peg$literalExpectation("todo",!1),peg$c144=function(validationkey,value){return{key:validationkey,value:value}},peg$c145="validation",peg$c146=peg$literalExpectation("validation",!1),peg$c147="};",peg$c148=peg$literalExpectation("};",!1),peg$c149=function(validation_items){return{config_kind:"validation",config_items:validation_items||[]}},peg$c150="dot",peg$c151=peg$literalExpectation("dot",!1),peg$c152="circo",peg$c153=peg$literalExpectation("circo",!1),peg$c154="fdp",peg$c155=peg$literalExpectation("fdp",!1),peg$c156="neato",peg$c157=peg$literalExpectation("neato",!1),peg$c158="in_shape",peg$c159=peg$literalExpectation("in_shape",!1),peg$c160="out_shape",peg$c161=peg$literalExpectation("out_shape",!1),peg$c162="node_shape",peg$c163=peg$literalExpectation("node_shape",!1),peg$c164="state",peg$c165=peg$literalExpectation("state",!1),peg$c166=function(state_items){return{config_kind:"state",config_items:state_items||[]}},peg$c167=function(actionkey,value){return{key:actionkey,value:value}},peg$c168="action",peg$c169=peg$literalExpectation("action",!1),peg$c170=function(action_items){return{config_kind:"action",config_items:action_items||[]}},peg$c171=function(transitionkey,value){return{key:transitionkey,value:value}},peg$c172=peg$otherExpectation("graph default edge color"),peg$c173=function(value){return{key:"graph_default_edge_color",value:value}},peg$c174="transition",peg$c175=peg$literalExpectation("transition",!1),peg$c176=function(transition_items){return{config_kind:"transition",config_items:transition_items||[]}},peg$c177="graph_layout",peg$c178=peg$literalExpectation("graph_layout",!1),peg$c179=function(value){return{key:"graph_layout",value:value}},peg$c180="start_nodes",peg$c181=peg$literalExpectation("start_nodes",!1),peg$c182=function(value){return{key:"start_nodes",value:value}},peg$c183="end_nodes",peg$c184=peg$literalExpectation("end_nodes",!1),peg$c185=function(value){return{key:"end_nodes",value:value}},peg$c186="graph_bg_color",peg$c187=peg$literalExpectation("graph_bg_color",!1),peg$c188=function(value){return{key:"graph_bg_color",value:value}},peg$c189=peg$otherExpectation("configuration"),peg$c190="color",peg$c191=peg$literalExpectation("color",!1),peg$c192=function(value){return{key:"state color",value:value}},peg$c193=peg$otherExpectation("state quality"),peg$c194=function(name,value){return{key:"state quality",name:name,value:value}},peg$c195=peg$otherExpectation("state definition"),peg$c196=function(name,sq){return{key:"State qualities",value:sq}},peg$c197="machine name",peg$c198=peg$literalExpectation("machine name",!1),peg$c199=function(name){return{key:"Machine name",value:name}},peg$c200="group",peg$c201=peg$literalExpectation("group",!1),peg$c202=function(name,nl){return{key:"group definition",value:{name:name,list:nl}}},peg$c203="/*",peg$c204=peg$literalExpectation("/*",!1),peg$c205="*/",peg$c206=peg$literalExpectation("*/",!1),peg$c207={type:"any"},peg$c208=function(){return{key:"comment"}},peg$c209="//",peg$c210=peg$literalExpectation("//",!1),peg$currPos=0,peg$savedPos=0,peg$posDetailsCache=[{line:1,column:1}],peg$maxFailPos=0,peg$maxFailExpected=[],peg$silentFails=0;if("startRule"in options){if(!(options.startRule in peg$startRuleFunctions))throw new Error("Can't start parsing from rule \""+options.startRule+'".');peg$startRuleFunction=peg$startRuleFunctions[options.startRule]}if((peg$result=peg$startRuleFunction())!==peg$FAILED&&peg$currPos===input.length)return peg$result;throw peg$result!==peg$FAILED&&peg$currPos1&&void 0!==arguments[1]?arguments[1]:"probability";if(!Array.isArray(options))throw new TypeError("options must be a non-empty array of objects");if("object"!==_typeof(options[0]))throw new TypeError("options must be a non-empty array of objects");for(var or_one=function(item){return void 0===item?1:item},rnd=function(cap){return Math.random()*cap}(options.reduce(function(acc,val){return acc+or_one(val[probability_property])},0)),cursor=0,cursor_sum=0;(cursor_sum+=options[cursor++][probability_property])<=rnd;);return options[cursor-1]},seq=function(n){return new Array(n).fill(!0).map(function(_,i){return i})},histograph=function(a){return a.sort().reduce(function(m,v){return m.set(v,m.has(v)?m.get(v)+1:1),m},new Map)},weighted_sample_select=function(n,options,probability_property){return seq(n).map(function(i){return weighted_rand_select(options,probability_property)})};exports.seq=seq,exports.histograph=histograph,exports.weighted_histo_key=function(n,options,probability_property,extract){return histograph(weighted_sample_select(n,options,probability_property).map(function(s){return s[extract]}))},exports.weighted_rand_select=weighted_rand_select,exports.weighted_sample_select=weighted_sample_select},{}],jssm:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i":case"=>":case"~>":return"none";case"<-":case"<->":case"<-=>":case"<-~>":return"legal";case"<=":case"<=>":case"<=->":case"<=~>":return"main";case"<~":case"<~>":case"<~->":case"<~=>":return"forced";default:throw new Error("arrow_direction: unknown arrow type "+arrow)}}function arrow_right_kind(arrow){switch(String(arrow)){case"<-":case"<=":case"<~":return"none";case"->":case"<->":case"<=->":case"<~->":return"legal";case"=>":case"<=>":case"<-=>":case"<~=>":return"main";case"~>":case"<~>":case"<-~>":case"<=~>":return"forced";default:throw new Error("arrow_direction: unknown arrow type "+arrow)}}function compile_rule_transition_step(acc,from,to,this_se,next_se){var edges=[],uFrom=Array.isArray(from)?from:[from],uTo=Array.isArray(to)?to:[to];uFrom.map(function(f){uTo.map(function(t){var rk=arrow_right_kind(this_se.kind),lk=arrow_left_kind(this_se.kind),right={from:f,to:t,kind:rk,forced_only:"forced"===rk,main_path:"main"===rk};this_se.r_action&&(right.action=this_se.r_action),"none"!==right.kind&&edges.push(right);var left={from:t,to:f,kind:lk,forced_only:"forced"===lk,main_path:"main"===lk};this_se.l_action&&(left.action=this_se.l_action),"none"!==left.kind&&edges.push(left)})});var new_acc=acc.concat(edges);return next_se?compile_rule_transition_step(new_acc,to,next_se.to,next_se,next_se.se):new_acc}function compile_rule_handle_transition(rule){return compile_rule_transition_step([],rule.from,rule.se.to,rule.se,rule.se.se)}function compile_rule_handler(rule){if("transition"===rule.key)return{agg_as:"transition",val:compile_rule_handle_transition(rule)};if(["graph_layout","start_nodes","end_nodes"].includes(rule.key))return{agg_as:rule.key,val:rule.value};throw new Error("compile_rule_handler: Unknown rule: "+JSON.stringify(rule))}function compile(tree){var _ref,results={graph_layout:[],transition:[],start_nodes:[],end_nodes:[],initial_state:[]};tree.map(function(tr){var rule=compile_rule_handler(tr),agg_as=rule.agg_as,val=rule.val;results[agg_as]=results[agg_as].concat(val)}),["graph_layout","initial_state"].map(function(oneOnlyKey){if(results[oneOnlyKey].length>1)throw new Error("May only have one "+oneOnlyKey+" statement maximum: "+JSON.stringify(results[oneOnlyKey]))});var assembled_transitions=(_ref=[]).concat.apply(_ref,_toConsumableArray(results.transition)),result_cfg={initial_state:results.start_nodes.length?results.start_nodes[0]:assembled_transitions[0].from,transitions:assembled_transitions};return results.graph_layout.length&&(result_cfg.layout=results.graph_layout[0]),result_cfg}function make(plan){return compile(parse(plan))}Object.defineProperty(exports,"__esModule",{value:!0}),exports.weighted_histo_key=exports.weighted_sample_select=exports.histograph=exports.weighted_rand_select=exports.seq=exports.arrow_right_kind=exports.arrow_left_kind=exports.arrow_direction=exports.sm=exports.compile=exports.parse=exports.make=exports.Machine=exports.version=void 0;var _createClass=function(){function defineProperties(target,props){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:this.state();return{entrances:this.list_entrances(whichState),exits:this.list_exits(whichState)}}},{key:"list_entrances",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return(this._states.get(whichState)||{}).from||[]}},{key:"list_exits",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return(this._states.get(whichState)||{}).to||[]}},{key:"probable_exits_for",value:function(whichState){var _this2=this,wstate=this._states.get(whichState);if(!wstate)throw new Error("No such state "+JSON.stringify(whichState)+" in probable_exits_for");return wstate.to.map(function(ws){return _this2.lookup_transition_for(_this2.state(),ws)}).filter(Boolean)}},{key:"probabilistic_transition",value:function(){var selected=(0,_jssmUtil.weighted_rand_select)(this.probable_exits_for(this.state()));return this.transition(selected.to)}},{key:"probabilistic_walk",value:function(n){var _this3=this;return(0,_jssmUtil.seq)(n).map(function(){var state_was=_this3.state();return _this3.probabilistic_transition(),state_was}).concat([this.state()])}},{key:"probabilistic_histo_walk",value:function(n){return(0,_jssmUtil.histograph)(this.probabilistic_walk(n))}},{key:"actions",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state(),wstate=this._reverse_actions.get(whichState);if(wstate)return[].concat(_toConsumableArray(wstate.keys()));throw new Error("No such state "+JSON.stringify(whichState))}},{key:"list_states_having_action",value:function(whichState){var wstate=this._actions.get(whichState);if(wstate)return[].concat(_toConsumableArray(wstate.keys()));throw new Error("No such state "+JSON.stringify(whichState))}},{key:"list_exit_actions",value:function(){var _this4=this,whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state(),ra_base=this._reverse_actions.get(whichState);if(!ra_base)throw new Error("No such state "+JSON.stringify(whichState));return[].concat(_toConsumableArray(ra_base.values())).map(function(edgeId){return _this4._edges[edgeId]}).filter(function(o){return o.from===whichState}).map(function(filtered){return filtered.action})}},{key:"probable_action_exits",value:function(){var _this5=this,whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state(),ra_base=this._reverse_actions.get(whichState);if(!ra_base)throw new Error("No such state "+JSON.stringify(whichState));return[].concat(_toConsumableArray(ra_base.values())).map(function(edgeId){return _this5._edges[edgeId]}).filter(function(o){return o.from===whichState}).map(function(filtered){return{action:filtered.action,probability:filtered.probability}})}},{key:"is_unenterable",value:function(whichState){return 0===this.list_entrances(whichState).length}},{key:"has_unenterables",value:function(){var _this6=this;return this.states().some(function(x){return _this6.is_unenterable(x)})}},{key:"is_terminal",value:function(){return this.state_is_terminal(this.state())}},{key:"state_is_terminal",value:function(whichState){return 0===this.list_exits(whichState).length}},{key:"has_terminals",value:function(){var _this7=this;return this.states().some(function(x){return _this7.state_is_terminal(x)})}},{key:"is_complete",value:function(){return this.state_is_complete(this.state())}},{key:"state_is_complete",value:function(whichState){var wstate=this._states.get(whichState);if(wstate)return wstate.complete;throw new Error("No such state "+JSON.stringify(whichState))}},{key:"has_completes",value:function(){var _this8=this;return this.states().some(function(x){return _this8.state_is_complete(x)})}},{key:"action",value:function(name,newData){if(this.valid_action(name,newData)){var edge=this.current_action_edge_for(name);return this._state=edge.to,!0}return!1}},{key:"transition",value:function(newState,newData){return!!this.valid_transition(newState,newData)&&(this._state=newState,!0)}},{key:"force_transition",value:function(newState,newData){return!!this.valid_force_transition(newState,newData)&&(this._state=newState,!0)}},{key:"current_action_for",value:function(action){var action_base=this._actions.get(action);return action_base?action_base.get(this.state()):void 0}},{key:"current_action_edge_for",value:function(action){var idx=this.current_action_for(action);if(void 0===idx||null===idx)throw new Error("No such action "+JSON.stringify(action));return this._edges[idx]}},{key:"valid_action",value:function(action,_newData){return void 0!==this.current_action_for(action)}},{key:"valid_transition",value:function(newState,_newData){var transition_for=this.lookup_transition_for(this.state(),newState);return!!transition_for&&!transition_for.forced_only}},{key:"valid_force_transition",value:function(newState,_newData){return void 0!==this.lookup_transition_for(this.state(),newState)}}]),Machine}();exports.version="4.4.2",exports.Machine=Machine,exports.make=make,exports.parse=parse,exports.compile=compile,exports.sm=function(template_strings){var _arguments=arguments;return new Machine(make(template_strings.reduce(function(acc,val,idx){return""+acc+_arguments[idx]+val})))},exports.arrow_direction=function(arrow){switch(String(arrow)){case"->":case"=>":case"~>":return"right";case"<-":case"<=":case"<~":return"left";case"<->":case"<-=>":case"<-~>":case"<=>":case"<=->":case"<=~>":case"<~>":case"<~->":case"<~=>":return"both";default:throw new Error("arrow_direction: unknown arrow type "+arrow)}},exports.arrow_left_kind=arrow_left_kind,exports.arrow_right_kind=arrow_right_kind,exports.seq=_jssmUtil.seq,exports.weighted_rand_select=_jssmUtil.weighted_rand_select,exports.histograph=_jssmUtil.histograph,exports.weighted_sample_select=_jssmUtil.weighted_sample_select,exports.weighted_histo_key=_jssmUtil.weighted_histo_key},{"./jssm-dot.js":1,"./jssm-util.js":2}]},{},[]); \ No newline at end of file diff --git a/docs/lib/index.html b/docs/lib/index.html index 20862b18..eeeaac32 100644 --- a/docs/lib/index.html +++ b/docs/lib/index.html @@ -2,7 +2,7 @@ - jssm 3.9.3 | Documentation + jssm 4.4.2 | Documentation @@ -14,7 +14,7 @@

jssm

-
3.9.3
+
4.4.2
=6.0.0" }, @@ -8,8 +8,6 @@ "main": "dist/jssm.es5.browserified.js", "scripts": { "nyc-test": "nyc ava src/js/tests/*.js", - "test": "ava src/js/tests/*.js", - "test-verbose": "ava src/js/tests/*.js -v", "removedir": "rimraf build -f && rimraf dist -f && rimraf docs -f", "createdir": "mkdir build && mkdir dist && mkdir docs && cd docs && mkdir docs && cd ..", "clean": "npm run removedir && rm -f src/js/jssm-dot.js && npm run createdir", @@ -20,20 +18,19 @@ "make": "npm run clean && npm run peg && npm run babel && npm run rename && npm run setver && npm run pack", "flow": "flow", "peg": "rm -f src/js/jssm-dot.js && pegjs src/js/jssm-dot.peg && cp src/js/jssm-dot.js build/", - "eslint": "eslint src/js/jssm.js src/js/tests/*.js", + "eslint": "eslint src/js/jssm.js src/js/jssm-types.js src/js/tests/*.js", "nyc-html": "nyc ava report --reporter=html", "coverage": "nyc report --reporter=text-lcov | coveralls", "vet": "npm run flow && npm run eslint", "audit": "echo \\\"major\\\" remaining. . : `grep major src/js/jssm*.js | wc -l`\\\\n\\\"wasteful\\\" remaining : `grep wasteful src/js/jssm*.js | wc -l`\\\\n\\\"any\\\" remaining. . . : `grep any src/js/jssm*.js | wc -l`\\\\n\\\"mixed\\\" remaining. . : `grep mixed src/js/jssm*.js | wc -l`\\\\n\\\"todo\\\" remaining . . : `grep todo src/js/jssm*.js | wc -l`\\\\n\\\"nextdo\\\" remaining . : `grep nextdo src/js/jssm*.js | wc -l`\\\\n\\\"whargarbl\\\" remaining: `grep whargarbl src/js/jssm*.js | wc -l`\\\\n\\\"comeback\\\" remaining : `grep comeback src/js/jssm*.js | wc -l`\\\\n\\\"fixme\\\" remaining. . : `grep fixme src/js/jssm*.js | wc -l`\\\\n\\\"stochable\\\" remaining: `grep stochable src/js/jssm*.js | wc -l`\\\\n\\\"checkme\\\" remaining. : `grep checkme src/js/jssm*.js | wc -l`", - "qbuild": "npm run eslint && npm run make && npm run test-verbose && npm run minify && npm run docs && npm run site && npm run dist", - "build": "npm run make && npm run vet && npm run test-verbose && npm run audit && npm run minify && npm run docs && npm run site && npm run dist", - "nyc-build": "npm run vet && npm run make && npm run test-verbose && npm run audit && npm run nyc-test", + "qbuild": "npm run eslint && npm run make && npm run nyc-test && npm run minify && npm run docs && npm run site && npm run dist", + "build": "npm run make && npm run vet && npm run nyc-test && npm run audit && npm run minify && npm run docs && npm run site && npm run dist", "minify": "uglifyjs ./build/jssm.es5.cjs.js -o ./build/jssm.es5.cjs.min.js --compress", "pretest": "npm run build", "dist": "cp build/jssm.es5.cjs.* dist/", "site": "cp src/site/* docs/", "docs": "documentation build src/js/** -f html -o docs/lib", - "travis": "rm -f src/js/jssm-dot.js && npm run nyc-build && npm run nyc-test && npm run coverage" + "travis": "rm -f src/js/jssm-dot.js && npm run coverage" }, "repository": { "type": "git", @@ -88,13 +85,15 @@ "del-cli": "^1.1.0", "documentation": "^4.0.0", "eslint": "^4.3.0", - "eslint-config-stonecypher": "^1.12.3", + "eslint-config-stonecypher": "^1.13.1", "eslint-plugin-ava": "^4.2.1", "eslint-plugin-flowtype": "^2.35.0", "eslint-plugin-fp": "^2.3.0", "eslint-plugin-jsdoc": "^3.1.2", + "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-new-with-error": "^1.1.0", "eslint-plugin-promise": "^3.5.0", + "eslint-plugin-react": "^7.1.0", "eslint-plugin-unicorn": "^2.1.2", "flow-bin": "^0.49.1", "gulp-string-replace": "^0.4.0", diff --git a/src/demo/index.html b/src/demo/index.html index f8a4b79d..d044023b 100644 --- a/src/demo/index.html +++ b/src/demo/index.html @@ -4,18 +4,35 @@ + - + Loading… diff --git a/src/js/jssm-dot.peg b/src/js/jssm-dot.peg index c0cd6583..180702fb 100644 --- a/src/js/jssm-dot.peg +++ b/src/js/jssm-dot.peg @@ -11,35 +11,70 @@ GvizShape -ForwardLightArrow "forward light arrow" +ForwardLightArrow "forward light arrow ->" = "->" -TwoWayLightArrow "two way light arrow" +TwoWayLightArrow "two way light arrow <->" = "<->" -ForwardFatArrow "forward fat arrow" +BackLightArrow "back light arrow <-" + = "<-" + + +ForwardFatArrow "forward fat arrow =>" = "=>" -TwoWayFatArrow "two way fat arrow" +TwoWayFatArrow "two way fat arrow <=>" = "<=>" -ForwardTildeArrow "forward tilde arrow" +BackFatArrow "back fat arrow <=" + = "<=" + + +ForwardTildeArrow "forward tilde arrow ~>" = "~>" -TwoWayTildeArrow "two way tilde arrow" +TwoWayTildeArrow "two way tilde arrow <~>" = "<~>" +BackTildeArrow "back tilde arrow <~" + = "<~" + + +LightFatArrow "light fat arrow <-=>" + = "<-=>" + +LightTildeArrow "light tilde arrow <-~>" + = "<-~>" + +FatLightArrow "fat light arrow <=->" + = "<=->" + +FatTildeArrow "fat tilde arrow <=~>" + = "<=~>" + +TildeLightArrow "tilde light arrow <~->" + = "<~->" + +TildeFatArrow "tilde fat arrow <~=>" + = "<~=>" + + LightArrow "light arrow" - = ForwardLightArrow / TwoWayLightArrow + = ForwardLightArrow / TwoWayLightArrow / BackLightArrow FatArrow "fat arrow" - = ForwardFatArrow / TwoWayFatArrow + = ForwardFatArrow / TwoWayFatArrow / BackFatArrow TildeArrow "tilde arrow" - = ForwardTildeArrow / TwoWayTildeArrow + = ForwardTildeArrow / TwoWayTildeArrow / BackTildeArrow + +MixedArrow "mixed arrow" + = LightFatArrow / LightTildeArrow / FatLightArrow / FatTildeArrow / TildeLightArrow / TildeFatArrow + Arrow "arrow" - = LightArrow / FatArrow / TildeArrow + = MixedArrow / LightArrow / FatArrow / TildeArrow @@ -71,7 +106,7 @@ Unescaped = [\x20-\x21\x23-\x5B\x5D-\u10FFFF] // explicitly omits " ActionLabelChar = ActionLabelUnescaped / Escape Sequence:( - '`' + "'" / "\\" / "/" / "b" { return "\b"; } @@ -86,12 +121,15 @@ ActionLabelChar ) { return Sequence; } -ActionLabelQuoteMark = '`' -ActionLabelUnescaped = [\x20-\x5B\x5D-\x5F\x61-\u10FFFF] // explicitly omits ` +ActionLabelQuoteMark = "'" +ActionLabelUnescaped = [\x20-\x26\x28-\x5B\x5D-\u10FFFF] // explicitly omits ' which is hex 27 ActionLabel "action label" = ActionLabelQuoteMark chars:ActionLabelChar* ActionLabelQuoteMark { return chars.join(""); } +LineTerminator + = [\n\r\u2028\u2029] + Whitespace "whitespace" = [ \t\n\r\v]* @@ -144,25 +182,31 @@ LabelOrLabelList Subexp - = Whitespace lactl:ActionLabel? - Whitespace ldesc:ArrowDesc? - Whitespace arrow:Arrow - Whitespace rdesc:ArrowDesc? - Whitespace ractl:ActionLabel? - Whitespace label:LabelOrLabelList - Whitespace tail:Subexp? { + = Whitespace r_action : ActionLabel? + Whitespace l_desc : ArrowDesc? + Whitespace arrow : Arrow + Whitespace r_desc : ArrowDesc? + Whitespace l_action : ActionLabel? + Whitespace label : LabelOrLabelList + Whitespace tail : Subexp? { + const base = {kind: arrow, to: label}; - if (tail && (tail !== [])) { base.se = tail; } - if (ldesc) { base.ldesc = ldesc; } - if (rdesc) { base.rdesc = rdesc; } + if (tail && (tail !== [])) { base.se = tail; } + if (l_desc) { base.l_desc = l_desc; } + if (r_desc) { base.r_desc = r_desc; } + if (l_action) { base.l_action = l_action; } + if (r_action) { base.r_action = r_action; } return base; + } + + Exp = label:LabelOrLabelList se:Subexp Whitespace ';' Whitespace { - const base = {from: label}; + const base = { key: 'transition', from: label }; if (se && (se !== [])) { base.se = se; } return base; } @@ -189,6 +233,8 @@ ConfigValidation GvizLayout = "dot" / "circo" + / "fdp" + / "neato" StateItemShapeKey = "in_shape" @@ -198,12 +244,8 @@ StateItemShapeKey StateItemShape = Whitespace key:StateItemShapeKey Whitespace ":" Whitespace value:GvizShape Whitespace ";" Whitespace { return {key:key, value:value}; } -StateItemGraphLayout - = Whitespace "graph_layout" Whitespace ":" Whitespace value:GvizLayout Whitespace ";" Whitespace { return {key:"graph_layout", value:value}; } - StateItem = StateItemShape - / StateItemGraphLayout StateItems = StateItem+ @@ -253,52 +295,29 @@ ConfigTransition -GraphBg - = Whitespace "graph_bg" Whitespace ":" Whitespace value:GvizShape Whitespace ";" Whitespace { return {key:"graph_bg", value:value}; } - -MinTransitionsPerState - = Whitespace "min_transitions_per_state" Whitespace ":" Whitespace value:Label Whitespace ";" Whitespace { return {key:"min_transitions_per_state", value:value}; } - -MaxTransitionsPerState - = Whitespace "max_transitions_per_state" Whitespace ":" Whitespace value:Label Whitespace ";" Whitespace { return {key:"max_transitions_per_state", value:value}; } - -GraphInputs - = Whitespace "inputs" Whitespace ":" Whitespace value:LabelList Whitespace ";" Whitespace { return {key:"inputs", value:value}; } - -GraphOutputs - = Whitespace "outputs" Whitespace ":" Whitespace value:LabelList Whitespace ";" Whitespace { return {key:"outputs", value:value}; } - -GraphStartNodes - = Whitespace "start_nodes" Whitespace ":" Whitespace value:LabelList Whitespace ";" Whitespace { return {key:"start_nodes", value:value}; } - -GraphEndNodes - = Whitespace "end_nodes" Whitespace ":" Whitespace value:LabelList Whitespace ";" Whitespace { return {key:"end_nodes", value:value}; } +ConfigGraphLayout + = Whitespace "graph_layout" Whitespace ":" Whitespace value:GvizLayout Whitespace ";" Whitespace { return {key:"graph_layout", value:value}; } -GraphItem - = GraphBg - / MinTransitionsPerState - / MaxTransitionsPerState - / GraphStartNodes - / GraphEndNodes - / GraphInputs - / GraphOutputs +ConfigStartNodes + = Whitespace "start_nodes" Whitespace ":" Whitespace value:LabelList Whitespace ";" Whitespace { return {key:"start_nodes", value:value}; } -GraphItems - = GraphItem+ +ConfigEndNodes + = Whitespace "end_nodes" Whitespace ":" Whitespace value:LabelList Whitespace ";" Whitespace { return {key:"end_nodes", value:value}; } -ConfigGraph "graph configuration" - = Whitespace "graph" Whitespace ":" Whitespace "{" Whitespace graph_items:GraphItems? Whitespace "};" Whitespace { - return { config_kind: "graph", config_items: graph_items || [] }; - } +ConfigGraphBgColor + = Whitespace "graph_bg_color" Whitespace ":" Whitespace value:Color Whitespace ";" Whitespace { return {key:"graph_bg_color", value:value}; } Config "configuration" - = ConfigGraph + = ConfigGraphLayout + / ConfigStartNodes + / ConfigEndNodes / ConfigTransition / ConfigAction / ConfigState / ConfigValidation + / ConfigGraphBgColor @@ -317,10 +336,28 @@ StateDef "state definition" +MachineName + = Whitespace "machine name" Whitespace ":" Whitespace name:Label Whitespace ";" Whitespace { return { key: "Machine name", value: name }; } + + + +StateGroupDef + = Whitespace "group" Whitespace name:Label Whitespace ":" Whitespace nl:LabelOrLabelList Whitespace ";" Whitespace { return { key: "group definition", value: { name: name, list: nl } }; } + + + +Comment + = Whitespace "/*" (!"*/" .)* "*/" Whitespace { return { key: 'comment' }; } + / Whitespace "//" (!LineTerminator .)* Whitespace + + Term = Exp / StateDef + / MachineName + / StateGroupDef / Config + / Comment TermList = term:Term* diff --git a/src/js/jssm-types.js b/src/js/jssm-types.js index a9978f23..051901c8 100644 --- a/src/js/jssm-types.js +++ b/src/js/jssm-types.js @@ -5,13 +5,22 @@ -type JssmSuccess = { success: true }; -type JssmFailure = { success: false, error: mixed }; -type JssmIncomplete = { success: 'incomplete' }; -type JssmResult = JssmSuccess | JssmFailure | JssmIncomplete; +type JssmSuccess = { success: true }; +type JssmFailure = { success: false, error: mixed }; +type JssmIncomplete = { success: 'incomplete' }; +type JssmResult = JssmSuccess | JssmFailure | JssmIncomplete; -type JssmPermitted = 'required' | 'disallowed'; -type JssmPermittedOpt = 'required' | 'disallowed' | 'optional'; +type JssmPermitted = 'required' | 'disallowed'; +type JssmPermittedOpt = 'required' | 'disallowed' | 'optional'; + +type JssmArrow = '->' | '<->' | '<=->' | '<~->' + | '=>' | '<=>' | '<-=>' | '<~=>' + | '~>' | '<~>' | '<-~>' | '<=~>'; + +type JssmArrowDirection = 'left' | 'right' | 'both'; +type JssmArrowKind = 'none' | 'legal' | 'main' | 'forced'; + +type JssmLayout = 'dot' | 'circo' | 'twopi' | 'fdp'; @@ -43,7 +52,9 @@ type JssmGenericState = { type JssmTransitionPermitter = (OldState: NT, NewState: NT, OldData: DT, NewData: DT) => boolean; -type JssmTransitionPermitterMaybeArray = JssmTransitionPermitter | Array< JssmTransitionPermitter >; + +type JssmTransitionPermitterMaybeArray = JssmTransitionPermitter + | Array< JssmTransitionPermitter >; @@ -83,14 +94,16 @@ type JssmTransition = { action? : NT, check? : JssmTransitionPermitterMaybeArray, // validate this edge's transition; usually about data probability? : number, // for stoch modelling, would like to constrain to [0..1], dunno how - usual? : string // most common exit, for graphing; likelihood overrides + kind : JssmArrowKind, + forced_only : boolean, + main_path : boolean }; type JssmTransitions = Array< JssmTransition >; type JssmTransitionList = { - entrances : Array, - exits : Array + entrances : Array, + exits : Array }; @@ -100,6 +113,8 @@ type JssmGenericConfig = { initial_state : NT, + layout? : JssmLayout, + complete? : Array, transitions : JssmTransitions, @@ -117,7 +132,45 @@ type JssmGenericConfig = { simplify_bidi? : boolean, - auto_api? : boolean | string; // boolean false means don't; boolean true means do; string means do-with-this-prefix + auto_api? : boolean | string // boolean false means don't; boolean true means do; string means do-with-this-prefix + +}; + + + + + +type JssmCompileRule = { + + agg_as : string, + val : mixed + +}; + + + + + +type JssmCompileSe = { + + to : NT, + se : JssmCompileSe, + kind : JssmArrow, + l_action? : NT, + r_action? : NT + +}; + + + + + +type JssmCompileSeStart = { + + from : NT, + se : JssmCompileSe, + key : string, + value? : string | mixed | number }; @@ -125,13 +178,35 @@ type JssmGenericConfig = { +type JssmParseTree = Array< JssmCompileSeStart >; + + + + + export type { JssmTransition, + JssmTransitions, JssmTransitionList, + JssmArrow, + JssmArrowKind, + JssmArrowDirection, + JssmGenericConfig, JssmGenericState, + JssmGenericMachine, + + JssmParseTree, + JssmCompileSe, + JssmCompileSeStart, + JssmCompileRule, + + JssmPermitted, + JssmResult, + + JssmLayout, JssmMachineInternalState diff --git a/src/js/jssm.js b/src/js/jssm.js index 9251c9a3..f0244f2a 100644 --- a/src/js/jssm.js +++ b/src/js/jssm.js @@ -4,26 +4,246 @@ // @flow import type { + JssmGenericState, JssmGenericConfig, JssmTransition, JssmTransitionList, - JssmMachineInternalState + JssmMachineInternalState, + JssmParseTree, + JssmCompileSe, JssmCompileSeStart, JssmCompileRule, + JssmArrow, JssmArrowDirection, JssmArrowKind, + JssmLayout + } from './jssm-types'; + + + + +import { seq, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key } from './jssm-util.js'; + +const parse : (string) => JssmParseTree = require('./jssm-dot.js').parse; // eslint-disable-line flowtype/no-weak-types // todo whargarbl remove any + const version : null = null; // replaced from package.js in build -import { seq, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key } from './jssm-util.js'; +function arrow_direction(arrow : JssmArrow) : JssmArrowDirection { + + switch ( String(arrow) ) { + + case '->' : case '=>' : case '~>' : + return 'right'; + + case '<-' : case '<=' : case '<~' : + return 'left'; + + case '<->': case '<-=>': case '<-~>': + case '<=>': case '<=->': case '<=~>': + case '<~>': case '<~->': case '<~=>': + return 'both'; + + default: + throw new Error(`arrow_direction: unknown arrow type ${arrow}`); + + } + +} + + + + + +function arrow_left_kind(arrow : JssmArrow) : JssmArrowKind { + + switch ( String(arrow) ) { + + case '->': case '=>' : case '~>': + return 'none'; + + case '<-': case '<->': case '<-=>': case '<-~>': + return 'legal'; + + case '<=': case '<=>': case '<=->': case '<=~>': + return 'main'; + + case '<~': case '<~>': case '<~->': case '<~=>': + return 'forced'; + + default: + throw new Error(`arrow_direction: unknown arrow type ${arrow}`); + + } + +} + + + + + +function arrow_right_kind(arrow : JssmArrow) : JssmArrowKind { + + switch ( String(arrow) ) { + + case '<-': case '<=' : case '<~': + return 'none'; + + case '->': case '<->': case '<=->': case '<~->': + return 'legal'; + + case '=>': case '<=>': case '<-=>': case '<~=>': + return 'main'; + + case '~>': case '<~>': case '<-~>': case '<=~>': + return 'forced'; + + default: + throw new Error(`arrow_direction: unknown arrow type ${arrow}`); + + } + +} + + + + + +function compile_rule_transition_step( + acc : Array< JssmTransition >, + from : mNT, + to : mNT, + this_se : JssmCompileSe, + next_se : JssmCompileSe + ) : Array< JssmTransition > { // todo flow describe the parser representation of a transition step extension + + const edges : Array< JssmTransition > = []; + + const uFrom : Array< mNT > = (Array.isArray(from)? from : [from]), + uTo : Array< mNT > = (Array.isArray(to)? to : [to] ); + + uFrom.map( (f:mNT) => { + uTo.map( (t:mNT) => { + + const rk : JssmArrowKind = arrow_right_kind(this_se.kind), + lk : JssmArrowKind = arrow_left_kind(this_se.kind); + + + const right : JssmTransition = { + from : f, + to : t, + kind : rk, + forced_only : rk === 'forced', + main_path : rk === 'main' + }; + + if (this_se.r_action) { right.action = this_se.r_action; } + if (right.kind !== 'none') { edges.push(right); } + + + const left : JssmTransition = { + from : t, + to : f, + kind : lk, + forced_only : lk === 'forced', + main_path : lk === 'main' + }; + + if (this_se.l_action) { left.action = this_se.l_action; } + if (left.kind !== 'none') { edges.push(left); } + + }); + }); + + const new_acc : Array< JssmTransition > = acc.concat(edges); + + if (next_se) { + return compile_rule_transition_step(new_acc, to, next_se.to, next_se, next_se.se); + } else { + return new_acc; + } + +} + -const parse : (string) => Array = require('./jssm-dot.js').parse; // todo burn out any + +function compile_rule_handle_transition(rule : JssmCompileSeStart) : mixed { // todo flow describe the parser representation of a transition + return compile_rule_transition_step([], rule.from, rule.se.to, rule.se, rule.se.se); +} + + + +function compile_rule_handler(rule : JssmCompileSeStart) : JssmCompileRule { // todo flow describe the output of the parser + + if (rule.key === 'transition') { return { agg_as: 'transition', val: compile_rule_handle_transition(rule) }; } + + const tautologies : Array = ['graph_layout', 'start_nodes', 'end_nodes']; + if (tautologies.includes(rule.key)) { + return { agg_as: rule.key, val: rule.value }; + } + + throw new Error(`compile_rule_handler: Unknown rule: ${JSON.stringify(rule)}`); + +} + + + +function compile(tree : JssmParseTree) : JssmGenericConfig { // todo flow describe the output of the parser + + const results : { + graph_layout : Array< JssmLayout >, + transition : Array< JssmTransition >, + start_nodes : Array< mNT >, + end_nodes : Array< mNT >, + initial_state : Array< mNT > + } = { + graph_layout : [], + transition : [], + start_nodes : [], + end_nodes : [], + initial_state : [] + }; + + tree.map( (tr : JssmCompileSeStart) => { + + const rule : JssmCompileRule = compile_rule_handler(tr), + agg_as : string = rule.agg_as, + val : mixed = rule.val; // todo better types + + results[agg_as] = results[agg_as].concat(val); + + }); + + ['graph_layout', 'initial_state'].map( (oneOnlyKey : string) => { + if (results[oneOnlyKey].length > 1) { + throw new Error(`May only have one ${oneOnlyKey} statement maximum: ${JSON.stringify(results[oneOnlyKey])}`); + } + }); + + const assembled_transitions : Array< JssmTransition > = [].concat(... results['transition']); + + const result_cfg : JssmGenericConfig = { + initial_state : results.start_nodes.length? results.start_nodes[0] : assembled_transitions[0].from, + transitions : assembled_transitions + }; + + if (results.graph_layout.length) { result_cfg.layout = results.graph_layout[0]; } + + return result_cfg; + +} +function make(plan : string) : JssmGenericConfig { + return compile(parse(plan)); +} + + -class machine { + +class Machine { _state : mNT; @@ -33,10 +253,12 @@ class machine { _named_transitions : Map; _actions : Map>; _reverse_actions : Map>; - _reverse_action_targets : Map>; + _reverse_action_targets : Map>; + + _layout : JssmLayout; // whargarbl this badly needs to be broken up, monolith master - constructor({ initial_state, complete=[], transitions } : JssmGenericConfig) { + constructor({ initial_state, complete=[], transitions, layout = 'dot' } : JssmGenericConfig) { this._state = initial_state; this._states = new Map(); @@ -47,27 +269,33 @@ class machine { this._reverse_actions = new Map(); this._reverse_action_targets = new Map(); // todo - transitions.map( (tr:any) => { // whargarbl burn out any + this._layout = layout; + + transitions.map( (tr:JssmTransition) => { if (tr.from === undefined) { throw new Error(`transition must define 'from': ${JSON.stringify(tr)}`); } if (tr.to === undefined) { throw new Error(`transition must define 'to': ${ JSON.stringify(tr)}`); } // get the cursors. what a mess - let cursor_from = this._states.get(tr.from); - if (cursor_from === undefined) { - this._new_state({name: tr.from, from: [], to: [], complete: complete.includes(tr.from) }); - cursor_from = (this._states.get(tr.from) : any); + const cursor_from : JssmGenericState + = this._states.get(tr.from) + || { name: tr.from, from: [], to: [], complete: complete.includes(tr.from) }; + + if (!(this._states.has(tr.from))) { + this._new_state(cursor_from); } - let cursor_to = this._states.get(tr.to); - if (cursor_to === undefined) { - this._new_state({name: tr.to, from: [], to: [], complete: complete.includes(tr.to) }); - cursor_to = (this._states.get(tr.to) : any); + const cursor_to : JssmGenericState + = this._states.get(tr.to) + || {name: tr.to, from: [], to: [], complete: complete.includes(tr.to) }; + + if (!(this._states.has(tr.to))) { + this._new_state(cursor_to); } // guard against existing connections being re-added if (cursor_from.to.includes(tr.to)) { - throw new Error(`already has ${tr.from} to ${tr.to}`); + throw new Error(`already has ${JSON.stringify(tr.from)} to ${JSON.stringify(tr.to)}`); } else { cursor_from.to.push(tr.to); cursor_to.from.push(tr.from); @@ -75,19 +303,21 @@ class machine { // add the edge; note its id this._edges.push(tr); - const thisEdgeId = this._edges.length - 1; + const thisEdgeId : number = this._edges.length - 1; // guard against repeating a transition name if (tr.name) { - if (this._named_transitions.has(tr.name)) { throw new Error(`named transition "${tr.name}" already created`); } - else { this._named_transitions.set(tr.name, thisEdgeId); } + if (this._named_transitions.has(tr.name)) { + throw new Error(`named transition "${JSON.stringify(tr.name)}" already created`); + } else { + this._named_transitions.set(tr.name, thisEdgeId); + } } // set up the mapping, so that edges can be looked up by endpoint pairs - let from_mapping = this._edge_map.get(tr.from); - if (from_mapping === undefined) { - this._edge_map.set(tr.from, new Map()); - from_mapping = (this._edge_map.get(tr.from) : any); // whargarbl burn out uses of any + const from_mapping : Map = this._edge_map.get(tr.from) || new Map(); + if (!(this._edge_map.has(tr.from))) { + this._edge_map.set(tr.from, from_mapping); } // const to_mapping = from_mapping.get(tr.to); @@ -98,21 +328,21 @@ class machine { // forward mapping first by action name - let actionMap = this._actions.get(tr.action); + let actionMap : ?Map = this._actions.get(tr.action); if (!(actionMap)) { actionMap = new Map(); this._actions.set(tr.action, actionMap); } if (actionMap.has(tr.from)) { - throw new Error(`action ${tr.action} already attached to origin ${tr.from}`); + throw new Error(`action ${JSON.stringify(tr.action)} already attached to origin ${JSON.stringify(tr.from)}`); } else { actionMap.set(tr.from, thisEdgeId); } // reverse mapping first by state origin name - let rActionMap = this._reverse_actions.get(tr.from); + let rActionMap : ?Map = this._reverse_actions.get(tr.from); if (!(rActionMap)) { rActionMap = new Map(); this._reverse_actions.set(tr.from, rActionMap); @@ -150,7 +380,7 @@ class machine { _new_state(state_config : JssmGenericState) : mNT { // whargarbl get that state_config any under control if (this._states.has(state_config.name)) { - throw new Error(`state ${(state_config.name:any)} already exists`); + throw new Error(`state ${JSON.stringify(state_config.name)} already exists`); } this._states.set(state_config.name, state_config); @@ -182,6 +412,10 @@ class machine { return this.state_is_final(this.state()); } + layout() : string { + return String(this._layout); + } + machine_state() : JssmMachineInternalState { @@ -213,7 +447,7 @@ class machine { } state_for(whichState : mNT) : JssmGenericState { - const state = this._states.get(whichState); + const state : ?JssmGenericState = this._states.get(whichState); if (state) { return state; } else { throw new Error(`no such state ${JSON.stringify(state)}`); } } @@ -234,13 +468,23 @@ class machine { - get_transition_by_state_names(from: mNT, to: mNT) { - return this._edge_map.has(from)? (this._edge_map.get(from) : any).get(to) : undefined; + get_transition_by_state_names(from: mNT, to: mNT) : ?number { + + const emg : ?Map = this._edge_map.get(from); + + if (emg) { + return emg.get(to); + } else { + return undefined; + } + } + + lookup_transition_for(from: mNT, to: mNT) : ?JssmTransition { - const id = this.get_transition_by_state_names(from, to); - return (id === undefined)? undefined : this._edges[id]; + const id : ?number = this.get_transition_by_state_names(from, to); + return ((id === undefined) || (id === null))? undefined : this._edges[id]; } @@ -261,19 +505,22 @@ class machine { probable_exits_for(whichState : mNT) : Array< JssmTransition > { - const wstate = this._states.get(whichState); + const wstate : ?JssmGenericState = this._states.get(whichState); if (!(wstate)) { throw new Error(`No such state ${JSON.stringify(whichState)} in probable_exits_for`); } - const wstate_to = wstate.to, - wtf = wstate_to.map(ws => this.lookup_transition_for(this.state(), ws)).filter(defined => defined); + const wstate_to : Array< mNT > = wstate.to, + + wtf : Array< JssmTransition > + = wstate_to + .map( (ws) : ?JssmTransition => this.lookup_transition_for(this.state(), ws)) + .filter(Boolean); - return (wtf:any); // :any because it can't see that .filter(d => d) removes - // the undefineds, and l_t_f returns ?jt, but this returns jt + return wtf; } probabilistic_transition() : boolean { - const selected = weighted_rand_select(this.probable_exits_for(this.state())); + const selected : JssmTransition = weighted_rand_select(this.probable_exits_for(this.state())); return this.transition( selected.to ); } @@ -287,20 +534,20 @@ class machine { .concat([this.state()]); } - probabilistic_histo_walk(n : number) : Map { + probabilistic_histo_walk(n : number) : Map { return histograph(this.probabilistic_walk(n)); } actions(whichState : mNT = this.state() ) : Array { - const wstate = this._reverse_actions.get(whichState); + const wstate : ?Map = this._reverse_actions.get(whichState); if (wstate) { return [... wstate.keys()]; } else { throw new Error(`No such state ${JSON.stringify(whichState)}`); } } list_states_having_action(whichState : mNT) : Array { - const wstate = this._actions.get(whichState); + const wstate : ?Map = this._actions.get(whichState); if (wstate) { return [... wstate.keys()]; } else { throw new Error(`No such state ${JSON.stringify(whichState)}`); } } @@ -314,26 +561,26 @@ class machine { .map( filtered => filtered.from ); } */ - list_exit_actions(whichState : mNT = this.state() ) : Array { // these are mNT - const ra_base = this._reverse_actions.get(whichState); + list_exit_actions(whichState : mNT = this.state() ) : Array { // these are mNT, not ?mNT + const ra_base : ?Map = this._reverse_actions.get(whichState); if (!(ra_base)) { throw new Error(`No such state ${JSON.stringify(whichState)}`); } return [... ra_base.values()] - .map ( (edgeId:number) => this._edges[edgeId] ) - .filter ( (o:JssmTransition) => o.from === whichState ) - .map ( filtered => filtered.action ); + .map ( (edgeId:number) : JssmTransition => this._edges[edgeId] ) + .filter ( (o:JssmTransition) : boolean => o.from === whichState ) + .map ( (filtered : JssmTransition) : ?mNT => filtered.action ); } - probable_action_exits(whichState : mNT = this.state() ) : Array { // these are mNT - const ra_base = this._reverse_actions.get(whichState); + probable_action_exits(whichState : mNT = this.state() ) : Array { // these are mNT + const ra_base : ?Map = this._reverse_actions.get(whichState); if (!(ra_base)) { throw new Error(`No such state ${JSON.stringify(whichState)}`); } return [... ra_base.values()] - .map ( (edgeId:number) => this._edges[edgeId] ) - .filter ( (o:JssmTransition) => o.from === whichState ) - .map ( filtered => ( { action : filtered.action, - probability : filtered.probability } ) - ); + .map ( (edgeId:number) : JssmTransition => this._edges[edgeId] ) + .filter ( (o:JssmTransition) : boolean => o.from === whichState ) + .map ( (filtered) : mixed => ( { action : filtered.action, + probability : filtered.probability } ) + ); } @@ -344,7 +591,7 @@ class machine { } has_unenterables() : boolean { - return this.states().some(x => this.is_unenterable(x)); + return this.states().some( (x) : boolean => this.is_unenterable(x)); } @@ -359,7 +606,7 @@ class machine { } has_terminals() : boolean { - return this.states().some(x => this.state_is_terminal(x)); + return this.states().some( (x) : boolean => this.state_is_terminal(x)); } @@ -369,13 +616,13 @@ class machine { } state_is_complete(whichState : mNT) : boolean { - const wstate = this._states.get(whichState); + const wstate : ?JssmGenericState = this._states.get(whichState); if (wstate) { return wstate.complete; } else { throw new Error(`No such state ${JSON.stringify(whichState)}`); } } has_completes() : boolean { - return this.states().some(x => this.state_is_complete(x)); + return this.states().some( (x) : boolean => this.state_is_complete(x) ); } @@ -385,7 +632,7 @@ class machine { // todo whargarbl implement data stuff // todo major incomplete whargarbl comeback if (this.valid_action(name, newData)) { - const edge = this.current_action_edge_for(name); + const edge : JssmTransition = this.current_action_edge_for(name); this._state = edge.to; return true; } else { @@ -405,7 +652,6 @@ class machine { } } -/* whargarbl reintroduce after valid_force_transition is re-enabled // can leave machine in inconsistent state. generally do not use force_transition(newState : mNT, newData? : mDT) : boolean { // todo whargarbl implement hooks @@ -418,18 +664,17 @@ class machine { return false; } } -*/ current_action_for(action : mNT) : number | void { - const action_base = this._actions.get(action); + const action_base : ?Map = this._actions.get(action); return action_base? action_base.get(this.state()) : undefined; } current_action_edge_for(action : mNT) : JssmTransition { - const idx = this.current_action_for(action); - if (idx === undefined) { throw new Error(`No such action ${JSON.stringify(action)}`); } + const idx : ?number = this.current_action_for(action); + if ((idx === undefined) || (idx === null)) { throw new Error(`No such action ${JSON.stringify(action)}`); } return this._edges[idx]; } @@ -444,14 +689,21 @@ class machine { // todo whargarbl implement hooks // todo whargarbl implement data stuff // todo major incomplete whargarbl comeback - return (this.lookup_transition_for(this.state(), newState) !== undefined); + const transition_for : ?JssmTransition = this.lookup_transition_for(this.state(), newState); + + if (!(transition_for)) { return false; } + if (transition_for.forced_only) { return false; } + + return true; + } -/* todo whargarbl re-enable force_transition/1 after implementing this - valid_force_transition(newState : mNT, newData? : mDT) : boolean { - return false; // major todo whargarbl + valid_force_transition(newState : mNT, _newData? : mDT) : boolean { // todo comeback unignore newData + // todo whargarbl implement hooks + // todo whargarbl implement data stuff + // todo major incomplete whargarbl comeback + return (this.lookup_transition_for(this.state(), newState) !== undefined); } -*/ } @@ -460,12 +712,47 @@ class machine { +function sm(template_strings : Array /* , arguments */) : Machine { + + // foo`a${1}b${2}c` will come in as (['a','b','c'],1,2) + // this includes when a and c are empty strings + // therefore template_strings will always have one more el than template_args + // therefore map the smaller container and toss the last one on on the way out + + return new Machine(make(template_strings.reduce( + + // in general avoiding `arguments` is smart. however with the template + // string notation, as designed, it's not really worth the hassle + + /* eslint-disable fp/no-arguments */ + /* eslint-disable prefer-rest-params */ + (acc, val, idx) : string => `${acc}${arguments[idx]}${val}` // arguments[0] is never loaded, so args doesn't need to be gated + /* eslint-enable prefer-rest-params */ + /* eslint-enable fp/no-arguments */ + + ))); + +} + + + + + export { version, - machine, - parse, + Machine, + + make, + parse, + compile, + + sm, + + arrow_direction, + arrow_left_kind, + arrow_right_kind, // todo whargarbl these should be exported to a utility library seq, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key diff --git a/src/js/tests/array_transitions.js b/src/js/tests/array_transitions.js new file mode 100644 index 00000000..93a9af79 --- /dev/null +++ b/src/js/tests/array_transitions.js @@ -0,0 +1,54 @@ + +/* eslint-disable max-len */ + +import {describe} from 'ava-spec'; + +const jssm = require('../../../build/jssm.es5.js'); + + + + + +describe('array on left', async it => { + + const aLeft = [{main_path: false,forced_only: false,"from":"a","to":"d","kind":"legal"}, + {main_path: false,forced_only: false,"from":"b","to":"d","kind":"legal"}, + {main_path: false,forced_only: false,"from":"c","to":"d","kind":"legal"}]; + + it('[a b c]->d;', t => t.deepEqual(aLeft, jssm.compile(jssm.parse('[a b c]->d;')).transitions )); + +}); + + + + + +describe('array on right', async it => { + + const aRight = [{main_path: false,forced_only: false,"from":"a","to":"b","kind":"legal"}, + {main_path: false,forced_only: false,"from":"a","to":"c","kind":"legal"}, + {main_path: false,forced_only: false,"from":"a","to":"d","kind":"legal"}]; + + it('a->[b c d];', t => t.deepEqual(aRight, jssm.compile(jssm.parse('a->[b c d];')).transitions )); + +}); + + + + + +describe('array on both sides', async it => { + + const aBoth = [{main_path: false,forced_only: false,"from":"a","to":"x","kind":"legal"}, + {main_path: false,forced_only: false,"from":"a","to":"y","kind":"legal"}, + {main_path: false,forced_only: false,"from":"a","to":"z","kind":"legal"}, + {main_path: false,forced_only: false,"from":"b","to":"x","kind":"legal"}, + {main_path: false,forced_only: false,"from":"b","to":"y","kind":"legal"}, + {main_path: false,forced_only: false,"from":"b","to":"z","kind":"legal"}, + {main_path: false,forced_only: false,"from":"c","to":"x","kind":"legal"}, + {main_path: false,forced_only: false,"from":"c","to":"y","kind":"legal"}, + {main_path: false,forced_only: false,"from":"c","to":"z","kind":"legal"}]; + + it('[a b c]->[x y z];', t => t.deepEqual(aBoth, jssm.compile(jssm.parse('[a b c]->[x y z];')).transitions )); + +}); diff --git a/src/js/tests/arrow.js b/src/js/tests/arrow.js new file mode 100644 index 00000000..9ef7ebad --- /dev/null +++ b/src/js/tests/arrow.js @@ -0,0 +1,109 @@ + +/* eslint-disable max-len */ + +import {describe} from 'ava-spec'; + +const jssm = require('../../../build/jssm.es5.js'); + + + + + +describe('arrow_direction', async it => { + + it('<-', t => t.is('left', jssm.arrow_direction('<-') ) ); + it('<=', t => t.is('left', jssm.arrow_direction('<=') ) ); + it('<~', t => t.is('left', jssm.arrow_direction('<~') ) ); + + it('->', t => t.is('right', jssm.arrow_direction('->') ) ); + it('=>', t => t.is('right', jssm.arrow_direction('=>') ) ); + it('~>', t => t.is('right', jssm.arrow_direction('~>') ) ); + + it('<->', t => t.is('both', jssm.arrow_direction('<->') ) ); + it('<=>', t => t.is('both', jssm.arrow_direction('<=>') ) ); + it('<~>', t => t.is('both', jssm.arrow_direction('<~>') ) ); + + it('<-=>', t => t.is('both', jssm.arrow_direction('<-=>') ) ); + it('<=->', t => t.is('both', jssm.arrow_direction('<=->') ) ); + it('<-~>', t => t.is('both', jssm.arrow_direction('<-~>') ) ); + it('<~->', t => t.is('both', jssm.arrow_direction('<~->') ) ); + it('<=~>', t => t.is('both', jssm.arrow_direction('<=~>') ) ); + it('<~=>', t => t.is('both', jssm.arrow_direction('<~=>') ) ); + +}); + + + + + +describe('arrow_left_kind', async it => { + + it('->', t => t.is('none', jssm.arrow_left_kind('->') ) ); + it('=>', t => t.is('none', jssm.arrow_left_kind('=>') ) ); + it('~>', t => t.is('none', jssm.arrow_left_kind('~>') ) ); + + it('<-', t => t.is('legal', jssm.arrow_left_kind('<-') ) ); + it('<->', t => t.is('legal', jssm.arrow_left_kind('<->') ) ); + it('<-=>', t => t.is('legal', jssm.arrow_left_kind('<-=>') ) ); + it('<-~>', t => t.is('legal', jssm.arrow_left_kind('<-~>') ) ); + + it('<=', t => t.is('main', jssm.arrow_left_kind('<=') ) ); + it('<=>', t => t.is('main', jssm.arrow_left_kind('<=>') ) ); + it('<=->', t => t.is('main', jssm.arrow_left_kind('<=->') ) ); + it('<=~>', t => t.is('main', jssm.arrow_left_kind('<=~>') ) ); + + it('<~', t => t.is('forced', jssm.arrow_left_kind('<~') ) ); + it('<~>', t => t.is('forced', jssm.arrow_left_kind('<~>') ) ); + it('<~->', t => t.is('forced', jssm.arrow_left_kind('<~->') ) ); + it('<~=>', t => t.is('forced', jssm.arrow_left_kind('<~=>') ) ); + +}); + + + + + +describe('arrow_right_kind', async it => { + + it('<-', t => t.is('none', jssm.arrow_right_kind('<-') ) ); + it('<=', t => t.is('none', jssm.arrow_right_kind('<=') ) ); + it('<~', t => t.is('none', jssm.arrow_right_kind('<~') ) ); + + it('->', t => t.is('legal', jssm.arrow_right_kind('->') ) ); + it('<->', t => t.is('legal', jssm.arrow_right_kind('<->') ) ); + it('<=->', t => t.is('legal', jssm.arrow_right_kind('<=->') ) ); + it('<~->', t => t.is('legal', jssm.arrow_right_kind('<~->') ) ); + + it('=>', t => t.is('main', jssm.arrow_right_kind('=>') ) ); + it('<=>', t => t.is('main', jssm.arrow_right_kind('<=>') ) ); + it('<-=>', t => t.is('main', jssm.arrow_right_kind('<-=>') ) ); + it('<~=>', t => t.is('main', jssm.arrow_right_kind('<~=>') ) ); + + it('~>', t => t.is('forced', jssm.arrow_right_kind('~>') ) ); + it('<~>', t => t.is('forced', jssm.arrow_right_kind('<~>') ) ); + it('<-~>', t => t.is('forced', jssm.arrow_right_kind('<-~>') ) ); + it('<=~>', t => t.is('forced', jssm.arrow_right_kind('<=~>') ) ); + +}); + + + + + +describe('error catchery', async _parse_it => { + + describe('unknown arrow direction', async it => { + it('throws', t => t.throws( () => { jssm.arrow_direction('boop'); } )); + }); + + describe('unknown arrow left kind', async it => { + it('throws', t => t.throws( () => { jssm.arrow_left_kind('boop'); } )); + }); + + describe('unknown arrow right kind', async it => { + it('throws', t => t.throws( () => { jssm.arrow_right_kind('boop'); } )); + }); + +}); + +// stochable diff --git a/src/js/tests/compile.js b/src/js/tests/compile.js new file mode 100644 index 00000000..a07e0078 --- /dev/null +++ b/src/js/tests/compile.js @@ -0,0 +1,48 @@ + +/* eslint-disable max-len */ + +import {describe} from 'ava-spec'; + +const jssm = require('../../../build/jssm.es5.js'); + + + + + +describe('compile/1', async _parse_it => { + + describe('a->b;', async it => { + const a_to_b_str = `a->b;`; + it('doesn\'t throw', t => t.notThrows(() => { jssm.compile(jssm.parse(a_to_b_str)); }) ); + }); + + describe('a->b->c;', async it => { + const a_to_b_to_c_str = `a->b->c;`; + it('doesn\'t throw', t => t.notThrows(() => { jssm.compile(jssm.parse(a_to_b_to_c_str)); }) ); + }); + + describe('template tokens', async it => { + const a_through_e_token_str = `a->${'b'}->c->${'d'}->e;`; + it('doesn\'t throw', t => t.notThrows(() => { jssm.compile(jssm.parse(a_through_e_token_str)); }) ); + }); + + describe('all arrows', async it => { + const all_arrows = `a -> b => c ~> d <-> e <=> f <~> g <-=> h <=-> i <~-> j <-~> k <=~> l <~=> m <- n <= o <~ p;`; + it('doesn\'t throw', t => t.notThrows(() => { jssm.compile(jssm.parse(all_arrows)); }) ); + }); + +}); + + + + + +describe('error catchery', async _parse_it => { + + describe('unknown rule', async it => { + it('throws', t => t.throws( () => { jssm.compile( [{"key":"FAKE_RULE","from":"a","se":{"kind":"->","to":"b"}}] ); } )); + }); + +}); + +// stochable diff --git a/src/js/tests/forced transitions.js b/src/js/tests/forced transitions.js new file mode 100644 index 00000000..78a23b66 --- /dev/null +++ b/src/js/tests/forced transitions.js @@ -0,0 +1,29 @@ + +/* eslint-disable max-len */ + +import {describe} from 'ava-spec'; + +const jssm = require('../../../build/jssm.es5.js'), + sm = jssm.sm; + + + + + +describe('reject and accept correctly', async it => { + + const machine = sm` a ~> b -> c; `; + + it('starts in a', t => t.is('a', machine.state() )); + it('rejects transition to b', t => t.is(false, machine.transition('b') )); + it('still in a', t => t.is('a', machine.state() )); + it('rejects transition to c', t => t.is(false, machine.transition('c') )); + it('still in a', t => t.is('a', machine.state() )); + it('rejects forced transition to c', t => t.is(false, machine.force_transition('c') )); + it('still in a', t => t.is('a', machine.state() )); + it('accepts forced transition to b', t => t.is(true, machine.force_transition('b') )); + it('now in b', t => t.is('b', machine.state() )); + it('accepts transition to c', t => t.is(true, machine.transition('c') )); + it('now in c', t => t.is('c', machine.state() )); + +}); diff --git a/src/js/tests/general.js b/src/js/tests/general.js index 63d2d411..50ea8308 100644 --- a/src/js/tests/general.js +++ b/src/js/tests/general.js @@ -15,82 +15,9 @@ test('build-set version number is present', t => t.is(typeof jssm.version, 'stri -describe('Simple stop light', async it => { - - const trs = [ - { name: 'SwitchToWarn', action: 'Proceed', from:'Green', to:'Yellow' }, - { name: 'SwitchToHalt', action: 'Proceed', from:'Yellow', to:'Red' }, - { name: 'SwitchToGo', action: 'Proceed', from:'Red', to:'Green' } - ], - light = new jssm.machine({ - initial_state : 'Red', - transitions : trs - }); - - const r_states = light.states(); - it('has the right state count', t => t.is(r_states.length, 3)); - trs.map(t => t.to).map(c => - it(`has state "${c}"`, t => t.is(r_states.includes(c), true)) - ); - - const r_names = light.list_named_transitions(); - it('has the right named transition count', t => t.is(r_names.size, 3)); - trs.map(t => t.name) - .map(a => - it(`has named transition "${a}"`, t => t.is(r_names.has(a), true)) - ); - - it.describe('- `proceed` walkthrough', async it2 => { - - it2('machine starts red', t => t.is("Red", light.state())); - it2('proceed is true', t => t.is(true, light.action('Proceed'))); - it2('light is now green', t => t.is("Green", light.state())); - it2('proceed is true', t => t.is(true, light.action('Proceed'))); - it2('light is now yellow', t => t.is("Yellow", light.state())); - it2('proceed is true', t => t.is(true, light.action('Proceed'))); - it2('light is red again', t => t.is("Red", light.state())); - - }); - - it.describe('- mixed - `proceed` and `transition`', async it3 => { - - it3('machine starts red', t => t.is("Red", light.state())); - it3('proceed is true', t => t.is(true, light.action('Proceed'))); - it3('light is now green', t => t.is("Green", light.state())); - - it3('green refuses transition red', t => t.is(false, light.transition('Red'))); - it3('green still green', t => t.is("Green", light.state())); - it3('green refuses transition green', t => t.is(false, light.transition('Green'))); - it3('green still green', t => t.is("Green", light.state())); - it3('green accepts transition yellow', t => t.is(true, light.transition('Yellow'))); - it3('green now yellow', t => t.is("Yellow", light.state())); - - it3('proceed is true', t => t.is(true, light.action('Proceed'))); - it3('light is red again', t => t.is("Red", light.state())); - - it3('red refuses transition yellow', t => t.is(false, light.transition('Yellow'))); - it3('red still red', t => t.is("Red", light.state())); - it3('red refuses transition red', t => t.is(false, light.transition('Red'))); - it3('red still red', t => t.is("Red", light.state())); - it3('red accepts transition green', t => t.is(true, light.transition('Green'))); - it3('red now green', t => t.is("Green", light.state())); - - it3('proceed is true', t => t.is(true, light.action('Proceed'))); - it3('light is yellow again', t => t.is("Yellow", light.state())); - it3('proceed is true', t => t.is(true, light.action('Proceed'))); - it3('light is finally red again', t => t.is("Red", light.state())); - - }); - -}); - - - - - describe('Stochastic weather', async _it => { - new jssm.machine({ + new jssm.Machine({ initial_state: 'breezy', @@ -150,89 +77,9 @@ describe('Stochastic weather', async _it => { -describe('Complex stop light', async it => { - - const light2 = new jssm.machine({ - - initial_state: 'off', - - transitions:[ - - { name:'turn_on', action:'power_on', from:'off', to:'red'}, - - { action:'power_off', from:'red', to:'off' }, - { action:'power_off', from:'yellow', to:'off' }, - { action:'power_off', from:'green', to:'off' }, - - { name:'switch_warn', action:'proceed', from:'green', to:'yellow' }, - { name:'switch_halt', action:'proceed', from:'yellow', to:'red' }, - { name:'switch_go', action:'proceed', from:'red', to:'green' } - - ] - - }); - - const r_states = light2.states(); - it('has the right state count', t => t.is(r_states.length, 4)); - ['red', 'yellow', 'green', 'off'].map(c => - it(`has state "${c}"`, t => t.is(r_states.includes(c), true)) - ); - - const r_names = light2.list_named_transitions(); - it('has the right named transition count', t => t.is(r_names.size, 4)); - ['turn_on', 'switch_warn', 'switch_halt', 'switch_go'].map(a => - it(`has named transition "${a}"`, t => t.is(r_names.has(a), true)) - ); - - it('has the right exit actions for red', t => t.deepEqual(['power_off', 'proceed'], light2.list_exit_actions('red'))); - - - it.describe('- `transition` walkthrough', async it2 => { - - it2('machine starts off', t => t.is("off", light2.state())); - it2('off refuses green', t => t.is(false, light2.transition('green'))); - it2('off refuses yellow', t => t.is(false, light2.transition('yellow'))); - - it2('off refuses proceed', t => t.is(false, light2.action('proceed'))); - - it2('off accepts red', t => t.is(true, light2.transition('red'))); - it2('off is now red', t => t.is("red", light2.state())); - it2('red refuses yellow', t => t.is(false, light2.transition('yellow'))); - it2('red still red', t => t.is("red", light2.state())); - it2('red refuses red', t => t.is(false, light2.transition('red'))); - it2('red still red', t => t.is("red", light2.state())); - - it2('red accepts green', t => t.is(true, light2.transition('green'))); - it2('red now green', t => t.is("green", light2.state())); - it2('green refuses red', t => t.is(false, light2.transition('red'))); - it2('green still green', t => t.is("green", light2.state())); - it2('green refuses green', t => t.is(false, light2.transition('green'))); - it2('green still green', t => t.is("green", light2.state())); - - it2('green accepts yellow', t => t.is(true, light2.transition('yellow'))); - it2('green now yellow', t => t.is("yellow", light2.state())); - it2('yellow refuses green', t => t.is(false, light2.transition('green'))); - it2('yellow still yellow', t => t.is("yellow", light2.state())); - it2('yellow refuses yellow', t => t.is(false, light2.transition('yellow'))); - it2('yellow still yellow', t => t.is("yellow", light2.state())); - - it2('yellow accepts red', t => t.is(true, light2.transition('red'))); - it2('back to red', t => t.is("red", light2.state())); - - it2('proceed is true', t => t.is(true, light2.action('proceed'))); - it2('light is now green', t => t.is("green", light2.state())); - - }); - -}); - - - - - describe('list exit actions', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { from:'off', to:'red', action:'on' }, { from:'red', to:'off',action:'off' } ] }); @@ -249,7 +96,7 @@ describe('list exit actions', async it => { describe('probable exits for', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { from:'off', to:'red' } ] }); @@ -267,7 +114,7 @@ describe('probable exits for', async it => { describe('probable action exits', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { from:'off', to:'red', action:'on' }, { from:'red', to:'off',action:'off' } ] }); @@ -289,7 +136,7 @@ describe('probable action exits', async it => { describe('probabilistic_transition', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { from:'off', to:'red' } ] }); @@ -306,7 +153,7 @@ describe('probabilistic_transition', async it => { describe('probabilistic_walk', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { from:'off', to:'red' }, { from:'red', to:'off' } ] }); @@ -323,7 +170,7 @@ describe('probabilistic_walk', async it => { describe('probabilistic_histo_walk', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { from:'off', to:'red' }, { from:'red', to:'off' } ] }); @@ -342,7 +189,7 @@ describe('probabilistic_histo_walk', async it => { describe('reports state_is_final', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { from:'off', to:'red' }, @@ -365,7 +212,7 @@ describe('reports state_is_final', async it => { describe('reports is_final', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { from:'off', to:'red' } @@ -390,7 +237,7 @@ describe('reports is_final', async it => { describe('reports state_is_terminal', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ] }); @@ -406,7 +253,7 @@ describe('reports state_is_terminal', async it => { describe('reports is_terminal', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ] }); @@ -429,7 +276,7 @@ describe('reports is_terminal', async it => { describe('reports state_is_complete', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ], complete:['off'] // huhu @@ -446,7 +293,7 @@ describe('reports state_is_complete', async it => { describe('reports is_complete', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ], complete:['off'] // huhu @@ -470,7 +317,7 @@ describe('reports is_complete', async it => { describe('reports on actions', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ] }); @@ -490,7 +337,7 @@ describe('reports on actions', async it => { describe('actions', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { from:'off', to:'red', action:'on' }, { from:'red', to:'off',action:'off' } ] }); @@ -512,7 +359,7 @@ describe('actions', async it => { describe('states having action', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { from:'off', to:'red', action:'on' }, { from:'red', to:'off',action:'off' } ] }); @@ -528,7 +375,7 @@ describe('states having action', async it => { describe('unenterables', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ] }); @@ -545,7 +392,7 @@ describe('unenterables', async it => { describe('reports on action edges', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ] }); @@ -561,7 +408,7 @@ describe('reports on action edges', async it => { describe('reports on states', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ] }); @@ -578,7 +425,7 @@ describe('reports on states', async it => { describe('returns states', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ] }); @@ -593,7 +440,7 @@ describe('returns states', async it => { describe('reports on transitions', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ] }); @@ -643,7 +490,7 @@ describe('reports on transitions', async it => { describe('transition by state names', async it => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'off', transitions:[ { name:'turn_on', action:'power_on', from:'off', to:'red'} ] }); @@ -663,7 +510,7 @@ describe('Illegal machines', async it => { it('catch repeated names', t => t.throws(() => { - new jssm.machine({ + new jssm.Machine({ initial_state: 'moot', transitions:[ { name:'identical', from:'1', to:'2' }, @@ -676,7 +523,7 @@ describe('Illegal machines', async it => { it('must define from', t => t.throws(() => { - new jssm.machine({ + new jssm.Machine({ initial_state: 'moot', transitions:[ { name:'identical', to:'2' } @@ -688,7 +535,7 @@ describe('Illegal machines', async it => { it('must define to', t => t.throws(() => { - new jssm.machine({ + new jssm.Machine({ initial_state: 'moot', transitions:[ { name:'identical', from:'1' } @@ -700,7 +547,7 @@ describe('Illegal machines', async it => { it('must not have two identical edges', t => t.throws(() => { - new jssm.machine({ + new jssm.Machine({ initial_state: 'moot', transitions:[ { name:'id1', from:'1', to:'2' }, @@ -713,7 +560,7 @@ describe('Illegal machines', async it => { it('must not have two of the same action from the same source', t => t.throws(() => { - new jssm.machine({ + new jssm.Machine({ initial_state: 'moot', transitions:[ { name:'id1', from:'1', to:'2', action:'identical' }, @@ -726,7 +573,7 @@ describe('Illegal machines', async it => { it('must not have completion of non-state', t => t.throws(() => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'moot', transitions:[ { name:'id1', from:'1', to:'2', action:'identical' } @@ -740,7 +587,7 @@ describe('Illegal machines', async it => { it('internal state helper must not accept double states', t => t.throws(() => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: 'moot', transitions:[ { name:'id1', from:'1', to:'2', action:'identical' } @@ -755,7 +602,7 @@ describe('Illegal machines', async it => { it('can\'t get actions of non-state', t => t.throws(() => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: '1', transitions:[ { name:'id1', from:'1', to:'2', action:'identical' } @@ -769,7 +616,7 @@ describe('Illegal machines', async it => { it('can\'t get states having non-action', t => t.throws(() => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: '1', transitions:[ { name:'id1', from:'1', to:'2', action:'identical' } @@ -783,7 +630,7 @@ describe('Illegal machines', async it => { it('can\'t list exit states of non-action', t => t.throws(() => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: '1', transitions:[ { name:'id1', from:'1', to:'2', action:'identical' } @@ -797,7 +644,7 @@ describe('Illegal machines', async it => { it('probable exits for throws on non-state', t => t.throws(() => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: '1', transitions:[ { name:'id1', from:'1', to:'2', action:'identical' } @@ -814,7 +661,7 @@ test(t => { it('no probable action exits of non-action', t => t.throws(() => { - const machine = new jssm.machine({ + const machine = new jssm.Machine({ initial_state: '1', transitions:[ { name:'id1', from:'1', to:'2', action:'identical' } diff --git a/src/js/tests/graph node lists.js b/src/js/tests/graph node lists.js new file mode 100644 index 00000000..4db82fca --- /dev/null +++ b/src/js/tests/graph node lists.js @@ -0,0 +1,16 @@ + +/* eslint-disable max-len */ + +import {describe} from 'ava-spec'; + +const jssm = require('../../../build/jssm.es5.js'), + sm = jssm.sm; + + + + + +describe('graph node lists', async it => { + it('start nodes don\'t throw', t => t.notThrows(() => { const _a = sm`start_nodes: [a b c]; a->b->c->d;`; }) ); + it('end nodes don\'t throw', t => t.notThrows(() => { const _a = sm`end_nodes: [a b c]; a->b->c->d;`; }) ); +}); diff --git a/src/js/tests/layout.js b/src/js/tests/layout.js new file mode 100644 index 00000000..3d7d04ea --- /dev/null +++ b/src/js/tests/layout.js @@ -0,0 +1,30 @@ + +/* eslint-disable max-len */ + +import {describe} from 'ava-spec'; + +const jssm = require('../../../build/jssm.es5.js'), + sm = jssm.sm; + + + + + +describe('graph attributes don\'t throw', async it => { + const machine = sm`graph_layout: circo; a->b->c->d->e->f->a;`; + it('layout is circo', t => t.is('circo', machine.layout() )); +}); + + + + + +describe('error catchery', async _parse_it => { + + describe('double graph_layout', async it => { + it('throws', t => t.throws( () => { + const _machine = sm`graph_layout: circo; graph_layout: circo; a->b->c->d->e->f->a;`; + } )); + }); + +}); diff --git a/src/js/tests/parse actions.js b/src/js/tests/parse actions.js new file mode 100644 index 00000000..175452d7 --- /dev/null +++ b/src/js/tests/parse actions.js @@ -0,0 +1,35 @@ + +/* eslint-disable max-len */ + +import {describe} from 'ava-spec'; + +const jssm = require('../../../build/jssm.es5.js'), + sm = jssm.sm; + + + + + +describe('matter', async it => { + + const matter = sm` Solid 'Heat' <-> 'Cool' Liquid 'Heat' <-> 'Cool' Gas 'Heat' <-> 'Cool' Plasma; `; + + it( 'starts Solid', t => t.is('Solid', matter.state() )); + it( 'Heat is true', t => t.is(true, matter.action('Heat') )); + it( 'is now Liquid', t => t.is('Liquid', matter.state() )); + it( 'Heat is true', t => t.is(true, matter.action('Heat') )); + it( 'is now Gas', t => t.is('Gas', matter.state() )); + it( 'Heat is true', t => t.is(true, matter.action('Heat') )); + it( 'is now Plasma', t => t.is('Plasma', matter.state() )); + it( 'Heat is false', t => t.is(false, matter.action('Heat') )); + it( 'is now Plasma', t => t.is('Plasma', matter.state() )); + it( 'Cool is true', t => t.is(true, matter.action('Cool') )); + it( 'is now Gas', t => t.is('Gas', matter.state() )); + it( 'Cool is true', t => t.is(true, matter.action('Cool') )); + it( 'is now Liquid', t => t.is('Liquid', matter.state() )); + it( 'Cool is true', t => t.is(true, matter.action('Cool') )); + it( 'is now Solid', t => t.is('Solid', matter.state() )); + it( 'Cool is false', t => t.is(false, matter.action('Cool') )); + it( 'is now Solid', t => t.is('Solid', matter.state() )); + +}); diff --git a/src/js/tests/parse.js b/src/js/tests/parse.js index cb376787..172394ba 100644 --- a/src/js/tests/parse.js +++ b/src/js/tests/parse.js @@ -13,10 +13,10 @@ describe('parse/1', async _parse_it => { describe('forward arrow', async it => { - const AtoB = [{"from": "a","se": {"kind": "->","to": "b"}}], - AdB = [{"from": "a","se": {"kind": "->","to": "b","ldesc": [{"key":"arc_label","value":"d"}]}}], - ABd = [{"from": "a","se": {"kind": "->","to": "b","rdesc": [{"key":"arc_label","value":"d"}]}}], - AdBd = [{"from": "a","se": {"kind": "->","to": "b","ldesc": [{"key":"arc_label","value":"d"}],"rdesc": [{"key":"arc_label","value":"f"}]}}]; + const AtoB = [{"key": "transition", "from": "a", "se": {"kind": "->","to": "b"}}], + AdB = [{"key": "transition", "from": "a", "se": {"kind": "->","to": "b","l_desc": [{"key":"arc_label","value":"d"}]}}], + ABd = [{"key": "transition", "from": "a", "se": {"kind": "->","to": "b","r_desc": [{"key":"arc_label","value":"d"}]}}], + AdBd = [{"key": "transition", "from": "a", "se": {"kind": "->","to": "b","l_desc": [{"key":"arc_label","value":"d"}],"r_desc": [{"key":"arc_label","value":"f"}]}}]; const echo_equal = (testt, validator) => it(test, t => t.deepEqual(validator, jssm.parse(testt))); @@ -32,10 +32,10 @@ describe('parse/1', async _parse_it => { describe('double arrow', async it => { - const AtoB = [{"from": "a","se": {"kind": "<->","to": "b"}}], - AdB = [{"from": "a","se": {"kind": "<->","to": "b","ldesc": [{"key":"arc_label","value":"d"}]}}], - ABd = [{"from": "a","se": {"kind": "<->","to": "b","rdesc": [{"key":"arc_label","value":"d"}]}}], - AdBd = [{"from": "a","se": {"kind": "<->","to": "b","ldesc": [{"key":"arc_label","value":"d"}],"rdesc": [{"key":"arc_label","value":"f"}]}}]; + const AtoB = [{"key": "transition", "from": "a", "se": {"kind": "<->","to": "b"}}], + AdB = [{"key": "transition", "from": "a", "se": {"kind": "<->","to": "b","l_desc": [{"key":"arc_label","value":"d"}]}}], + ABd = [{"key": "transition", "from": "a", "se": {"kind": "<->","to": "b","r_desc": [{"key":"arc_label","value":"d"}]}}], + AdBd = [{"key": "transition", "from": "a", "se": {"kind": "<->","to": "b","l_desc": [{"key":"arc_label","value":"d"}],"r_desc": [{"key":"arc_label","value":"f"}]}}]; const echo_equal = (testt, validator) => it(test, t => t.deepEqual(validator, jssm.parse(testt))); @@ -50,12 +50,12 @@ describe('parse/1', async _parse_it => { }); describe('chain', async it => { - const AtoBtoC = [{"from":"a","se":{"kind":"->","to":"b","se":{"kind":"->","to":"c"}}}]; + const AtoBtoC = [{"key":"transition","from":"a","se":{"kind":"->","to":"b","se":{"kind":"->","to":"c"}}}]; it('a->b->c;', t => t.deepEqual(AtoBtoC, jssm.parse('a->b->c;') )); }); describe('sequence', async it => { - const AtoB_CtoD = [{"from":"a","se":{"kind":"->","to":"b"}},{"from":"c","se":{"kind":"->","to":"d"}}]; + const AtoB_CtoD = [{"key":"transition","from":"a","se":{"kind":"->","to":"b"}},{"key":"transition","from":"c","se":{"kind":"->","to":"d"}}]; it('a->b;c->d;', t => t.deepEqual(AtoB_CtoD, jssm.parse('a->b;c->d;') )); }); @@ -63,8 +63,14 @@ describe('parse/1', async _parse_it => { // todo: graph: {outputs: [foo]} describe('torture', async it => { - const augh = `a->b-> c-> d -> e;`; + + const augh = ` + a->b-> c-> d -> e +-> +f <- g <= h <-> i <=> j ~> k <~ l <~> m <~-> n <-~> o <=~> p <~=> q <-=> r <=-> s 'A' <= 'B' t;`; + it('doesn\'t throw', t => t.notThrows(() => { jssm.parse(augh); }) ); + }); }); diff --git a/src/js/tests/sm_tag.js b/src/js/tests/sm_tag.js new file mode 100644 index 00000000..1774b94e --- /dev/null +++ b/src/js/tests/sm_tag.js @@ -0,0 +1,29 @@ + +/* eslint-disable max-len */ + +import {describe} from 'ava-spec'; + +const jssm = require('../../../build/jssm.es5.js'), + sm = jssm.sm; + + + + + +describe('sm``', async _parse_it => { + + describe('simple sm`a->b;`', async it => { + it('doesn\'t throw', t => t.notThrows(() => { const _foo = sm`a -> b;`; }) ); + }); + + describe('long and chain sm`a->b;c->d;e->f->g;h->i;`', async it => { + it('doesn\'t throw', t => t.notThrows(() => { const _foo = sm`a->b;c->d;e->f->g;h->i;`; }) ); + }); + + describe('template tags`', async it => { + it('doesn\'t throw', t => t.notThrows(() => { const bar = 'c->d', baz = 'b->h->i;f->h', _foo = sm`a->b;${bar};e->f->g;${baz};`; }) ); + }); + +}); + +// stochable diff --git a/src/js/tests/stop light.js b/src/js/tests/stop light.js new file mode 100644 index 00000000..5cfe0284 --- /dev/null +++ b/src/js/tests/stop light.js @@ -0,0 +1,159 @@ + +/* eslint-disable max-len */ + +import {describe} from 'ava-spec'; + +const jssm = require('../../../build/jssm.es5.js'); + + + + + +describe('Simple stop light', async it => { + + const trs = [ + { name: 'SwitchToWarn', action: 'Proceed', from:'Green', to:'Yellow' }, + { name: 'SwitchToHalt', action: 'Proceed', from:'Yellow', to:'Red' }, + { name: 'SwitchToGo', action: 'Proceed', from:'Red', to:'Green' } + ], + light = new jssm.Machine({ + initial_state : 'Red', + transitions : trs + }); + + const r_states = light.states(); + it('has the right state count', t => t.is(r_states.length, 3)); + trs.map(t => t.to).map(c => + it(`has state "${c}"`, t => t.is(r_states.includes(c), true)) + ); + + const r_names = light.list_named_transitions(); + it('has the right named transition count', t => t.is(r_names.size, 3)); + trs.map(t => t.name) + .map(a => + it(`has named transition "${a}"`, t => t.is(r_names.has(a), true)) + ); + + it.describe('- `proceed` walkthrough', async it2 => { + + it2('machine starts red', t => t.is("Red", light.state())); + it2('proceed is true', t => t.is(true, light.action('Proceed'))); + it2('light is now green', t => t.is("Green", light.state())); + it2('proceed is true', t => t.is(true, light.action('Proceed'))); + it2('light is now yellow', t => t.is("Yellow", light.state())); + it2('proceed is true', t => t.is(true, light.action('Proceed'))); + it2('light is red again', t => t.is("Red", light.state())); + + }); + + it.describe('- mixed - `proceed` and `transition`', async it3 => { + + it3('machine starts red', t => t.is("Red", light.state())); + it3('proceed is true', t => t.is(true, light.action('Proceed'))); + it3('light is now green', t => t.is("Green", light.state())); + + it3('green refuses transition red', t => t.is(false, light.transition('Red'))); + it3('green still green', t => t.is("Green", light.state())); + it3('green refuses transition green', t => t.is(false, light.transition('Green'))); + it3('green still green', t => t.is("Green", light.state())); + it3('green accepts transition yellow', t => t.is(true, light.transition('Yellow'))); + it3('green now yellow', t => t.is("Yellow", light.state())); + + it3('proceed is true', t => t.is(true, light.action('Proceed'))); + it3('light is red again', t => t.is("Red", light.state())); + + it3('red refuses transition yellow', t => t.is(false, light.transition('Yellow'))); + it3('red still red', t => t.is("Red", light.state())); + it3('red refuses transition red', t => t.is(false, light.transition('Red'))); + it3('red still red', t => t.is("Red", light.state())); + it3('red accepts transition green', t => t.is(true, light.transition('Green'))); + it3('red now green', t => t.is("Green", light.state())); + + it3('proceed is true', t => t.is(true, light.action('Proceed'))); + it3('light is yellow again', t => t.is("Yellow", light.state())); + it3('proceed is true', t => t.is(true, light.action('Proceed'))); + it3('light is finally red again', t => t.is("Red", light.state())); + + }); + +}); + + + + + +describe('Complex stop light', async it => { + + const light2 = new jssm.Machine({ + + initial_state: 'off', + + transitions:[ + + { name:'turn_on', action:'power_on', from:'off', to:'red'}, + + { action:'power_off', from:'red', to:'off' }, + { action:'power_off', from:'yellow', to:'off' }, + { action:'power_off', from:'green', to:'off' }, + + { name:'switch_warn', action:'proceed', from:'green', to:'yellow' }, + { name:'switch_halt', action:'proceed', from:'yellow', to:'red' }, + { name:'switch_go', action:'proceed', from:'red', to:'green' } + + ] + + }); + + const r_states = light2.states(); + it('has the right state count', t => t.is(r_states.length, 4)); + ['red', 'yellow', 'green', 'off'].map(c => + it(`has state "${c}"`, t => t.is(r_states.includes(c), true)) + ); + + const r_names = light2.list_named_transitions(); + it('has the right named transition count', t => t.is(r_names.size, 4)); + ['turn_on', 'switch_warn', 'switch_halt', 'switch_go'].map(a => + it(`has named transition "${a}"`, t => t.is(r_names.has(a), true)) + ); + + it('has the right exit actions for red', t => t.deepEqual(['power_off', 'proceed'], light2.list_exit_actions('red'))); + + + it.describe('- `transition` walkthrough', async it2 => { + + it2('machine starts off', t => t.is("off", light2.state())); + it2('off refuses green', t => t.is(false, light2.transition('green'))); + it2('off refuses yellow', t => t.is(false, light2.transition('yellow'))); + + it2('off refuses proceed', t => t.is(false, light2.action('proceed'))); + + it2('off accepts red', t => t.is(true, light2.transition('red'))); + it2('off is now red', t => t.is("red", light2.state())); + it2('red refuses yellow', t => t.is(false, light2.transition('yellow'))); + it2('red still red', t => t.is("red", light2.state())); + it2('red refuses red', t => t.is(false, light2.transition('red'))); + it2('red still red', t => t.is("red", light2.state())); + + it2('red accepts green', t => t.is(true, light2.transition('green'))); + it2('red now green', t => t.is("green", light2.state())); + it2('green refuses red', t => t.is(false, light2.transition('red'))); + it2('green still green', t => t.is("green", light2.state())); + it2('green refuses green', t => t.is(false, light2.transition('green'))); + it2('green still green', t => t.is("green", light2.state())); + + it2('green accepts yellow', t => t.is(true, light2.transition('yellow'))); + it2('green now yellow', t => t.is("yellow", light2.state())); + it2('yellow refuses green', t => t.is(false, light2.transition('green'))); + it2('yellow still yellow', t => t.is("yellow", light2.state())); + it2('yellow refuses yellow', t => t.is(false, light2.transition('yellow'))); + it2('yellow still yellow', t => t.is("yellow", light2.state())); + + it2('yellow accepts red', t => t.is(true, light2.transition('red'))); + it2('back to red', t => t.is("red", light2.state())); + + it2('proceed is true', t => t.is(true, light2.action('proceed'))); + it2('light is now green', t => t.is("green", light2.state())); + + }); + +});