UNPKG

rollo

Version:

The Rollo programming language for the Orbotix Sphero robot using Node.js and Cylon.js

1,550 lines (1,425 loc) 112 kB
module.exports = (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 = { type: "literal", value: "#", description: "\"#\"" }, peg$c2 = "let", peg$c3 = { type: "literal", value: "let", description: "\"let\"" }, peg$c4 = "speed", peg$c5 = { type: "literal", value: "speed", description: "\"speed\"" }, peg$c6 = "waitfortap", peg$c7 = { type: "literal", value: "waitForTap", description: "\"waitForTap\"" }, peg$c8 = "waitforhit", peg$c9 = { type: "literal", value: "waitForHit", description: "\"waitForHit\"" }, peg$c10 = "wait", peg$c11 = { type: "literal", value: "wait", description: "\"wait\"" }, peg$c12 = "delay", peg$c13 = { type: "literal", value: "delay", description: "\"delay\"" }, peg$c14 = "go", peg$c15 = { type: "literal", value: "go", description: "\"go\"" }, peg$c16 = "turn", peg$c17 = { type: "literal", value: "turn", description: "\"turn\"" }, peg$c18 = "turnright", peg$c19 = { type: "literal", value: "turnRight", description: "\"turnRight\"" }, peg$c20 = "right", peg$c21 = { type: "literal", value: "right", description: "\"right\"" }, peg$c22 = "turnleft", peg$c23 = { type: "literal", value: "turnLeft", description: "\"turnLeft\"" }, peg$c24 = "left", peg$c25 = { type: "literal", value: "left", description: "\"left\"" }, peg$c26 = "flash", peg$c27 = { type: "literal", value: "flash", description: "\"flash\"" }, peg$c28 = "color", peg$c29 = { type: "literal", value: "color", description: "\"color\"" }, peg$c30 = "pulse", peg$c31 = { type: "literal", value: "pulse", description: "\"pulse\"" }, peg$c32 = "log", peg$c33 = { type: "literal", value: "log", description: "\"log\"" }, peg$c34 = "say", peg$c35 = { type: "literal", value: "say", description: "\"say\"" }, peg$c36 = "gosub", peg$c37 = { type: "literal", value: "gosub", description: "\"gosub\"" }, peg$c38 = "call", peg$c39 = { type: "literal", value: "call", description: "\"call\"" }, peg$c40 = "loop", peg$c41 = { type: "literal", value: "loop", description: "\"loop\"" }, peg$c42 = "repeat", peg$c43 = { type: "literal", value: "repeat", description: "\"repeat\"" }, peg$c44 = "sub", peg$c45 = { type: "literal", value: "sub", description: "\"sub\"" }, peg$c46 = "while", peg$c47 = { type: "literal", value: "while", description: "\"while\"" }, peg$c48 = "if", peg$c49 = { type: "literal", value: "if", description: "\"if\"" }, peg$c50 = peg$FAILED, peg$c51 = "else", peg$c52 = { type: "literal", value: "else", description: "\"else\"" }, peg$c53 = function(b) { return b; }, peg$c54 = "do", peg$c55 = { type: "literal", value: "do", description: "\"do\"" }, peg$c56 = "until", peg$c57 = { type: "literal", value: "until", description: "\"until\"" }, peg$c58 = "stop", peg$c59 = { type: "literal", value: "stop", description: "\"stop\"" }, peg$c60 = "turnaround", peg$c61 = { type: "literal", value: "turnAround", description: "\"turnAround\"" }, peg$c62 = "reverse", peg$c63 = { type: "literal", value: "reverse", description: "\"reverse\"" }, peg$c64 = "pointme", peg$c65 = { type: "literal", value: "pointMe", description: "\"pointMe\"" }, peg$c66 = [], peg$c67 = /^[0-9.]/, peg$c68 = { type: "class", value: "[0-9.]", description: "[0-9.]" }, peg$c69 = function(n) { return parseInt(n.join("")); }, peg$c70 = "0x", peg$c71 = { type: "literal", value: "0x", description: "\"0x\"" }, peg$c72 = /^[0-9a-fA-F]/, peg$c73 = { type: "class", value: "[0-9a-fA-F]", description: "[0-9a-fA-F]" }, peg$c74 = function(n1, n2) { return parseInt(n1 + n2.join("")); }, peg$c75 = "time", peg$c76 = { type: "literal", value: "time", description: "\"time\"" }, peg$c77 = null, peg$c78 = "s", peg$c79 = { type: "literal", value: "s", description: "\"s\"" }, peg$c80 = "then", peg$c81 = { type: "literal", value: "then", description: "\"then\"" }, peg$c82 = "%", peg$c83 = { type: "literal", value: "%", description: "\"%\"" }, peg$c84 = "second", peg$c85 = { type: "literal", value: "second", description: "\"second\"" }, peg$c86 = "degree", peg$c87 = { type: "literal", value: "degree", description: "\"degree\"" }, peg$c88 = /^[a-zA-Z]/, peg$c89 = { type: "class", value: "[a-zA-Z]", description: "[a-zA-Z]" }, peg$c90 = /^[a-zA-Z0-9]/, peg$c91 = { type: "class", value: "[a-zA-Z0-9]", description: "[a-zA-Z0-9]" }, peg$c92 = function(s, s2) { return (s + s2.join("")).toLowerCase(); }, peg$c93 = /^[a-zA-Z0-9 ]/, peg$c94 = { type: "class", value: "[a-zA-Z0-9 ]", description: "[a-zA-Z0-9 ]" }, peg$c95 = function(s) { return s.join(""); }, peg$c96 = " ", peg$c97 = { type: "literal", value: " ", description: "\" \"" }, peg$c98 = function(c, l, b) { return { number: line(), line: [c.toLowerCase(), l, b] }; }, peg$c99 = /^[^\r\^\n]/, peg$c100 = { type: "class", value: "[^\\r\\^\\n]", description: "[^\\r\\^\\n]" }, peg$c101 = function(c) { return { number: line(), line: ['#']}; }, peg$c102 = function(c, e, b) { return { number: line(), line: [c.toLowerCase(), e, b]}; }, peg$c103 = function(c, e, b, c2) { return { number: line(), line: [c.toLowerCase(), e, b, (c2 ? c2 : [])]}; }, peg$c104 = function(c, b, c2, e) { return { number: line(), line: [c.toLowerCase()+c2, e, b]}; }, peg$c105 = function(c, n, b) { return { number: line(), line: [c.toLowerCase(), n, b]}; }, peg$c106 = "=", peg$c107 = { type: "literal", value: "=", description: "\"=\"" }, peg$c108 = function(c, v, a) { return { number: line(), line: [c.toLowerCase(), v, a]}; }, peg$c109 = function(c, n) { return { number: line(), line: [c.toLowerCase(), n]}; }, peg$c110 = function(c, l) { return { number: line(), line: [c.toLowerCase(), l]}; }, peg$c111 = /^[']/, peg$c112 = { type: "class", value: "[']", description: "[']" }, peg$c113 = function(c, s) { return { number: line(), line: [c.toLowerCase(), s]}; }, peg$c114 = /^["]/, peg$c115 = { type: "class", value: "[\"]", description: "[\"]" }, peg$c116 = "()", peg$c117 = { type: "literal", value: "()", description: "\"()\"" }, peg$c118 = function(c) { return { number: line(), line: [c.toLowerCase()]}; }, peg$c119 = "+", peg$c120 = { type: "literal", value: "+", description: "\"+\"" }, peg$c121 = function(left, right) { return ['+', [left, right]]; }, peg$c122 = "-", peg$c123 = { type: "literal", value: "-", description: "\"-\"" }, peg$c124 = function(left, right) { return ['-', [left, right]]; }, peg$c125 = "*", peg$c126 = { type: "literal", value: "*", description: "\"*\"" }, peg$c127 = function(left, right) { return ['*', [left, right]]; }, peg$c128 = "/", peg$c129 = { type: "literal", value: "/", description: "\"/\"" }, peg$c130 = function(left, right) { return ['/', [left, right]]; }, peg$c131 = /^[ \t]/, peg$c132 = { type: "class", value: "[ \\t]", description: "[ \\t]" }, peg$c133 = "is", peg$c134 = { type: "literal", value: "is", description: "\"is\"" }, peg$c135 = function(n) { return n; }, peg$c136 = function(v) { return v; }, peg$c137 = function(f) { return f; }, peg$c138 = "(", peg$c139 = { type: "literal", value: "(", description: "\"(\"" }, peg$c140 = ")", peg$c141 = { type: "literal", value: ")", description: "\")\"" }, peg$c142 = function(additive) { return additive; }, peg$c143 = /^[.]/, peg$c144 = { type: "class", value: "[.]", description: "[.]" }, peg$c145 = function(i, p, d) { return Number(i.join("") + (p ? p : '') + d.join("")); }, peg$c146 = function(i, p, d) { return Number("-" + i.join("") + (p ? p : '') + d.join("")); }, peg$c147 = function(i) { return Number(i); }, peg$c148 = function(i) { return Number("-" + i); }, peg$c149 = /^[0-9]/, peg$c150 = { type: "class", value: "[0-9]", description: "[0-9]" }, peg$c151 = function(digits) { return parseInt(digits.join(""), 10); }, peg$c152 = "$", peg$c153 = { type: "literal", value: "$", description: "\"$\"" }, peg$c154 = function(n) { return "$" + n.join(""); }, peg$c155 = function(l) { return "^"+l; }, peg$c156 = "===", peg$c157 = { type: "literal", value: "===", description: "\"===\"" }, peg$c158 = function() { return '=='; }, peg$c159 = "==", peg$c160 = { type: "literal", value: "==", description: "\"==\"" }, peg$c161 = "equals", peg$c162 = { type: "literal", value: "equals", description: "\"equals\"" }, peg$c163 = "equal", peg$c164 = { type: "literal", value: "equal", description: "\"equal\"" }, peg$c165 = "to", peg$c166 = { type: "literal", value: "to", description: "\"to\"" }, peg$c167 = "!==", peg$c168 = { type: "literal", value: "!==", description: "\"!==\"" }, peg$c169 = function() { return '!='; }, peg$c170 = "!=", peg$c171 = { type: "literal", value: "!=", description: "\"!=\"" }, peg$c172 = "not", peg$c173 = { type: "literal", value: "not", description: "\"not\"" }, peg$c174 = "<=", peg$c175 = { type: "literal", value: "<=", description: "\"<=\"" }, peg$c176 = function() { return '<='; }, peg$c177 = ">=", peg$c178 = { type: "literal", value: ">=", description: "\">=\"" }, peg$c179 = function() { return '>='; }, peg$c180 = "less", peg$c181 = { type: "literal", value: "less", description: "\"less\"" }, peg$c182 = "than", peg$c183 = { type: "literal", value: "than", description: "\"than\"" }, peg$c184 = function() { return '<'; }, peg$c185 = "more", peg$c186 = { type: "literal", value: "more", description: "\"more\"" }, peg$c187 = function() { return '>'; }, peg$c188 = "greater", peg$c189 = { type: "literal", value: "greater", description: "\"greater\"" }, peg$c190 = /^[><]/, peg$c191 = { type: "class", value: "[><]", description: "[><]" }, peg$c192 = function(c) { return c; }, peg$c193 = function(a1, c, a2) { return [c, a1, a2]; }, peg$c194 = "{", peg$c195 = { type: "literal", value: "{", description: "\"{\"" }, peg$c196 = "}", peg$c197 = { type: "literal", value: "}", description: "\"}\"" }, peg$c198 = function(i) { return i }, peg$c199 = /^[\r\n]/, peg$c200 = { type: "class", value: "[\\r\\n]", description: "[\\r\\n]" }, peg$c201 = /^[^\r\n]/, peg$c202 = { type: "class", value: "[^\\r\\n]", description: "[^\\r\\n]" }, peg$c203 = function(s) { return s }, 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; s0 = peg$parselines(); return s0; } function peg$parsecmdComment() { var s0; if (input.charCodeAt(peg$currPos) === 35) { s0 = peg$c0; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c1); } } return s0; } function peg$parsecmdWithAssignment() { var s0; if (input.substr(peg$currPos, 3).toLowerCase() === peg$c2) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } return s0; } function peg$parsecmdWithPercent() { var s0; if (input.substr(peg$currPos, 5).toLowerCase() === peg$c4) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c5); } } return s0; } function peg$parsecmdWithSeconds() { var s0; if (input.substr(peg$currPos, 10).toLowerCase() === peg$c6) { s0 = input.substr(peg$currPos, 10); peg$currPos += 10; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c7); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 10).toLowerCase() === peg$c8) { s0 = input.substr(peg$currPos, 10); peg$currPos += 10; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c9); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 4).toLowerCase() === peg$c10) { s0 = input.substr(peg$currPos, 4); peg$currPos += 4; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c11); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 5).toLowerCase() === peg$c12) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c13); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 2).toLowerCase() === peg$c14) { s0 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c15); } } } } } } return s0; } function peg$parsecmdWithDegrees() { var s0; if (input.substr(peg$currPos, 4).toLowerCase() === peg$c16) { s0 = input.substr(peg$currPos, 4); peg$currPos += 4; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c17); } } return s0; } function peg$parsecmdWithPosDegrees() { var s0; if (input.substr(peg$currPos, 9).toLowerCase() === peg$c18) { s0 = input.substr(peg$currPos, 9); peg$currPos += 9; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c19); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 5).toLowerCase() === peg$c20) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c21); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 8).toLowerCase() === peg$c22) { s0 = input.substr(peg$currPos, 8); peg$currPos += 8; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c23); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 4).toLowerCase() === peg$c24) { s0 = input.substr(peg$currPos, 4); peg$currPos += 4; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c25); } } } } } return s0; } function peg$parsecmdWithHexNumber() { var s0; if (input.substr(peg$currPos, 5).toLowerCase() === peg$c26) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c27); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 5).toLowerCase() === peg$c28) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c29); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 5).toLowerCase() === peg$c30) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c31); } } } } return s0; } function peg$parsecmdWithString() { var s0; if (input.substr(peg$currPos, 3).toLowerCase() === peg$c32) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c33); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 3).toLowerCase() === peg$c34) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c35); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 5).toLowerCase() === peg$c26) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c27); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 5).toLowerCase() === peg$c28) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c29); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 5).toLowerCase() === peg$c30) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c31); } } } } } } return s0; } function peg$parsecmdWithLabel() { var s0; if (input.substr(peg$currPos, 5).toLowerCase() === peg$c36) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c37); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 4).toLowerCase() === peg$c38) { s0 = input.substr(peg$currPos, 4); peg$currPos += 4; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c39); } } } return s0; } function peg$parsecmdBlock() { var s0; if (input.substr(peg$currPos, 4).toLowerCase() === peg$c40) { s0 = input.substr(peg$currPos, 4); peg$currPos += 4; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c41); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 6).toLowerCase() === peg$c42) { s0 = input.substr(peg$currPos, 6); peg$currPos += 6; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c43); } } } return s0; } function peg$parsecmdBlockWithLabel() { var s0; if (input.substr(peg$currPos, 3).toLowerCase() === peg$c44) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c45); } } return s0; } function peg$parsecmdBlockWithExpression() { var s0; if (input.substr(peg$currPos, 5).toLowerCase() === peg$c46) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c47); } } return s0; } function peg$parsecmdIf() { var s0; if (input.substr(peg$currPos, 2).toLowerCase() === peg$c48) { s0 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c49); } } return s0; } function peg$parsecmdIfElse() { var s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 4).toLowerCase() === peg$c51) { s2 = input.substr(peg$currPos, 4); 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) { s4 = peg$parseblock(); if (s4 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c53(s4); s0 = s1; } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } return s0; } function peg$parsecmdDoPart1() { var s0; if (input.substr(peg$currPos, 2).toLowerCase() === peg$c54) { s0 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c55); } } return s0; } function peg$parsecmdDoPart2() { var s0; if (input.substr(peg$currPos, 5).toLowerCase() === peg$c46) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c47); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 5).toLowerCase() === peg$c56) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c57); } } } return s0; } function peg$parsecmd() { var s0; if (input.substr(peg$currPos, 2).toLowerCase() === peg$c14) { s0 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c15); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 4).toLowerCase() === peg$c58) { s0 = input.substr(peg$currPos, 4); peg$currPos += 4; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c59); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 10).toLowerCase() === peg$c6) { s0 = input.substr(peg$currPos, 10); peg$currPos += 10; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c7); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 10).toLowerCase() === peg$c8) { s0 = input.substr(peg$currPos, 10); peg$currPos += 10; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c9); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 10).toLowerCase() === peg$c60) { s0 = input.substr(peg$currPos, 10); peg$currPos += 10; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 7).toLowerCase() === peg$c62) { s0 = input.substr(peg$currPos, 7); peg$currPos += 7; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c63); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 8).toLowerCase() === peg$c22) { s0 = input.substr(peg$currPos, 8); peg$currPos += 8; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c23); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 4).toLowerCase() === peg$c24) { s0 = input.substr(peg$currPos, 4); peg$currPos += 4; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c25); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 9).toLowerCase() === peg$c18) { s0 = input.substr(peg$currPos, 9); peg$currPos += 9; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c19); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 5).toLowerCase() === peg$c20) { s0 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c21); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 7).toLowerCase() === peg$c64) { s0 = input.substr(peg$currPos, 7); peg$currPos += 7; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c65); } } } } } } } } } } } } return s0; } function peg$parseposNumber() { var s0, s1, s2; s0 = peg$currPos; s1 = []; if (peg$c67.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c68); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); if (peg$c67.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c68); } } } } else { s1 = peg$c50; } if (s1 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c69(s1); } s0 = s1; return s0; } function peg$parsehexNumber() { var s0, s1, s2, s3; s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c70) { s1 = peg$c70; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c71); } } if (s1 !== peg$FAILED) { s2 = []; if (peg$c72.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c73); } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); if (peg$c72.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c73); } } } } else { s2 = peg$c50; } if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c74(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } return s0; } function peg$parsetimes() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parse__(); if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 4).toLowerCase() === peg$c75) { s2 = input.substr(peg$currPos, 4); peg$currPos += 4; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c76); } } if (s2 !== peg$FAILED) { if (input.substr(peg$currPos, 1).toLowerCase() === peg$c78) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c79); } } if (s3 === peg$FAILED) { s3 = peg$c77; } if (s3 !== peg$FAILED) { s1 = [s1, s2, s3]; s0 = s1; } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } return s0; } function peg$parsethen() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parse__(); if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 4).toLowerCase() === peg$c80) { s2 = input.substr(peg$currPos, 4); peg$currPos += 4; } 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$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } return s0; } function peg$parsepercent() { var s0, s1, s2; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 37) { s2 = peg$c82; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c83); } } if (s2 !== peg$FAILED) { s1 = [s1, s2]; s0 = s1; } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } return s0; } function peg$parseseconds() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parse__(); if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 6).toLowerCase() === peg$c84) { s2 = input.substr(peg$currPos, 6); peg$currPos += 6; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c85); } } if (s2 !== peg$FAILED) { if (input.substr(peg$currPos, 1).toLowerCase() === peg$c78) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c79); } } if (s3 === peg$FAILED) { s3 = peg$c77; } if (s3 !== peg$FAILED) { s1 = [s1, s2, s3]; s0 = s1; } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } return s0; } function peg$parsedegrees() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parse__(); if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 6).toLowerCase() === peg$c86) { s2 = input.substr(peg$currPos, 6); peg$currPos += 6; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c87); } } if (s2 !== peg$FAILED) { if (input.substr(peg$currPos, 1).toLowerCase() === peg$c78) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c79); } } if (s3 === peg$FAILED) { s3 = peg$c77; } if (s3 !== peg$FAILED) { s1 = [s1, s2, s3]; s0 = s1; } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } return s0; } function peg$parselabel() { var s0, s1, s2, s3; s0 = peg$currPos; if (peg$c88.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c89); } } if (s1 !== peg$FAILED) { s2 = []; if (peg$c90.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c91); } } while (s3 !== peg$FAILED) { s2.push(s3); if (peg$c90.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c91); } } } if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c92(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } return s0; } function peg$parsestring() { var s0, s1, s2; 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); } } 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); } } } if (s1 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c95(s1); } s0 = s1; return s0; } function peg$parserootStatement() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$parsecmdBlockWithLabel(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { s3 = peg$parselabel(); if (s3 !== peg$FAILED) { s4 = []; if (input.charCodeAt(peg$currPos) === 32) { s5 = peg$c96; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c97); } } while (s5 !== peg$FAILED) { s4.push(s5); if (input.charCodeAt(peg$currPos) === 32) { s5 = peg$c96; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c97); } } } if (s4 !== peg$FAILED) { s5 = peg$parseblock(); if (s5 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c98(s1, s3, s5); s0 = s1; } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } return s0; } function peg$parsestatement() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; s1 = peg$parsecmdComment(); if (s1 !== peg$FAILED) { s2 = []; if (peg$c99.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c100); } } while (s3 !== peg$FAILED) { s2.push(s3); if (peg$c99.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c100); } } } if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c101(s1); s0 = s1; } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parsecmdBlockWithExpression(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { s3 = peg$parseexpression(); if (s3 !== peg$FAILED) { s4 = peg$parse_(); if (s4 !== peg$FAILED) { s5 = peg$parseblock(); if (s5 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c102(s1, s3, s5); s0 = s1; } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parsecmdIf(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { s3 = peg$parseexpression(); if (s3 !== peg$FAILED) { s4 = peg$parse_(); if (s4 !== peg$FAILED) { s5 = peg$parseblock(); if (s5 !== peg$FAILED) { s6 = peg$parsecmdIfElse(); if (s6 === peg$FAILED) { s6 = peg$c77; } if (s6 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c103(s1, s3, s5, s6); s0 = s1; } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parsecmdDoPart1(); if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { s3 = peg$parseblock(); if (s3 !== peg$FAILED) { s4 = peg$parse_(); if (s4 !== peg$FAILED) { s5 = peg$parsecmdDoPart2(); if (s5 !== peg$FAILED) { s6 = peg$parse__(); if (s6 !== peg$FAILED) { s7 = peg$parseexpression(); if (s7 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c104(s1, s3, s5, s7); s0 = s1; } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parsecmdBlock(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { s3 = peg$parsenumber(); if (s3 !== peg$FAILED) { s4 = peg$parsetimes(); if (s4 === peg$FAILED) { s4 = peg$c77; } if (s4 !== peg$FAILED) { s5 = peg$parse_(); if (s5 !== peg$FAILED) { s6 = peg$parseblock(); if (s6 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c105(s1, s3, s6); s0 = s1; } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } } else { peg$currPos = s0; s0 = peg$c50; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parsecmdWithAssignment(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { s3 = peg$parsevariable(); if (s3 !== peg$FAILED) { s4 = peg$parse_(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 61) { s5 = peg$c106; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c107); } } if (s5 !== peg$FAILED) { s6 = peg$parse_(); if (s6 !== peg$FAILED) {