Selaa lähdekoodia

MPIDE-27: integrate parser into old editor shell

Took the bits of the MPIDE we had lying around and hooked up our new
parser. Rewrote the Ace mode (now with embedded Javascript) tweaked the
npm start script to give us something that will run right now.
Austin Meagher 10 vuotta sitten
vanhempi
commit
7c5d79612d

+ 1 - 1
package.json

@@ -13,7 +13,7 @@
   },
   "scripts": {
     "postinstall": "./postinstall.sh",
-    "start": "http-server build/web/ -p 8000 -c-1",
+    "start": "cp ./build/lib/parser/modellang.js ./src/web/assets/scripts; http-server src/web/ -p 8000 -c-1",
     "test": "karma start karma.conf.js",
     "test-single-run": "karma start karma.conf.js --single-run",
     "preupdate-webdriver": "npm install",

+ 1 - 1
src/web/.jshintrc

@@ -1,5 +1,5 @@
 {
-	"extends": "../.jshintrc",
+	"extends": "../../.jshintrc",
 	"browser": true,
 	"jquery": true,
 	"globals": {

+ 2986 - 0
src/web/assets/scripts/modellang-parser.js

@@ -0,0 +1,2986 @@
+modellangParser = (function() {
+  /*
+   * Generated by PEG.js 0.8.0.
+   *
+   * http://pegjs.majda.cz/
+   */
+
+  function peg$subclass(child, parent) {
+    function ctor() { this.constructor = child; }
+    ctor.prototype = parent.prototype;
+    child.prototype = new ctor();
+  }
+
+  function SyntaxError(message, expected, found, offset, line, column) {
+    this.message  = message;
+    this.expected = expected;
+    this.found    = found;
+    this.offset   = offset;
+    this.line     = line;
+    this.column   = column;
+
+    this.name     = "SyntaxError";
+  }
+
+  peg$subclass(SyntaxError, Error);
+
+  function parse(input) {
+    var options = arguments.length > 1 ? arguments[1] : {},
+
+        peg$FAILED = {},
+
+        peg$startRuleFunctions = { start: peg$parsestart },
+        peg$startRuleFunction  = peg$parsestart,
+
+        peg$c0 = [],
+        peg$c1 = function(s) { return model(s); },
+        peg$c2 = peg$FAILED,
+        peg$c3 = function(s) { return s; },
+        peg$c4 = { type: "other", description: "System" },
+        peg$c5 = function(id) { ast.toplevelname = id; ast.localrefs = []; },
+        peg$c6 = void 0,
+        peg$c7 = function(id, body) { return new ast.System(id, body, ast.localrefs); },
+        peg$c8 = { type: "other", description: "Behavior" },
+        peg$c9 = function(id, body) { return new ast.Behavior(id, body, ast.localrefs); },
+        peg$c10 = { type: "other", description: "Interaction" },
+        peg$c11 = function(interaction) { return interaction; },
+        peg$c12 = function(a) { return a; },
+        peg$c13 = function(first, type, second, rest) { return new ast.Interaction(type, [first, second].concat(rest)); },
+        peg$c14 = function(t) { return t; },
+        peg$c15 = { type: "other", description: "Selector" },
+        peg$c16 = function() { ast.selector = true; },
+        peg$c17 = null,
+        peg$c18 = "{",
+        peg$c19 = { type: "literal", value: "{", description: "\"{\"" },
+        peg$c20 = "}",
+        peg$c21 = { type: "literal", value: "}", description: "\"}\"" },
+        peg$c22 = function(c) { return c; },
+        peg$c23 = ":",
+        peg$c24 = { type: "literal", value: ":", description: "\":\"" },
+        peg$c25 = function(pre, sys, pattern, post) { ast.selector = false; return new ast.Selector(sys, pattern, pre, post); },
+        peg$c26 = function(sys, pattern) { ast.selector = false; return new ast.Selector(sys, pattern); },
+        peg$c27 = { type: "other", description: "Behavior Pattern" },
+        peg$c28 = function(item) { return item; },
+        peg$c29 = function(head, tail) {
+                var body = [head].concat(tail);
+                for (var i = 0; i < body.length; i++) {
+                    if (body[i].scope.max && body[i].scope.min > body[i].scope.max)
+                        ast.errors.push(err(2,` (${body[i].id})`));
+                }
+                return new ast.Alternation(body);
+            },
+        peg$c30 = function(body) {
+                for (var i = 0; i < body.length; i++) {
+                    if (body[i].scope.max && body[i].scope.min > body[i].scope.max)
+                        ast.errors.push(err(2,` (${body[i].id})`));
+                }
+                return new ast.Sequence(body);
+            },
+        peg$c31 = function(i, q) { return scopify(i, q); },
+        peg$c32 = function(i, q) { if (ast.localrefs.indexOf(i.id) === -1 && !ast.selector) { ast.localrefs.push(i.id); } return scopify(i, q); },
+        peg$c33 = { type: "other", description: "Group" },
+        peg$c34 = "(",
+        peg$c35 = { type: "literal", value: "(", description: "\"(\"" },
+        peg$c36 = ")",
+        peg$c37 = { type: "literal", value: ")", description: "\")\"" },
+        peg$c38 = function(async, body) { return new ast.Group(async, body); },
+        peg$c39 = { type: "other", description: "Quantifier" },
+        peg$c40 = "+",
+        peg$c41 = { type: "literal", value: "+", description: "\"+\"" },
+        peg$c42 = function() { return {min:1, max:null}; },
+        peg$c43 = "*",
+        peg$c44 = { type: "literal", value: "*", description: "\"*\"" },
+        peg$c45 = function() { return {min:0, max:null}; },
+        peg$c46 = "?",
+        peg$c47 = { type: "literal", value: "?", description: "\"?\"" },
+        peg$c48 = function() { return {min:0, max:1}; },
+        peg$c49 = function(u, v) { return {u:u, v:v}; },
+        peg$c50 = function(lo, hi) { return minmaxify(lo, hi); },
+        peg$c51 = { type: "other", description: "Trigger" },
+        peg$c52 = function(selector, body) { return new ast.Trigger(selector, body); },
+        peg$c53 = { type: "other", description: "Init Block" },
+        peg$c54 = function(system, body) { return new ast.Init(system, body); },
+        peg$c55 = /^[^{}]/,
+        peg$c56 = { type: "class", value: "[^{}]", description: "[^{}]" },
+        peg$c57 = function() { return text().trim(); },
+        peg$c58 = function(id) { return id; },
+        peg$c59 = function(id) {
+                if (!ast.selector) {
+                    if (id === ast.toplevelname) {
+                        ast.errors.push(err(3, ` (${id})`));
+                        ast.toplevelname = null;
+                    } else ast.references.push(id);
+                }
+                return { type: "Behavior", id:id };
+            },
+        peg$c60 = "SYSTEM",
+        peg$c61 = { type: "literal", value: "SYSTEM", description: "\"SYSTEM\"" },
+        peg$c62 = "BEHAVIOR",
+        peg$c63 = { type: "literal", value: "BEHAVIOR", description: "\"BEHAVIOR\"" },
+        peg$c64 = "INTERACTION",
+        peg$c65 = { type: "literal", value: "INTERACTION", description: "\"INTERACTION\"" },
+        peg$c66 = "WHEN",
+        peg$c67 = { type: "literal", value: "WHEN", description: "\"WHEN\"" },
+        peg$c68 = "INIT",
+        peg$c69 = { type: "literal", value: "INIT", description: "\"INIT\"" },
+        peg$c70 = "ASYNC",
+        peg$c71 = { type: "literal", value: "ASYNC", description: "\"ASYNC\"" },
+        peg$c72 = "->",
+        peg$c73 = { type: "literal", value: "->", description: "\"->\"" },
+        peg$c74 = function() { return "Then"; },
+        peg$c75 = "==",
+        peg$c76 = { type: "literal", value: "==", description: "\"==\"" },
+        peg$c77 = function() { return "Join"; },
+        peg$c78 = "=",
+        peg$c79 = { type: "literal", value: "=", description: "\"=\"" },
+        peg$c80 = ",",
+        peg$c81 = { type: "literal", value: ",", description: "\",\"" },
+        peg$c82 = "|",
+        peg$c83 = { type: "literal", value: "|", description: "\"|\"" },
+        peg$c84 = ";",
+        peg$c85 = { type: "literal", value: ";", description: "\";\"" },
+        peg$c86 = { type: "other", description: "Identifier" },
+        peg$c87 = /^[A-Za-z]/,
+        peg$c88 = { type: "class", value: "[A-Za-z]", description: "[A-Za-z]" },
+        peg$c89 = /^[a-zA-Z0-9_]/,
+        peg$c90 = { type: "class", value: "[a-zA-Z0-9_]", description: "[a-zA-Z0-9_]" },
+        peg$c91 = function() { return text(); },
+        peg$c92 = { type: "other", description: "Integer" },
+        peg$c93 = /^[0-9]/,
+        peg$c94 = { type: "class", value: "[0-9]", description: "[0-9]" },
+        peg$c95 = function() { return parseInt(text()); },
+        peg$c96 = { type: "other", description: "Integer > 0" },
+        peg$c97 = /^[1-9]/,
+        peg$c98 = { type: "class", value: "[1-9]", description: "[1-9]" },
+        peg$c99 = { type: "other", description: "Integer >= 0" },
+        peg$c100 = "0",
+        peg$c101 = { type: "literal", value: "0", description: "\"0\"" },
+        peg$c102 = function() { return 0; },
+        peg$c103 = { type: "other", description: "Optional Whitespace" },
+        peg$c104 = /^[ \t\n\r]/,
+        peg$c105 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" },
+        peg$c106 = function() { return null; },
+        peg$c107 = { type: "other", description: "Required Whitespace" },
+        peg$c108 = { type: "other", description: "Newline" },
+        peg$c109 = /^[\n]/,
+        peg$c110 = { type: "class", value: "[\\n]", description: "[\\n]" },
+        peg$c111 = { type: "other", description: "Comment Line" },
+        peg$c112 = "//",
+        peg$c113 = { type: "literal", value: "//", description: "\"//\"" },
+        peg$c114 = /^[^\n]/,
+        peg$c115 = { type: "class", value: "[^\\n]", description: "[^\\n]" },
+        peg$c116 = function(c) { return new ast.Comment(false, c.join("")); },
+        peg$c117 = { type: "other", description: "Comment Block" },
+        peg$c118 = "/*",
+        peg$c119 = { type: "literal", value: "/*", description: "\"/*\"" },
+        peg$c120 = "*/",
+        peg$c121 = { type: "literal", value: "*/", description: "\"*/\"" },
+        peg$c122 = { type: "any", description: "any character" },
+        peg$c123 = function(c) {return c},
+        peg$c124 = function(c) { return new ast.Comment(true, c.join("")); },
+
+        peg$currPos          = 0,
+        peg$reportedPos      = 0,
+        peg$cachedPos        = 0,
+        peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },
+        peg$maxFailPos       = 0,
+        peg$maxFailExpected  = [],
+        peg$silentFails      = 0,
+
+        peg$result;
+
+    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];
+    }
+
+    function text() {
+      return input.substring(peg$reportedPos, peg$currPos);
+    }
+
+    function offset() {
+      return peg$reportedPos;
+    }
+
+    function line() {
+      return peg$computePosDetails(peg$reportedPos).line;
+    }
+
+    function column() {
+      return peg$computePosDetails(peg$reportedPos).column;
+    }
+
+    function expected(description) {
+      throw peg$buildException(
+        null,
+        [{ type: "other", description: description }],
+        peg$reportedPos
+      );
+    }
+
+    function error(message) {
+      throw peg$buildException(message, null, peg$reportedPos);
+    }
+
+    function peg$computePosDetails(pos) {
+      function advance(details, startPos, endPos) {
+        var p, ch;
+
+        for (p = startPos; p < endPos; p++) {
+          ch = input.charAt(p);
+          if (ch === "\n") {
+            if (!details.seenCR) { details.line++; }
+            details.column = 1;
+            details.seenCR = false;
+          } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
+            details.line++;
+            details.column = 1;
+            details.seenCR = true;
+          } else {
+            details.column++;
+            details.seenCR = false;
+          }
+        }
+      }
+
+      if (peg$cachedPos !== pos) {
+        if (peg$cachedPos > pos) {
+          peg$cachedPos = 0;
+          peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };
+        }
+        advance(peg$cachedPosDetails, peg$cachedPos, pos);
+        peg$cachedPos = pos;
+      }
+
+      return peg$cachedPosDetails;
+    }
+
+    function peg$fail(expected) {
+      if (peg$currPos < peg$maxFailPos) { return; }
+
+      if (peg$currPos > peg$maxFailPos) {
+        peg$maxFailPos = peg$currPos;
+        peg$maxFailExpected = [];
+      }
+
+      peg$maxFailExpected.push(expected);
+    }
+
+    function peg$buildException(message, expected, pos) {
+      function cleanupExpected(expected) {
+        var i = 1;
+
+        expected.sort(function(a, b) {
+          if (a.description < b.description) {
+            return -1;
+          } else if (a.description > b.description) {
+            return 1;
+          } else {
+            return 0;
+          }
+        });
+
+        while (i < expected.length) {
+          if (expected[i - 1] === expected[i]) {
+            expected.splice(i, 1);
+          } else {
+            i++;
+          }
+        }
+      }
+
+      function buildMessage(expected, found) {
+        function stringEscape(s) {
+          function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
+
+          return s
+            .replace(/\\/g,   '\\\\')
+            .replace(/"/g,    '\\"')
+            .replace(/\x08/g, '\\b')
+            .replace(/\t/g,   '\\t')
+            .replace(/\n/g,   '\\n')
+            .replace(/\f/g,   '\\f')
+            .replace(/\r/g,   '\\r')
+            .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
+            .replace(/[\x10-\x1F\x80-\xFF]/g,    function(ch) { return '\\x'  + hex(ch); })
+            .replace(/[\u0180-\u0FFF]/g,         function(ch) { return '\\u0' + hex(ch); })
+            .replace(/[\u1080-\uFFFF]/g,         function(ch) { return '\\u'  + hex(ch); });
+        }
+
+        var expectedDescs = new Array(expected.length),
+            expectedDesc, foundDesc, i;
+
+        for (i = 0; i < expected.length; i++) {
+          expectedDescs[i] = expected[i].description;
+        }
+
+        expectedDesc = expected.length > 1
+          ? expectedDescs.slice(0, -1).join(", ")
+              + " or "
+              + expectedDescs[expected.length - 1]
+          : expectedDescs[0];
+
+        foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
+
+        return "Expected " + expectedDesc + " but " + foundDesc + " found.";
+      }
+
+      var posDetails = peg$computePosDetails(pos),
+          found      = pos < input.length ? input.charAt(pos) : null;
+
+      if (expected !== null) {
+        cleanupExpected(expected);
+      }
+
+      return new SyntaxError(
+        message !== null ? message : buildMessage(expected, found),
+        expected,
+        found,
+        pos,
+        posDetails.line,
+        posDetails.column
+      );
+    }
+
+    function peg$parsestart() {
+      var s0, s1, s2;
+
+      s0 = peg$currPos;
+      s1 = [];
+      s2 = peg$parsestatement();
+      while (s2 !== peg$FAILED) {
+        s1.push(s2);
+        s2 = peg$parsestatement();
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c1(s1);
+      }
+      s0 = s1;
+
+      return s0;
+    }
+
+    function peg$parsestatement() {
+      var s0, s1, s2;
+
+      s0 = peg$currPos;
+      s1 = peg$parsesystem_statement();
+      if (s1 === peg$FAILED) {
+        s1 = peg$parsebehavior_statement();
+        if (s1 === peg$FAILED) {
+          s1 = peg$parseinteraction_statement();
+          if (s1 === peg$FAILED) {
+            s1 = peg$parsetrigger();
+            if (s1 === peg$FAILED) {
+              s1 = peg$parseinit();
+            }
+          }
+        }
+      }
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parse_SEMI_();
+        if (s2 !== peg$FAILED) {
+          peg$reportedPos = s0;
+          s1 = peg$c3(s1);
+          s0 = s1;
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parsesystem_statement() {
+      var s0, s1, s2, s3, s4, s5, s6;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      s1 = peg$parse_SYSTEM_();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parse_COLON_();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parsesystem_id();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = peg$currPos;
+            s4 = peg$c5(s3);
+            if (s4) {
+              s4 = peg$c2;
+            } else {
+              s4 = peg$c6;
+            }
+            if (s4 !== peg$FAILED) {
+              s5 = peg$parse_EQ_();
+              if (s5 !== peg$FAILED) {
+                s6 = peg$parsebehavior_pattern();
+                if (s6 !== peg$FAILED) {
+                  peg$reportedPos = s0;
+                  s1 = peg$c7(s3, s6);
+                  s0 = s1;
+                } else {
+                  peg$currPos = s0;
+                  s0 = peg$c2;
+                }
+              } else {
+                peg$currPos = s0;
+                s0 = peg$c2;
+              }
+            } else {
+              peg$currPos = s0;
+              s0 = peg$c2;
+            }
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c4); }
+      }
+
+      return s0;
+    }
+
+    function peg$parsebehavior_statement() {
+      var s0, s1, s2, s3, s4, s5, s6;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      s1 = peg$parse_BEHAVIOR_();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parse_COLON_();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parsebehavior_id();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = peg$currPos;
+            s4 = peg$c5(s3);
+            if (s4) {
+              s4 = peg$c2;
+            } else {
+              s4 = peg$c6;
+            }
+            if (s4 !== peg$FAILED) {
+              s5 = peg$parse_EQ_();
+              if (s5 !== peg$FAILED) {
+                s6 = peg$parsebehavior_pattern();
+                if (s6 !== peg$FAILED) {
+                  peg$reportedPos = s0;
+                  s1 = peg$c9(s3, s6);
+                  s0 = s1;
+                } else {
+                  peg$currPos = s0;
+                  s0 = peg$c2;
+                }
+              } else {
+                peg$currPos = s0;
+                s0 = peg$c2;
+              }
+            } else {
+              peg$currPos = s0;
+              s0 = peg$c2;
+            }
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c8); }
+      }
+
+      return s0;
+    }
+
+    function peg$parseinteraction_statement() {
+      var s0, s1, s2, s3;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      s1 = peg$parse_INTERACTION_();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parse_COLON_();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parseinteraction_body();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c11(s3);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c10); }
+      }
+
+      return s0;
+    }
+
+    function peg$parseinteraction_body() {
+      var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11;
+
+      s0 = peg$currPos;
+      s1 = peg$parseselector_pattern();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parse_();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parseTHEN();
+          if (s3 !== peg$FAILED) {
+            s4 = peg$parse_();
+            if (s4 !== peg$FAILED) {
+              s5 = peg$parseselector_pattern();
+              if (s5 !== peg$FAILED) {
+                s6 = [];
+                s7 = peg$currPos;
+                s8 = peg$parse_();
+                if (s8 !== peg$FAILED) {
+                  s9 = peg$parseTHEN();
+                  if (s9 !== peg$FAILED) {
+                    s10 = peg$parse_();
+                    if (s10 !== peg$FAILED) {
+                      s11 = peg$parseselector_pattern();
+                      if (s11 !== peg$FAILED) {
+                        peg$reportedPos = s7;
+                        s8 = peg$c12(s11);
+                        s7 = s8;
+                      } else {
+                        peg$currPos = s7;
+                        s7 = peg$c2;
+                      }
+                    } else {
+                      peg$currPos = s7;
+                      s7 = peg$c2;
+                    }
+                  } else {
+                    peg$currPos = s7;
+                    s7 = peg$c2;
+                  }
+                } else {
+                  peg$currPos = s7;
+                  s7 = peg$c2;
+                }
+                while (s7 !== peg$FAILED) {
+                  s6.push(s7);
+                  s7 = peg$currPos;
+                  s8 = peg$parse_();
+                  if (s8 !== peg$FAILED) {
+                    s9 = peg$parseTHEN();
+                    if (s9 !== peg$FAILED) {
+                      s10 = peg$parse_();
+                      if (s10 !== peg$FAILED) {
+                        s11 = peg$parseselector_pattern();
+                        if (s11 !== peg$FAILED) {
+                          peg$reportedPos = s7;
+                          s8 = peg$c12(s11);
+                          s7 = s8;
+                        } else {
+                          peg$currPos = s7;
+                          s7 = peg$c2;
+                        }
+                      } else {
+                        peg$currPos = s7;
+                        s7 = peg$c2;
+                      }
+                    } else {
+                      peg$currPos = s7;
+                      s7 = peg$c2;
+                    }
+                  } else {
+                    peg$currPos = s7;
+                    s7 = peg$c2;
+                  }
+                }
+                if (s6 !== peg$FAILED) {
+                  peg$reportedPos = s0;
+                  s1 = peg$c13(s1, s3, s5, s6);
+                  s0 = s1;
+                } else {
+                  peg$currPos = s0;
+                  s0 = peg$c2;
+                }
+              } else {
+                peg$currPos = s0;
+                s0 = peg$c2;
+              }
+            } else {
+              peg$currPos = s0;
+              s0 = peg$c2;
+            }
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      if (s0 === peg$FAILED) {
+        s0 = peg$currPos;
+        s1 = peg$parseselector_pattern_sans();
+        if (s1 !== peg$FAILED) {
+          s2 = peg$parse_();
+          if (s2 !== peg$FAILED) {
+            s3 = peg$parseJOIN();
+            if (s3 !== peg$FAILED) {
+              s4 = peg$parse_();
+              if (s4 !== peg$FAILED) {
+                s5 = peg$parseselector_pattern_sans();
+                if (s5 !== peg$FAILED) {
+                  s6 = [];
+                  s7 = peg$currPos;
+                  s8 = peg$parse_();
+                  if (s8 !== peg$FAILED) {
+                    s9 = peg$parseJOIN();
+                    if (s9 !== peg$FAILED) {
+                      s10 = peg$parse_();
+                      if (s10 !== peg$FAILED) {
+                        s11 = peg$parseselector_pattern_sans();
+                        if (s11 !== peg$FAILED) {
+                          peg$reportedPos = s7;
+                          s8 = peg$c12(s11);
+                          s7 = s8;
+                        } else {
+                          peg$currPos = s7;
+                          s7 = peg$c2;
+                        }
+                      } else {
+                        peg$currPos = s7;
+                        s7 = peg$c2;
+                      }
+                    } else {
+                      peg$currPos = s7;
+                      s7 = peg$c2;
+                    }
+                  } else {
+                    peg$currPos = s7;
+                    s7 = peg$c2;
+                  }
+                  while (s7 !== peg$FAILED) {
+                    s6.push(s7);
+                    s7 = peg$currPos;
+                    s8 = peg$parse_();
+                    if (s8 !== peg$FAILED) {
+                      s9 = peg$parseJOIN();
+                      if (s9 !== peg$FAILED) {
+                        s10 = peg$parse_();
+                        if (s10 !== peg$FAILED) {
+                          s11 = peg$parseselector_pattern_sans();
+                          if (s11 !== peg$FAILED) {
+                            peg$reportedPos = s7;
+                            s8 = peg$c12(s11);
+                            s7 = s8;
+                          } else {
+                            peg$currPos = s7;
+                            s7 = peg$c2;
+                          }
+                        } else {
+                          peg$currPos = s7;
+                          s7 = peg$c2;
+                        }
+                      } else {
+                        peg$currPos = s7;
+                        s7 = peg$c2;
+                      }
+                    } else {
+                      peg$currPos = s7;
+                      s7 = peg$c2;
+                    }
+                  }
+                  if (s6 !== peg$FAILED) {
+                    peg$reportedPos = s0;
+                    s1 = peg$c13(s1, s3, s5, s6);
+                    s0 = s1;
+                  } else {
+                    peg$currPos = s0;
+                    s0 = peg$c2;
+                  }
+                } else {
+                  peg$currPos = s0;
+                  s0 = peg$c2;
+                }
+              } else {
+                peg$currPos = s0;
+                s0 = peg$c2;
+              }
+            } else {
+              peg$currPos = s0;
+              s0 = peg$c2;
+            }
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      }
+
+      return s0;
+    }
+
+    function peg$parseinteraction_type() {
+      var s0, s1, s2, s3;
+
+      s0 = peg$currPos;
+      s1 = peg$parse_();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parseTHEN();
+        if (s2 === peg$FAILED) {
+          s2 = peg$parseJOIN();
+        }
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parse_();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c14(s2);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parseselector_pattern() {
+      var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      peg$reportedPos = peg$currPos;
+      s1 = peg$c16();
+      if (s1) {
+        s1 = peg$c2;
+      } else {
+        s1 = peg$c6;
+      }
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parse_();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$currPos;
+          if (input.charCodeAt(peg$currPos) === 123) {
+            s4 = peg$c18;
+            peg$currPos++;
+          } else {
+            s4 = peg$FAILED;
+            if (peg$silentFails === 0) { peg$fail(peg$c19); }
+          }
+          if (s4 !== peg$FAILED) {
+            s5 = peg$parsecode_block();
+            if (s5 !== peg$FAILED) {
+              if (input.charCodeAt(peg$currPos) === 125) {
+                s6 = peg$c20;
+                peg$currPos++;
+              } else {
+                s6 = peg$FAILED;
+                if (peg$silentFails === 0) { peg$fail(peg$c21); }
+              }
+              if (s6 !== peg$FAILED) {
+                peg$reportedPos = s3;
+                s4 = peg$c22(s5);
+                s3 = s4;
+              } else {
+                peg$currPos = s3;
+                s3 = peg$c2;
+              }
+            } else {
+              peg$currPos = s3;
+              s3 = peg$c2;
+            }
+          } else {
+            peg$currPos = s3;
+            s3 = peg$c2;
+          }
+          if (s3 === peg$FAILED) {
+            s3 = peg$c17;
+          }
+          if (s3 !== peg$FAILED) {
+            s4 = peg$parse_();
+            if (s4 !== peg$FAILED) {
+              s5 = peg$parsesystem_id();
+              if (s5 !== peg$FAILED) {
+                if (input.charCodeAt(peg$currPos) === 58) {
+                  s6 = peg$c23;
+                  peg$currPos++;
+                } else {
+                  s6 = peg$FAILED;
+                  if (peg$silentFails === 0) { peg$fail(peg$c24); }
+                }
+                if (s6 !== peg$FAILED) {
+                  s7 = peg$parse_();
+                  if (s7 !== peg$FAILED) {
+                    s8 = peg$parsebehavior_pattern();
+                    if (s8 !== peg$FAILED) {
+                      s9 = peg$parse_();
+                      if (s9 !== peg$FAILED) {
+                        s10 = peg$currPos;
+                        if (input.charCodeAt(peg$currPos) === 123) {
+                          s11 = peg$c18;
+                          peg$currPos++;
+                        } else {
+                          s11 = peg$FAILED;
+                          if (peg$silentFails === 0) { peg$fail(peg$c19); }
+                        }
+                        if (s11 !== peg$FAILED) {
+                          s12 = peg$parsecode_block();
+                          if (s12 !== peg$FAILED) {
+                            if (input.charCodeAt(peg$currPos) === 125) {
+                              s13 = peg$c20;
+                              peg$currPos++;
+                            } else {
+                              s13 = peg$FAILED;
+                              if (peg$silentFails === 0) { peg$fail(peg$c21); }
+                            }
+                            if (s13 !== peg$FAILED) {
+                              peg$reportedPos = s10;
+                              s11 = peg$c22(s12);
+                              s10 = s11;
+                            } else {
+                              peg$currPos = s10;
+                              s10 = peg$c2;
+                            }
+                          } else {
+                            peg$currPos = s10;
+                            s10 = peg$c2;
+                          }
+                        } else {
+                          peg$currPos = s10;
+                          s10 = peg$c2;
+                        }
+                        if (s10 === peg$FAILED) {
+                          s10 = peg$c17;
+                        }
+                        if (s10 !== peg$FAILED) {
+                          s11 = peg$parse_();
+                          if (s11 !== peg$FAILED) {
+                            peg$reportedPos = s0;
+                            s1 = peg$c25(s3, s5, s8, s10);
+                            s0 = s1;
+                          } else {
+                            peg$currPos = s0;
+                            s0 = peg$c2;
+                          }
+                        } else {
+                          peg$currPos = s0;
+                          s0 = peg$c2;
+                        }
+                      } else {
+                        peg$currPos = s0;
+                        s0 = peg$c2;
+                      }
+                    } else {
+                      peg$currPos = s0;
+                      s0 = peg$c2;
+                    }
+                  } else {
+                    peg$currPos = s0;
+                    s0 = peg$c2;
+                  }
+                } else {
+                  peg$currPos = s0;
+                  s0 = peg$c2;
+                }
+              } else {
+                peg$currPos = s0;
+                s0 = peg$c2;
+              }
+            } else {
+              peg$currPos = s0;
+              s0 = peg$c2;
+            }
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c15); }
+      }
+
+      return s0;
+    }
+
+    function peg$parseselector_pattern_sans() {
+      var s0, s1, s2, s3, s4, s5, s6, s7;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      peg$reportedPos = peg$currPos;
+      s1 = peg$c16();
+      if (s1) {
+        s1 = peg$c2;
+      } else {
+        s1 = peg$c6;
+      }
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parse_();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parsesystem_id();
+          if (s3 !== peg$FAILED) {
+            if (input.charCodeAt(peg$currPos) === 58) {
+              s4 = peg$c23;
+              peg$currPos++;
+            } else {
+              s4 = peg$FAILED;
+              if (peg$silentFails === 0) { peg$fail(peg$c24); }
+            }
+            if (s4 !== peg$FAILED) {
+              s5 = peg$parse_();
+              if (s5 !== peg$FAILED) {
+                s6 = peg$parsebehavior_pattern();
+                if (s6 !== peg$FAILED) {
+                  s7 = peg$parse_();
+                  if (s7 !== peg$FAILED) {
+                    peg$reportedPos = s0;
+                    s1 = peg$c26(s3, s6);
+                    s0 = s1;
+                  } else {
+                    peg$currPos = s0;
+                    s0 = peg$c2;
+                  }
+                } else {
+                  peg$currPos = s0;
+                  s0 = peg$c2;
+                }
+              } else {
+                peg$currPos = s0;
+                s0 = peg$c2;
+              }
+            } else {
+              peg$currPos = s0;
+              s0 = peg$c2;
+            }
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c15); }
+      }
+
+      return s0;
+    }
+
+    function peg$parsebehavior_pattern() {
+      var s0, s1;
+
+      peg$silentFails++;
+      s0 = [];
+      s1 = peg$parsealternation();
+      if (s1 === peg$FAILED) {
+        s1 = peg$parsesequence();
+      }
+      if (s1 !== peg$FAILED) {
+        while (s1 !== peg$FAILED) {
+          s0.push(s1);
+          s1 = peg$parsealternation();
+          if (s1 === peg$FAILED) {
+            s1 = peg$parsesequence();
+          }
+        }
+      } else {
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c27); }
+      }
+
+      return s0;
+    }
+
+    function peg$parsealternation() {
+      var s0, s1, s2, s3, s4, s5;
+
+      s0 = peg$currPos;
+      s1 = peg$parsepattern_element();
+      if (s1 !== peg$FAILED) {
+        s2 = [];
+        s3 = peg$currPos;
+        s4 = peg$parse_PIPE_();
+        if (s4 !== peg$FAILED) {
+          s5 = peg$parsepattern_element();
+          if (s5 !== peg$FAILED) {
+            peg$reportedPos = s3;
+            s4 = peg$c28(s5);
+            s3 = s4;
+          } else {
+            peg$currPos = s3;
+            s3 = peg$c2;
+          }
+        } else {
+          peg$currPos = s3;
+          s3 = peg$c2;
+        }
+        if (s3 !== peg$FAILED) {
+          while (s3 !== peg$FAILED) {
+            s2.push(s3);
+            s3 = peg$currPos;
+            s4 = peg$parse_PIPE_();
+            if (s4 !== peg$FAILED) {
+              s5 = peg$parsepattern_element();
+              if (s5 !== peg$FAILED) {
+                peg$reportedPos = s3;
+                s4 = peg$c28(s5);
+                s3 = s4;
+              } else {
+                peg$currPos = s3;
+                s3 = peg$c2;
+              }
+            } else {
+              peg$currPos = s3;
+              s3 = peg$c2;
+            }
+          }
+        } else {
+          s2 = peg$c2;
+        }
+        if (s2 !== peg$FAILED) {
+          peg$reportedPos = s0;
+          s1 = peg$c29(s1, s2);
+          s0 = s1;
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parsesequence() {
+      var s0, s1, s2;
+
+      s0 = peg$currPos;
+      s1 = [];
+      s2 = peg$parsepattern_element();
+      if (s2 !== peg$FAILED) {
+        while (s2 !== peg$FAILED) {
+          s1.push(s2);
+          s2 = peg$parsepattern_element();
+        }
+      } else {
+        s1 = peg$c2;
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c30(s1);
+      }
+      s0 = s1;
+
+      return s0;
+    }
+
+    function peg$parsepattern_element() {
+      var s0, s1, s2, s3, s4;
+
+      s0 = peg$currPos;
+      s1 = peg$parse_();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parsegroup();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parsequantifier();
+          if (s3 === peg$FAILED) {
+            s3 = peg$c17;
+          }
+          if (s3 !== peg$FAILED) {
+            s4 = peg$parse_();
+            if (s4 !== peg$FAILED) {
+              peg$reportedPos = s0;
+              s1 = peg$c31(s2, s3);
+              s0 = s1;
+            } else {
+              peg$currPos = s0;
+              s0 = peg$c2;
+            }
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      if (s0 === peg$FAILED) {
+        s0 = peg$currPos;
+        s1 = peg$parse_();
+        if (s1 !== peg$FAILED) {
+          s2 = peg$parseevent_ref();
+          if (s2 !== peg$FAILED) {
+            s3 = peg$parsequantifier();
+            if (s3 === peg$FAILED) {
+              s3 = peg$c17;
+            }
+            if (s3 !== peg$FAILED) {
+              s4 = peg$parse_();
+              if (s4 !== peg$FAILED) {
+                peg$reportedPos = s0;
+                s1 = peg$c32(s2, s3);
+                s0 = s1;
+              } else {
+                peg$currPos = s0;
+                s0 = peg$c2;
+              }
+            } else {
+              peg$currPos = s0;
+              s0 = peg$c2;
+            }
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      }
+
+      return s0;
+    }
+
+    function peg$parsegroup() {
+      var s0, s1, s2, s3, s4, s5, s6, s7;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      s1 = peg$parse_();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parseASYNC();
+        if (s2 === peg$FAILED) {
+          s2 = peg$c17;
+        }
+        if (s2 !== peg$FAILED) {
+          if (input.charCodeAt(peg$currPos) === 40) {
+            s3 = peg$c34;
+            peg$currPos++;
+          } else {
+            s3 = peg$FAILED;
+            if (peg$silentFails === 0) { peg$fail(peg$c35); }
+          }
+          if (s3 !== peg$FAILED) {
+            s4 = peg$parse_();
+            if (s4 !== peg$FAILED) {
+              s5 = peg$parsebehavior_pattern();
+              if (s5 !== peg$FAILED) {
+                s6 = peg$parse_();
+                if (s6 !== peg$FAILED) {
+                  if (input.charCodeAt(peg$currPos) === 41) {
+                    s7 = peg$c36;
+                    peg$currPos++;
+                  } else {
+                    s7 = peg$FAILED;
+                    if (peg$silentFails === 0) { peg$fail(peg$c37); }
+                  }
+                  if (s7 !== peg$FAILED) {
+                    peg$reportedPos = s0;
+                    s1 = peg$c38(s2, s5);
+                    s0 = s1;
+                  } else {
+                    peg$currPos = s0;
+                    s0 = peg$c2;
+                  }
+                } else {
+                  peg$currPos = s0;
+                  s0 = peg$c2;
+                }
+              } else {
+                peg$currPos = s0;
+                s0 = peg$c2;
+              }
+            } else {
+              peg$currPos = s0;
+              s0 = peg$c2;
+            }
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c33); }
+      }
+
+      return s0;
+    }
+
+    function peg$parsequantifier() {
+      var s0, s1, s2;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      if (input.charCodeAt(peg$currPos) === 43) {
+        s1 = peg$c40;
+        peg$currPos++;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c41); }
+      }
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parse_();
+        if (s2 !== peg$FAILED) {
+          peg$reportedPos = s0;
+          s1 = peg$c42();
+          s0 = s1;
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      if (s0 === peg$FAILED) {
+        s0 = peg$currPos;
+        if (input.charCodeAt(peg$currPos) === 42) {
+          s1 = peg$c43;
+          peg$currPos++;
+        } else {
+          s1 = peg$FAILED;
+          if (peg$silentFails === 0) { peg$fail(peg$c44); }
+        }
+        if (s1 !== peg$FAILED) {
+          s2 = peg$parse_();
+          if (s2 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c45();
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+        if (s0 === peg$FAILED) {
+          s0 = peg$currPos;
+          if (input.charCodeAt(peg$currPos) === 63) {
+            s1 = peg$c46;
+            peg$currPos++;
+          } else {
+            s1 = peg$FAILED;
+            if (peg$silentFails === 0) { peg$fail(peg$c47); }
+          }
+          if (s1 !== peg$FAILED) {
+            s2 = peg$parse_();
+            if (s2 !== peg$FAILED) {
+              peg$reportedPos = s0;
+              s1 = peg$c48();
+              s0 = s1;
+            } else {
+              peg$currPos = s0;
+              s0 = peg$c2;
+            }
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+          if (s0 === peg$FAILED) {
+            s0 = peg$parsequantifier_range();
+          }
+        }
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c39); }
+      }
+
+      return s0;
+    }
+
+    function peg$parsequantifier_range() {
+      var s0, s1, s2, s3, s4, s5, s6, s7;
+
+      s0 = peg$currPos;
+      if (input.charCodeAt(peg$currPos) === 123) {
+        s1 = peg$c18;
+        peg$currPos++;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c19); }
+      }
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parse_();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parseINT_GTE0();
+          if (s3 !== peg$FAILED) {
+            s4 = peg$currPos;
+            s5 = peg$parse_COMMA_();
+            if (s5 !== peg$FAILED) {
+              s6 = peg$parseINT_GT0();
+              if (s6 === peg$FAILED) {
+                s6 = peg$c17;
+              }
+              if (s6 !== peg$FAILED) {
+                peg$reportedPos = s4;
+                s5 = peg$c49(s5, s6);
+                s4 = s5;
+              } else {
+                peg$currPos = s4;
+                s4 = peg$c2;
+              }
+            } else {
+              peg$currPos = s4;
+              s4 = peg$c2;
+            }
+            if (s4 === peg$FAILED) {
+              s4 = peg$c17;
+            }
+            if (s4 !== peg$FAILED) {
+              s5 = peg$parse_();
+              if (s5 !== peg$FAILED) {
+                if (input.charCodeAt(peg$currPos) === 125) {
+                  s6 = peg$c20;
+                  peg$currPos++;
+                } else {
+                  s6 = peg$FAILED;
+                  if (peg$silentFails === 0) { peg$fail(peg$c21); }
+                }
+                if (s6 !== peg$FAILED) {
+                  s7 = peg$parse_();
+                  if (s7 !== peg$FAILED) {
+                    peg$reportedPos = s0;
+                    s1 = peg$c50(s3, s4);
+                    s0 = s1;
+                  } else {
+                    peg$currPos = s0;
+                    s0 = peg$c2;
+                  }
+                } else {
+                  peg$currPos = s0;
+                  s0 = peg$c2;
+                }
+              } else {
+                peg$currPos = s0;
+                s0 = peg$c2;
+              }
+            } else {
+              peg$currPos = s0;
+              s0 = peg$c2;
+            }
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parsetrigger() {
+      var s0, s1, s2, s3, s4, s5, s6;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      s1 = peg$parse_WHEN_();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parse_COLON_();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parseselector_pattern_sans();
+          if (s3 !== peg$FAILED) {
+            if (input.charCodeAt(peg$currPos) === 123) {
+              s4 = peg$c18;
+              peg$currPos++;
+            } else {
+              s4 = peg$FAILED;
+              if (peg$silentFails === 0) { peg$fail(peg$c19); }
+            }
+            if (s4 !== peg$FAILED) {
+              s5 = peg$parsecode_block();
+              if (s5 !== peg$FAILED) {
+                if (input.charCodeAt(peg$currPos) === 125) {
+                  s6 = peg$c20;
+                  peg$currPos++;
+                } else {
+                  s6 = peg$FAILED;
+                  if (peg$silentFails === 0) { peg$fail(peg$c21); }
+                }
+                if (s6 !== peg$FAILED) {
+                  peg$reportedPos = s0;
+                  s1 = peg$c52(s3, s5);
+                  s0 = s1;
+                } else {
+                  peg$currPos = s0;
+                  s0 = peg$c2;
+                }
+              } else {
+                peg$currPos = s0;
+                s0 = peg$c2;
+              }
+            } else {
+              peg$currPos = s0;
+              s0 = peg$c2;
+            }
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c51); }
+      }
+
+      return s0;
+    }
+
+    function peg$parseinit() {
+      var s0, s1, s2, s3, s4, s5, s6, s7;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      s1 = peg$parse_INIT_();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parse_COLON_();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parsesystem_id();
+          if (s3 === peg$FAILED) {
+            s3 = peg$c17;
+          }
+          if (s3 !== peg$FAILED) {
+            s4 = peg$parse_();
+            if (s4 !== peg$FAILED) {
+              if (input.charCodeAt(peg$currPos) === 123) {
+                s5 = peg$c18;
+                peg$currPos++;
+              } else {
+                s5 = peg$FAILED;
+                if (peg$silentFails === 0) { peg$fail(peg$c19); }
+              }
+              if (s5 !== peg$FAILED) {
+                s6 = peg$parsecode_block();
+                if (s6 !== peg$FAILED) {
+                  if (input.charCodeAt(peg$currPos) === 125) {
+                    s7 = peg$c20;
+                    peg$currPos++;
+                  } else {
+                    s7 = peg$FAILED;
+                    if (peg$silentFails === 0) { peg$fail(peg$c21); }
+                  }
+                  if (s7 !== peg$FAILED) {
+                    peg$reportedPos = s0;
+                    s1 = peg$c54(s3, s6);
+                    s0 = s1;
+                  } else {
+                    peg$currPos = s0;
+                    s0 = peg$c2;
+                  }
+                } else {
+                  peg$currPos = s0;
+                  s0 = peg$c2;
+                }
+              } else {
+                peg$currPos = s0;
+                s0 = peg$c2;
+              }
+            } else {
+              peg$currPos = s0;
+              s0 = peg$c2;
+            }
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c53); }
+      }
+
+      return s0;
+    }
+
+    function peg$parsecode_block() {
+      var s0, s1, s2, s3, s4, s5;
+
+      s0 = peg$currPos;
+      s1 = [];
+      if (peg$c55.test(input.charAt(peg$currPos))) {
+        s2 = input.charAt(peg$currPos);
+        peg$currPos++;
+      } else {
+        s2 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c56); }
+      }
+      while (s2 !== peg$FAILED) {
+        s1.push(s2);
+        if (peg$c55.test(input.charAt(peg$currPos))) {
+          s2 = input.charAt(peg$currPos);
+          peg$currPos++;
+        } else {
+          s2 = peg$FAILED;
+          if (peg$silentFails === 0) { peg$fail(peg$c56); }
+        }
+      }
+      if (s1 !== peg$FAILED) {
+        s2 = peg$currPos;
+        if (input.charCodeAt(peg$currPos) === 123) {
+          s3 = peg$c18;
+          peg$currPos++;
+        } else {
+          s3 = peg$FAILED;
+          if (peg$silentFails === 0) { peg$fail(peg$c19); }
+        }
+        if (s3 !== peg$FAILED) {
+          s4 = peg$parsecode_block();
+          if (s4 !== peg$FAILED) {
+            if (input.charCodeAt(peg$currPos) === 125) {
+              s5 = peg$c20;
+              peg$currPos++;
+            } else {
+              s5 = peg$FAILED;
+              if (peg$silentFails === 0) { peg$fail(peg$c21); }
+            }
+            if (s5 !== peg$FAILED) {
+              s3 = [s3, s4, s5];
+              s2 = s3;
+            } else {
+              peg$currPos = s2;
+              s2 = peg$c2;
+            }
+          } else {
+            peg$currPos = s2;
+            s2 = peg$c2;
+          }
+        } else {
+          peg$currPos = s2;
+          s2 = peg$c2;
+        }
+        if (s2 === peg$FAILED) {
+          s2 = peg$c17;
+        }
+        if (s2 !== peg$FAILED) {
+          s3 = [];
+          if (peg$c55.test(input.charAt(peg$currPos))) {
+            s4 = input.charAt(peg$currPos);
+            peg$currPos++;
+          } else {
+            s4 = peg$FAILED;
+            if (peg$silentFails === 0) { peg$fail(peg$c56); }
+          }
+          while (s4 !== peg$FAILED) {
+            s3.push(s4);
+            if (peg$c55.test(input.charAt(peg$currPos))) {
+              s4 = input.charAt(peg$currPos);
+              peg$currPos++;
+            } else {
+              s4 = peg$FAILED;
+              if (peg$silentFails === 0) { peg$fail(peg$c56); }
+            }
+          }
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c57();
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parsebehavior_id() {
+      var s0, s1;
+
+      s0 = peg$currPos;
+      s1 = peg$parseID();
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c58(s1);
+      }
+      s0 = s1;
+
+      return s0;
+    }
+
+    function peg$parsesystem_id() {
+      var s0, s1;
+
+      s0 = peg$currPos;
+      s1 = peg$parseID();
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c58(s1);
+      }
+      s0 = s1;
+
+      return s0;
+    }
+
+    function peg$parseevent_ref() {
+      var s0, s1;
+
+      s0 = peg$currPos;
+      s1 = peg$parseID();
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c59(s1);
+      }
+      s0 = s1;
+
+      return s0;
+    }
+
+    function peg$parseKEYWORD() {
+      var s0;
+
+      s0 = peg$parseSYSTEM();
+      if (s0 === peg$FAILED) {
+        s0 = peg$parseBEHAVIOR();
+        if (s0 === peg$FAILED) {
+          s0 = peg$parseINTERACTION();
+          if (s0 === peg$FAILED) {
+            s0 = peg$parseASYNC();
+          }
+        }
+      }
+
+      return s0;
+    }
+
+    function peg$parseSYSTEM() {
+      var s0, s1;
+
+      s0 = peg$currPos;
+      if (input.substr(peg$currPos, 6) === peg$c60) {
+        s1 = peg$c60;
+        peg$currPos += 6;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c61); }
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c14(s1);
+      }
+      s0 = s1;
+
+      return s0;
+    }
+
+    function peg$parseBEHAVIOR() {
+      var s0, s1;
+
+      s0 = peg$currPos;
+      if (input.substr(peg$currPos, 8) === peg$c62) {
+        s1 = peg$c62;
+        peg$currPos += 8;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c63); }
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c14(s1);
+      }
+      s0 = s1;
+
+      return s0;
+    }
+
+    function peg$parseINTERACTION() {
+      var s0, s1;
+
+      s0 = peg$currPos;
+      if (input.substr(peg$currPos, 11) === peg$c64) {
+        s1 = peg$c64;
+        peg$currPos += 11;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c65); }
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c14(s1);
+      }
+      s0 = s1;
+
+      return s0;
+    }
+
+    function peg$parseWHEN() {
+      var s0, s1;
+
+      s0 = peg$currPos;
+      if (input.substr(peg$currPos, 4) === peg$c66) {
+        s1 = peg$c66;
+        peg$currPos += 4;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c67); }
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c14(s1);
+      }
+      s0 = s1;
+
+      return s0;
+    }
+
+    function peg$parseINIT() {
+      var s0, s1;
+
+      s0 = peg$currPos;
+      if (input.substr(peg$currPos, 4) === peg$c68) {
+        s1 = peg$c68;
+        peg$currPos += 4;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c69); }
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c14(s1);
+      }
+      s0 = s1;
+
+      return s0;
+    }
+
+    function peg$parseASYNC() {
+      var s0, s1;
+
+      s0 = peg$currPos;
+      if (input.substr(peg$currPos, 5) === peg$c70) {
+        s1 = peg$c70;
+        peg$currPos += 5;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c71); }
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c14(s1);
+      }
+      s0 = s1;
+
+      return s0;
+    }
+
+    function peg$parseTHEN() {
+      var s0, s1;
+
+      s0 = peg$currPos;
+      if (input.substr(peg$currPos, 2) === peg$c72) {
+        s1 = peg$c72;
+        peg$currPos += 2;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c73); }
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c74();
+      }
+      s0 = s1;
+
+      return s0;
+    }
+
+    function peg$parseJOIN() {
+      var s0, s1;
+
+      s0 = peg$currPos;
+      if (input.substr(peg$currPos, 2) === peg$c75) {
+        s1 = peg$c75;
+        peg$currPos += 2;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c76); }
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c77();
+      }
+      s0 = s1;
+
+      return s0;
+    }
+
+    function peg$parse_SYSTEM_() {
+      var s0, s1, s2, s3;
+
+      s0 = peg$currPos;
+      s1 = peg$parse_();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parseSYSTEM();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parse_();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c14(s2);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parse_BEHAVIOR_() {
+      var s0, s1, s2, s3;
+
+      s0 = peg$currPos;
+      s1 = peg$parse_();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parseBEHAVIOR();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parse_();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c14(s2);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parse_INTERACTION_() {
+      var s0, s1, s2, s3;
+
+      s0 = peg$currPos;
+      s1 = peg$parse_();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parseINTERACTION();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parse_();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c14(s2);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parse_WHEN_() {
+      var s0, s1, s2, s3;
+
+      s0 = peg$currPos;
+      s1 = peg$parse_();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parseWHEN();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parse_();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c14(s2);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parse_INIT_() {
+      var s0, s1, s2, s3;
+
+      s0 = peg$currPos;
+      s1 = peg$parse_();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parseINIT();
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parse_();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c14(s2);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parse_EQ_() {
+      var s0, s1, s2, s3;
+
+      s0 = peg$currPos;
+      s1 = peg$parse_();
+      if (s1 !== peg$FAILED) {
+        if (input.charCodeAt(peg$currPos) === 61) {
+          s2 = peg$c78;
+          peg$currPos++;
+        } else {
+          s2 = peg$FAILED;
+          if (peg$silentFails === 0) { peg$fail(peg$c79); }
+        }
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parse_();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c14(s2);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parse_COMMA_() {
+      var s0, s1, s2, s3;
+
+      s0 = peg$currPos;
+      s1 = peg$parse_();
+      if (s1 !== peg$FAILED) {
+        if (input.charCodeAt(peg$currPos) === 44) {
+          s2 = peg$c80;
+          peg$currPos++;
+        } else {
+          s2 = peg$FAILED;
+          if (peg$silentFails === 0) { peg$fail(peg$c81); }
+        }
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parse_();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c14(s2);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parse_PIPE_() {
+      var s0, s1, s2, s3;
+
+      s0 = peg$currPos;
+      s1 = peg$parse_();
+      if (s1 !== peg$FAILED) {
+        if (input.charCodeAt(peg$currPos) === 124) {
+          s2 = peg$c82;
+          peg$currPos++;
+        } else {
+          s2 = peg$FAILED;
+          if (peg$silentFails === 0) { peg$fail(peg$c83); }
+        }
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parse_();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c14(s2);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parse_COLON_() {
+      var s0, s1, s2, s3;
+
+      s0 = peg$currPos;
+      s1 = peg$parse_();
+      if (s1 !== peg$FAILED) {
+        if (input.charCodeAt(peg$currPos) === 58) {
+          s2 = peg$c23;
+          peg$currPos++;
+        } else {
+          s2 = peg$FAILED;
+          if (peg$silentFails === 0) { peg$fail(peg$c24); }
+        }
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parse_();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c14(s2);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parse_SEMI_() {
+      var s0, s1, s2, s3;
+
+      s0 = peg$currPos;
+      s1 = peg$parse_();
+      if (s1 !== peg$FAILED) {
+        if (input.charCodeAt(peg$currPos) === 59) {
+          s2 = peg$c84;
+          peg$currPos++;
+        } else {
+          s2 = peg$FAILED;
+          if (peg$silentFails === 0) { peg$fail(peg$c85); }
+        }
+        if (s2 !== peg$FAILED) {
+          s3 = peg$parse_();
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c14(s2);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+
+      return s0;
+    }
+
+    function peg$parseID() {
+      var s0, s1, s2, s3, s4;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      s1 = peg$currPos;
+      peg$silentFails++;
+      s2 = peg$parseKEYWORD();
+      peg$silentFails--;
+      if (s2 === peg$FAILED) {
+        s1 = peg$c6;
+      } else {
+        peg$currPos = s1;
+        s1 = peg$c2;
+      }
+      if (s1 !== peg$FAILED) {
+        if (peg$c87.test(input.charAt(peg$currPos))) {
+          s2 = input.charAt(peg$currPos);
+          peg$currPos++;
+        } else {
+          s2 = peg$FAILED;
+          if (peg$silentFails === 0) { peg$fail(peg$c88); }
+        }
+        if (s2 !== peg$FAILED) {
+          s3 = [];
+          if (peg$c89.test(input.charAt(peg$currPos))) {
+            s4 = input.charAt(peg$currPos);
+            peg$currPos++;
+          } else {
+            s4 = peg$FAILED;
+            if (peg$silentFails === 0) { peg$fail(peg$c90); }
+          }
+          while (s4 !== peg$FAILED) {
+            s3.push(s4);
+            if (peg$c89.test(input.charAt(peg$currPos))) {
+              s4 = input.charAt(peg$currPos);
+              peg$currPos++;
+            } else {
+              s4 = peg$FAILED;
+              if (peg$silentFails === 0) { peg$fail(peg$c90); }
+            }
+          }
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c91();
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c86); }
+      }
+
+      return s0;
+    }
+
+    function peg$parseINT() {
+      var s0, s1, s2;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      s1 = [];
+      if (peg$c93.test(input.charAt(peg$currPos))) {
+        s2 = input.charAt(peg$currPos);
+        peg$currPos++;
+      } else {
+        s2 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c94); }
+      }
+      if (s2 !== peg$FAILED) {
+        while (s2 !== peg$FAILED) {
+          s1.push(s2);
+          if (peg$c93.test(input.charAt(peg$currPos))) {
+            s2 = input.charAt(peg$currPos);
+            peg$currPos++;
+          } else {
+            s2 = peg$FAILED;
+            if (peg$silentFails === 0) { peg$fail(peg$c94); }
+          }
+        }
+      } else {
+        s1 = peg$c2;
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c95();
+      }
+      s0 = s1;
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c92); }
+      }
+
+      return s0;
+    }
+
+    function peg$parseINT_GT0() {
+      var s0, s1, s2, s3;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      if (peg$c97.test(input.charAt(peg$currPos))) {
+        s1 = input.charAt(peg$currPos);
+        peg$currPos++;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c98); }
+      }
+      if (s1 !== peg$FAILED) {
+        s2 = [];
+        if (peg$c93.test(input.charAt(peg$currPos))) {
+          s3 = input.charAt(peg$currPos);
+          peg$currPos++;
+        } else {
+          s3 = peg$FAILED;
+          if (peg$silentFails === 0) { peg$fail(peg$c94); }
+        }
+        while (s3 !== peg$FAILED) {
+          s2.push(s3);
+          if (peg$c93.test(input.charAt(peg$currPos))) {
+            s3 = input.charAt(peg$currPos);
+            peg$currPos++;
+          } else {
+            s3 = peg$FAILED;
+            if (peg$silentFails === 0) { peg$fail(peg$c94); }
+          }
+        }
+        if (s2 !== peg$FAILED) {
+          peg$reportedPos = s0;
+          s1 = peg$c95();
+          s0 = s1;
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c96); }
+      }
+
+      return s0;
+    }
+
+    function peg$parseINT_GTE0() {
+      var s0, s1;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      if (input.charCodeAt(peg$currPos) === 48) {
+        s1 = peg$c100;
+        peg$currPos++;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c101); }
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c102();
+      }
+      s0 = s1;
+      if (s0 === peg$FAILED) {
+        s0 = peg$parseINT_GT0();
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c99); }
+      }
+
+      return s0;
+    }
+
+    function peg$parse_() {
+      var s0, s1, s2;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      s1 = [];
+      if (peg$c104.test(input.charAt(peg$currPos))) {
+        s2 = input.charAt(peg$currPos);
+        peg$currPos++;
+      } else {
+        s2 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c105); }
+      }
+      if (s2 === peg$FAILED) {
+        s2 = peg$parseCOMMENT();
+      }
+      while (s2 !== peg$FAILED) {
+        s1.push(s2);
+        if (peg$c104.test(input.charAt(peg$currPos))) {
+          s2 = input.charAt(peg$currPos);
+          peg$currPos++;
+        } else {
+          s2 = peg$FAILED;
+          if (peg$silentFails === 0) { peg$fail(peg$c105); }
+        }
+        if (s2 === peg$FAILED) {
+          s2 = peg$parseCOMMENT();
+        }
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c106();
+      }
+      s0 = s1;
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c103); }
+      }
+
+      return s0;
+    }
+
+    function peg$parse__() {
+      var s0, s1, s2;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      if (peg$c104.test(input.charAt(peg$currPos))) {
+        s1 = input.charAt(peg$currPos);
+        peg$currPos++;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c105); }
+      }
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parse_();
+        if (s2 === peg$FAILED) {
+          s2 = peg$c17;
+        }
+        if (s2 !== peg$FAILED) {
+          peg$reportedPos = s0;
+          s1 = peg$c106();
+          s0 = s1;
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c107); }
+      }
+
+      return s0;
+    }
+
+    function peg$parseNL() {
+      var s0, s1;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      if (peg$c109.test(input.charAt(peg$currPos))) {
+        s1 = input.charAt(peg$currPos);
+        peg$currPos++;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c110); }
+      }
+      if (s1 !== peg$FAILED) {
+        peg$reportedPos = s0;
+        s1 = peg$c106();
+      }
+      s0 = s1;
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c108); }
+      }
+
+      return s0;
+    }
+
+    function peg$parseCOMMENT() {
+      var s0, s1, s2;
+
+      s0 = peg$currPos;
+      s1 = peg$parseCOMMENT_LINE();
+      if (s1 !== peg$FAILED) {
+        s2 = peg$parseNL();
+        if (s2 === peg$FAILED) {
+          s2 = peg$c17;
+        }
+        if (s2 !== peg$FAILED) {
+          peg$reportedPos = s0;
+          s1 = peg$c22(s1);
+          s0 = s1;
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      if (s0 === peg$FAILED) {
+        s0 = peg$currPos;
+        s1 = peg$parseCOMMENT_BLOCK();
+        if (s1 !== peg$FAILED) {
+          s2 = peg$parseNL();
+          if (s2 === peg$FAILED) {
+            s2 = peg$c17;
+          }
+          if (s2 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c22(s1);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      }
+
+      return s0;
+    }
+
+    function peg$parseCOMMENT_LINE() {
+      var s0, s1, s2, s3;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      if (input.substr(peg$currPos, 2) === peg$c112) {
+        s1 = peg$c112;
+        peg$currPos += 2;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c113); }
+      }
+      if (s1 !== peg$FAILED) {
+        s2 = [];
+        if (peg$c114.test(input.charAt(peg$currPos))) {
+          s3 = input.charAt(peg$currPos);
+          peg$currPos++;
+        } else {
+          s3 = peg$FAILED;
+          if (peg$silentFails === 0) { peg$fail(peg$c115); }
+        }
+        while (s3 !== peg$FAILED) {
+          s2.push(s3);
+          if (peg$c114.test(input.charAt(peg$currPos))) {
+            s3 = input.charAt(peg$currPos);
+            peg$currPos++;
+          } else {
+            s3 = peg$FAILED;
+            if (peg$silentFails === 0) { peg$fail(peg$c115); }
+          }
+        }
+        if (s2 !== peg$FAILED) {
+          peg$reportedPos = s0;
+          s1 = peg$c116(s2);
+          s0 = s1;
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c111); }
+      }
+
+      return s0;
+    }
+
+    function peg$parseCOMMENT_BLOCK() {
+      var s0, s1, s2, s3, s4, s5;
+
+      peg$silentFails++;
+      s0 = peg$currPos;
+      if (input.substr(peg$currPos, 2) === peg$c118) {
+        s1 = peg$c118;
+        peg$currPos += 2;
+      } else {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c119); }
+      }
+      if (s1 !== peg$FAILED) {
+        s2 = [];
+        s3 = peg$currPos;
+        s4 = peg$currPos;
+        peg$silentFails++;
+        if (input.substr(peg$currPos, 2) === peg$c120) {
+          s5 = peg$c120;
+          peg$currPos += 2;
+        } else {
+          s5 = peg$FAILED;
+          if (peg$silentFails === 0) { peg$fail(peg$c121); }
+        }
+        peg$silentFails--;
+        if (s5 === peg$FAILED) {
+          s4 = peg$c6;
+        } else {
+          peg$currPos = s4;
+          s4 = peg$c2;
+        }
+        if (s4 !== peg$FAILED) {
+          if (input.length > peg$currPos) {
+            s5 = input.charAt(peg$currPos);
+            peg$currPos++;
+          } else {
+            s5 = peg$FAILED;
+            if (peg$silentFails === 0) { peg$fail(peg$c122); }
+          }
+          if (s5 !== peg$FAILED) {
+            peg$reportedPos = s3;
+            s4 = peg$c123(s5);
+            s3 = s4;
+          } else {
+            peg$currPos = s3;
+            s3 = peg$c2;
+          }
+        } else {
+          peg$currPos = s3;
+          s3 = peg$c2;
+        }
+        while (s3 !== peg$FAILED) {
+          s2.push(s3);
+          s3 = peg$currPos;
+          s4 = peg$currPos;
+          peg$silentFails++;
+          if (input.substr(peg$currPos, 2) === peg$c120) {
+            s5 = peg$c120;
+            peg$currPos += 2;
+          } else {
+            s5 = peg$FAILED;
+            if (peg$silentFails === 0) { peg$fail(peg$c121); }
+          }
+          peg$silentFails--;
+          if (s5 === peg$FAILED) {
+            s4 = peg$c6;
+          } else {
+            peg$currPos = s4;
+            s4 = peg$c2;
+          }
+          if (s4 !== peg$FAILED) {
+            if (input.length > peg$currPos) {
+              s5 = input.charAt(peg$currPos);
+              peg$currPos++;
+            } else {
+              s5 = peg$FAILED;
+              if (peg$silentFails === 0) { peg$fail(peg$c122); }
+            }
+            if (s5 !== peg$FAILED) {
+              peg$reportedPos = s3;
+              s4 = peg$c123(s5);
+              s3 = s4;
+            } else {
+              peg$currPos = s3;
+              s3 = peg$c2;
+            }
+          } else {
+            peg$currPos = s3;
+            s3 = peg$c2;
+          }
+        }
+        if (s2 !== peg$FAILED) {
+          if (input.substr(peg$currPos, 2) === peg$c120) {
+            s3 = peg$c120;
+            peg$currPos += 2;
+          } else {
+            s3 = peg$FAILED;
+            if (peg$silentFails === 0) { peg$fail(peg$c121); }
+          }
+          if (s3 !== peg$FAILED) {
+            peg$reportedPos = s0;
+            s1 = peg$c124(s2);
+            s0 = s1;
+          } else {
+            peg$currPos = s0;
+            s0 = peg$c2;
+          }
+        } else {
+          peg$currPos = s0;
+          s0 = peg$c2;
+        }
+      } else {
+        peg$currPos = s0;
+        s0 = peg$c2;
+      }
+      peg$silentFails--;
+      if (s0 === peg$FAILED) {
+        s1 = peg$FAILED;
+        if (peg$silentFails === 0) { peg$fail(peg$c117); }
+      }
+
+      return s0;
+    }
+
+
+        /*global parse, options, offset, line, column, text, SyntaxError*/
+        var opts = arguments[2] || options,
+            fileName = opts.fileName || "NOFILENAME",
+            locations = opts.locations !== undefined ? opts.locations : true,
+            comments = opts.comments !== undefined ? opts.comments : false,
+            showAst = opts.showAst !== undefined ? opts.showAst : false;
+
+        var err = function err(msg, suffix, opts) {
+            opts = opts || {};
+            if (typeof msg === "number") msg = "ERR" + msg + ": " + errors[msg];
+            if (suffix) msg += suffix;
+            return new SyntaxError(msg,
+                opts.expected || null,
+                opts.found || null,
+                offset(),
+                opts.line || line(),
+                opts.col || column()
+            );
+        };
+
+        var errors = [
+            "reference to an undefined system",
+            "reference to system in a behavior",
+            "scope lower bound exceeds its upper bound",
+            "definition is recursive"
+        ];
+
+        var scopify = function scopify(i, q) {
+            if (q === null) q = {min:1, max:1};
+            i.scope = q;
+            return i;
+        }
+
+        var minmaxify = function minmaxify(lo, hi) {
+            var m = hi ? hi.v || null : lo;
+            return {min:lo, max:m};
+        }
+
+        var model = function model(statements) {
+
+            var model = {
+                systems: {},
+                behaviors: {},
+                interactions: [],
+                triggers: [],
+                init: [],
+            };
+
+            if (showAst) model.ast = statements;
+
+            // accumulate varying statements into a flatter structure
+            for (var s in statements) {
+                var statement = statements[s];
+
+                switch(statements[s].type) {
+                    case "System":
+                        model.systems[statement.id] = statement;
+                        break;
+                    case "Behavior":
+                        model.behaviors[statement.id] = statement;
+                        break;
+                    case "Then":
+                    case "Join":
+                        model.interactions.push(statement);
+                        break;
+                    case "Trigger":
+                        model.triggers.push(statement);
+                        break;
+                    case "Init":
+                        model.init.push(statement);
+                    default: break;
+                }
+            }
+
+            // add atomic events to behaviors list
+            for (var r in ast.references) {
+                var ref = ast.references[r];
+
+                if (!model.behaviors[ref])
+                    model.behaviors[ref] = new ast.Behavior(ref, [], [])
+            }
+
+            return errorCheck(model);
+        };
+
+        var errorCheck = function errorCheck(model) {
+            model.errors = ast.errors;
+
+            for (var i in model.interactions) {
+                model.interactions[i].body.forEach(function (sys) {
+                    if (sys.type === "Selector" && !model.systems[sys.system])
+                        model.errors.push(err(0, ` (${sys.system})`, sys.location));
+                });
+            }
+
+            for (var t in model.triggers) {
+                var sys = model.triggers[t].on;
+                if (sys.type === "Selector" && !model.systems[sys.system])
+                    model.errors.push(err(0, ` (${sys.system})`, sys.location));
+            }
+
+            for (var i in model.init) {
+                var sys = model.init[i].system;
+                if (sys && !model.systems[sys])
+                    model.errors.push(err(0, ` (${sys})`, model.init[i].location));
+            }
+
+            for (var b in model.behaviors) {
+                var bhv = model.behaviors[b];
+                bhv.refs.forEach(function (ref) {
+                    if (model.systems[ref])
+                        model.errors.push(err(1, ` (${ref} in ${bhv.id})`, bhv.location));
+                });
+            }
+
+            return model;
+        };
+
+        var ast = {
+
+            comments: [],
+            errors: [],
+            references: [],
+
+            Base: function Base(type) {
+                this.type = type;
+                if (locations) {
+                    this.location = {
+                        pos: offset(),
+                        line: line(),
+                        col: column(),
+                        len: text().length,
+                    };
+                }
+            },
+
+            Comment: function Comment(block, text) {
+                ast.Base.call(this, "Comment");
+                this.block = block;
+                this.text = text;
+                ast.comments.push(this);
+            },
+
+            Id: function Id(type, id) {
+                ast.Base.call(this, type);
+                this.id = id;
+            },
+
+            System: function System(id, body, refs) {
+                ast.Id.call(this, "System", id);
+                this.body = body;
+                this.refs = refs;
+                this.properties = {};
+                this.scope = { min:1, max:1 };
+            },
+
+            Behavior: function Behavior(id, body, refs) {
+                ast.Id.call(this, "Behavior", id);
+                this.body = body;
+                this.refs = refs;
+                this.properties = {};
+            },
+
+            Interaction: function Interaction(type, body) {
+                ast.Base.call(this, type);
+                this.body = body;
+            },
+
+            Sequence: function Sequence(body) {
+                ast.Base.call(this, "Sequence");
+                this.body = body;
+                this.scope = { min:1, max:1 };
+            },
+
+            Alternation: function Alternation(body) {
+                ast.Base.call(this, "Alternation");
+                this.body = body;
+                this.scope = { min:1, max:1 };
+            },
+
+            Group: function Group(async, body) {
+                ast.Base.call(this, "Group");
+                this.async = async;
+                this.body = body;
+            },
+
+            Selector: function Selector(system, pattern, pre, post) {
+                ast.Base.call(this, "Selector");
+                this.system = system;
+                this.pattern = pattern;
+                this.pre = pre || null;
+                this.post = post || null;
+            },
+
+            Trigger: function Trigger(selector, body) {
+                ast.Base.call(this, "Trigger");
+                this.on = selector;
+                this.do = body;
+            },
+
+            Init: function Init(system, body) {
+                ast.Base.call(this, "Init");
+                this.system = system;
+                this.do = body;
+            },
+
+        };
+
+
+
+    peg$result = peg$startRuleFunction();
+
+    if (peg$result !== peg$FAILED && peg$currPos === input.length) {
+      return peg$result;
+    } else {
+      if (peg$result !== peg$FAILED && peg$currPos < input.length) {
+        peg$fail({ type: "end", description: "end of input" });
+      }
+
+      throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);
+    }
+  }
+
+  return {
+    SyntaxError: SyntaxError,
+    parse:       parse
+  };
+})();

