UNPKG

slv-utils

Version:

Utilities for working with SLV and DAT files.

1,850 lines (1,739 loc) 64.8 kB
/* * Generated by PEG.js 0.10.0. * * http://pegjs.org/ */ "use strict"; function peg$subclass(child, parent) { function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); } function peg$SyntaxError(message, expected, found, location) { this.message = message; this.expected = expected; this.found = found; this.location = location; this.name = "SyntaxError"; if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(this, peg$SyntaxError); } } peg$subclass(peg$SyntaxError, Error); peg$SyntaxError.buildMessage = function(expected, found) { var DESCRIBE_EXPECTATION_FNS = { literal: function(expectation) { return "\"" + literalEscape(expectation.text) + "\""; }, "class": function(expectation) { var escapedParts = "", i; for (i = 0; i < expectation.parts.length; i++) { escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]); } return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; }, any: function(expectation) { return "any character"; }, end: function(expectation) { return "end of input"; }, other: function(expectation) { return expectation.description; } }; function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } function literalEscape(s) { return s .replace(/\\/g, '\\\\') .replace(/"/g, '\\"') .replace(/\0/g, '\\0') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); } function classEscape(s) { return s .replace(/\\/g, '\\\\') .replace(/\]/g, '\\]') .replace(/\^/g, '\\^') .replace(/-/g, '\\-') .replace(/\0/g, '\\0') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); } function describeExpectation(expectation) { return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); } function describeExpected(expected) { var descriptions = new Array(expected.length), i, j; for (i = 0; i < expected.length; i++) { descriptions[i] = describeExpectation(expected[i]); } descriptions.sort(); if (descriptions.length > 0) { for (i = 1, j = 1; i < descriptions.length; i++) { if (descriptions[i - 1] !== descriptions[i]) { descriptions[j] = descriptions[i]; j++; } } descriptions.length = j; } switch (descriptions.length) { case 1: return descriptions[0]; case 2: return descriptions[0] + " or " + descriptions[1]; default: return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1]; } } function describeFound(found) { return found ? "\"" + literalEscape(found) + "\"" : "end of input"; } return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; }; function peg$parse(input, options) { options = options !== void 0 ? options : {}; var peg$FAILED = {}, peg$startRuleFunctions = { start: peg$parsestart }, peg$startRuleFunction = peg$parsestart, peg$c0 = "/*", peg$c1 = peg$literalExpectation("/*", false), peg$c2 = "if ", peg$c3 = peg$literalExpectation("if ", false), peg$c4 = function(r) { return r }, peg$c5 = function(a) { //console.log(`RECORD ${a.length}`) for (let i in a) { ////console.log(a[i]) //console.log(` V: ${a[i].value}; - ${a[i].type}`) } return a }, peg$c6 = " ", peg$c7 = peg$literalExpectation(" ", false), peg$c8 = function(n) { //console.log("number "+n.join('')) let number = n.join('') let value = parseFloat(n.join('')) value = isNaN(value) ? null : value return { type: "number", value } }, peg$c9 = "&", peg$c10 = peg$literalExpectation("&", false), peg$c11 = function(n) { let numbers = n.join('') // 1,8,2,.,4,4, ,5,6 =>182.44 56 let matrix = numbers.trim().replace(/\r/g, '').split('\n') let value = matrix.map((line) => { return line .trim() .split(' ') .map((x) => { let value = parseFloat(x) //console.log(`before ${value}`) value = isNaN(value) ? null : value ////console.log(`after ${value}`) return value }) }) if (value.length === 1) { value = value[0] } return { type: "arrayNumber", value } }, peg$c12 = function(s) { let value = s.join('') return { type: "string", value } }, peg$c13 = function(s) { let value = s.join('') return { type: "strings", value: value.split(' ') } }, peg$c14 = "!", peg$c15 = peg$literalExpectation("!", false), peg$c16 = /^[{}]/, peg$c17 = peg$classExpectation(["{", "}"], false, false), peg$c18 = function(b, level, comment) { let newLine = false if ((b.join('').indexOf('\n') != -1) || (location().start.column == 1)) { newLine = true } let headerLevel = 0 level = level.join('') if (level != '') { headerLevel = level.match(/!/g).length } return { type: "lineComment", header: headerLevel, value: comment.join(''), newLine } }, peg$c19 = "*/", peg$c20 = peg$literalExpectation("*/", false), peg$c21 = function(s) { return { type: "multylineComment", value: s.join('') } }, peg$c22 = function(s) { return s }, peg$c23 = "=", peg$c24 = peg$literalExpectation("=", false), peg$c25 = ";", peg$c26 = peg$literalExpectation(";", false), peg$c27 = function(b, lhs, rhs) { //console.log(`numeric LHS: ${lhs.join('')}`) ////console.log(`numeric RHS: ${rhs.join('')}`) let newLine = ((location().start.column == 1) || b.join('').match(/\n/)) ? true:false return { type: "numeric", value: { 'lhs': lhs.join(''), 'rhs': rhs.join(''), newLine } } }, peg$c28 = function(lhs, rhs) { //console.log('expr') return { type: "expression", value: { 'lhs': lhs.join(''), 'rhs': rhs.join('').replace(/\r/g, ''), 'newLine': location().start.column == 1 } } }, peg$c29 = function(b) { let newLine = ((location().start.column == 1) || b.join('').match(/\n/)) ? true:false return { type: "emptyNumeric", value: '', newLine } }, peg$c30 = /^[*]/, peg$c31 = peg$classExpectation(["*"], false, false), peg$c32 = function() { return { type: "string", value: "*" } }, peg$c33 = "if", peg$c34 = peg$literalExpectation("if", false), peg$c35 = "{", peg$c36 = peg$literalExpectation("{", false), peg$c37 = "}", peg$c38 = peg$literalExpectation("}", false), peg$c39 = function(cond, then, otherwise) { ////console.log("CondExpr") return { type: "conditionExpression", condition: cond, then: then, else: otherwise } }, peg$c40 = "(", peg$c41 = peg$literalExpectation("(", false), peg$c42 = ")", peg$c43 = peg$literalExpectation(")", false), peg$c44 = function(lhs, sign, rhs) { //console.log('Cond') //console.log(`conditional LHS: ${lhs.join('')}`) //console.log(`conditional RHS: ${rhs.join('')}`) return { lhs: lhs.join(''), rhs: rhs.join(''), sign: sign.join('') } }, peg$c45 = function(result) { ////console.log('branch') return result }, peg$c46 = "else", peg$c47 = peg$literalExpectation("else", false), peg$c48 = function(value) { return value }, peg$c49 = "\r", peg$c50 = peg$literalExpectation("\r", false), peg$c51 = "\n", peg$c52 = peg$literalExpectation("\n", false), peg$c53 = function(s) { return s.join('') }, peg$c54 = /^[A-Za-z_0-9]/, peg$c55 = peg$classExpectation([["A", "Z"], ["a", "z"], "_", ["0", "9"]], false, false), peg$c56 = /^[[\]]/, peg$c57 = peg$classExpectation(["[", "]"], false, false), peg$c58 = /^[0-9eE.+\-]/, peg$c59 = peg$classExpectation([["0", "9"], "e", "E", ".", "+", "-"], false, false), peg$c60 = /^[*\/+-\^%]/, peg$c61 = peg$classExpectation(["*", "/", ["+", "^"], "%"], false, false), peg$c62 = /^[[\]()]/, peg$c63 = peg$classExpectation(["[", "]", "(", ")"], false, false), peg$c64 = /^[?!.,$@~\u2116%&:;<>\/|\\\uFFFD#]/, peg$c65 = peg$classExpectation(["?", "!", ".", ",", "$", "@", "~", "\u2116", "%", "&", ":", ";", "<", ">", "/", "|", "\\", "\uFFFD", "#"], false, false), peg$c66 = /^['"`]/, peg$c67 = peg$classExpectation(["'", "\"", "`"], false, false), peg$c68 = /^[<>=!]/, peg$c69 = peg$classExpectation(["<", ">", "=", "!"], false, false), peg$c70 = /^[0-9 .,+\-*\^\/A-Za-z()[\]_\r\n]/, peg$c71 = peg$classExpectation([["0", "9"], " ", ".", ",", "+", "-", "*", "^", "/", ["A", "Z"], ["a", "z"], "(", ")", "[", "]", "_", "\r", "\n"], false, false), peg$c72 = "//", peg$c73 = peg$literalExpectation("//", false), peg$c74 = "<?NE?>", peg$c75 = peg$literalExpectation("<?NE?>", false), peg$c76 = "<?NB?>", peg$c77 = peg$literalExpectation("<?NB?>", false), peg$c78 = "", peg$c79 = "#dbs#", peg$c80 = peg$literalExpectation("#dbs#", false), peg$c81 = function() { return { type: "emptyValue", value: null } }, peg$c82 = function() { return { "type": "string", "value": "#dbs#" } }, peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], 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$savedPos, peg$currPos); } function location() { return peg$computeLocation(peg$savedPos, peg$currPos); } function expected(description, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) throw peg$buildStructuredError( [peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location ); } function error(message, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) throw peg$buildSimpleError(message, location); } function peg$literalExpectation(text, ignoreCase) { return { type: "literal", text: text, ignoreCase: ignoreCase }; } function peg$classExpectation(parts, inverted, ignoreCase) { return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; } function peg$anyExpectation() { return { type: "any" }; } function peg$endExpectation() { return { type: "end" }; } function peg$otherExpectation(description) { return { type: "other", description: description }; } function peg$computePosDetails(pos) { var details = peg$posDetailsCache[pos], p; if (details) { return details; } else { p = pos - 1; while (!peg$posDetailsCache[p]) { p--; } details = peg$posDetailsCache[p]; details = { line: details.line, column: details.column }; while (p < pos) { if (input.charCodeAt(p) === 10) { details.line++; details.column = 1; } else { details.column++; } p++; } peg$posDetailsCache[pos] = details; return details; } } function peg$computeLocation(startPos, endPos) { var startPosDetails = peg$computePosDetails(startPos), endPosDetails = peg$computePosDetails(endPos); return { start: { offset: startPos, line: startPosDetails.line, column: startPosDetails.column }, end: { offset: endPos, line: endPosDetails.line, column: endPosDetails.column } }; } 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$buildSimpleError(message, location) { return new peg$SyntaxError(message, null, null, location); } function peg$buildStructuredError(expected, found, location) { return new peg$SyntaxError( peg$SyntaxError.buildMessage(expected, found), expected, found, location ); } function peg$parsestart() { var s0; s0 = peg$parseoneValue(); if (s0 === peg$FAILED) { s0 = peg$parserecord(); if (s0 === peg$FAILED) { s0 = peg$parsefamilySign(); if (s0 === peg$FAILED) { s0 = peg$parseemptyValue(); } } } return s0; } function peg$parseoneValue() { var s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$currPos; peg$silentFails++; if (input.substr(peg$currPos, 2) === peg$c0) { s2 = peg$c0; peg$currPos += 2; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c1); } } if (s2 === peg$FAILED) { if (input.substr(peg$currPos, 3) === peg$c2) { s2 = peg$c2; peg$currPos += 3; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } if (s2 === peg$FAILED) { s2 = peg$parseemptyValueEndDBS(); } } peg$silentFails--; if (s2 === peg$FAILED) { s1 = void 0; } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { s2 = peg$parsesimpleDataTypes(); if (s2 !== peg$FAILED) { s3 = peg$currPos; peg$silentFails++; s4 = peg$parsesimpleDataTypes(); peg$silentFails--; if (s4 === peg$FAILED) { s3 = void 0; } else { peg$currPos = s3; s3 = peg$FAILED; } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c4(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parserecord() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$currPos; peg$silentFails++; s2 = peg$parseemptyValueEndDBS(); peg$silentFails--; if (s2 === peg$FAILED) { s1 = void 0; } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parsecondExpression(); if (s3 === peg$FAILED) { s3 = peg$parsemultylineComment(); if (s3 === peg$FAILED) { s3 = peg$parsenumeric(); if (s3 === peg$FAILED) { s3 = peg$parsemathExpression(); if (s3 === peg$FAILED) { s3 = peg$parsevariable(); if (s3 === peg$FAILED) { s3 = peg$parsesentence(); if (s3 === peg$FAILED) { s3 = peg$parselineComment(); if (s3 === peg$FAILED) { s3 = peg$parseemptyNumeric(); if (s3 === peg$FAILED) { s3 = peg$parsenumbers(); } } } } } } } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsecondExpression(); if (s3 === peg$FAILED) { s3 = peg$parsemultylineComment(); if (s3 === peg$FAILED) { s3 = peg$parsenumeric(); if (s3 === peg$FAILED) { s3 = peg$parsemathExpression(); if (s3 === peg$FAILED) { s3 = peg$parsevariable(); if (s3 === peg$FAILED) { s3 = peg$parsesentence(); if (s3 === peg$FAILED) { s3 = peg$parselineComment(); if (s3 === peg$FAILED) { s3 = peg$parseemptyNumeric(); if (s3 === peg$FAILED) { s3 = peg$parsenumbers(); } } } } } } } } } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { s3 = peg$parsedbsPattern(); if (s3 === peg$FAILED) { s3 = null; } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c5(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsenumber() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = []; s2 = peg$parsedigits(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsedigits(); } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { s2 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 32) { s3 = peg$c6; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c7); } } peg$silentFails--; if (s3 === peg$FAILED) { s2 = void 0; } else { peg$currPos = s2; s2 = peg$FAILED; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c8(s1); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsenumbers() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$currPos; peg$silentFails++; s2 = peg$parseemptyValueEndDBS(); peg$silentFails--; if (s2 === peg$FAILED) { s1 = void 0; } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parsedigits(); if (s3 === peg$FAILED) { s3 = peg$parsespace(); if (s3 === peg$FAILED) { s3 = peg$parsebreak(); } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsedigits(); if (s3 === peg$FAILED) { s3 = peg$parsespace(); if (s3 === peg$FAILED) { s3 = peg$parsebreak(); } } } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 38) { s3 = peg$c9; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c10); } } if (s3 === peg$FAILED) { s3 = null; } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c11(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsevariable() { var s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; s1 = []; s2 = peg$parsevariableName(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsevariableName(); } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { s2 = peg$currPos; peg$silentFails++; s3 = peg$currPos; s4 = []; s5 = peg$parsebreak(); if (s5 === peg$FAILED) { s5 = peg$parsespace(); } if (s5 !== peg$FAILED) { while (s5 !== peg$FAILED) { s4.push(s5); s5 = peg$parsebreak(); if (s5 === peg$FAILED) { s5 = peg$parsespace(); } } } else { s4 = peg$FAILED; } if (s4 !== peg$FAILED) { s5 = []; s6 = peg$parsevariableName(); if (s6 !== peg$FAILED) { while (s6 !== peg$FAILED) { s5.push(s6); s6 = peg$parsevariableName(); } } else { s5 = peg$FAILED; } if (s5 !== peg$FAILED) { s4 = [s4, s5]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } peg$silentFails--; if (s3 === peg$FAILED) { s2 = void 0; } else { peg$currPos = s2; s2 = peg$FAILED; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c12(s1); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsesentence() { var s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$currPos; peg$silentFails++; s2 = peg$currPos; s3 = []; s4 = peg$parsespace(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parsespace(); } if (s3 !== peg$FAILED) { s4 = peg$parsesignLineComment(); if (s4 !== peg$FAILED) { s3 = [s3, s4]; s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } if (s2 === peg$FAILED) { s2 = peg$parseemptyValueEndDBS(); } peg$silentFails--; if (s2 === peg$FAILED) { s1 = void 0; } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parsevariableName(); if (s3 === peg$FAILED) { s3 = peg$parsedigits(); if (s3 === peg$FAILED) { s3 = peg$parseotherSings(); if (s3 === peg$FAILED) { s3 = peg$parsequoteSings(); if (s3 === peg$FAILED) { s3 = peg$parsespace(); if (s3 === peg$FAILED) { s3 = peg$parsebrackets(); } } } } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsevariableName(); if (s3 === peg$FAILED) { s3 = peg$parsedigits(); if (s3 === peg$FAILED) { s3 = peg$parseotherSings(); if (s3 === peg$FAILED) { s3 = peg$parsequoteSings(); if (s3 === peg$FAILED) { s3 = peg$parsespace(); if (s3 === peg$FAILED) { s3 = peg$parsebrackets(); } } } } } } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c13(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parselineComment() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = []; s2 = peg$parsebreak(); if (s2 === peg$FAILED) { s2 = peg$parsespace(); } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsebreak(); if (s2 === peg$FAILED) { s2 = peg$parsespace(); } } if (s1 !== peg$FAILED) { s2 = peg$parsesignLineComment(); if (s2 !== peg$FAILED) { s3 = []; if (input.charCodeAt(peg$currPos) === 33) { s4 = peg$c14; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c15); } } while (s4 !== peg$FAILED) { s3.push(s4); if (input.charCodeAt(peg$currPos) === 33) { s4 = peg$c14; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c15); } } } if (s3 !== peg$FAILED) { s4 = []; s5 = peg$parsevariableName(); if (s5 === peg$FAILED) { s5 = peg$parsedigits(); if (s5 === peg$FAILED) { s5 = peg$parseotherSings(); if (s5 === peg$FAILED) { s5 = peg$parsebrackets(); if (s5 === peg$FAILED) { if (peg$c16.test(input.charAt(peg$currPos))) { s5 = input.charAt(peg$currPos); peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c17); } } if (s5 === peg$FAILED) { s5 = peg$parsequoteSings(); if (s5 === peg$FAILED) { s5 = peg$parsespace(); if (s5 === peg$FAILED) { s5 = peg$parsemathSings(); } } } } } } } while (s5 !== peg$FAILED) { s4.push(s5); s5 = peg$parsevariableName(); if (s5 === peg$FAILED) { s5 = peg$parsedigits(); if (s5 === peg$FAILED) { s5 = peg$parseotherSings(); if (s5 === peg$FAILED) { s5 = peg$parsebrackets(); if (s5 === peg$FAILED) { if (peg$c16.test(input.charAt(peg$currPos))) { s5 = input.charAt(peg$currPos); peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c17); } } if (s5 === peg$FAILED) { s5 = peg$parsequoteSings(); if (s5 === peg$FAILED) { s5 = peg$parsespace(); if (s5 === peg$FAILED) { s5 = peg$parsemathSings(); } } } } } } } } if (s4 !== peg$FAILED) { s5 = peg$parsebreak(); if (s5 === peg$FAILED) { s5 = null; } if (s5 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c18(s1, s3, s4); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsemultylineComment() { var s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = []; s2 = peg$parsespace(); if (s2 === peg$FAILED) { s2 = peg$parsebreak(); } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsespace(); if (s2 === peg$FAILED) { s2 = peg$parsebreak(); } } if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c0) { s2 = peg$c0; peg$currPos += 2; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c1); } } if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parsemultyCommentSymbolsRule(); if (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parsemultyCommentSymbolsRule(); } } else { s3 = peg$FAILED; } if (s3 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c19) { s4 = peg$c19; peg$currPos += 2; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c20); } } if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c21(s3); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsemultyCommentSymbolsRule() { var s0, s1, s2; s0 = peg$currPos; s1 = peg$currPos; peg$silentFails++; if (input.substr(peg$currPos, 2) === peg$c19) { s2 = peg$c19; peg$currPos += 2; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c20); } } peg$silentFails--; if (s2 === peg$FAILED) { s1 = void 0; } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { s2 = peg$parsevariableName(); if (s2 === peg$FAILED) { s2 = peg$parsedigits(); if (s2 === peg$FAILED) { s2 = peg$parseotherSings(); if (s2 === peg$FAILED) { s2 = peg$parsebrackets(); if (s2 === peg$FAILED) { if (peg$c16.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c17); } } if (s2 === peg$FAILED) { s2 = peg$parsequoteSings(); if (s2 === peg$FAILED) { s2 = peg$parsespace(); if (s2 === peg$FAILED) { s2 = peg$parsemathSings(); if (s2 === peg$FAILED) { s2 = peg$parsebreak(); } } } } } } } } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c22(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsenumeric() { var s0, s1, s2, s3, s4, s5, s6, s7, s8; s0 = peg$currPos; s1 = []; s2 = peg$parsebreak(); if (s2 === peg$FAILED) { s2 = peg$parsespace(); } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsebreak(); if (s2 === peg$FAILED) { s2 = peg$parsespace(); } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parsevariableName(); if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsevariableName(); } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parsespace(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parsespace(); } if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 61) { s4 = peg$c23; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c24); } } if (s4 !== peg$FAILED) { s5 = []; s6 = peg$parsespace(); while (s6 !== peg$FAILED) { s5.push(s6); s6 = peg$parsespace(); } if (s5 !== peg$FAILED) { s6 = []; s7 = peg$parsedigits(); if (s7 !== peg$FAILED) { while (s7 !== peg$FAILED) { s6.push(s7); s7 = peg$parsedigits(); } } else { s6 = peg$FAILED; } if (s6 !== peg$FAILED) { s7 = []; s8 = peg$parsebreak(); if (s8 === peg$FAILED) { s8 = peg$parsespace(); } while (s8 !== peg$FAILED) { s7.push(s8); s8 = peg$parsebreak(); if (s8 === peg$FAILED) { s8 = peg$parsespace(); } } if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { s8 = peg$c25; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c26); } } if (s8 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c27(s1, s2, s6); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsemathExpression() { var s0, s1, s2, s3, s4, s5, s6, s7, s8; s0 = peg$currPos; s1 = []; s2 = peg$parsebreak(); if (s2 === peg$FAILED) { s2 = peg$parsespace(); } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsebreak(); if (s2 === peg$FAILED) { s2 = peg$parsespace(); } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parsevariableName(); if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsevariableName(); } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parsebreak(); if (s4 === peg$FAILED) { s4 = peg$parsespace(); } while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parsebreak(); if (s4 === peg$FAILED) { s4 = peg$parsespace(); } } if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 61) { s4 = peg$c23; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c24); } } if (s4 !== peg$FAILED) { s5 = []; s6 = peg$parseexpressionSymbols(); if (s6 !== peg$FAILED) { while (s6 !== peg$FAILED) { s5.push(s6); s6 = peg$parseexpressionSymbols(); } } else { s5 = peg$FAILED; } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { s6 = peg$c25; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c26); } } if (s6 !== peg$FAILED) { s7 = []; s8 = peg$parsebreak(); if (s8 === peg$FAILED) { s8 = peg$parsespace(); } while (s8 !== peg$FAILED) { s7.push(s8); s8 = peg$parsebreak(); if (s8 === peg$FAILED) { s8 = peg$parsespace(); } } if (s7 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c28(s2, s5); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseemptyNumeric() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parsebreak(); if (s2 === peg$FAILED) { s2 = peg$parsespace(); } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsebreak(); if (s2 === peg$FAILED) { s2 = peg$parsespace(); } } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { s2 = peg$c25; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c26); } } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c29(s1); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsefamilySign() { var s0, s1; s0 = peg$currPos; if (peg$c30.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c31); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c32(); } s0 = s1; return s0; } function peg$parsecondExpression() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; s0 = peg$currPos; s1 = []; s2 = peg$parsebreak(); if (s2 === peg$FAILED) { s2 = peg$parsespace(); } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsebreak(); if (s2 === peg$FAILED) { s2 = peg$parsespace(); } } if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c33) { s2 = peg$c33; peg$currPos += 2; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c34); } } if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parsespace(); if (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parsespace(); } } else { s3 = peg$FAILED; } if (s3 !== peg$FAILED) { s4 = peg$parsecondition(); if (s4 !== peg$FAILED) { s5 = []; s6 = peg$parsebreak(); if (s6 === peg$FAILED) { s6 = peg$parsespace(); } while (s6 !== peg$FAILED) { s5.push(s6); s6 = peg$parsebreak(); if (s6 === peg$FAILED) { s6 = peg$parsespace(); } } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 123) { s6 = peg$c35; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c36); } } if (s6 !== peg$FAILED) { s7 = []; s8 = peg$parsebranchPattern(); if (s8 !== peg$FAILED) { while (s8 !== peg$FAILED) { s7.push(s8); s8 = peg$parsebranchPattern(); } } else { s7 = peg$FAILED; } if (s7 !== peg$FAILED) { s8 = []; s9 = peg$parsebreak(); if (s9 === peg$FAILED) { s9 = peg$parsespace(); } while (s9 !== peg$FAILED) { s8.push(s9); s9 = peg$parsebreak(); if (s9 === peg$FAILED) { s9 = peg$parsespace(); } } if (s8 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s9 = peg$c37; peg$currPos++; } else { s9 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c38); } } if (s9 !== peg$FAILED) { s10 = []; s11 = peg$parseotherwiseBranch(); if (s11 !== peg$FAILED) { while (s11 !== peg$FAILED) { s10.push(s11); s11 = peg$parseotherwiseBranch(); } } else { s10 = peg$FAILED; } if (s10 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c39(s4, s7, s10); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsecondition() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10; s0 = peg$currPos; s1 = []; s2 = peg$parsebreak(); if (s2 === peg$FAILED) { s2 = peg$parsespace(); } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsebreak(); if (s2 === peg$FAILED) { s2 = peg$parsespace(); } } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 40) { s2 = peg$c40; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c41); } } if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parsespace(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parsespace(); } if (s3 !== peg$FAILED) { s4 = []; s5 = peg$parsevariableName(); if (s5 !== peg$FAILED) { while (s5 !== peg$FAILED) { s4.push(s5); s5 = peg$parsevariableName(); } } else { s4 = peg$FAILED; } if (s4 !== peg$FAILED) { s5 = []; s6 = peg$parsespace(); while (s6 !== peg$FAILED) { s5.push(s6); s6 = peg$parsespace(); } if (s5 !== peg$FAILED) { s6 = []; s7 = peg$parsecomparisonSings(); if (s7 !== peg$FAILED) { while (s7 !== peg$FAILED) { s6.push(s7); s7 = peg$parsecomparisonSings(); } } else { s6 = peg$FAILED; } if (s6 !== peg$FAILED) { s7 = []; s8 = peg$parsespace(); while (s8 !== peg$FAILED) { s7.push(s8); s8 = peg$parsespace(); } if (s7 !== peg$FAILED) { s8 = []; s9 = peg$parsevariableName(); if (s9 !== peg$FAILED) { while (s9 !== peg$FAILED) { s8.push(s9); s9 = peg$parsevariableName(); } } else { s8 = peg$FAILED; } if (s8 !== peg$FAILED) { s9 = []; s10 = peg$parsespace(); while (s10 !== peg$FAILED) { s9.push(s10); s10 = peg$parsespace(); } if (s9 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { s10 = peg$c42; peg$currPos++; } else { s10 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c43); } } if (s10 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c44(s4, s6, s8); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsebranchPattern() { var s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$currPos; peg$silentFails++; s2 = peg$currPos; s3 = []; s4 = peg$parsebreak(); if (s4 === peg$FAILED) { s4 = peg$parsespace(); } while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parsebreak(); if (s4 === peg$FAILED) { s4 = peg$parsespace(); } } if (s3 !== peg$FAILED) {