+ 3 - 3
src/web/assets/scripts/mp2-parser-worker.js → src/web/assets/scripts/modellang-worker.js

@@ -1,5 +1,5 @@
-/*global importScripts, postMessage, mp2*/
-importScripts("mp2-parser.js");
+/*global importScripts, postMessage, modellangParser*/
+importScripts("modellang-parser.js");
 
 onmessage = function(msg) { //jshint ignore:line
 	var data = msg.data,
@@ -7,7 +7,7 @@ onmessage = function(msg) { //jshint ignore:line
 	try {
 		results = {
 			id: data.id,
-			parsed: mp2.parse(data.input),
+			parsed: modellangParser.parse(data.input),
 		};
 	} catch (err) {
 		results = {

+ 1096 - 0
src/web/assets/scripts/modellang.js

@@ -0,0 +1,1096 @@
+/*global ace*/
+
+ace.define("ace/mode/modellang_highlight_rules",
+["require", "exports", "module", "ace/lib/oop"],
+function(require, exports, module) {
+	"use strict";
+
+	var oop = require("../lib/oop");
+	var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+	var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
+
+	var ModellangHighlightRules = function() {
+
+		this.$rules = {
+
+			start: [
+				{
+					token: "comment.line.double-slash",
+					regex: /\/\/.*/,
+				},
+				{
+					token: "comment.block",
+					regex: /\/\*/,
+					next: "comment",
+				},
+				{
+					token: [
+						"keyword",
+						"text",
+						"variable.other",
+						"text",
+						"punctuation.operator",
+						],
+					regex: /(\bSYSTEM\b:)(\s*)(\w+)(\s*)(=)/,
+					push: "behaviorPattern",
+				},
+				{
+					token: [
+						"keyword",
+						"text",
+						"support.constant",
+						"text",
+						"punctuation.operator",
+						],
+					regex: /(\bBEHAVIOR\b:)(\s*)(\w+)(\s*)(=)/,
+					push: "behaviorPattern",
+				},
+				{
+					token: "keyword.control",
+					regex: /(\bINTERACTION\b:)/,
+					push: "behaviorPattern",
+				},
+				{
+					token: [
+						"keyword.control",
+						"text",
+						"variable",
+						"support.constant",
+						"support.constant",
+						"text",
+						"text",
+						],
+					regex: /(\bWHEN\b:)(\s*)(\w+)(:)(\w+)(\s+)({)/,
+					next: "javascript-start",
+				},
+				{
+					token: [
+						"keyword.control",
+						"text",
+						"variable",
+						"text",
+						"text",
+						],
+					regex: /(\bINIT\b:)(\s*)(\w+)(\s*)({)/,
+					next: "javascript-start",
+				},
+				{
+					token: "text",
+					regex: /\s+/,
+				},
+				{
+					defaultToken: "text"
+				},
+			],
+
+			behaviorPattern: [
+				{
+					token: "punctuation.operator",
+					regex: /;/,
+					next: "pop",
+				},
+				{ // identifiers
+					token: "text",
+					regex: /./,
+				},
+			],
+
+			comment: [
+				// multi-line comment terminator
+				{
+					token: "comment.block",
+					regex: /.*?\*\//,
+					next: "start",
+				},
+				// stuff
+				{
+					regex: /.*/,
+					token: "comment.block",
+				},
+			],
+
+			meta: {
+				dontIndentStates: ["comment"],
+				lineComment: "//",
+			},
+
+		};
+
+		this.embedRules(JavaScriptHighlightRules, "javascript-", [
+			{
+				token: "text",
+				regex: /(};)/, // the js parser won't be in a state where this would be valid,
+				next: "start", // so it's relatively safe to use to escape
+			}
+		]);
+		this.normalizeRules();
+	};
+
+	oop.inherits(ModellangHighlightRules, TextHighlightRules);
+
+	exports.ModellangHighlightRules = ModellangHighlightRules;
+
+});
+
+/* jshint ignore:start */
+// jscs: disable
+ace.define("ace/mode/modellang",
+["require", "exports", "module", "ace/lib/oop", "ace/mode/text", "ace/mode/modellang_highlight_rules"],
+function(require, exports, module) {
+	"use strict";
+
+	var oop = require("../lib/oop");
+	var TextMode = require("./text").Mode;
+	var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
+	var CstyleFoldMode = require("./folding/cstyle").FoldMode;
+	var ModellangHighlightRules = require("./modellang_highlight_rules").ModellangHighlightRules;
+
+	var Mode = function() {
+		this.HighlightRules = ModellangHighlightRules;
+
+		this.$behaviour = new CstyleBehaviour();
+		this.foldingRules = new CstyleFoldMode();
+	};
+	oop.inherits(Mode, TextMode);
+
+	(function() {
+		this.lineCommentStart = "//";
+		this.blockComment = {start:"/*", end:"*/"};
+		this.$id = "ace/mode/modellang";
+
+		this.getNextLineIndent = function(state, line, tab) {
+			var indent = this.$getIndent(line);
+
+			var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
+			var tokens = tokenizedLine.tokens;
+
+			if (tokens.length && tokens[tokens.length - 1].type === "comment") {
+				return indent;
+			}
+
+			var match;
+			if (state === "eventPatternList") {
+				match = line.match(/^.*(?:[:]).*$/);
+				if (match) {
+					indent += tab;
+				}
+			} else if (state[0] === "coordinate" || state[0] === "doBlock") {
+				match = line.match(/^.*(?:\bDO)\s*$/);
+				if (match) {
+					indent += tab;
+				}
+			}
+
+			return indent;
+		};
+	}).call(Mode.prototype);
+
+	exports.Mode = Mode;
+});
+
+ace.define("ace/mode/behaviour/cstyle",
+["require", "exports", "module", "ace/lib/oop", "ace/mode/behaviour", "ace/token_iterator", "ace/lib/lang"],
+function(require, exports, module) {
+	"use strict";
+
+	var oop = require("../../lib/oop");
+	var Behaviour = require("../behaviour").Behaviour;
+	var TokenIterator = require("../../token_iterator").TokenIterator;
+	var lang = require("../../lib/lang");
+
+	var SAFE_INSERT_IN_TOKENS =
+		["text", "paren.rparen", "punctuation.operator"];
+	var SAFE_INSERT_BEFORE_TOKENS =
+		["text", "paren.rparen", "punctuation.operator", "comment"];
+
+	var context;
+	var contextCache = {};
+	var initContext = function(editor) {
+		var id = -1;
+		if (editor.multiSelect) {
+			id = editor.selection.index;
+			if (contextCache.rangeCount !== editor.multiSelect.rangeCount)
+				contextCache = {rangeCount: editor.multiSelect.rangeCount};
+		}
+		if (contextCache[id])
+			return context = contextCache[id];
+		context = contextCache[id] = {
+			autoInsertedBrackets: 0,
+			autoInsertedRow: -1,
+			autoInsertedLineEnd: "",
+			maybeInsertedBrackets: 0,
+			maybeInsertedRow: -1,
+			maybeInsertedLineStart: "",
+			maybeInsertedLineEnd: "",
+		};
+	};
+
+	var getWrapped = function(selection, selected, opening, closing) {
+		var rowDiff = selection.end.row - selection.start.row;
+		return {
+			text: opening + selected + closing,
+			selection: [
+					0,
+					selection.start.column + 1,
+					rowDiff,
+					selection.end.column + (rowDiff ? 0 : 1),
+				],
+		};
+	};
+
+	var CstyleBehaviour = function() {
+		this.add("braces", "insertion", function(state, action, editor, session, text) {
+			var cursor = editor.getCursorPosition();
+			var line = session.doc.getLine(cursor.row);
+			if (text === "{") {
+				initContext(editor);
+				var selection = editor.getSelectionRange();
+				var selected = session.doc.getTextRange(selection);
+				if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
+					return getWrapped(selection, selected, "{", "}");
+				} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
+					if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
+						CstyleBehaviour.recordAutoInsert(editor, session, "}");
+						return {
+							text: "{}",
+							selection: [1, 1],
+						};
+					} else {
+						CstyleBehaviour.recordMaybeInsert(editor, session, "{");
+						return {
+							text: "{",
+							selection: [1, 1],
+						};
+					}
+				}
+			} else if (text === "}") {
+				initContext(editor);
+				var rightChar = line.substring(cursor.column, cursor.column + 1);
+				if (rightChar === "}") {
+					var matching = session.$findOpeningBracket("}", {column: cursor.column + 1, row: cursor.row});
+					if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
+						CstyleBehaviour.popAutoInsertedClosing();
+						return {
+							text: "",
+							selection: [1, 1],
+						};
+					}
+				}
+			} else if (text === "\n" || text === "\r\n") {
+				initContext(editor);
+				var closing = "";
+				if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
+					closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
+					CstyleBehaviour.clearMaybeInsertedClosing();
+				}
+				var rightChar = line.substring(cursor.column, cursor.column + 1);
+				if (rightChar === "}") {
+					var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}, "}");
+					if (!openBracePos)
+						return null;
+					var next_indent = this.$getIndent(session.getLine(openBracePos.row));
+				} else if (closing) {
+					var next_indent = this.$getIndent(line);
+				} else {
+					CstyleBehaviour.clearMaybeInsertedClosing();
+					return;
+				}
+				var indent = next_indent + session.getTabString();
+
+				return {
+					text: "\n" + indent + "\n" + next_indent + closing,
+					selection: [1, indent.length, 1, indent.length],
+				};
+			} else {
+				CstyleBehaviour.clearMaybeInsertedClosing();
+			}
+		});
+
+		this.add("braces", "deletion", function(state, action, editor, session, range) {
+			var selected = session.doc.getTextRange(range);
+			if (!range.isMultiLine() && selected === "{") {
+				initContext(editor);
+				var line = session.doc.getLine(range.start.row);
+				var rightChar = line.substring(range.end.column, range.end.column + 1);
+				if (rightChar === "}") {
+					range.end.column++;
+					return range;
+				} else {
+					context.maybeInsertedBrackets--;
+				}
+			}
+		});
+
+		this.add("parens", "insertion", function(state, action, editor, session, text) {
+			if (text === "(") {
+				initContext(editor);
+				var selection = editor.getSelectionRange();
+				var selected = session.doc.getTextRange(selection);
+				if (selected !== "" && editor.getWrapBehavioursEnabled()) {
+					return getWrapped(selection, selected, "(", ")");
+				} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
+					CstyleBehaviour.recordAutoInsert(editor, session, ")");
+					return {
+						text: "()",
+						selection: [1, 1],
+					};
+				}
+			} else if (text === ")") {
+				initContext(editor);
+				var cursor = editor.getCursorPosition();
+				var line = session.doc.getLine(cursor.row);
+				var rightChar = line.substring(cursor.column, cursor.column + 1);
+				if (rightChar === ")") {
+					var matching = session.$findOpeningBracket(")", {column: cursor.column + 1, row: cursor.row});
+					if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
+						CstyleBehaviour.popAutoInsertedClosing();
+						return {
+							text: "",
+							selection: [1, 1],
+						};
+					}
+				}
+			}
+		});
+
+		this.add("parens", "deletion", function(state, action, editor, session, range) {
+			var selected = session.doc.getTextRange(range);
+			if (!range.isMultiLine() && selected === "(") {
+				initContext(editor);
+				var line = session.doc.getLine(range.start.row);
+				var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
+				if (rightChar === ")") {
+					range.end.column++;
+					return range;
+				}
+			}
+		});
+
+		this.add("brackets", "insertion", function(state, action, editor, session, text) {
+			if (text == "[") {
+				initContext(editor);
+				var selection = editor.getSelectionRange();
+				var selected = session.doc.getTextRange(selection);
+				if (selected !== "" && editor.getWrapBehavioursEnabled()) {
+					return getWrapped(selection, selected, "[", "]");
+				} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
+					CstyleBehaviour.recordAutoInsert(editor, session, "]");
+					return {
+						text: "[]",
+						selection: [1, 1],
+					};
+				}
+			} else if (text == "]") {
+				initContext(editor);
+				var cursor = editor.getCursorPosition();
+				var line = session.doc.getLine(cursor.row);
+				var rightChar = line.substring(cursor.column, cursor.column + 1);
+				if (rightChar == "]") {
+					var matching = session.$findOpeningBracket("]", {column: cursor.column + 1, row: cursor.row});
+					if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
+						CstyleBehaviour.popAutoInsertedClosing();
+						return {
+							text: "",
+							selection: [1, 1],
+						};
+					}
+				}
+			}
+		});
+
+		this.add("brackets", "deletion", function(state, action, editor, session, range) {
+			var selected = session.doc.getTextRange(range);
+			if (!range.isMultiLine() && selected == "[") {
+				initContext(editor);
+				var line = session.doc.getLine(range.start.row);
+				var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
+				if (rightChar == "]") {
+					range.end.column++;
+					return range;
+				}
+			}
+		});
+
+		this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
+			if (text === '"' || text === "'") {
+				initContext(editor);
+				var quote = text;
+				var selection = editor.getSelectionRange();
+				var selected = session.doc.getTextRange(selection);
+				if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
+					return getWrapped(selection, selected, quote, quote);
+				} else if (!selected) {
+					var cursor = editor.getCursorPosition();
+					var line = session.doc.getLine(cursor.row);
+					var leftChar = line.substring(cursor.column - 1, cursor.column);
+					var rightChar = line.substring(cursor.column, cursor.column + 1);
+
+					var token = session.getTokenAt(cursor.row, cursor.column);
+					var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
+					if (leftChar === "\\" && token && /escape/.test(token.type))
+						return null;
+
+					var stringBefore = token && /string/.test(token.type);
+					var stringAfter = !rightToken || /string/.test(rightToken.type);
+
+					var pair;
+					if (rightChar === quote) {
+						pair = stringBefore !== stringAfter;
+					} else {
+						if (stringBefore && !stringAfter)
+							return null; // wrap string with different quote
+						if (stringBefore && stringAfter)
+							return null; // do not pair quotes inside strings
+						var wordRe = session.$mode.tokenRe;
+						wordRe.lastIndex = 0;
+						var isWordBefore = wordRe.test(leftChar);
+						wordRe.lastIndex = 0;
+						var isWordAfter = wordRe.test(leftChar);
+						if (isWordBefore || isWordAfter)
+							return null; // before or after alphanumeric
+						if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
+							return null; // there is rightChar and it isn't closing
+						pair = true;
+					}
+					return {
+						text: pair ? quote + quote : "",
+						selection: [1, 1],
+					};
+				}
+			}
+		});
+
+		this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
+			var selected = session.doc.getTextRange(range);
+			if (!range.isMultiLine() && (selected === '"' || selected === "'")) {
+				initContext(editor);
+				var line = session.doc.getLine(range.start.row);
+				var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
+				if (rightChar === selected) {
+					range.end.column++;
+					return range;
+				}
+			}
+		});
+
+	};
+
+
+	CstyleBehaviour.isSaneInsertion = function(editor, session) {
+		var cursor = editor.getCursorPosition();
+		var iterator = new TokenIterator(session, cursor.row, cursor.column);
+		if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
+			var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
+			if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
+				return false;
+		}
+		iterator.stepForward();
+		return iterator.getCurrentTokenRow() !== cursor.row ||
+			this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
+	};
+
+	CstyleBehaviour.$matchTokenType = function(token, types) {
+		return types.indexOf(token.type || token) > -1;
+	};
+
+	CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
+		var cursor = editor.getCursorPosition();
+		var line = session.doc.getLine(cursor.row);
+		if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
+			context.autoInsertedBrackets = 0;
+		context.autoInsertedRow = cursor.row;
+		context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
+		context.autoInsertedBrackets++;
+	};
+
+	CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
+		var cursor = editor.getCursorPosition();
+		var line = session.doc.getLine(cursor.row);
+		if (!this.isMaybeInsertedClosing(cursor, line))
+			context.maybeInsertedBrackets = 0;
+		context.maybeInsertedRow = cursor.row;
+		context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
+		context.maybeInsertedLineEnd = line.substr(cursor.column);
+		context.maybeInsertedBrackets++;
+	};
+
+	CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
+		return context.autoInsertedBrackets > 0 &&
+			cursor.row === context.autoInsertedRow &&
+			bracket === context.autoInsertedLineEnd[0] &&
+			line.substr(cursor.column) === context.autoInsertedLineEnd;
+	};
+
+	CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
+		return context.maybeInsertedBrackets > 0 &&
+			cursor.row === context.maybeInsertedRow &&
+			line.substr(cursor.column) === context.maybeInsertedLineEnd &&
+			line.substr(0, cursor.column) === context.maybeInsertedLineStart;
+	};
+
+	CstyleBehaviour.popAutoInsertedClosing = function() {
+		context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
+		context.autoInsertedBrackets--;
+	};
+
+	CstyleBehaviour.clearMaybeInsertedClosing = function() {
+		if (context) {
+			context.maybeInsertedBrackets = 0;
+			context.maybeInsertedRow = -1;
+		}
+	};
+
+
+
+	oop.inherits(CstyleBehaviour, Behaviour);
+
+	exports.CstyleBehaviour = CstyleBehaviour;
+});
+
+ace.define("ace/mode/folding/cstyle",
+["require", "exports", "module", "ace/lib/oop", "ace/range", "ace/mode/folding/fold_mode"],
+function(require, exports, module) {
+	"use strict";
+
+	var oop = require("../../lib/oop");
+	var Range = require("../../range").Range;
+	var BaseFoldMode = require("./fold_mode").FoldMode;
+
+	var FoldMode = exports.FoldMode = function(commentRegex) {
+		if (commentRegex) {
+			this.foldingStartMarker = new RegExp(
+				this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
+			);
+			this.foldingStopMarker = new RegExp(
+				this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
+			);
+		}
+	};
+	oop.inherits(FoldMode, BaseFoldMode);
+
+	(function() {
+
+		this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
+		this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
+		this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
+		this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
+		this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
+		this._getFoldWidgetBase = this.getFoldWidget;
+		this.getFoldWidget = function(session, foldStyle, row) {
+			var line = session.getLine(row);
+
+			if (this.singleLineBlockCommentRe.test(line)) {
+				if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
+					return "";
+			}
+
+			var fw = this._getFoldWidgetBase(session, foldStyle, row);
+
+			if (!fw && this.startRegionRe.test(line))
+				return "start"; // lineCommentRegionStart
+
+			return fw;
+		};
+
+		this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
+			var line = session.getLine(row);
+
+			if (this.startRegionRe.test(line))
+				return this.getCommentRegionBlock(session, line, row);
+
+			var match = line.match(this.foldingStartMarker);
+			if (match) {
+				var i = match.index;
+
+				if (match[1])
+					return this.openingBracketBlock(session, match[1], row, i);
+
+				var range = session.getCommentFoldRange(row, i + match[0].length, 1);
+
+				if (range && !range.isMultiLine()) {
+					if (forceMultiline) {
+						range = this.getSectionRange(session, row);
+					} else if (foldStyle !== "all")
+						range = null;
+				}
+
+				return range;
+			}
+
+			if (foldStyle === "markbegin")
+				return;
+
+			match = line.match(this.foldingStopMarker);
+			if (match) {
+				var i = match.index + match[0].length;
+
+				if (match[1])
+					return this.closingBracketBlock(session, match[1], row, i);
+
+				return session.getCommentFoldRange(row, i, -1);
+			}
+		};
+
+		this.getSectionRange = function(session, row) {
+			var line = session.getLine(row);
+			var startIndent = line.search(/\S/);
+			var startRow = row;
+			var startColumn = line.length;
+			row = row + 1;
+			var endRow = row;
+			var maxRow = session.getLength();
+			while (++row < maxRow) {
+				line = session.getLine(row);
+				var indent = line.search(/\S/);
+				if (indent === -1)
+					continue;
+				if (startIndent > indent)
+					break;
+				var subRange = this.getFoldWidgetRange(session, "all", row);
+
+				if (subRange) {
+					if (subRange.start.row <= startRow) {
+						break;
+					} else if (subRange.isMultiLine()) {
+						row = subRange.end.row;
+					} else if (startIndent === indent) {
+						break;
+					}
+				}
+				endRow = row;
+			}
+
+			return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
+		};
+
+		this.getCommentRegionBlock = function(session, line, row) {
+			var startColumn = line.search(/\s*$/);
+			var maxRow = session.getLength();
+			var startRow = row;
+
+			var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
+			var depth = 1;
+			while (++row < maxRow) {
+				line = session.getLine(row);
+				var m = re.exec(line);
+				if (!m) continue;
+				if (m[1]) depth--;
+				else depth++;
+
+				if (!depth) break;
+			}
+
+			var endRow = row;
+			if (endRow > startRow) {
+				return new Range(startRow, startColumn, endRow, line.length);
+			}
+		};
+
+	}).call(FoldMode.prototype);
+});
+
+ace.define("ace/mode/javascript_highlight_rules",
+["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"],
+function(require, exports, module) {
+	"use strict";
+
+	var oop = require("../lib/oop");
+	var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
+	var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+
+	var JavaScriptHighlightRules = function(options) {
+	    var keywordMapper = this.createKeywordMapper({
+	        "variable.language":
+	            "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|"  + // Constructors
+	            "Namespace|QName|XML|XMLList|"                                             + // E4X
+	            "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|"   +
+	            "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|"                    +
+	            "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|"   + // Errors
+	            "SyntaxError|TypeError|URIError|"                                          +
+	            "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
+	            "isNaN|parseFloat|parseInt|"                                               +
+	            "JSON|Math|"                                                               + // Other
+	            "this|arguments|prototype|window|document"                                 , // Pseudo
+	        "keyword":
+	            "const|yield|import|get|set|" +
+	            "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
+	            "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
+	            "__parent__|__count__|escape|unescape|with|__proto__|" +
+	            "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
+	        "storage.type":
+	            "const|let|var|function",
+	        "constant.language":
+	            "null|Infinity|NaN|undefined",
+	        "support.function":
+	            "alert",
+	        "constant.language.boolean": "true|false"
+	    }, "identifier");
+	    var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
+	    var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
+
+	    var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
+	        "u[0-9a-fA-F]{4}|" + // unicode
+	        "[0-2][0-7]{0,2}|" + // oct
+	        "3[0-6][0-7]?|" + // oct
+	        "37[0-7]?|" + // oct
+	        "[4-7][0-7]?|" + //oct
+	        ".)";
+
+	    this.$rules = {
+	        "no_regex" : [
+	            {
+	                token : "comment",
+	                regex : "\\/\\/",
+	                next : "line_comment"
+	            },
+	            DocCommentHighlightRules.getStartRule("doc-start"),
+	            {
+	                token : "comment", // multi line comment
+	                regex : /\/\*/,
+	                next : "comment"
+	            }, {
+	                token : "string",
+	                regex : "'(?=.)",
+	                next  : "qstring"
+	            }, {
+	                token : "string",
+	                regex : '"(?=.)',
+	                next  : "qqstring"
+	            }, {
+	                token : "constant.numeric", // hex
+	                regex : /0[xX][0-9a-fA-F]+\b/
+	            }, {
+	                token : "constant.numeric", // float
+	                regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
+	            }, {
+	                token : [
+	                    "storage.type", "punctuation.operator", "support.function",
+	                    "punctuation.operator", "entity.name.function", "text","keyword.operator"
+	                ],
+	                regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
+	                next: "function_arguments"
+	            }, {
+	                token : [
+	                    "storage.type", "punctuation.operator", "entity.name.function", "text",
+	                    "keyword.operator", "text", "storage.type", "text", "paren.lparen"
+	                ],
+	                regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
+	                next: "function_arguments"
+	            }, {
+	                token : [
+	                    "entity.name.function", "text", "keyword.operator", "text", "storage.type",
+	                    "text", "paren.lparen"
+	                ],
+	                regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
+	                next: "function_arguments"
+	            }, {
+	                token : [
+	                    "storage.type", "punctuation.operator", "entity.name.function", "text",
+	                    "keyword.operator", "text",
+	                    "storage.type", "text", "entity.name.function", "text", "paren.lparen"
+	                ],
+	                regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
+	                next: "function_arguments"
+	            }, {
+	                token : [
+	                    "storage.type", "text", "entity.name.function", "text", "paren.lparen"
+	                ],
+	                regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
+	                next: "function_arguments"
+	            }, {
+	                token : [
+	                    "entity.name.function", "text", "punctuation.operator",
+	                    "text", "storage.type", "text", "paren.lparen"
+	                ],
+	                regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
+	                next: "function_arguments"
+	            }, {
+	                token : [
+	                    "text", "text", "storage.type", "text", "paren.lparen"
+	                ],
+	                regex : "(:)(\\s*)(function)(\\s*)(\\()",
+	                next: "function_arguments"
+	            }, {
+	                token : "keyword",
+	                regex : "(?:" + kwBeforeRe + ")\\b",
+	                next : "start"
+	            }, {
+	                token : ["punctuation.operator", "support.function"],
+	                regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
+	            }, {
+	                token : ["punctuation.operator", "support.function.dom"],
+	                regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
+	            }, {
+	                token : ["punctuation.operator", "support.constant"],
+	                regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
+	            }, {
+	                token : ["support.constant"],
+	                regex : /that\b/
+	            }, {
+	                token : ["storage.type", "punctuation.operator", "support.function.firebug"],
+	                regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
+	            }, {
+	                token : keywordMapper,
+	                regex : identifierRe
+	            }, {
+	                token : "keyword.operator",
+	                regex : /--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/,
+	                next  : "start"
+	            }, {
+	                token : "punctuation.operator",
+	                regex : /[?:,;.]/,
+	                next  : "start"
+	            }, {
+	                token : "paren.lparen",
+	                regex : /[\[({]/,
+	                next  : "start"
+	            }, {
+	                token : "paren.rparen",
+	                regex : /[\])}]/
+	            }, {
+	                token: "comment",
+	                regex: /^#!.*$/
+	            }
+	        ],
+	        "start": [
+	            DocCommentHighlightRules.getStartRule("doc-start"),
+	            {
+	                token : "comment", // multi line comment
+	                regex : "\\/\\*",
+	                next : "comment_regex_allowed"
+	            }, {
+	                token : "comment",
+	                regex : "\\/\\/",
+	                next : "line_comment_regex_allowed"
+	            }, {
+	                token: "string.regexp",
+	                regex: "\\/",
+	                next: "regex"
+	            }, {
+	                token : "text",
+	                regex : "\\s+|^$",
+	                next : "start"
+	            }, {
+	                token: "empty",
+	                regex: "",
+	                next: "no_regex"
+	            }
+	        ],
+	        "regex": [
+	            {
+	                token: "regexp.keyword.operator",
+	                regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
+	            }, {
+	                token: "string.regexp",
+	                regex: "/[sxngimy]*",
+	                next: "no_regex"
+	            }, {
+	                token : "invalid",
+	                regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
+	            }, {
+	                token : "constant.language.escape",
+	                regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
+	            }, {
+	                token : "constant.language.delimiter",
+	                regex: /\|/
+	            }, {
+	                token: "constant.language.escape",
+	                regex: /\[\^?/,
+	                next: "regex_character_class"
+	            }, {
+	                token: "empty",
+	                regex: "$",
+	                next: "no_regex"
+	            }, {
+	                defaultToken: "string.regexp"
+	            }
+	        ],
+	        "regex_character_class": [
+	            {
+	                token: "regexp.charclass.keyword.operator",
+	                regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
+	            }, {
+	                token: "constant.language.escape",
+	                regex: "]",
+	                next: "regex"
+	            }, {
+	                token: "constant.language.escape",
+	                regex: "-"
+	            }, {
+	                token: "empty",
+	                regex: "$",
+	                next: "no_regex"
+	            }, {
+	                defaultToken: "string.regexp.charachterclass"
+	            }
+	        ],
+	        "function_arguments": [
+	            {
+	                token: "variable.parameter",
+	                regex: identifierRe
+	            }, {
+	                token: "punctuation.operator",
+	                regex: "[, ]+"
+	            }, {
+	                token: "punctuation.operator",
+	                regex: "$"
+	            }, {
+	                token: "empty",
+	                regex: "",
+	                next: "no_regex"
+	            }
+	        ],
+	        "comment_regex_allowed" : [
+	            DocCommentHighlightRules.getTagRule(),
+	            {token : "comment", regex : "\\*\\/", next : "start"},
+	            {defaultToken : "comment", caseInsensitive: true}
+	        ],
+	        "comment" : [
+	            DocCommentHighlightRules.getTagRule(),
+	            {token : "comment", regex : "\\*\\/", next : "no_regex"},
+	            {defaultToken : "comment", caseInsensitive: true}
+	        ],
+	        "line_comment_regex_allowed" : [
+	            DocCommentHighlightRules.getTagRule(),
+	            {token : "comment", regex : "$|^", next : "start"},
+	            {defaultToken : "comment", caseInsensitive: true}
+	        ],
+	        "line_comment" : [
+	            DocCommentHighlightRules.getTagRule(),
+	            {token : "comment", regex : "$|^", next : "no_regex"},
+	            {defaultToken : "comment", caseInsensitive: true}
+	        ],
+	        "qqstring" : [
+	            {
+	                token : "constant.language.escape",
+	                regex : escapedRe
+	            }, {
+	                token : "string",
+	                regex : "\\\\$",
+	                next  : "qqstring"
+	            }, {
+	                token : "string",
+	                regex : '"|$',
+	                next  : "no_regex"
+	            }, {
+	                defaultToken: "string"
+	            }
+	        ],
+	        "qstring" : [
+	            {
+	                token : "constant.language.escape",
+	                regex : escapedRe
+	            }, {
+	                token : "string",
+	                regex : "\\\\$",
+	                next  : "qstring"
+	            }, {
+	                token : "string",
+	                regex : "'|$",
+	                next  : "no_regex"
+	            }, {
+	                defaultToken: "string"
+	            }
+	        ]
+	    };
+
+
+	    if (!options || !options.noES6) {
+	        this.$rules.no_regex.unshift({
+	            regex: "[{}]", onMatch: function(val, state, stack) {
+	                this.next = val == "{" ? this.nextState : "";
+	                if (val == "{" && stack.length) {
+	                    stack.unshift("start", state);
+	                    return "paren";
+	                }
+	                if (val == "}" && stack.length) {
+	                    stack.shift();
+	                    this.next = stack.shift();
+	                    if (this.next.indexOf("string") != -1)
+	                        return "paren.quasi.end";
+	                }
+	                return val == "{" ? "paren.lparen" : "paren.rparen";
+	            },
+	            nextState: "start"
+	        }, {
+	            token : "string.quasi.start",
+	            regex : /`/,
+	            push  : [{
+	                token : "constant.language.escape",
+	                regex : escapedRe
+	            }, {
+	                token : "paren.quasi.start",
+	                regex : /\${/,
+	                push  : "start"
+	            }, {
+	                token : "string.quasi.end",
+	                regex : /`/,
+	                next  : "pop"
+	            }, {
+	                defaultToken: "string.quasi"
+	            }]
+	        });
+	    }
+
+	    this.embedRules(DocCommentHighlightRules, "doc-",
+	        [ DocCommentHighlightRules.getEndRule("no_regex") ]);
+
+	    this.normalizeRules();
+	};
+
+	oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
+
+	exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
+});
+
+ace.define("ace/mode/doc_comment_highlight_rules",
+["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],
+function(require, exports, module) {
+	"use strict";
+
+	var oop = require("../lib/oop");
+	var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+
+	var DocCommentHighlightRules = function() {
+	    this.$rules = {
+	        "start" : [ {
+	            token : "comment.doc.tag",
+	            regex : "@[\\w\\d_]+" // TODO: fix email addresses
+	        },
+	        DocCommentHighlightRules.getTagRule(),
+	        {
+	            defaultToken : "comment.doc",
+	            caseInsensitive: true
+	        }]
+	    };
+	};
+
+	oop.inherits(DocCommentHighlightRules, TextHighlightRules);
+
+	DocCommentHighlightRules.getTagRule = function(start) {
+	    return {
+	        token : "comment.doc.tag.storage.type",
+	        regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
+	    };
+	}
+
+	DocCommentHighlightRules.getStartRule = function(start) {
+	    return {
+	        token : "comment.doc", // doc comment
+	        regex : "\\/\\*(?=\\*)",
+	        next  : start
+	    };
+	};
+
+	DocCommentHighlightRules.getEndRule = function (start) {
+	    return {
+	        token : "comment.doc", // closing comment
+	        regex : "\\*\\/",
+	        next  : start
+	    };
+	};
+
+
+	exports.DocCommentHighlightRules = DocCommentHighlightRules;
+
+});

+ 0 - 850
src/web/assets/scripts/mp.js

@@ -1,850 +0,0 @@
-/*global ace*/
-
-ace.define("ace/mode/mp_highlight_rules",
-["require", "exports", "module", "ace/lib/oop"],
-function(require, exports, module) {
-	"use strict";
-
-	var oop = require("../lib/oop");
-	var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
-
-	var MpHighlightRules = function() {
-
-		this.$rules = {
-
-			// identifier: [a-zA-Z0-9]\w*
-			// variable:   \$\w+
-			start: [
-				// line comment
-				{
-					token: "comment.line.double-slash",
-					regex: /\/\/.*/,
-				},
-				// multi-line comment
-				{
-					token: "comment.block",
-					regex: /\/\*/,
-					next: "comment",
-				},
-				// schema
-				{
-					token: [
-						"keyword.operator",
-						"text",
-						"entity.name.section",
-						"text",
-						"punctuation.operator",
-						],
-					regex: /(\bSCHEMA\b)(\s+)([a-zA-Z0-9]\w*)(\s*)(;?)/,
-				},
-				// includes
-				{
-					token: [
-						"keyword.operator",
-						"text",
-						"entity.name.section",
-						"text",
-						"punctuation.operator",
-						],
-					regex: /(\bINCLUDE\b)(\s+)([a-zA-Z0-9]\w*)(\s*)(;)/,
-				},
-				// roots
-				{
-					token: [
-						"keyword",
-						"text",
-						"variable.other",
-						"text",
-						"punctuation.operator",
-						],
-					regex: /(\bROOT\b)(\s+)([a-zA-Z0-9]\w*)(\s*)(:)/,
-					push: "eventPatternList",
-				},
-				// events
-				{
-					token: [
-						"variable.other",
-						"text",
-						"punctuation.operator",
-						],
-					regex: /([a-zA-Z0-9]\w*)(\s*)(:)/,
-					push: "eventPatternList",
-				},
-				// push: shareAll
-				{
-					token: "entity.name.tag",
-					regex: /([a-zA-Z0-9$]\w*)(?=[$\w\s,]+\bSHARE\s+ALL\b)/,
-					push: "shareAll",
-				},
-				// push: coordinate
-				{
-					token: "keyword.control",
-					regex: /(\bCOORDINATE\b)/,
-					push: "coordinate",
-				},
-				// whitespace
-				{
-					token: "text",
-					regex: /\s+/,
-				},
-				// default: invalid
-				{
-					defaultToken: "invalid"
-				},
-			],
-
-			eventPatternList: [
-				// opening bracket
-				{
-					token: [
-						"paren.lparen.type",
-						"paren.lparen.quantifier",
-						],
-					regex: /([\[({])([*+]?)/,
-				},
-				// closing bracket
-				{
-					token: [
-						"paren.rparen.quantifier",
-						"paren.rparen.type",
-						],
-					regex: /([*+]?)([\])}])/,
-				},
-				// scope
-				{
-					token: [
-						"comment",
-						"comment",
-						"comment",
-						"comment",
-					],
-					regex: /(<)(\d)(\.\.\d)?(>)/,
-				},
-				// seperators
-				{
-					token: "keyword.operator",
-					regex: /[,|]/,
-				},
-				// identifiers
-				{
-					token: "text",
-					regex: /\$\w[\w\d_]*/,
-				},
-				{
-					token: "punctuation.operator",
-					regex: /;/,
-					next: "pop",
-				},
-			],
-
-			shareAll: [
-				// share all
-				{
-					token: "support.function",
-					regex: /(\bSHARE\s+ALL\b)/,
-				},
-				// id list
-				{
-					token: "entity.name.tag",
-					regex: /([a-zA-Z0-9]\w*)/,
-				},
-				// list seperator
-				{
-					token: "text",
-					regex: /[, ]/,
-				},
-				// pop: semicolon
-				{
-					token: "punctuation.operator",
-					regex: /(;)/,
-					next: "pop",
-				},
-			],
-
-			coordinate: [
-				// async flag
-				{
-					token: "support.function",
-					regex: /(<!>)/,
-				},
-				// coordination source list
-				{
-					token: [
-						"variable",
-						"punctuation.operator",
-						"text",
-						"text",
-						"text",
-						],
-					regex: /(\$\w+)(\s*:\s*)([a-zA-Z0-9]\w*|[(](([a-zA-Z0-9]\w*\s*\|?)+)[)])/,
-				},
-				// coordination source from
-				{
-					token:[
-						"keyword.control",
-						"text",
-						"variable",
-						"text",
-						],
-					regex: /(\bFROM\b)(\s+)(?:(\$\w+)|([a-zA-Z0-9]\w*))/,
-				},
-				// push: doBlock
-				{
-					token: "support.constant",
-					regex: /(\bDO\b)/,
-					push: "doBlock",
-				},
-				// pop: semi
-				{
-					token: "punctuation.operator",
-					regex: /;/,
-					next: "pop",
-				},
-				// seperator
-				{
-					token: "punctuation.operator",
-					regex: /,/,
-				},
-				// whitespace
-				{
-					token: "text",
-					regex: /\s+/,
-				},
-			],
-
-			addRelation: [
-				// relationship list
-				{
-					token: [
-						"variable",
-						"text",
-						"support.function",
-						"text",
-						"variable",
-						],
-					regex: /(\$\w+)(\s+)(IN|PRECEDES|CONTAINS|FOLLOWS)(\s+)(\$\w+)/,
-				},
-				// seperator
-				{
-					token: "text",
-					regex: /[, ]/,
-				},
-				// pop: semicolon
-				{
-					token: "punctuation.operator",
-					regex: /;/,
-					next: "pop",
-				},
-			],
-
-			doBlock: [
-				// push: addRelation
-				{
-					token: "support.function",
-					regex: /(\bADD\b)/,
-					push: "addRelation",
-				},
-				// push: share all
-				{
-					token: "text",
-					regex: /([a-zA-Z0-9]\w*)(?=[\w\s,]+\bSHARE\s+ALL\b)/,
-					push: "shareAll",
-				},
-				// push: coordinate
-				{
-					token: "keyword.control",
-					regex: /(\bCOORDINATE\b)/,
-					push: "coordinate",
-				},
-				// pop: od
-				{
-					token: "support.constant",
-					regex: /(\bOD\b)/,
-					next: "pop",
-				},
-			],
-
-			comment: [
-				// multi-line comment terminator
-				{
-					token: "comment.block",
-					regex: /.*?\*\//,
-					next: "start",
-				},
-				// stuff
-				{
-					regex: /.*/,
-					token: "comment.block",
-				},
-			],
-
-			meta: {
-				dontIndentStates: ["comment"],
-				lineComment: "//",
-			},
-
-		};
-
-		this.normalizeRules();
-	};
-
-	oop.inherits(MpHighlightRules, TextHighlightRules);
-
-	exports.MpHighlightRules = MpHighlightRules;
-
-});
-
-ace.define("ace/mode/mp",
-["require", "exports", "module", "ace/lib/oop", "ace/mode/text", "ace/mode/mp_highlight_rules"],
-function(require, exports, module) {
-	"use strict";
-
-	var oop = require("../lib/oop");
-	var TextMode = require("./text").Mode;
-	var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
-	var CstyleFoldMode = require("./folding/cstyle").FoldMode;
-	var MpHighlightRules = require("./mp_highlight_rules").MpHighlightRules;
-
-	var Mode = function() {
-		this.HighlightRules = MpHighlightRules;
-
-		this.$behaviour = new CstyleBehaviour();
-		this.foldingRules = new CstyleFoldMode();
-	};
-	oop.inherits(Mode, TextMode);
-
-	(function() {
-		this.lineCommentStart = "//";
-		this.blockComment = {start:"/*", end:"*/"};
-		this.$id = "ace/mode/mp";
-
-		this.getNextLineIndent = function(state, line, tab) {
-			var indent = this.$getIndent(line);
-
-			var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
-			var tokens = tokenizedLine.tokens;
-
-			if (tokens.length && tokens[tokens.length - 1].type === "comment") {
-				return indent;
-			}
-
-			var match;
-			if (state === "eventPatternList") {
-				match = line.match(/^.*(?:[:]).*$/);
-				if (match) {
-					indent += tab;
-				}
-			} else if (state[0] === "coordinate" || state[0] === "doBlock") {
-				match = line.match(/^.*(?:\bDO)\s*$/);
-				if (match) {
-					indent += tab;
-				}
-			}
-
-			return indent;
-		};
-	}).call(Mode.prototype);
-
-	exports.Mode = Mode;
-});
-
-ace.define("ace/mode/behaviour/cstyle",
-["require", "exports", "module", "ace/lib/oop", "ace/mode/behaviour", "ace/token_iterator", "ace/lib/lang"],
-function(require, exports, module) {
-	"use strict";
-
-	var oop = require("../../lib/oop");
-	var Behaviour = require("../behaviour").Behaviour;
-	var TokenIterator = require("../../token_iterator").TokenIterator;
-	var lang = require("../../lib/lang");
-
-	var SAFE_INSERT_IN_TOKENS =
-		["text", "paren.rparen", "punctuation.operator"];
-	var SAFE_INSERT_BEFORE_TOKENS =
-		["text", "paren.rparen", "punctuation.operator", "comment"];
-
-	var context;
-	var contextCache = {};
-	var initContext = function(editor) {
-		var id = -1;
-		if (editor.multiSelect) {
-			id = editor.selection.index;
-			if (contextCache.rangeCount !== editor.multiSelect.rangeCount)
-				contextCache = {rangeCount: editor.multiSelect.rangeCount};
-		}
-		if (contextCache[id])
-			return context = contextCache[id];
-		context = contextCache[id] = {
-			autoInsertedBrackets: 0,
-			autoInsertedRow: -1,
-			autoInsertedLineEnd: "",
-			maybeInsertedBrackets: 0,
-			maybeInsertedRow: -1,
-			maybeInsertedLineStart: "",
-			maybeInsertedLineEnd: "",
-		};
-	};
-
-	var getWrapped = function(selection, selected, opening, closing) {
-		var rowDiff = selection.end.row - selection.start.row;
-		return {
-			text: opening + selected + closing,
-			selection: [
-					0,
-					selection.start.column + 1,
-					rowDiff,
-					selection.end.column + (rowDiff ? 0 : 1),
-				],
-		};
-	};
-
-	var CstyleBehaviour = function() {
-		this.add("braces", "insertion", function(state, action, editor, session, text) {
-			var cursor = editor.getCursorPosition();
-			var line = session.doc.getLine(cursor.row);
-			if (text === "{") {
-				initContext(editor);
-				var selection = editor.getSelectionRange();
-				var selected = session.doc.getTextRange(selection);
-				if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
-					return getWrapped(selection, selected, "{", "}");
-				} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
-					if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
-						CstyleBehaviour.recordAutoInsert(editor, session, "}");
-						return {
-							text: "{}",
-							selection: [1, 1],
-						};
-					} else {
-						CstyleBehaviour.recordMaybeInsert(editor, session, "{");
-						return {
-							text: "{",
-							selection: [1, 1],
-						};
-					}
-				}
-			} else if (text === "}") {
-				initContext(editor);
-				var rightChar = line.substring(cursor.column, cursor.column + 1);
-				if (rightChar === "}") {
-					var matching = session.$findOpeningBracket("}", {column: cursor.column + 1, row: cursor.row});
-					if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
-						CstyleBehaviour.popAutoInsertedClosing();
-						return {
-							text: "",
-							selection: [1, 1],
-						};
-					}
-				}
-			} else if (text === "\n" || text === "\r\n") {
-				initContext(editor);
-				var closing = "";
-				if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
-					closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
-					CstyleBehaviour.clearMaybeInsertedClosing();
-				}
-				var rightChar = line.substring(cursor.column, cursor.column + 1);
-				if (rightChar === "}") {
-					var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}, "}");
-					if (!openBracePos)
-						return null;
-					var next_indent = this.$getIndent(session.getLine(openBracePos.row));
-				} else if (closing) {
-					var next_indent = this.$getIndent(line);
-				} else {
-					CstyleBehaviour.clearMaybeInsertedClosing();
-					return;
-				}
-				var indent = next_indent + session.getTabString();
-
-				return {
-					text: "\n" + indent + "\n" + next_indent + closing,
-					selection: [1, indent.length, 1, indent.length],
-				};
-			} else {
-				CstyleBehaviour.clearMaybeInsertedClosing();
-			}
-		});
-
-		this.add("braces", "deletion", function(state, action, editor, session, range) {
-			var selected = session.doc.getTextRange(range);
-			if (!range.isMultiLine() && selected === "{") {
-				initContext(editor);
-				var line = session.doc.getLine(range.start.row);
-				var rightChar = line.substring(range.end.column, range.end.column + 1);
-				if (rightChar === "}") {
-					range.end.column++;
-					return range;
-				} else {
-					context.maybeInsertedBrackets--;
-				}
-			}
-		});
-
-		this.add("parens", "insertion", function(state, action, editor, session, text) {
-			if (text === "(") {
-				initContext(editor);
-				var selection = editor.getSelectionRange();
-				var selected = session.doc.getTextRange(selection);
-				if (selected !== "" && editor.getWrapBehavioursEnabled()) {
-					return getWrapped(selection, selected, "(", ")");
-				} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
-					CstyleBehaviour.recordAutoInsert(editor, session, ")");
-					return {
-						text: "()",
-						selection: [1, 1],
-					};
-				}
-			} else if (text === ")") {
-				initContext(editor);
-				var cursor = editor.getCursorPosition();
-				var line = session.doc.getLine(cursor.row);
-				var rightChar = line.substring(cursor.column, cursor.column + 1);
-				if (rightChar === ")") {
-					var matching = session.$findOpeningBracket(")", {column: cursor.column + 1, row: cursor.row});
-					if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
-						CstyleBehaviour.popAutoInsertedClosing();
-						return {
-							text: "",
-							selection: [1, 1],
-						};
-					}
-				}
-			}
-		});
-
-		this.add("parens", "deletion", function(state, action, editor, session, range) {
-			var selected = session.doc.getTextRange(range);
-			if (!range.isMultiLine() && selected === "(") {
-				initContext(editor);
-				var line = session.doc.getLine(range.start.row);
-				var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
-				if (rightChar === ")") {
-					range.end.column++;
-					return range;
-				}
-			}
-		});
-
-		this.add("brackets", "insertion", function(state, action, editor, session, text) {
-			if (text == "[") {
-				initContext(editor);
-				var selection = editor.getSelectionRange();
-				var selected = session.doc.getTextRange(selection);
-				if (selected !== "" && editor.getWrapBehavioursEnabled()) {
-					return getWrapped(selection, selected, "[", "]");
-				} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
-					CstyleBehaviour.recordAutoInsert(editor, session, "]");
-					return {
-						text: "[]",
-						selection: [1, 1],
-					};
-				}
-			} else if (text == "]") {
-				initContext(editor);
-				var cursor = editor.getCursorPosition();
-				var line = session.doc.getLine(cursor.row);
-				var rightChar = line.substring(cursor.column, cursor.column + 1);
-				if (rightChar == "]") {
-					var matching = session.$findOpeningBracket("]", {column: cursor.column + 1, row: cursor.row});
-					if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
-						CstyleBehaviour.popAutoInsertedClosing();
-						return {
-							text: "",
-							selection: [1, 1],
-						};
-					}
-				}
-			}
-		});
-
-		this.add("brackets", "deletion", function(state, action, editor, session, range) {
-			var selected = session.doc.getTextRange(range);
-			if (!range.isMultiLine() && selected == "[") {
-				initContext(editor);
-				var line = session.doc.getLine(range.start.row);
-				var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
-				if (rightChar == "]") {
-					range.end.column++;
-					return range;
-				}
-			}
-		});
-
-		this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
-			if (text === '"' || text === "'") {
-				initContext(editor);
-				var quote = text;
-				var selection = editor.getSelectionRange();
-				var selected = session.doc.getTextRange(selection);
-				if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
-					return getWrapped(selection, selected, quote, quote);
-				} else if (!selected) {
-					var cursor = editor.getCursorPosition();
-					var line = session.doc.getLine(cursor.row);
-					var leftChar = line.substring(cursor.column - 1, cursor.column);
-					var rightChar = line.substring(cursor.column, cursor.column + 1);
-
-					var token = session.getTokenAt(cursor.row, cursor.column);
-					var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
-					if (leftChar === "\\" && token && /escape/.test(token.type))
-						return null;
-
-					var stringBefore = token && /string/.test(token.type);
-					var stringAfter = !rightToken || /string/.test(rightToken.type);
-
-					var pair;
-					if (rightChar === quote) {
-						pair = stringBefore !== stringAfter;
-					} else {
-						if (stringBefore && !stringAfter)
-							return null; // wrap string with different quote
-						if (stringBefore && stringAfter)
-							return null; // do not pair quotes inside strings
-						var wordRe = session.$mode.tokenRe;
-						wordRe.lastIndex = 0;
-						var isWordBefore = wordRe.test(leftChar);
-						wordRe.lastIndex = 0;
-						var isWordAfter = wordRe.test(leftChar);
-						if (isWordBefore || isWordAfter)
-							return null; // before or after alphanumeric
-						if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
-							return null; // there is rightChar and it isn't closing
-						pair = true;
-					}
-					return {
-						text: pair ? quote + quote : "",
-						selection: [1, 1],
-					};
-				}
-			}
-		});
-
-		this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
-			var selected = session.doc.getTextRange(range);
-			if (!range.isMultiLine() && (selected === '"' || selected === "'")) {
-				initContext(editor);
-				var line = session.doc.getLine(range.start.row);
-				var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
-				if (rightChar === selected) {
-					range.end.column++;
-					return range;
-				}
-			}
-		});
-
-	};
-
-
-	CstyleBehaviour.isSaneInsertion = function(editor, session) {
-		var cursor = editor.getCursorPosition();
-		var iterator = new TokenIterator(session, cursor.row, cursor.column);
-		if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
-			var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
-			if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
-				return false;
-		}
-		iterator.stepForward();
-		return iterator.getCurrentTokenRow() !== cursor.row ||
-			this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
-	};
-
-	CstyleBehaviour.$matchTokenType = function(token, types) {
-		return types.indexOf(token.type || token) > -1;
-	};
-
-	CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
-		var cursor = editor.getCursorPosition();
-		var line = session.doc.getLine(cursor.row);
-		if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
-			context.autoInsertedBrackets = 0;
-		context.autoInsertedRow = cursor.row;
-		context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
-		context.autoInsertedBrackets++;
-	};
-
-	CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
-		var cursor = editor.getCursorPosition();
-		var line = session.doc.getLine(cursor.row);
-		if (!this.isMaybeInsertedClosing(cursor, line))
-			context.maybeInsertedBrackets = 0;
-		context.maybeInsertedRow = cursor.row;
-		context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
-		context.maybeInsertedLineEnd = line.substr(cursor.column);
-		context.maybeInsertedBrackets++;
-	};
-
-	CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
-		return context.autoInsertedBrackets > 0 &&
-			cursor.row === context.autoInsertedRow &&
-			bracket === context.autoInsertedLineEnd[0] &&
-			line.substr(cursor.column) === context.autoInsertedLineEnd;
-	};
-
-	CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
-		return context.maybeInsertedBrackets > 0 &&
-			cursor.row === context.maybeInsertedRow &&
-			line.substr(cursor.column) === context.maybeInsertedLineEnd &&
-			line.substr(0, cursor.column) === context.maybeInsertedLineStart;
-	};
-
-	CstyleBehaviour.popAutoInsertedClosing = function() {
-		context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
-		context.autoInsertedBrackets--;
-	};
-
-	CstyleBehaviour.clearMaybeInsertedClosing = function() {
-		if (context) {
-			context.maybeInsertedBrackets = 0;
-			context.maybeInsertedRow = -1;
-		}
-	};
-
-
-
-	oop.inherits(CstyleBehaviour, Behaviour);
-
-	exports.CstyleBehaviour = CstyleBehaviour;
-});
-
-ace.define("ace/mode/folding/cstyle",
-["require", "exports", "module", "ace/lib/oop", "ace/range", "ace/mode/folding/fold_mode"],
-function(require, exports, module) {
-	"use strict";
-
-	var oop = require("../../lib/oop");
-	var Range = require("../../range").Range;
-	var BaseFoldMode = require("./fold_mode").FoldMode;
-
-	var FoldMode = exports.FoldMode = function(commentRegex) {
-		if (commentRegex) {
-			this.foldingStartMarker = new RegExp(
-				this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
-			);
-			this.foldingStopMarker = new RegExp(
-				this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
-			);
-		}
-	};
-	oop.inherits(FoldMode, BaseFoldMode);
-
-	(function() {
-
-		this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
-		this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
-		this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
-		this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
-		this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
-		this._getFoldWidgetBase = this.getFoldWidget;
-		this.getFoldWidget = function(session, foldStyle, row) {
-			var line = session.getLine(row);
-
-			if (this.singleLineBlockCommentRe.test(line)) {
-				if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
-					return "";
-			}
-
-			var fw = this._getFoldWidgetBase(session, foldStyle, row);
-
-			if (!fw && this.startRegionRe.test(line))
-				return "start"; // lineCommentRegionStart
-
-			return fw;
-		};
-
-		this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
-			var line = session.getLine(row);
-
-			if (this.startRegionRe.test(line))
-				return this.getCommentRegionBlock(session, line, row);
-
-			var match = line.match(this.foldingStartMarker);
-			if (match) {
-				var i = match.index;
-
-				if (match[1])
-					return this.openingBracketBlock(session, match[1], row, i);
-
-				var range = session.getCommentFoldRange(row, i + match[0].length, 1);
-
-				if (range && !range.isMultiLine()) {
-					if (forceMultiline) {
-						range = this.getSectionRange(session, row);
-					} else if (foldStyle !== "all")
-						range = null;
-				}
-
-				return range;
-			}
-
-			if (foldStyle === "markbegin")
-				return;
-
-			match = line.match(this.foldingStopMarker);
-			if (match) {
-				var i = match.index + match[0].length;
-
-				if (match[1])
-					return this.closingBracketBlock(session, match[1], row, i);
-
-				return session.getCommentFoldRange(row, i, -1);
-			}
-		};
-
-		this.getSectionRange = function(session, row) {
-			var line = session.getLine(row);
-			var startIndent = line.search(/\S/);
-			var startRow = row;
-			var startColumn = line.length;
-			row = row + 1;
-			var endRow = row;
-			var maxRow = session.getLength();
-			while (++row < maxRow) {
-				line = session.getLine(row);
-				var indent = line.search(/\S/);
-				if (indent === -1)
-					continue;
-				if (startIndent > indent)
-					break;
-				var subRange = this.getFoldWidgetRange(session, "all", row);
-
-				if (subRange) {
-					if (subRange.start.row <= startRow) {
-						break;
-					} else if (subRange.isMultiLine()) {
-						row = subRange.end.row;
-					} else if (startIndent === indent) {
-						break;
-					}
-				}
-				endRow = row;
-			}
-
-			return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
-		};
-
-		this.getCommentRegionBlock = function(session, line, row) {
-			var startColumn = line.search(/\s*$/);
-			var maxRow = session.getLength();
-			var startRow = row;
-
-			var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
-			var depth = 1;
-			while (++row < maxRow) {
-				line = session.getLine(row);
-				var m = re.exec(line);
-				if (!m) continue;
-				if (m[1]) depth--;
-				else depth++;
-
-				if (!depth) break;
-			}
-
-			var endRow = row;
-			if (endRow > startRow) {
-				return new Range(startRow, startColumn, endRow, line.length);
-			}
-		};
-
-	}).call(FoldMode.prototype);
-});

+ 0 - 4363
src/web/assets/scripts/mp2-parser.js

@@ -1,4363 +0,0 @@
-mp2 = (function() {
-  /*
-   * Generated by PEG.js 0.8.0.
-   *
-   * http://pegjs.majda.cz/
-   */
-
-  function peg$subclass(child, parent) {
-    function ctor() { this.constructor = child; }
-    ctor.prototype = parent.prototype;
-    child.prototype = new ctor();
-  }
-
-  function SyntaxError(message, expected, found, offset, line, column) {
-    this.message  = message;
-    this.expected = expected;
-    this.found    = found;
-    this.offset   = offset;
-    this.line     = line;
-    this.column   = column;
-
-    this.name     = "SyntaxError";
-  }
-
-  peg$subclass(SyntaxError, Error);
-
-  function parse(input) {
-    var options = arguments.length > 1 ? arguments[1] : {},
-
-        peg$FAILED = {},
-
-        peg$startRuleFunctions = { start: peg$parsestart },
-        peg$startRuleFunction  = peg$parsestart,
-
-        peg$c0 = peg$FAILED,
-        peg$c1 = function() { ast.errors = []; },
-        peg$c2 = void 0,
-        peg$c3 = function(m) {
-            m.errors = ast.errors;
-            return m;
-          },
-        peg$c4 = null,
-        peg$c5 = [],
-        peg$c6 = function(includes, statements) { return new ast.Schema(includes, statements); },
-        peg$c7 = { type: "other", description: "INCLUDE statement" },
-        peg$c8 = function(id) { return new ast.Include(id); },
-        peg$c9 = function(s) { return s },
-        peg$c10 = function(r, id) { ast.ruleId = id.id; },
-        peg$c11 = function(r, id, pl) {
-              var rule = new (r ? ast.RootRule : ast.CompositeRule)(id, pl);
-              if (id.id in ast.rulesById) ast.errors.push(err(20, id.id));
-              ast.rulesById[rule.id.id] = rule;
-              return rule;
-            },
-        peg$c12 = function(list) { return new ast.Sequence(list); },
-        peg$c13 = function(id) {
-              if (id.id === ast.ruleId) ast.errors.push(err(5,id));
-              return id;
-            },
-        peg$c14 = function(item) {return item},
-        peg$c15 = function(item, tail) { return new ast.Alternative([item].concat(tail)); },
-        peg$c16 = function(f) { return new ast.Probability(f); },
-        peg$c17 = function(a, b) { return new ast.MinMax(a !== null ? a[0] : b, b); },
-        peg$c18 = function(s, pl) { return new ast.Iterator(s !== null ? s : new ast.MinMax(0, null), pl); },
-        peg$c19 = function(s, pl) { return new ast.Iterator(s !== null ? s : new ast.MinMax(1, null), pl); },
-        peg$c20 = function(pl) { return new ast.Set(pl); },
-        peg$c21 = function(item) { return item; },
-        peg$c22 = function(item, tail) { return [item].concat(tail); },
-        peg$c23 = function(s, pl) { return new ast.SetIterator(s !== null ? s : new ast.MinMax(0, null), pl); },
-        peg$c24 = function(s, pl) { return new ast.SetIterator(s !== null ? s : new ast.MinMax(1, null), pl); },
-        peg$c25 = function(pl) { return new ast.Optional(pl); },
-        peg$c26 = function(share, on) { return new ast.ShareAll(share, on); },
-        peg$c27 = function(id) {
-              if (!(id.id in ast.rulesById)) ast.errors.push(err(21, id.id)); //TODO: move to errors
-              else if (ast.rulesById[id.id].ruleType !== "RootRule") ast.errors.push(err(22, id.id)); //TODO: move to errors
-              return id;
-            },
-        peg$c28 = function(async, srcs, body) { return new ast.Coordinate(Boolean(async), srcs, body); },
-        peg$c29 = function(item) {
-                ast._srcs = {};
-                ast._srcs[item.id] = 1;
-                return [item];
-              },
-        peg$c30 = function(item) {
-                if (item.id in ast._srcs) ast.errors.push(err(19, item.id));
-                ast._srcs[item.id] = 1;
-                return item;
-              },
-        peg$c31 = function(head, tail) { return head.concat(tail); },
-        peg$c32 = function(item) { return item },
-        peg$c33 = function(v, s, f) {
-              var frm = f ? f[1] : null;
-              if (frm && frm[0] === "$" && !(frm in ast._srcs)) ast.errors.push(err(17, frm));
-              return new ast.CoordinateSource(v, s, frm);
-            },
-        peg$c34 = function(rels) { return new ast.AddOperation(rels); },
-        peg$c35 = function(item) {
-                if (!(item.src in ast._srcs)) ast.errors.push(err(17, item.src));
-                if (!(item.dst in ast._srcs)) ast.errors.push(err(17, item.dst));
-                return [item];
-              },
-        peg$c36 = function(item) {
-                if (!(item.src in ast._srcs)) ast.errors.push(err(17, item.src));
-                if (!(item.dst in ast._srcs)) ast.errors.push(err(17, item.dst));
-                return item;
-              },
-        peg$c37 = function(start, relType, second) { return new ast.Relationship(start, relType, second); },
-        peg$c38 = function(alts) { return new ast.Alternative(alts); },
-        peg$c39 = function(item) {return item;},
-        peg$c40 = { type: "other", description: "SCHEMA identifier" },
-        peg$c41 = "WHEN",
-        peg$c42 = { type: "literal", value: "WHEN", description: "\"WHEN\"" },
-        peg$c43 = "COORDINATE",
-        peg$c44 = { type: "literal", value: "COORDINATE", description: "\"COORDINATE\"" },
-        peg$c45 = "ENSURE",
-        peg$c46 = { type: "literal", value: "ENSURE", description: "\"ENSURE\"" },
-        peg$c47 = "DO",
-        peg$c48 = { type: "literal", value: "DO", description: "\"DO\"" },
-        peg$c49 = "OD",
-        peg$c50 = { type: "literal", value: "OD", description: "\"OD\"" },
-        peg$c51 = "FROM",
-        peg$c52 = { type: "literal", value: "FROM", description: "\"FROM\"" },
-        peg$c53 = { type: "other", description: "ROOT identifier" },
-        peg$c54 = function(id) { return new ast.Event(id); },
-        peg$c55 = { type: "other", description: "EVENT identifier" },
-        peg$c56 = { type: "other", description: "VARIABLE" },
-        peg$c57 = "$",
-        peg$c58 = { type: "literal", value: "$", description: "\"$\"" },
-        peg$c59 = function(id) { return "$" + id; },
-        peg$c60 = /^[A-Za-z]/,
-        peg$c61 = { type: "class", value: "[A-Za-z]", description: "[A-Za-z]" },
-        peg$c62 = /^[a-zA-Z0-9_]/,
-        peg$c63 = { type: "class", value: "[a-zA-Z0-9_]", description: "[a-zA-Z0-9_]" },
-        peg$c64 = function(a, b) { return a + b.join(""); },
-        peg$c65 = /^[0-9]/,
-        peg$c66 = { type: "class", value: "[0-9]", description: "[0-9]" },
-        peg$c67 = function(a) { return a.join(""); },
-        peg$c68 = /^[1-9]/,
-        peg$c69 = { type: "class", value: "[1-9]", description: "[1-9]" },
-        peg$c70 = ".",
-        peg$c71 = { type: "literal", value: ".", description: "\".\"" },
-        peg$c72 = function(a, b) { return parseFloat(b ? a.join("") + "." + b[1].join("") : a.join("")); },
-        peg$c73 = function(b) { return parseFloat("." + b.join("")); },
-        peg$c74 = "(*",
-        peg$c75 = { type: "literal", value: "(*", description: "\"(*\"" },
-        peg$c76 = "*)",
-        peg$c77 = { type: "literal", value: "*)", description: "\"*)\"" },
-        peg$c78 = "(+",
-        peg$c79 = { type: "literal", value: "(+", description: "\"(+\"" },
-        peg$c80 = "+)",
-        peg$c81 = { type: "literal", value: "+)", description: "\"+)\"" },
-        peg$c82 = "{*",
-        peg$c83 = { type: "literal", value: "{*", description: "\"{*\"" },
-        peg$c84 = "*}",
-        peg$c85 = { type: "literal", value: "*}", description: "\"*}\"" },
-        peg$c86 = "{+",
-        peg$c87 = { type: "literal", value: "{+", description: "\"{+\"" },
-        peg$c88 = "+}",
-        peg$c89 = { type: "literal", value: "+}", description: "\"+}\"" },
-        peg$c90 = "<!>",
-        peg$c91 = { type: "literal", value: "<!>", description: "\"<!>\"" },
-        peg$c92 = "|+|",
-        peg$c93 = { type: "literal", value: "|+|", description: "\"|+|\"" },
-        peg$c94 = "..",
-        peg$c95 = { type: "literal", value: "..", description: "\"..\"" },
-        peg$c96 = "(",
-        peg$c97 = { type: "literal", value: "(", description: "\"(\"" },
-        peg$c98 = ")",
-        peg$c99 = { type: "literal", value: ")", description: "\")\"" },
-        peg$c100 = "{",
-        peg$c101 = { type: "literal", value: "{", description: "\"{\"" },
-        peg$c102 = "}",
-        peg$c103 = { type: "literal", value: "}", description: "\"}\"" },
-        peg$c104 = "[",
-        peg$c105 = { type: "literal", value: "[", description: "\"[\"" },
-        peg$c106 = "]",
-        peg$c107 = { type: "literal", value: "]", description: "\"]\"" },
-        peg$c108 = "<",
-        peg$c109 = { type: "literal", value: "<", description: "\"<\"" },
-        peg$c110 = ">",
-        peg$c111 = { type: "literal", value: ">", description: "\">\"" },
-        peg$c112 = "<<",
-        peg$c113 = { type: "literal", value: "<<", description: "\"<<\"" },
-        peg$c114 = ">>",
-        peg$c115 = { type: "literal", value: ">>", description: "\">>\"" },
-        peg$c116 = ":",
-        peg$c117 = { type: "literal", value: ":", description: "\":\"" },
-        peg$c118 = ";",
-        peg$c119 = { type: "literal", value: ";", description: "\";\"" },
-        peg$c120 = ",",
-        peg$c121 = { type: "literal", value: ",", description: "\",\"" },
-        peg$c122 = "|",
-        peg$c123 = { type: "literal", value: "|", description: "\"|\"" },
-        peg$c124 = "SCHEMA",
-        peg$c125 = { type: "literal", value: "SCHEMA", description: "\"SCHEMA\"" },
-        peg$c126 = "INCLUDE",
-        peg$c127 = { type: "literal", value: "INCLUDE", description: "\"INCLUDE\"" },
-        peg$c128 = "ROOT",
-        peg$c129 = { type: "literal", value: "ROOT", description: "\"ROOT\"" },
-        peg$c130 = "SHARE",
-        peg$c131 = { type: "literal", value: "SHARE", description: "\"SHARE\"" },
-        peg$c132 = "ALL",
-        peg$c133 = { type: "literal", value: "ALL", description: "\"ALL\"" },
-        peg$c134 = "ADD",
-        peg$c135 = { type: "literal", value: "ADD", description: "\"ADD\"" },
-        peg$c136 = "IN",
-        peg$c137 = { type: "literal", value: "IN", description: "\"IN\"" },
-        peg$c138 = function() { return "IN"; },
-        peg$c139 = "CONTAINS",
-        peg$c140 = { type: "literal", value: "CONTAINS", description: "\"CONTAINS\"" },
-        peg$c141 = function() { return "CONTAINS"; },
-        peg$c142 = "PRECEDES",
-        peg$c143 = { type: "literal", value: "PRECEDES", description: "\"PRECEDES\"" },
-        peg$c144 = function() { return "PRECEDES"; },
-        peg$c145 = "FOLLOWS",
-        peg$c146 = { type: "literal", value: "FOLLOWS", description: "\"FOLLOWS\"" },
-        peg$c147 = function() { return "FOLLOWS"; },
-        peg$c148 = "this",
-        peg$c149 = { type: "literal", value: "this", description: "\"this\"" },
-        peg$c150 = function() { return "this"; },
-        peg$c151 = "BUILD",
-        peg$c152 = { type: "literal", value: "BUILD", description: "\"BUILD\"" },
-        peg$c153 = "NEW",
-        peg$c154 = { type: "literal", value: "NEW", description: "\"NEW\"" },
-        peg$c155 = "MAP",
-        peg$c156 = { type: "literal", value: "MAP", description: "\"MAP\"" },
-        peg$c157 = { type: "any", description: "any character" },
-        peg$c158 = { type: "other", description: "optional whitespace" },
-        peg$c159 = /^[ \t\n\r]/,
-        peg$c160 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" },
-        peg$c161 = function() { return null; },
-        peg$c162 = { type: "other", description: "required whitespace" },
-        peg$c163 = { type: "other", description: "newline" },
-        peg$c164 = /^[\n]/,
-        peg$c165 = { type: "class", value: "[\\n]", description: "[\\n]" },
-        peg$c166 = function(c) { return c },
-        peg$c167 = { type: "other", description: "comment line" },
-        peg$c168 = "//",
-        peg$c169 = { type: "literal", value: "//", description: "\"//\"" },
-        peg$c170 = /^[^\n]/,
-        peg$c171 = { type: "class", value: "[^\\n]", description: "[^\\n]" },
-        peg$c172 = function(c) { return new ast.Comment(false, c.join("")); },
-        peg$c173 = { type: "other", description: "comment block" },
-        peg$c174 = "/*",
-        peg$c175 = { type: "literal", value: "/*", description: "\"/*\"" },
-        peg$c176 = "*/",
-        peg$c177 = { type: "literal", value: "*/", description: "\"*/\"" },
-        peg$c178 = function(c) { return new ast.Comment(true, c.join("")); },
-        peg$c179 = function(c) { return c; },
-
-        peg$currPos          = 0,
-        peg$reportedPos      = 0,
-        peg$cachedPos        = 0,
-        peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },
-        peg$maxFailPos       = 0,
-        peg$maxFailExpected  = [],
-        peg$silentFails      = 0,
-
-        peg$result;
-
-    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];
-    }
-
-    function text() {
-      return input.substring(peg$reportedPos, peg$currPos);
-    }
-
-    function offset() {
-      return peg$reportedPos;
-    }
-
-    function line() {
-      return peg$computePosDetails(peg$reportedPos).line;
-    }
-
-    function column() {
-      return peg$computePosDetails(peg$reportedPos).column;
-    }
-
-    function expected(description) {
-      throw peg$buildException(
-        null,
-        [{ type: "other", description: description }],
-        peg$reportedPos
-      );
-    }
-
-    function error(message) {
-      throw peg$buildException(message, null, peg$reportedPos);
-    }
-
-    function peg$computePosDetails(pos) {
-      function advance(details, startPos, endPos) {
-        var p, ch;
-
-        for (p = startPos; p < endPos; p++) {
-          ch = input.charAt(p);
-          if (ch === "\n") {
-            if (!details.seenCR) { details.line++; }
-            details.column = 1;
-            details.seenCR = false;
-          } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
-            details.line++;
-            details.column = 1;
-            details.seenCR = true;
-          } else {
-            details.column++;
-            details.seenCR = false;
-          }
-        }
-      }
-
-      if (peg$cachedPos !== pos) {
-        if (peg$cachedPos > pos) {
-          peg$cachedPos = 0;
-          peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };
-        }
-        advance(peg$cachedPosDetails, peg$cachedPos, pos);
-        peg$cachedPos = pos;
-      }
-
-      return peg$cachedPosDetails;
-    }
-
-    function peg$fail(expected) {
-      if (peg$currPos < peg$maxFailPos) { return; }
-
-      if (peg$currPos > peg$maxFailPos) {
-        peg$maxFailPos = peg$currPos;
-        peg$maxFailExpected = [];
-      }
-
-      peg$maxFailExpected.push(expected);
-    }
-
-    function peg$buildException(message, expected, pos) {
-      function cleanupExpected(expected) {
-        var i = 1;
-
-        expected.sort(function(a, b) {
-          if (a.description < b.description) {
-            return -1;
-          } else if (a.description > b.description) {
-            return 1;
-          } else {
-            return 0;
-          }
-        });
-
-        while (i < expected.length) {
-          if (expected[i - 1] === expected[i]) {
-            expected.splice(i, 1);
-          } else {
-            i++;
-          }
-        }
-      }
-
-      function buildMessage(expected, found) {
-        function stringEscape(s) {
-          function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
-
-          return s
-            .replace(/\\/g,   '\\\\')
-            .replace(/"/g,    '\\"')
-            .replace(/\x08/g, '\\b')
-            .replace(/\t/g,   '\\t')
-            .replace(/\n/g,   '\\n')
-            .replace(/\f/g,   '\\f')
-            .replace(/\r/g,   '\\r')
-            .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
-            .replace(/[\x10-\x1F\x80-\xFF]/g,    function(ch) { return '\\x'  + hex(ch); })
-            .replace(/[\u0180-\u0FFF]/g,         function(ch) { return '\\u0' + hex(ch); })
-            .replace(/[\u1080-\uFFFF]/g,         function(ch) { return '\\u'  + hex(ch); });
-        }
-
-        var expectedDescs = new Array(expected.length),
-            expectedDesc, foundDesc, i;
-
-        for (i = 0; i < expected.length; i++) {
-          expectedDescs[i] = expected[i].description;
-        }
-
-        expectedDesc = expected.length > 1
-          ? expectedDescs.slice(0, -1).join(", ")
-              + " or "
-              + expectedDescs[expected.length - 1]
-          : expectedDescs[0];
-
-        foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
-
-        return "Expected " + expectedDesc + " but " + foundDesc + " found.";
-      }
-
-      var posDetails = peg$computePosDetails(pos),
-          found      = pos < input.length ? input.charAt(pos) : null;
-
-      if (expected !== null) {
-        cleanupExpected(expected);
-      }
-
-      return new SyntaxError(
-        message !== null ? message : buildMessage(expected, found),
-        expected,
-        found,
-        pos,
-        posDetails.line,
-        posDetails.column
-      );
-    }
-
-    function peg$parsestart() {
-      var s0, s1, s2;
-
-      s0 = peg$currPos;
-      peg$reportedPos = peg$currPos;
-      s1 = peg$c1();
-      if (s1) {
-        s1 = peg$c0;
-      } else {
-        s1 = peg$c2;
-      }
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parseschema();
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c3(s2);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseschema() {
-      var s0, s1, s2, s3, s4;
-
-      s0 = peg$currPos;
-      s1 = peg$currPos;
-      s2 = peg$parseSCHEMA();
-      if (s2 !== peg$FAILED) {
-        s3 = peg$parseschema_id();
-        if (s3 !== peg$FAILED) {
-          s4 = peg$parsesemi();
-          if (s4 === peg$FAILED) {
-            s4 = peg$c4;
-          }
-          if (s4 !== peg$FAILED) {
-            s2 = [s2, s3, s4];
-            s1 = s2;
-          } else {
-            peg$currPos = s1;
-            s1 = peg$c0;
-          }
-        } else {
-          peg$currPos = s1;
-          s1 = peg$c0;
-        }
-      } else {
-        peg$currPos = s1;
-        s1 = peg$c0;
-      }
-      if (s1 === peg$FAILED) {
-        s1 = peg$c4;
-      }
-      if (s1 !== peg$FAILED) {
-        s2 = [];
-        s3 = peg$parseschema_include();
-        while (s3 !== peg$FAILED) {
-          s2.push(s3);
-          s3 = peg$parseschema_include();
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = [];
-          s4 = peg$parseschema_statement();
-          while (s4 !== peg$FAILED) {
-            s3.push(s4);
-            s4 = peg$parseschema_statement();
-          }
-          if (s3 !== peg$FAILED) {
-            s4 = peg$parseEOF();
-            if (s4 !== peg$FAILED) {
-              peg$reportedPos = s0;
-              s1 = peg$c6(s2, s3);
-              s0 = s1;
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseschema_include() {
-      var s0, s1, s2, s3;
-
-      peg$silentFails++;
-      s0 = peg$currPos;
-      s1 = peg$parseINCLUDE();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parseschema_id();
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parsesemi();
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c8(s2);
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-      peg$silentFails--;
-      if (s0 === peg$FAILED) {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c7); }
-      }
-
-      return s0;
-    }
-
-    function peg$parseschema_statement() {
-      var s0, s1, s2;
-
-      s0 = peg$currPos;
-      s1 = peg$parserule();
-      if (s1 === peg$FAILED) {
-        s1 = peg$parsecomposition_operation();
-      }
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parsesemi();
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c9(s1);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parserule() {
-      var s0, s1, s2, s3, s4, s5;
-
-      s0 = peg$currPos;
-      s1 = peg$parseROOT();
-      if (s1 === peg$FAILED) {
-        s1 = peg$c4;
-      }
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parseroot_id();
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = peg$currPos;
-          s3 = peg$c10(s1, s2);
-          if (s3) {
-            s3 = peg$c0;
-          } else {
-            s3 = peg$c2;
-          }
-          if (s3 !== peg$FAILED) {
-            s4 = peg$parsecolon();
-            if (s4 !== peg$FAILED) {
-              s5 = peg$parsepattern_list();
-              if (s5 === peg$FAILED) {
-                s5 = peg$c4;
-              }
-              if (s5 !== peg$FAILED) {
-                peg$reportedPos = s0;
-                s1 = peg$c11(s1, s2, s5);
-                s0 = s1;
-              } else {
-                peg$currPos = s0;
-                s0 = peg$c0;
-              }
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsepattern_list() {
-      var s0, s1, s2;
-
-      s0 = peg$currPos;
-      s1 = [];
-      s2 = peg$parsepattern_unit();
-      if (s2 !== peg$FAILED) {
-        while (s2 !== peg$FAILED) {
-          s1.push(s2);
-          s2 = peg$parsepattern_unit();
-        }
-      } else {
-        s1 = peg$c0;
-      }
-      if (s1 !== peg$FAILED) {
-        peg$reportedPos = s0;
-        s1 = peg$c12(s1);
-      }
-      s0 = s1;
-
-      return s0;
-    }
-
-    function peg$parsepattern_unit() {
-      var s0, s1;
-
-      s0 = peg$currPos;
-      s1 = peg$parseevent_id();
-      if (s1 !== peg$FAILED) {
-        peg$reportedPos = s0;
-        s1 = peg$c13(s1);
-      }
-      s0 = s1;
-      if (s0 === peg$FAILED) {
-        s0 = peg$parsealternative();
-        if (s0 === peg$FAILED) {
-          s0 = peg$parseiterator();
-          if (s0 === peg$FAILED) {
-            s0 = peg$parseiterator_plus();
-            if (s0 === peg$FAILED) {
-              s0 = peg$parseset();
-              if (s0 === peg$FAILED) {
-                s0 = peg$parseset_iterator();
-                if (s0 === peg$FAILED) {
-                  s0 = peg$parseset_iterator_plus();
-                  if (s0 === peg$FAILED) {
-                    s0 = peg$parseoptional();
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-
-      return s0;
-    }
-
-    function peg$parsealternative() {
-      var s0, s1, s2, s3, s4, s5, s6;
-
-      s0 = peg$currPos;
-      s1 = peg$parseparenL();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parsepattern_list();
-        if (s2 !== peg$FAILED) {
-          s3 = [];
-          s4 = peg$currPos;
-          s5 = peg$parsepipe();
-          if (s5 !== peg$FAILED) {
-            s6 = peg$parsepattern_list();
-            if (s6 !== peg$FAILED) {
-              peg$reportedPos = s4;
-              s5 = peg$c14(s6);
-              s4 = s5;
-            } else {
-              peg$currPos = s4;
-              s4 = peg$c0;
-            }
-          } else {
-            peg$currPos = s4;
-            s4 = peg$c0;
-          }
-          while (s4 !== peg$FAILED) {
-            s3.push(s4);
-            s4 = peg$currPos;
-            s5 = peg$parsepipe();
-            if (s5 !== peg$FAILED) {
-              s6 = peg$parsepattern_list();
-              if (s6 !== peg$FAILED) {
-                peg$reportedPos = s4;
-                s5 = peg$c14(s6);
-                s4 = s5;
-              } else {
-                peg$currPos = s4;
-                s4 = peg$c0;
-              }
-            } else {
-              peg$currPos = s4;
-              s4 = peg$c0;
-            }
-          }
-          if (s3 !== peg$FAILED) {
-            s4 = peg$parseparenR();
-            if (s4 !== peg$FAILED) {
-              peg$reportedPos = s0;
-              s1 = peg$c15(s2, s3);
-              s0 = s1;
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseprobability() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parseltlt();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parsefloat();
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parsegtgt();
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c16(s2);
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseiterator_scope_any() {
-      var s0, s1, s2, s3, s4;
-
-      s0 = peg$currPos;
-      s1 = peg$parselt();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$currPos;
-        s3 = peg$parseinteger();
-        if (s3 !== peg$FAILED) {
-          s4 = peg$parseto();
-          if (s4 !== peg$FAILED) {
-            s3 = [s3, s4];
-            s2 = s3;
-          } else {
-            peg$currPos = s2;
-            s2 = peg$c0;
-          }
-        } else {
-          peg$currPos = s2;
-          s2 = peg$c0;
-        }
-        if (s2 === peg$FAILED) {
-          s2 = peg$c4;
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parseinteger();
-          if (s3 !== peg$FAILED) {
-            s4 = peg$parsegt();
-            if (s4 !== peg$FAILED) {
-              peg$reportedPos = s0;
-              s1 = peg$c17(s2, s3);
-              s0 = s1;
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseiterator_scope_some() {
-      var s0, s1, s2, s3, s4;
-
-      s0 = peg$currPos;
-      s1 = peg$parselt();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$currPos;
-        s3 = peg$parseinteger_gt0();
-        if (s3 !== peg$FAILED) {
-          s4 = peg$parseto();
-          if (s4 !== peg$FAILED) {
-            s3 = [s3, s4];
-            s2 = s3;
-          } else {
-            peg$currPos = s2;
-            s2 = peg$c0;
-          }
-        } else {
-          peg$currPos = s2;
-          s2 = peg$c0;
-        }
-        if (s2 === peg$FAILED) {
-          s2 = peg$c4;
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parseinteger_gt0();
-          if (s3 !== peg$FAILED) {
-            s4 = peg$parsegt();
-            if (s4 !== peg$FAILED) {
-              peg$reportedPos = s0;
-              s1 = peg$c17(s2, s3);
-              s0 = s1;
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseiterator() {
-      var s0, s1, s2, s3, s4;
-
-      s0 = peg$currPos;
-      s1 = peg$parsebegin_iter();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parseiterator_scope_any();
-        if (s2 === peg$FAILED) {
-          s2 = peg$c4;
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parsepattern_list();
-          if (s3 !== peg$FAILED) {
-            s4 = peg$parseend_iter();
-            if (s4 !== peg$FAILED) {
-              peg$reportedPos = s0;
-              s1 = peg$c18(s2, s3);
-              s0 = s1;
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseiterator_plus() {
-      var s0, s1, s2, s3, s4;
-
-      s0 = peg$currPos;
-      s1 = peg$parsebegin_itpl();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parseiterator_scope_some();
-        if (s2 === peg$FAILED) {
-          s2 = peg$c4;
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parsepattern_list();
-          if (s3 !== peg$FAILED) {
-            s4 = peg$parseend_itpl();
-            if (s4 !== peg$FAILED) {
-              peg$reportedPos = s0;
-              s1 = peg$c19(s2, s3);
-              s0 = s1;
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseset() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parsebraceL();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parsepattern_lists_by_comma();
-        if (s2 === peg$FAILED) {
-          s2 = peg$c4;
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parsebraceR();
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c20(s2);
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsepattern_lists_by_comma() {
-      var s0, s1, s2, s3, s4, s5;
-
-      s0 = peg$currPos;
-      s1 = peg$parsepattern_list();
-      if (s1 !== peg$FAILED) {
-        s2 = [];
-        s3 = peg$currPos;
-        s4 = peg$parsecomma();
-        if (s4 !== peg$FAILED) {
-          s5 = peg$parsepattern_list();
-          if (s5 !== peg$FAILED) {
-            peg$reportedPos = s3;
-            s4 = peg$c21(s5);
-            s3 = s4;
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        } else {
-          peg$currPos = s3;
-          s3 = peg$c0;
-        }
-        while (s3 !== peg$FAILED) {
-          s2.push(s3);
-          s3 = peg$currPos;
-          s4 = peg$parsecomma();
-          if (s4 !== peg$FAILED) {
-            s5 = peg$parsepattern_list();
-            if (s5 !== peg$FAILED) {
-              peg$reportedPos = s3;
-              s4 = peg$c21(s5);
-              s3 = s4;
-            } else {
-              peg$currPos = s3;
-              s3 = peg$c0;
-            }
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        }
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c22(s1, s2);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseset_iterator() {
-      var s0, s1, s2, s3, s4;
-
-      s0 = peg$currPos;
-      s1 = peg$parsebegin_seti();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parseiterator_scope_any();
-        if (s2 === peg$FAILED) {
-          s2 = peg$c4;
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parsepattern_list();
-          if (s3 !== peg$FAILED) {
-            s4 = peg$parseend_seti();
-            if (s4 !== peg$FAILED) {
-              peg$reportedPos = s0;
-              s1 = peg$c23(s2, s3);
-              s0 = s1;
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseset_iterator_plus() {
-      var s0, s1, s2, s3, s4;
-
-      s0 = peg$currPos;
-      s1 = peg$parsebegin_setp();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parseiterator_scope_some();
-        if (s2 === peg$FAILED) {
-          s2 = peg$c4;
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parsepattern_list();
-          if (s3 !== peg$FAILED) {
-            s4 = peg$parseend_setp();
-            if (s4 !== peg$FAILED) {
-              peg$reportedPos = s0;
-              s1 = peg$c24(s2, s3);
-              s0 = s1;
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseoptional() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parsebracketL();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parsepattern_list();
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parsebracketR();
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c25(s2);
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsecomposition_operation() {
-      var s0;
-
-      s0 = peg$parseshared_composition();
-      if (s0 === peg$FAILED) {
-        s0 = peg$parsecoordinate_composition();
-      }
-
-      return s0;
-    }
-
-    function peg$parseshared_composition() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parseroot_or_var_by_exunionstr_by_comma();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parseSHARE_ALL();
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parseevent_id_by_comma();
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c26(s1, s3);
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseroot_or_var() {
-      var s0, s1;
-
-      s0 = peg$currPos;
-      s1 = peg$parseroot_id();
-      if (s1 !== peg$FAILED) {
-        peg$reportedPos = s0;
-        s1 = peg$c27(s1);
-      }
-      s0 = s1;
-      if (s0 === peg$FAILED) {
-        s0 = peg$parsevariable();
-      }
-
-      return s0;
-    }
-
-    function peg$parseroot_or_var_by_exunionstr() {
-      var s0, s1, s2, s3, s4, s5;
-
-      s0 = peg$currPos;
-      s1 = peg$parseroot_or_var();
-      if (s1 !== peg$FAILED) {
-        s2 = [];
-        s3 = peg$currPos;
-        s4 = peg$parseexunionstr();
-        if (s4 !== peg$FAILED) {
-          s5 = peg$parseroot_or_var();
-          if (s5 !== peg$FAILED) {
-            peg$reportedPos = s3;
-            s4 = peg$c21(s5);
-            s3 = s4;
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        } else {
-          peg$currPos = s3;
-          s3 = peg$c0;
-        }
-        while (s3 !== peg$FAILED) {
-          s2.push(s3);
-          s3 = peg$currPos;
-          s4 = peg$parseexunionstr();
-          if (s4 !== peg$FAILED) {
-            s5 = peg$parseroot_or_var();
-            if (s5 !== peg$FAILED) {
-              peg$reportedPos = s3;
-              s4 = peg$c21(s5);
-              s3 = s4;
-            } else {
-              peg$currPos = s3;
-              s3 = peg$c0;
-            }
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        }
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c22(s1, s2);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseroot_or_var_by_exunionstr_by_comma() {
-      var s0, s1, s2, s3, s4, s5;
-
-      s0 = peg$currPos;
-      s1 = peg$parseroot_or_var_by_exunionstr();
-      if (s1 !== peg$FAILED) {
-        s2 = [];
-        s3 = peg$currPos;
-        s4 = peg$parsecomma();
-        if (s4 !== peg$FAILED) {
-          s5 = peg$parseroot_or_var_by_exunionstr();
-          if (s5 !== peg$FAILED) {
-            peg$reportedPos = s3;
-            s4 = peg$c21(s5);
-            s3 = s4;
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        } else {
-          peg$currPos = s3;
-          s3 = peg$c0;
-        }
-        while (s3 !== peg$FAILED) {
-          s2.push(s3);
-          s3 = peg$currPos;
-          s4 = peg$parsecomma();
-          if (s4 !== peg$FAILED) {
-            s5 = peg$parseroot_or_var_by_exunionstr();
-            if (s5 !== peg$FAILED) {
-              peg$reportedPos = s3;
-              s4 = peg$c21(s5);
-              s3 = s4;
-            } else {
-              peg$currPos = s3;
-              s3 = peg$c0;
-            }
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        }
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c22(s1, s2);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseevent_id_by_comma() {
-      var s0, s1, s2, s3, s4, s5;
-
-      s0 = peg$currPos;
-      s1 = peg$parseevent_id();
-      if (s1 !== peg$FAILED) {
-        s2 = [];
-        s3 = peg$currPos;
-        s4 = peg$parsecomma();
-        if (s4 !== peg$FAILED) {
-          s5 = peg$parseevent_id();
-          if (s5 !== peg$FAILED) {
-            s4 = [s4, s5];
-            s3 = s4;
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        } else {
-          peg$currPos = s3;
-          s3 = peg$c0;
-        }
-        while (s3 !== peg$FAILED) {
-          s2.push(s3);
-          s3 = peg$currPos;
-          s4 = peg$parsecomma();
-          if (s4 !== peg$FAILED) {
-            s5 = peg$parseevent_id();
-            if (s5 !== peg$FAILED) {
-              s4 = [s4, s5];
-              s3 = s4;
-            } else {
-              peg$currPos = s3;
-              s3 = peg$c0;
-            }
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        }
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c22(s1, s2);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsecoordinate_composition() {
-      var s0, s1, s2, s3, s4, s5, s6;
-
-      s0 = peg$currPos;
-      s1 = peg$parseCOORDINATE();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parseasyncstr();
-        if (s2 === peg$FAILED) {
-          s2 = peg$c4;
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parsecoordination_source_by_comma();
-          if (s3 !== peg$FAILED) {
-            s4 = peg$parseDO();
-            if (s4 !== peg$FAILED) {
-              s5 = [];
-              s6 = peg$parsedo_body_statement();
-              if (s6 !== peg$FAILED) {
-                while (s6 !== peg$FAILED) {
-                  s5.push(s6);
-                  s6 = peg$parsedo_body_statement();
-                }
-              } else {
-                s5 = peg$c0;
-              }
-              if (s5 !== peg$FAILED) {
-                s6 = peg$parseOD();
-                if (s6 !== peg$FAILED) {
-                  peg$reportedPos = s0;
-                  s1 = peg$c28(s2, s3, s5);
-                  s0 = s1;
-                } else {
-                  peg$currPos = s0;
-                  s0 = peg$c0;
-                }
-              } else {
-                peg$currPos = s0;
-                s0 = peg$c0;
-              }
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsecoordination_source_by_comma() {
-      var s0, s1, s2, s3, s4, s5;
-
-      s0 = peg$currPos;
-      s1 = peg$currPos;
-      s2 = peg$parsecoordination_source();
-      if (s2 !== peg$FAILED) {
-        peg$reportedPos = s1;
-        s2 = peg$c29(s2);
-      }
-      s1 = s2;
-      if (s1 !== peg$FAILED) {
-        s2 = [];
-        s3 = peg$currPos;
-        s4 = peg$parsecomma();
-        if (s4 !== peg$FAILED) {
-          s5 = peg$parsecoordination_source();
-          if (s5 !== peg$FAILED) {
-            peg$reportedPos = s3;
-            s4 = peg$c30(s5);
-            s3 = s4;
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        } else {
-          peg$currPos = s3;
-          s3 = peg$c0;
-        }
-        while (s3 !== peg$FAILED) {
-          s2.push(s3);
-          s3 = peg$currPos;
-          s4 = peg$parsecomma();
-          if (s4 !== peg$FAILED) {
-            s5 = peg$parsecoordination_source();
-            if (s5 !== peg$FAILED) {
-              peg$reportedPos = s3;
-              s4 = peg$c30(s5);
-              s3 = s4;
-            } else {
-              peg$currPos = s3;
-              s3 = peg$c0;
-            }
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        }
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c31(s1, s2);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsedo_body_statement() {
-      var s0, s1, s2;
-
-      s0 = peg$currPos;
-      s1 = peg$parseadd_relation();
-      if (s1 === peg$FAILED) {
-        s1 = peg$parseshared_composition();
-        if (s1 === peg$FAILED) {
-          s1 = peg$parsecoordinate_composition();
-        }
-      }
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parsesemi();
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c32(s1);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsecoordination_source() {
-      var s0, s1, s2, s3, s4, s5, s6;
-
-      s0 = peg$currPos;
-      s1 = peg$parsevariable();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parsecolon();
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parseselection_pattern();
-          if (s3 !== peg$FAILED) {
-            s4 = peg$currPos;
-            s5 = peg$parseFROM();
-            if (s5 !== peg$FAILED) {
-              s6 = peg$parseTHIS();
-              if (s6 === peg$FAILED) {
-                s6 = peg$parseroot_or_var();
-              }
-              if (s6 !== peg$FAILED) {
-                s5 = [s5, s6];
-                s4 = s5;
-              } else {
-                peg$currPos = s4;
-                s4 = peg$c0;
-              }
-            } else {
-              peg$currPos = s4;
-              s4 = peg$c0;
-            }
-            if (s4 === peg$FAILED) {
-              s4 = peg$c4;
-            }
-            if (s4 !== peg$FAILED) {
-              peg$reportedPos = s0;
-              s1 = peg$c33(s1, s3, s4);
-              s0 = s1;
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseadd_relation() {
-      var s0, s1, s2;
-
-      s0 = peg$currPos;
-      s1 = peg$parseADD();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parserelationships_by_comma();
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c34(s2);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parserelationships_by_comma() {
-      var s0, s1, s2, s3, s4, s5;
-
-      s0 = peg$currPos;
-      s1 = peg$currPos;
-      s2 = peg$parserelationship();
-      if (s2 !== peg$FAILED) {
-        peg$reportedPos = s1;
-        s2 = peg$c35(s2);
-      }
-      s1 = s2;
-      if (s1 !== peg$FAILED) {
-        s2 = [];
-        s3 = peg$currPos;
-        s4 = peg$parsecomma();
-        if (s4 !== peg$FAILED) {
-          s5 = peg$parserelationship();
-          if (s5 !== peg$FAILED) {
-            peg$reportedPos = s3;
-            s4 = peg$c36(s5);
-            s3 = s4;
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        } else {
-          peg$currPos = s3;
-          s3 = peg$c0;
-        }
-        while (s3 !== peg$FAILED) {
-          s2.push(s3);
-          s3 = peg$currPos;
-          s4 = peg$parsecomma();
-          if (s4 !== peg$FAILED) {
-            s5 = peg$parserelationship();
-            if (s5 !== peg$FAILED) {
-              peg$reportedPos = s3;
-              s4 = peg$c36(s5);
-              s3 = s4;
-            } else {
-              peg$currPos = s3;
-              s3 = peg$c0;
-            }
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        }
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c31(s1, s2);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parserelationship() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parsevariable();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parseIN();
-        if (s2 === peg$FAILED) {
-          s2 = peg$parsePRECEDES();
-          if (s2 === peg$FAILED) {
-            s2 = peg$parseCONTAINS();
-            if (s2 === peg$FAILED) {
-              s2 = peg$parseFOLLOWS();
-            }
-          }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parsevariable();
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c37(s1, s2, s3);
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseselection_pattern() {
-      var s0;
-
-      s0 = peg$parseevent_id();
-      if (s0 === peg$FAILED) {
-        s0 = peg$parsealternative_of_event_names();
-      }
-
-      return s0;
-    }
-
-    function peg$parsealternative_of_event_names() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parseparenL();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parseevent_id_by_pipe();
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parseparenR();
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c38(s2);
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseevent_id_by_pipe() {
-      var s0, s1, s2, s3, s4, s5;
-
-      s0 = peg$currPos;
-      s1 = peg$parseevent_id();
-      if (s1 !== peg$FAILED) {
-        s2 = [];
-        s3 = peg$currPos;
-        s4 = peg$parsepipe();
-        if (s4 !== peg$FAILED) {
-          s5 = peg$parseevent_id();
-          if (s5 !== peg$FAILED) {
-            peg$reportedPos = s3;
-            s4 = peg$c39(s5);
-            s3 = s4;
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        } else {
-          peg$currPos = s3;
-          s3 = peg$c0;
-        }
-        while (s3 !== peg$FAILED) {
-          s2.push(s3);
-          s3 = peg$currPos;
-          s4 = peg$parsepipe();
-          if (s4 !== peg$FAILED) {
-            s5 = peg$parseevent_id();
-            if (s5 !== peg$FAILED) {
-              peg$reportedPos = s3;
-              s4 = peg$c39(s5);
-              s3 = s4;
-            } else {
-              peg$currPos = s3;
-              s3 = peg$c0;
-            }
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-        }
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c22(s1, s2);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseschema_id() {
-      var s0, s1;
-
-      peg$silentFails++;
-      s0 = peg$parseid();
-      peg$silentFails--;
-      if (s0 === peg$FAILED) {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c40); }
-      }
-
-      return s0;
-    }
-
-    function peg$parsekeyword() {
-      var s0;
-
-      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); }
-      }
-      if (s0 === peg$FAILED) {
-        if (input.substr(peg$currPos, 10) === peg$c43) {
-          s0 = peg$c43;
-          peg$currPos += 10;
-        } else {
-          s0 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c44); }
-        }
-        if (s0 === peg$FAILED) {
-          if (input.substr(peg$currPos, 6) === peg$c45) {
-            s0 = peg$c45;
-            peg$currPos += 6;
-          } else {
-            s0 = peg$FAILED;
-            if (peg$silentFails === 0) { peg$fail(peg$c46); }
-          }
-          if (s0 === peg$FAILED) {
-            if (input.substr(peg$currPos, 2) === peg$c47) {
-              s0 = peg$c47;
-              peg$currPos += 2;
-            } else {
-              s0 = peg$FAILED;
-              if (peg$silentFails === 0) { peg$fail(peg$c48); }
-            }
-            if (s0 === peg$FAILED) {
-              if (input.substr(peg$currPos, 2) === peg$c49) {
-                s0 = peg$c49;
-                peg$currPos += 2;
-              } else {
-                s0 = peg$FAILED;
-                if (peg$silentFails === 0) { peg$fail(peg$c50); }
-              }
-              if (s0 === peg$FAILED) {
-                if (input.substr(peg$currPos, 4) === peg$c51) {
-                  s0 = peg$c51;
-                  peg$currPos += 4;
-                } else {
-                  s0 = peg$FAILED;
-                  if (peg$silentFails === 0) { peg$fail(peg$c52); }
-                }
-              }
-            }
-          }
-        }
-      }
-
-      return s0;
-    }
-
-    function peg$parseroot_id() {
-      var s0, s1, s2;
-
-      peg$silentFails++;
-      s0 = peg$currPos;
-      s1 = peg$currPos;
-      peg$silentFails++;
-      s2 = peg$parsekeyword();
-      peg$silentFails--;
-      if (s2 === peg$FAILED) {
-        s1 = peg$c2;
-      } else {
-        peg$currPos = s1;
-        s1 = peg$c0;
-      }
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parseid();
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c54(s2);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-      peg$silentFails--;
-      if (s0 === peg$FAILED) {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c53); }
-      }
-
-      return s0;
-    }
-
-    function peg$parseevent_id() {
-      var s0, s1, s2;
-
-      peg$silentFails++;
-      s0 = peg$currPos;
-      s1 = peg$currPos;
-      peg$silentFails++;
-      s2 = peg$parsekeyword();
-      peg$silentFails--;
-      if (s2 === peg$FAILED) {
-        s1 = peg$c2;
-      } else {
-        peg$currPos = s1;
-        s1 = peg$c0;
-      }
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parseid();
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c54(s2);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-      peg$silentFails--;
-      if (s0 === peg$FAILED) {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c55); }
-      }
-
-      return s0;
-    }
-
-    function peg$parsevariable() {
-      var s0, s1, s2, s3, s4;
-
-      peg$silentFails++;
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.charCodeAt(peg$currPos) === 36) {
-          s2 = peg$c57;
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c58); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parseid();
-          if (s3 !== peg$FAILED) {
-            s4 = peg$parse_();
-            if (s4 !== peg$FAILED) {
-              peg$reportedPos = s0;
-              s1 = peg$c59(s3);
-              s0 = s1;
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-      peg$silentFails--;
-      if (s0 === peg$FAILED) {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c56); }
-      }
-
-      return s0;
-    }
-
-    function peg$parseid() {
-      var s0, s1, s2, s3, s4;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (peg$c60.test(input.charAt(peg$currPos))) {
-          s2 = input.charAt(peg$currPos);
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c61); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = [];
-          if (peg$c62.test(input.charAt(peg$currPos))) {
-            s4 = input.charAt(peg$currPos);
-            peg$currPos++;
-          } else {
-            s4 = peg$FAILED;
-            if (peg$silentFails === 0) { peg$fail(peg$c63); }
-          }
-          while (s4 !== peg$FAILED) {
-            s3.push(s4);
-            if (peg$c62.test(input.charAt(peg$currPos))) {
-              s4 = input.charAt(peg$currPos);
-              peg$currPos++;
-            } else {
-              s4 = peg$FAILED;
-              if (peg$silentFails === 0) { peg$fail(peg$c63); }
-            }
-          }
-          if (s3 !== peg$FAILED) {
-            s4 = peg$parse_();
-            if (s4 !== peg$FAILED) {
-              peg$reportedPos = s0;
-              s1 = peg$c64(s2, s3);
-              s0 = s1;
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseinteger() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        s2 = [];
-        if (peg$c65.test(input.charAt(peg$currPos))) {
-          s3 = input.charAt(peg$currPos);
-          peg$currPos++;
-        } else {
-          s3 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c66); }
-        }
-        if (s3 !== peg$FAILED) {
-          while (s3 !== peg$FAILED) {
-            s2.push(s3);
-            if (peg$c65.test(input.charAt(peg$currPos))) {
-              s3 = input.charAt(peg$currPos);
-              peg$currPos++;
-            } else {
-              s3 = peg$FAILED;
-              if (peg$silentFails === 0) { peg$fail(peg$c66); }
-            }
-          }
-        } else {
-          s2 = peg$c0;
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c67(s2);
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseinteger_gt0() {
-      var s0, s1, s2, s3, s4;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (peg$c68.test(input.charAt(peg$currPos))) {
-          s2 = input.charAt(peg$currPos);
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c69); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = [];
-          if (peg$c65.test(input.charAt(peg$currPos))) {
-            s4 = input.charAt(peg$currPos);
-            peg$currPos++;
-          } else {
-            s4 = peg$FAILED;
-            if (peg$silentFails === 0) { peg$fail(peg$c66); }
-          }
-          while (s4 !== peg$FAILED) {
-            s3.push(s4);
-            if (peg$c65.test(input.charAt(peg$currPos))) {
-              s4 = input.charAt(peg$currPos);
-              peg$currPos++;
-            } else {
-              s4 = peg$FAILED;
-              if (peg$silentFails === 0) { peg$fail(peg$c66); }
-            }
-          }
-          if (s3 !== peg$FAILED) {
-            s4 = peg$parse_();
-            if (s4 !== peg$FAILED) {
-              peg$reportedPos = s0;
-              s1 = peg$c64(s2, s3);
-              s0 = s1;
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsefloat() {
-      var s0, s1, s2, s3, s4, s5, s6;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        s2 = [];
-        if (peg$c65.test(input.charAt(peg$currPos))) {
-          s3 = input.charAt(peg$currPos);
-          peg$currPos++;
-        } else {
-          s3 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c66); }
-        }
-        if (s3 !== peg$FAILED) {
-          while (s3 !== peg$FAILED) {
-            s2.push(s3);
-            if (peg$c65.test(input.charAt(peg$currPos))) {
-              s3 = input.charAt(peg$currPos);
-              peg$currPos++;
-            } else {
-              s3 = peg$FAILED;
-              if (peg$silentFails === 0) { peg$fail(peg$c66); }
-            }
-          }
-        } else {
-          s2 = peg$c0;
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$currPos;
-          if (input.charCodeAt(peg$currPos) === 46) {
-            s4 = peg$c70;
-            peg$currPos++;
-          } else {
-            s4 = peg$FAILED;
-            if (peg$silentFails === 0) { peg$fail(peg$c71); }
-          }
-          if (s4 !== peg$FAILED) {
-            s5 = [];
-            if (peg$c65.test(input.charAt(peg$currPos))) {
-              s6 = input.charAt(peg$currPos);
-              peg$currPos++;
-            } else {
-              s6 = peg$FAILED;
-              if (peg$silentFails === 0) { peg$fail(peg$c66); }
-            }
-            if (s6 !== peg$FAILED) {
-              while (s6 !== peg$FAILED) {
-                s5.push(s6);
-                if (peg$c65.test(input.charAt(peg$currPos))) {
-                  s6 = input.charAt(peg$currPos);
-                  peg$currPos++;
-                } else {
-                  s6 = peg$FAILED;
-                  if (peg$silentFails === 0) { peg$fail(peg$c66); }
-                }
-              }
-            } else {
-              s5 = peg$c0;
-            }
-            if (s5 !== peg$FAILED) {
-              s4 = [s4, s5];
-              s3 = s4;
-            } else {
-              peg$currPos = s3;
-              s3 = peg$c0;
-            }
-          } else {
-            peg$currPos = s3;
-            s3 = peg$c0;
-          }
-          if (s3 === peg$FAILED) {
-            s3 = peg$c4;
-          }
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c72(s2, s3);
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-      if (s0 === peg$FAILED) {
-        s0 = peg$currPos;
-        s1 = peg$parse_();
-        if (s1 !== peg$FAILED) {
-          if (input.charCodeAt(peg$currPos) === 46) {
-            s2 = peg$c70;
-            peg$currPos++;
-          } else {
-            s2 = peg$FAILED;
-            if (peg$silentFails === 0) { peg$fail(peg$c71); }
-          }
-          if (s2 !== peg$FAILED) {
-            s3 = [];
-            if (peg$c65.test(input.charAt(peg$currPos))) {
-              s4 = input.charAt(peg$currPos);
-              peg$currPos++;
-            } else {
-              s4 = peg$FAILED;
-              if (peg$silentFails === 0) { peg$fail(peg$c66); }
-            }
-            if (s4 !== peg$FAILED) {
-              while (s4 !== peg$FAILED) {
-                s3.push(s4);
-                if (peg$c65.test(input.charAt(peg$currPos))) {
-                  s4 = input.charAt(peg$currPos);
-                  peg$currPos++;
-                } else {
-                  s4 = peg$FAILED;
-                  if (peg$silentFails === 0) { peg$fail(peg$c66); }
-                }
-              }
-            } else {
-              s3 = peg$c0;
-            }
-            if (s3 !== peg$FAILED) {
-              peg$reportedPos = s0;
-              s1 = peg$c73(s3);
-              s0 = s1;
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      }
-
-      return s0;
-    }
-
-    function peg$parsebegin_iter() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c74) {
-          s2 = peg$c74;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c75); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseend_iter() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c76) {
-          s2 = peg$c76;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c77); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsebegin_itpl() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c78) {
-          s2 = peg$c78;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c79); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseend_itpl() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c80) {
-          s2 = peg$c80;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c81); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsebegin_seti() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c82) {
-          s2 = peg$c82;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c83); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseend_seti() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c84) {
-          s2 = peg$c84;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c85); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsebegin_setp() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c86) {
-          s2 = peg$c86;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c87); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseend_setp() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c88) {
-          s2 = peg$c88;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c89); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseasyncstr() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 3) === peg$c90) {
-          s2 = peg$c90;
-          peg$currPos += 3;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c91); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseexunionstr() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 3) === peg$c92) {
-          s2 = peg$c92;
-          peg$currPos += 3;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c93); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseto() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c94) {
-          s2 = peg$c94;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c95); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseparenL() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.charCodeAt(peg$currPos) === 40) {
-          s2 = peg$c96;
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c97); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseparenR() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.charCodeAt(peg$currPos) === 41) {
-          s2 = peg$c98;
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c99); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsebraceL() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.charCodeAt(peg$currPos) === 123) {
-          s2 = peg$c100;
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c101); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsebraceR() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.charCodeAt(peg$currPos) === 125) {
-          s2 = peg$c102;
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c103); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsebracketL() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.charCodeAt(peg$currPos) === 91) {
-          s2 = peg$c104;
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c105); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsebracketR() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.charCodeAt(peg$currPos) === 93) {
-          s2 = peg$c106;
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c107); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parselt() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.charCodeAt(peg$currPos) === 60) {
-          s2 = peg$c108;
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c109); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsegt() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.charCodeAt(peg$currPos) === 62) {
-          s2 = peg$c110;
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c111); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseltlt() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c112) {
-          s2 = peg$c112;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c113); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsegtgt() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c114) {
-          s2 = peg$c114;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c115); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsecolon() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.charCodeAt(peg$currPos) === 58) {
-          s2 = peg$c116;
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c117); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsesemi() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.charCodeAt(peg$currPos) === 59) {
-          s2 = peg$c118;
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c119); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsecomma() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.charCodeAt(peg$currPos) === 44) {
-          s2 = peg$c120;
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c121); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsepipe() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.charCodeAt(peg$currPos) === 124) {
-          s2 = peg$c122;
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c123); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseSCHEMA() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 6) === peg$c124) {
-          s2 = peg$c124;
-          peg$currPos += 6;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c125); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse__();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseINCLUDE() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 7) === peg$c126) {
-          s2 = peg$c126;
-          peg$currPos += 7;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c127); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse__();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseROOT() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 4) === peg$c128) {
-          s2 = peg$c128;
-          peg$currPos += 4;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c129); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse__();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseSHARE_ALL() {
-      var s0, s1, s2, s3, s4, s5;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 5) === peg$c130) {
-          s2 = peg$c130;
-          peg$currPos += 5;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c131); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse__();
-          if (s3 !== peg$FAILED) {
-            if (input.substr(peg$currPos, 3) === peg$c132) {
-              s4 = peg$c132;
-              peg$currPos += 3;
-            } else {
-              s4 = peg$FAILED;
-              if (peg$silentFails === 0) { peg$fail(peg$c133); }
-            }
-            if (s4 !== peg$FAILED) {
-              s5 = peg$parse__();
-              if (s5 !== peg$FAILED) {
-                s1 = [s1, s2, s3, s4, s5];
-                s0 = s1;
-              } else {
-                peg$currPos = s0;
-                s0 = peg$c0;
-              }
-            } else {
-              peg$currPos = s0;
-              s0 = peg$c0;
-            }
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseCOORDINATE() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 10) === peg$c43) {
-          s2 = peg$c43;
-          peg$currPos += 10;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c44); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse__();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseFROM() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 4) === peg$c51) {
-          s2 = peg$c51;
-          peg$currPos += 4;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c52); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse__();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseADD() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 3) === peg$c134) {
-          s2 = peg$c134;
-          peg$currPos += 3;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c135); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse__();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseIN() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c136) {
-          s2 = peg$c136;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c137); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse__();
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c138();
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseCONTAINS() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 8) === peg$c139) {
-          s2 = peg$c139;
-          peg$currPos += 8;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c140); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse__();
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c141();
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parsePRECEDES() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 8) === peg$c142) {
-          s2 = peg$c142;
-          peg$currPos += 8;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c143); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse__();
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c144();
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseFOLLOWS() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 7) === peg$c145) {
-          s2 = peg$c145;
-          peg$currPos += 7;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c146); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse__();
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c147();
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseTHIS() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 4) === peg$c148) {
-          s2 = peg$c148;
-          peg$currPos += 4;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c149); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c150();
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseDO() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c47) {
-          s2 = peg$c47;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c48); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseOD() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 2) === peg$c49) {
-          s2 = peg$c49;
-          peg$currPos += 2;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c50); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseBUILD() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 5) === peg$c151) {
-          s2 = peg$c151;
-          peg$currPos += 5;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c152); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseNEW() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 3) === peg$c153) {
-          s2 = peg$c153;
-          peg$currPos += 3;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c154); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseMAP() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 3) === peg$c155) {
-          s2 = peg$c155;
-          peg$currPos += 3;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c156); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseENSURE() {
-      var s0, s1, s2, s3;
-
-      s0 = peg$currPos;
-      s1 = peg$parse_();
-      if (s1 !== peg$FAILED) {
-        if (input.substr(peg$currPos, 6) === peg$c45) {
-          s2 = peg$c45;
-          peg$currPos += 6;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c46); }
-        }
-        if (s2 !== peg$FAILED) {
-          s3 = peg$parse_();
-          if (s3 !== peg$FAILED) {
-            s1 = [s1, s2, s3];
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parseEOF() {
-      var s0, s1;
-
-      s0 = peg$currPos;
-      peg$silentFails++;
-      if (input.length > peg$currPos) {
-        s1 = input.charAt(peg$currPos);
-        peg$currPos++;
-      } else {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c157); }
-      }
-      peg$silentFails--;
-      if (s1 === peg$FAILED) {
-        s0 = peg$c2;
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-    function peg$parse_() {
-      var s0, s1, s2;
-
-      peg$silentFails++;
-      s0 = peg$currPos;
-      s1 = [];
-      if (peg$c159.test(input.charAt(peg$currPos))) {
-        s2 = input.charAt(peg$currPos);
-        peg$currPos++;
-      } else {
-        s2 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c160); }
-      }
-      if (s2 === peg$FAILED) {
-        s2 = peg$parsecomment();
-      }
-      while (s2 !== peg$FAILED) {
-        s1.push(s2);
-        if (peg$c159.test(input.charAt(peg$currPos))) {
-          s2 = input.charAt(peg$currPos);
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c160); }
-        }
-        if (s2 === peg$FAILED) {
-          s2 = peg$parsecomment();
-        }
-      }
-      if (s1 !== peg$FAILED) {
-        peg$reportedPos = s0;
-        s1 = peg$c161();
-      }
-      s0 = s1;
-      peg$silentFails--;
-      if (s0 === peg$FAILED) {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c158); }
-      }
-
-      return s0;
-    }
-
-    function peg$parse__() {
-      var s0, s1, s2;
-
-      peg$silentFails++;
-      s0 = peg$currPos;
-      if (peg$c159.test(input.charAt(peg$currPos))) {
-        s1 = input.charAt(peg$currPos);
-        peg$currPos++;
-      } else {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c160); }
-      }
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parse_();
-        if (s2 === peg$FAILED) {
-          s2 = peg$c4;
-        }
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c161();
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-      peg$silentFails--;
-      if (s0 === peg$FAILED) {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c162); }
-      }
-
-      return s0;
-    }
-
-    function peg$parsenl() {
-      var s0, s1;
-
-      peg$silentFails++;
-      s0 = peg$currPos;
-      if (peg$c164.test(input.charAt(peg$currPos))) {
-        s1 = input.charAt(peg$currPos);
-        peg$currPos++;
-      } else {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c165); }
-      }
-      if (s1 !== peg$FAILED) {
-        peg$reportedPos = s0;
-        s1 = peg$c161();
-      }
-      s0 = s1;
-      peg$silentFails--;
-      if (s0 === peg$FAILED) {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c163); }
-      }
-
-      return s0;
-    }
-
-    function peg$parsecomment() {
-      var s0, s1, s2;
-
-      s0 = peg$currPos;
-      s1 = peg$parsecomment_line();
-      if (s1 !== peg$FAILED) {
-        s2 = peg$parsenl();
-        if (s2 === peg$FAILED) {
-          s2 = peg$c4;
-        }
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c166(s1);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-      if (s0 === peg$FAILED) {
-        s0 = peg$currPos;
-        s1 = peg$parsecomment_block();
-        if (s1 !== peg$FAILED) {
-          s2 = peg$parsenl();
-          if (s2 === peg$FAILED) {
-            s2 = peg$c4;
-          }
-          if (s2 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c166(s1);
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      }
-
-      return s0;
-    }
-
-    function peg$parsecomment_line() {
-      var s0, s1, s2, s3;
-
-      peg$silentFails++;
-      s0 = peg$currPos;
-      if (input.substr(peg$currPos, 2) === peg$c168) {
-        s1 = peg$c168;
-        peg$currPos += 2;
-      } else {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c169); }
-      }
-      if (s1 !== peg$FAILED) {
-        s2 = [];
-        if (peg$c170.test(input.charAt(peg$currPos))) {
-          s3 = input.charAt(peg$currPos);
-          peg$currPos++;
-        } else {
-          s3 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c171); }
-        }
-        while (s3 !== peg$FAILED) {
-          s2.push(s3);
-          if (peg$c170.test(input.charAt(peg$currPos))) {
-            s3 = input.charAt(peg$currPos);
-            peg$currPos++;
-          } else {
-            s3 = peg$FAILED;
-            if (peg$silentFails === 0) { peg$fail(peg$c171); }
-          }
-        }
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c172(s2);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-      peg$silentFails--;
-      if (s0 === peg$FAILED) {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c167); }
-      }
-
-      return s0;
-    }
-
-    function peg$parsecomment_block() {
-      var s0, s1, s2, s3;
-
-      peg$silentFails++;
-      s0 = peg$currPos;
-      if (input.substr(peg$currPos, 2) === peg$c174) {
-        s1 = peg$c174;
-        peg$currPos += 2;
-      } else {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c175); }
-      }
-      if (s1 !== peg$FAILED) {
-        s2 = [];
-        s3 = peg$parsecomment_block_char();
-        while (s3 !== peg$FAILED) {
-          s2.push(s3);
-          s3 = peg$parsecomment_block_char();
-        }
-        if (s2 !== peg$FAILED) {
-          if (input.substr(peg$currPos, 2) === peg$c176) {
-            s3 = peg$c176;
-            peg$currPos += 2;
-          } else {
-            s3 = peg$FAILED;
-            if (peg$silentFails === 0) { peg$fail(peg$c177); }
-          }
-          if (s3 !== peg$FAILED) {
-            peg$reportedPos = s0;
-            s1 = peg$c178(s2);
-            s0 = s1;
-          } else {
-            peg$currPos = s0;
-            s0 = peg$c0;
-          }
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-      peg$silentFails--;
-      if (s0 === peg$FAILED) {
-        s1 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c173); }
-      }
-
-      return s0;
-    }
-
-    function peg$parsecomment_block_char() {
-      var s0, s1, s2;
-
-      s0 = peg$currPos;
-      s1 = peg$currPos;
-      peg$silentFails++;
-      if (input.substr(peg$currPos, 2) === peg$c176) {
-        s2 = peg$c176;
-        peg$currPos += 2;
-      } else {
-        s2 = peg$FAILED;
-        if (peg$silentFails === 0) { peg$fail(peg$c177); }
-      }
-      peg$silentFails--;
-      if (s2 === peg$FAILED) {
-        s1 = peg$c2;
-      } else {
-        peg$currPos = s1;
-        s1 = peg$c0;
-      }
-      if (s1 !== peg$FAILED) {
-        if (input.length > peg$currPos) {
-          s2 = input.charAt(peg$currPos);
-          peg$currPos++;
-        } else {
-          s2 = peg$FAILED;
-          if (peg$silentFails === 0) { peg$fail(peg$c157); }
-        }
-        if (s2 !== peg$FAILED) {
-          peg$reportedPos = s0;
-          s1 = peg$c179(s2);
-          s0 = s1;
-        } else {
-          peg$currPos = s0;
-          s0 = peg$c0;
-        }
-      } else {
-        peg$currPos = s0;
-        s0 = peg$c0;
-      }
-
-      return s0;
-    }
-
-
-      /*global parse, options, offset, line, column, text, SyntaxError*/
-      //TODO: the 'MP2-parser.rig' takes a scope and bakes it into the output we will do that elsewhere
-      //TODO: the 'MP2-parser.rig' checks for various error scenarios that we might bake into this
-      //TODO: when we get to bool_expr might look into using the `ast-types` npm to make any code generation easier (escodegen)
-      var opts = arguments[2] || options,
-        fileName = opts.fileName || "NOFILENAME",
-        locations = opts.locations !== undefined ? opts.locations : false,
-        comments = opts.comments !== undefined ? opts.comments : false;
-
-      var uniqueNumber = 0,
-        getUniqueNumber = function getUniqueNumber() {
-          return uniqueNumber++;
-        };
-
-      var err = function err(msg, suffix) {
-          if (typeof msg === "number") msg = "ERR" + msg + ": " + errors[msg];
-          if (suffix) msg += suffix;
-          return new SyntaxError(msg, null, null, offset(), line(), column());
-      };
-
-      var ast = {
-
-        errors: [], // tracks all of the non-grammatical errors
-
-        rulesById: {}, // track all of the rules by their ID
-
-        Base: function Base(type) {
-          this.type = type;
-          if (locations) {
-            this.location = {
-              pos: offset(),
-              line: line(),
-              col: column(),
-              len: text().length,
-            };
-          }
-          if (comments && type !== "Comment") {
-            //TODO: not attached in right place
-             this.comments = ast._comments;
-             ast._comments = [];
-          }
-        },
-
-        _comments: [],
-        Comment: function Comment(block, text) {
-          ast.Base.call(this, "Comment");
-          this.block = block;
-          this.text = text;
-          ast._comments.push(this);
-        },
-
-        Id: function Id(type, id) {
-          ast.Base.call(this, type);
-          this.id = id;
-        },
-
-        Schema: function Schema(includes, statements) {
-          ast.Id.call(this, "Schema", fileName);
-          this.includes = includes;
-          this.statements = statements;
-        },
-
-        Include: function Include(id) {
-          throw err(12, "INCLUDE");
-          ast.Id.call(this, "Include", id);
-        },
-
-        Rule: function Rule(id, ruleType, patterns, buildBlock) {
-          ast.Id.call(this, "Rule", id);
-          this.ruleType = ruleType;
-          // this.refId = "Comp_" + getUniqueNumber(); // aka "work_name" in RIGAL code
-          this.patterns = patterns;
-          // this.buildBlock = buildBlock;
-        },
-
-        RootRule: function RootRule(id, patterns, buildBlock) {
-          ast.Rule.call(this, id, "RootRule", patterns, buildBlock);
-        },
-
-        CompositeRule: function CompositeRule(id, patterns, buildBlock) {
-          ast.Rule.call(this, id, "CompositeRule", patterns, buildBlock);
-        },
-
-        Event: function Event(id) {
-          ast.Id.call(this, "Event", id);
-        },
-
-        Sequence: function Sequence(body) { // aka pattern_list
-          ast.Base.call(this, "Sequence");
-          // this.refId = "Sq_" + getUniqueNumber(); // aka "name" in RIGAL code
-          this.body = body;
-        },
-
-        Alternative: function Alternative(body) {
-          ast.Base.call(this, "Alternative");
-          // this.refId = "Alt_" + getUniqueNumber(); // aka "name" in RIGAL code
-          this.body = body;  // aka "patterns" in the RIGAL codye
-        },
-
-        Probability: function Probability(p) {
-          throw err(12, "PROBABILITY");
-          ast.Base.call(this, "Probability");
-          this.p = p;
-        },
-
-        MinMax: function MinMax(min, max) {
-          ast.Base.call(this, "MinMax");
-          this.min = min;
-          this.max = max;
-        },
-
-        Iterator: function Iterator(scope, body) {
-          ast.Base.call(this, "Iterator");
-          // this.refId = "Itr_" + getUniqueNumber(); // aka "name" in RIGAL code
-          this.scope = scope;
-          this.body = body;
-        },
-
-        Set: function Set(body) {
-          ast.Base.call(this, "Set");
-          // this.refId = "Set_" + getUniqueNumber(); // aka "name" in RIGAL code
-          this.body = body;
-        },
-
-        SetIterator: function SetIterator(scope, body) {
-          ast.Base.call(this, "SetIterator");
-          // this.refId = "SetIterator_" + getUniqueNumber(); // aka "name" in RIGAL code
-          this.scope = scope;
-          this.body = body;
-        },
-
-        Optional: function Optional(body) {
-          ast.Base.call(this, "Optional");
-          // this.refId = "Opt_" + getUniqueNumber(); // aka "name" in RIGAL code
-          this.body = body;
-        },
-
-        Coordinate: function Coordinate(async, srcs, body) {
-          ast.Base.call(this, "Coordinate");
-          // this.refId = "Coordinate_" + getUniqueNumber(); // aka "work" in RIGAL code
-          this.async = async;
-          this.srcs = srcs;
-          this.body = body;
-        },
-
-        CoordinateSource: function CoordinateSource(id, select, from) {
-          ast.Id.call(this, "CoordinateSource", id);
-          this.select = select;
-          this.from = from || "<this>";
-        },
-
-        ShareAll: function ShareAll(hosts, events) {
-          ast.Base.call(this, "ShareAll");
-          // this.refId = "ShareAll_" + getUniqueNumber(); // aka "work" in RIGAL code
-          this.hosts = hosts;
-          this.events = events;
-        },
-
-        Relationship: function Relationship(src, relType, dst) {
-            ast.Base.call(this, "Relationship");
-            this.relType = relType;
-            this.src = src;
-            this.dst = dst;
-        },
-
-        AddOperation: function AddOperation(rels) {
-          ast.Base.call(this, "Add");
-          this.relationships = rels;
-        },
-
-      };
-
-      parse.ast = ast;
-
-      if (opts.ast) {
-        /*TODO: setup overrides from opts.ast on top of ast*/
-      }
-
-      var errors = {
-        // 1: "wrong schema name $a identifier expected/ !", //NOTE: probably not applicable if we make SCHEMA go away (or at least optional silliness)
-        // 2: "wrong event pattern $a / !",  //NOTE: errors handled by our generated parser
-        3: "trigger event $a should not appear in WHEN pattern list / !",
-        //// 4: "detected around token $a/ !", //NOTE: errors handled by our generated parser
-        5: "defined event name should not appear in rule body: ",
-        //TODO: 6: "recursion for event $a is detected/ !", //TODO: check for this
-        // 7: "syntax error in probability definition detected at $a/ !", //NOTE: just took out of parser for now
-        // 8: "schema name $a should be the same as input parameter/ !", //NOTE: disabled this restriction
-        // 9: "keyword 'DO' is expected in COORDINATE when actual token is $a / !", //NOTE: errors handled by our generated parser
-        // 10: "keyword 'OD' is expected in COORDINATE when actual token is $a / !", //NOTE: errors handled by our generated parser
-        // 11: "semicolon is expected when actual token is $a / !", //NOTE: errors handled by our generated parser
-        12: "not implemented yet: ",
-        // 13: "':' is expected when actual token is $a / !", //NOTE: errors handled by our generated parser
-        // 14: "incorrect variable name $a in the COORDINATE source / !", //NOTE: errors handled by our generated parser
-        // 15: "derivation for root $a should be completed before composition/ !", //NOTE: handled by 21
-        // 16: "wrong relation name $a in the ADD composition/ !", //NOTE: errors handled by our generated parser
-        17: "variable is not defined: ",
-        //TODO: 18: "shared event $a has not been defined in any grammar rule / !", //TODO: not sure how to recreate to test this
-        19: "variable has been defined twice: ",
-        //NOTE: additional errors added by us
-        20: "rule defined more than once: ",
-        21: "reference to undefined item: ",
-        22: "reference to non-root event: ",
-      };
-
-
-
-    peg$result = peg$startRuleFunction();
-
-    if (peg$result !== peg$FAILED && peg$currPos === input.length) {
-      return peg$result;
-    } else {
-      if (peg$result !== peg$FAILED && peg$currPos < input.length) {
-        peg$fail({ type: "end", description: "end of input" });
-      }
-
-      throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);
-    }
-  }
-
-  return {
-    SyntaxError: SyntaxError,
-    parse:       parse
-  };
-})();

+ 17 - 0
src/web/assets/scripts/snippets-modellang.js

@@ -0,0 +1,17 @@
+/*global ace*/
+
+ace.define("ace/snippets/modellang",
+["require", "exports", "module"],
+function(require, exports, module) {
+	"use strict";
+
+	exports.snippetText = "# SYSTEM\n" +
+		"snippet system\n" +
+		"	SYSTEM: ${1:system_name} = ${2:next_events_expression};\n" +
+		"# BEHAVIOR\n" +
+		"snippet behavior\n" +
+		"	BEHAVIOR: ${1:behavior_name} = ${2:next_events_expression};\n"
+		;
+
+	exports.scope = "modellang";
+});

+ 0 - 17
src/web/assets/scripts/snippets-mp2.js

@@ -1,17 +0,0 @@
-/*global ace*/
-
-ace.define("ace/snippets/mp2",
-["require", "exports", "module"],
-function(require, exports, module) {
-	"use strict";
-
-	exports.snippetText = "# SCHEMA\n" +
-		"snippet schema\n" +
-		"	SCHEMA ${1:schema_name};\n" +
-		"# ROOT\n" +
-		"snippet root\n" +
-		"	ROOT ${1:root_name}: ${2:next_events_expression}\n"
-		;
-
-	exports.scope = "mp2";
-});

+ 1 - 1
src/web/components/data/files.js

@@ -1,4 +1,4 @@
-angular.module("mp-ide.components.editor", [
+angular.module("modellang-ide.components.editor", [
 	"ui-ace",
 ])
 

+ 7 - 7
src/web/components/editor/editor.js

@@ -1,7 +1,7 @@
 "use strict";
 /*global ace*/
 
-angular.module("mp-ide.components.editor", [
+angular.module("modellang-ide.components.editor", [
 	"ui.ace",
 ])
 
@@ -12,7 +12,7 @@ function($window, $q) {
 		working = {},
 		worked = 0;
 	if (Boolean($window.Worker)) {
-		worker = new Worker("assets/mp2-parser-worker.js");
+		worker = new Worker("assets/scripts/modellang-worker.js");
 		worker.onmessage = function onParserWorkerMessage(msg) {
 			var data = msg.data,
 				work = working[data.id];
@@ -31,11 +31,11 @@ function($window, $q) {
 				});
 				working[id] = work;
 			} else {
-				$q.all($window.mp2 ? [] : [$.getScript("assets/mp2-parser.js")])
+				$q.all($window.modellangParser ? [] : [$.getScript("assets/scripts/modellang-parser.js")])
 					.then(function() {
 						var parsed;
 						try {
-							parsed = $window.mp2.parse(input);
+							parsed = $window.modellangParser.parse(input);
 						} catch (err) {
 							parsed = {
 								errors: [err],
@@ -72,8 +72,8 @@ function($timeout, parser) {
 					//TODO:  there is a flicker on load... AAAAAAHAHHAHAHAHAH!
 
 					//TODO: disable this syntax debugging code
-					var ttExt = ace.require("ace/token_tooltip");
-					new ttExt.TokenTooltip(editor); //jshint ignore:line
+					// var ttExt = ace.require("ace/token_tooltip");
+					// new ttExt.TokenTooltip(editor); //jshint ignore:line
 
 					//TODO: grab list of commands from Kyle's MongoDB IDE
 
@@ -130,7 +130,7 @@ function($timeout, parser) {
 ["$scope",
 function($scope) {
 	var defaults = {
-		mode: "mp",
+		mode: "modellang",
 		theme: "tomorrow_night",
 		require: ["ace/ext/language_tools"],
 		useSoftTabs: false,

+ 1 - 1
src/web/components/layout/layout.js

@@ -5,7 +5,7 @@
 //TODO: may eventually want to wrap up registering named component templates as a directive to reduce the amount of info in the toConfig()
 
 
-angular.module("mp-ide.components.layout", [
+angular.module("modellang-ide.components.layout", [
 	// deps go here
 ])
 

+ 1 - 1
src/web/components/menu/menu.js

@@ -1,6 +1,6 @@
 "use strict";
 
-angular.module("mp-ide.components.menu",
+angular.module("modellang-ide.components.menu",
 [//deps
 ])
 

+ 5 - 5
src/web/index.html

@@ -25,7 +25,7 @@
     <link rel="stylesheet" href="components/menu/menu.css">
     <link rel="stylesheet" href="components/layout/layout.css">
     <link rel="stylesheet" href="components/editor/editor.css">
-    <link rel="stylesheet" href="home/home.css">
+    <link rel="stylesheet" href="pages/home/home.css">
     <link rel="stylesheet" href="index.css">
 
 </head>
@@ -58,13 +58,13 @@
     <script src="bower_components/ace-builds/src-noconflict/ext-statusbar.js"></script>
     <script src="bower_components/angular-ui-ace/ui-ace.min.js"></script>
     <script src="assets/scripts/debug_ace_token_tooltip.js"></script>
-    <script src="assets/scripts/mp.js"></script>
-    <script src="assets/scripts/snippets-mp.js"></script>
+    <script src="assets/scripts/modellang.js"></script>
+    <script src="assets/scripts/snippets-modellang.js"></script>
     <script>
         /*global ace*/
         var aceConfig = ace.require("ace/config");
-        aceConfig.setModuleUrl("ace/mode/mp", "assets/scripts/mp.js");
-        aceConfig.setModuleUrl("ace/mode/mp", "assets/scripts/snippets-mp.js");
+        aceConfig.setModuleUrl("ace/mode/modellang", "assets/scripts/modellang.js");
+        aceConfig.setModuleUrl("ace/mode/modellang", "assets/scripts/snippets-modellang.js");
     </script>
 
     <!-- JS: App -->

+ 3 - 3
src/web/index.js

@@ -1,10 +1,10 @@
 "use strict";
 
 // Declare app level module which depends on views, and components
-angular.module("mp-ide", [
+angular.module("modellang-ide", [
 	"ngRoute",
-	"mp-ide.components.menu",
-	"mp-ide.home",
+	"modellang-ide.components.menu",
+	"modellang-ide.home",
 ])
 
 .config(

+ 3 - 3
src/web/pages/home/home.js

@@ -1,8 +1,8 @@
 "use strict";
 
-angular.module("mp-ide.home", [
-	"mp-ide.components.layout",
-	"mp-ide.components.editor",
+angular.module("modellang-ide.home", [
+	"modellang-ide.components.layout",
+	"modellang-ide.components.editor",
 ])
 
 .directive("home", function() {