├── bin └── tscn2json ├── src ├── browser.js ├── cli.js ├── index.js └── parser.js ├── package.json ├── LICENSE ├── README.md ├── .gitignore └── grammar └── tscn.pegjs /bin/tscn2json: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('../src/cli')(process.argv); -------------------------------------------------------------------------------- /src/browser.js: -------------------------------------------------------------------------------- 1 | const parser = require('./parser'); 2 | 3 | module.exports = async function convert(inputData) { 4 | if (!inputData) { 5 | throw Error(`'inputData' is empty`); 6 | } 7 | return parser.parse(inputData); 8 | } -------------------------------------------------------------------------------- /src/cli.js: -------------------------------------------------------------------------------- 1 | const convert = require('./'); 2 | 3 | module.exports = async argv => { 4 | const input = argv[2]; 5 | const output = argv[3]; 6 | 7 | if (!input) { 8 | console.log('Usage: tscn2json input [output]'); 9 | return; 10 | } 11 | 12 | try { 13 | const res = await convert({ input, output }); 14 | if (res) { 15 | console.log(JSON.stringify(res, null, 2)); 16 | } 17 | } catch(e) { 18 | console.error(e); 19 | } 20 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tscn2json", 3 | "version": "1.0.0", 4 | "description": "Tool to convert Godot tscn files to json", 5 | "main": "src/index.js", 6 | "browser": "src/browser.js", 7 | "keywords": [ 8 | "godot", 9 | "tscn", 10 | "parser", 11 | "cli" 12 | ], 13 | "author": { 14 | "name": "SAPer", 15 | "email": "gsaper@gmail.com" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/saperio/tscn2json.git" 20 | }, 21 | "homepage": "https://github.com/saperio/tscn2json", 22 | "bin": { 23 | "tscn2json": "bin/tscn2json" 24 | }, 25 | "files": [ 26 | "bin/**", 27 | "src/**" 28 | ], 29 | "scripts": { 30 | "generate-parser": "pegjs -o src/parser.js grammar/tscn.pegjs" 31 | }, 32 | "license": "MIT", 33 | "devDependencies": { 34 | "pegjs": "^0.10.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 SAPer (gsaper@gmail.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const parser = require('./parser'); 3 | 4 | module.exports = async function convert(options) { 5 | const { input, inputData, output } = options; 6 | 7 | if (!input && !inputData) { 8 | throw Error(`Both 'input' and 'inputData' are empty`); 9 | } 10 | 11 | const rawInput = inputData ? inputData : await readFile(input); 12 | const rawOutput = parser.parse(rawInput); 13 | 14 | if (!output) { 15 | return rawOutput; 16 | } 17 | 18 | await writeFile(output, JSON.stringify(rawOutput, null, 2)); 19 | } 20 | 21 | async function readFile(filename) { 22 | return new Promise((resolve, reject) => { 23 | fs.readFile(filename, (err, data) => { 24 | if (err) { 25 | reject(err); 26 | return; 27 | } 28 | 29 | resolve(data.toString()); 30 | }); 31 | }); 32 | } 33 | 34 | async function writeFile(filename, data) { 35 | return new Promise((resolve, reject) => { 36 | fs.writeFile(filename, data, err => { 37 | if (err) { 38 | reject(err); 39 | return; 40 | } 41 | 42 | resolve(); 43 | }); 44 | }); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | tscn2json - tool to convert [Godot](https://godotengine.org) .tscn files to json format, with command line and programmatic interfaces. Based on parser, generated with [PEG.js](https://pegjs.org), grammar can be found here: [grammar/tscn.pegjs](grammar/tscn.pegjs) 2 | ## Installation 3 | To use the tscn2json command, install globally: 4 | 5 | `npm install -g tscn2json` 6 | 7 | To use the JavaScript API, install locally: 8 | 9 | `npm install --save tscn2json` 10 | 11 | ## Command Line usage 12 | Usage is simple: `tscn2json input [output]` 13 | 14 | `input` - input tscn file, `output` - output json file, if omitted, result will be printed to `stdout`. 15 | 16 | Example: ```tscn2json scene.tscn parsed-scene.json``` 17 | ## Programmatic usage 18 | It's pretty easy to use it. `tscn2json` module exports one async function, you just have to include it and call with `options` object: 19 | ```javascript 20 | const convert = require('tscn2json'); 21 | 22 | (async () => { 23 | await convert({ 24 | input: 'scene.tscn', 25 | output: 'parsed-scene.json' 26 | }); 27 | })(); 28 | ``` 29 | Options can be 30 | * `options.input` - input file name 31 | * `options.inputData` - instead of file name, you can provide string with tscn data 32 | * `options.output` - output file name, if omitted, resulted json will be returned 33 | 34 | Here example with return json data: 35 | ```javascript 36 | const res = await convert({ input: 'scene.tscn' }); 37 | ``` -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /grammar/tscn.pegjs: -------------------------------------------------------------------------------- 1 | // PEG grammar for Godot .tscn files 2 | 3 | scene 4 | = descriptor:entity 5 | entities:(ws entity:entity ws { return entity; })* 6 | { return { descriptor: descriptor, entities: entities } } 7 | 8 | entity 9 | = begin_entity ws 10 | type:name ws 11 | heading:props 12 | end_entity ws 13 | props:props 14 | { return props ? 15 | { type: type, heading: heading, props: props } : 16 | { type: type, heading: heading } 17 | } 18 | 19 | props 20 | = props:( 21 | head:member 22 | tail:(ws m:member { return m; })* 23 | { 24 | var result = {}; 25 | 26 | [head].concat(tail).forEach(function(element) { 27 | result[element.name] = element.value; 28 | }); 29 | 30 | return result; 31 | } 32 | )? 33 | { return props; } 34 | 35 | member 36 | = name:name name_separator value:value { 37 | return { name: name, value: value }; 38 | } 39 | 40 | value 41 | = false 42 | / null 43 | / true 44 | / number 45 | / string 46 | / internal 47 | / array 48 | / json 49 | 50 | // Array 51 | array 52 | = begin_array 53 | values:value_list? 54 | end_array 55 | { return values !== null ? values : []; } 56 | 57 | value_list 58 | = head:value 59 | tail:(value_separator v:value { return v; })* 60 | { return [head].concat(tail); } 61 | 62 | // JSON 63 | begin_json = ws "{" ws 64 | end_json = ws "}" ws 65 | json_name 66 | = string 67 | / number 68 | json_name_separator = ws ":" ws 69 | json_value_separator = ws "," ws 70 | json 71 | = begin_json 72 | members:( 73 | head:json_member 74 | tail:(json_value_separator m:json_member { return m; })* 75 | { 76 | var result = {}; 77 | [head].concat(tail).forEach(function(element) { 78 | result[element.name] = element.value; 79 | }); 80 | return result; 81 | } 82 | )? 83 | end_json 84 | { return members !== null ? members: {}; } 85 | 86 | json_member 87 | = name:json_name json_name_separator value:value { 88 | return { name: name, value: value }; 89 | } 90 | 91 | // Godot internal types: Color, ExtResource, etc. 92 | internal 93 | = type:name 94 | "(" ws 95 | params:value_list? ws 96 | ")" 97 | { return { type: type, params: params } } 98 | 99 | // Common 100 | false 101 | = "false" { return false; } 102 | 103 | true 104 | = "true" { return true; } 105 | 106 | null 107 | = "null" { return null; } 108 | 109 | begin_array 110 | = ws "[" ws 111 | 112 | end_array 113 | = ws "]" ws 114 | 115 | begin_entity 116 | = ws "[" ws 117 | 118 | end_entity 119 | = ws "]" ws 120 | 121 | name_separator 122 | = ws "=" ws 123 | 124 | value_separator 125 | = ws "," ws 126 | 127 | ws "whitespace" 128 | = [ \t\n\r]* 129 | 130 | // Numbers 131 | number "number" 132 | = minus? int frac? exp? { return parseFloat(text()); } 133 | 134 | decimal_point 135 | = "." 136 | 137 | digit1_9 138 | = [1-9] 139 | 140 | e 141 | = [eE] 142 | 143 | exp 144 | = e (minus / plus)? DIGIT+ 145 | 146 | frac 147 | = decimal_point DIGIT+ 148 | 149 | int 150 | = zero / (digit1_9 DIGIT*) 151 | 152 | minus 153 | = "-" 154 | 155 | plus 156 | = "+" 157 | 158 | zero 159 | = "0" 160 | 161 | // Strings 162 | name 163 | = chars:[/_a-z0-9-]i* { return chars.join(''); } 164 | 165 | string "string" 166 | = quotation_mark chars:char* quotation_mark { return chars.join(''); } 167 | 168 | char 169 | = unescaped 170 | / escape 171 | sequence:( 172 | '"' 173 | / "\\" 174 | / "/" 175 | / "b" { return "\b"; } 176 | / "f" { return "\f"; } 177 | / "n" { return "\n"; } 178 | / "r" { return "\r"; } 179 | / "t" { return "\t"; } 180 | / "u" digits:$(HEXDIG HEXDIG HEXDIG HEXDIG) { 181 | return String.fromCharCode(parseInt(digits, 16)); 182 | } 183 | ) 184 | { return sequence; } 185 | 186 | escape 187 | = "\\" 188 | 189 | quotation_mark 190 | = '"' 191 | 192 | unescaped 193 | = [^\0-\x1F\x22\x5C] 194 | 195 | DIGIT 196 | = [0-9] 197 | 198 | HEXDIG 199 | = [0-9a-f]i -------------------------------------------------------------------------------- /src/parser.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by PEG.js 0.10.0. 3 | * 4 | * http://pegjs.org/ 5 | */ 6 | 7 | "use strict"; 8 | 9 | function peg$subclass(child, parent) { 10 | function ctor() { this.constructor = child; } 11 | ctor.prototype = parent.prototype; 12 | child.prototype = new ctor(); 13 | } 14 | 15 | function peg$SyntaxError(message, expected, found, location) { 16 | this.message = message; 17 | this.expected = expected; 18 | this.found = found; 19 | this.location = location; 20 | this.name = "SyntaxError"; 21 | 22 | if (typeof Error.captureStackTrace === "function") { 23 | Error.captureStackTrace(this, peg$SyntaxError); 24 | } 25 | } 26 | 27 | peg$subclass(peg$SyntaxError, Error); 28 | 29 | peg$SyntaxError.buildMessage = function(expected, found) { 30 | var DESCRIBE_EXPECTATION_FNS = { 31 | literal: function(expectation) { 32 | return "\"" + literalEscape(expectation.text) + "\""; 33 | }, 34 | 35 | "class": function(expectation) { 36 | var escapedParts = "", 37 | i; 38 | 39 | for (i = 0; i < expectation.parts.length; i++) { 40 | escapedParts += expectation.parts[i] instanceof Array 41 | ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) 42 | : classEscape(expectation.parts[i]); 43 | } 44 | 45 | return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; 46 | }, 47 | 48 | any: function(expectation) { 49 | return "any character"; 50 | }, 51 | 52 | end: function(expectation) { 53 | return "end of input"; 54 | }, 55 | 56 | other: function(expectation) { 57 | return expectation.description; 58 | } 59 | }; 60 | 61 | function hex(ch) { 62 | return ch.charCodeAt(0).toString(16).toUpperCase(); 63 | } 64 | 65 | function literalEscape(s) { 66 | return s 67 | .replace(/\\/g, '\\\\') 68 | .replace(/"/g, '\\"') 69 | .replace(/\0/g, '\\0') 70 | .replace(/\t/g, '\\t') 71 | .replace(/\n/g, '\\n') 72 | .replace(/\r/g, '\\r') 73 | .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) 74 | .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); 75 | } 76 | 77 | function classEscape(s) { 78 | return s 79 | .replace(/\\/g, '\\\\') 80 | .replace(/\]/g, '\\]') 81 | .replace(/\^/g, '\\^') 82 | .replace(/-/g, '\\-') 83 | .replace(/\0/g, '\\0') 84 | .replace(/\t/g, '\\t') 85 | .replace(/\n/g, '\\n') 86 | .replace(/\r/g, '\\r') 87 | .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) 88 | .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); 89 | } 90 | 91 | function describeExpectation(expectation) { 92 | return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); 93 | } 94 | 95 | function describeExpected(expected) { 96 | var descriptions = new Array(expected.length), 97 | i, j; 98 | 99 | for (i = 0; i < expected.length; i++) { 100 | descriptions[i] = describeExpectation(expected[i]); 101 | } 102 | 103 | descriptions.sort(); 104 | 105 | if (descriptions.length > 0) { 106 | for (i = 1, j = 1; i < descriptions.length; i++) { 107 | if (descriptions[i - 1] !== descriptions[i]) { 108 | descriptions[j] = descriptions[i]; 109 | j++; 110 | } 111 | } 112 | descriptions.length = j; 113 | } 114 | 115 | switch (descriptions.length) { 116 | case 1: 117 | return descriptions[0]; 118 | 119 | case 2: 120 | return descriptions[0] + " or " + descriptions[1]; 121 | 122 | default: 123 | return descriptions.slice(0, -1).join(", ") 124 | + ", or " 125 | + descriptions[descriptions.length - 1]; 126 | } 127 | } 128 | 129 | function describeFound(found) { 130 | return found ? "\"" + literalEscape(found) + "\"" : "end of input"; 131 | } 132 | 133 | return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; 134 | }; 135 | 136 | function peg$parse(input, options) { 137 | options = options !== void 0 ? options : {}; 138 | 139 | var peg$FAILED = {}, 140 | 141 | peg$startRuleFunctions = { scene: peg$parsescene }, 142 | peg$startRuleFunction = peg$parsescene, 143 | 144 | peg$c0 = function(descriptor, entity) { return entity; }, 145 | peg$c1 = function(descriptor, entities) { return { descriptor: descriptor, entities: entities } }, 146 | peg$c2 = function(type, heading, props) { return props ? 147 | { type: type, heading: heading, props: props } : 148 | { type: type, heading: heading } 149 | }, 150 | peg$c3 = function(head, m) { return m; }, 151 | peg$c4 = function(head, tail) { 152 | var result = {}; 153 | 154 | [head].concat(tail).forEach(function(element) { 155 | result[element.name] = element.value; 156 | }); 157 | 158 | return result; 159 | }, 160 | peg$c5 = function(props) { return props; }, 161 | peg$c6 = function(name, value) { 162 | return { name: name, value: value }; 163 | }, 164 | peg$c7 = function(values) { return values !== null ? values : []; }, 165 | peg$c8 = function(head, v) { return v; }, 166 | peg$c9 = function(head, tail) { return [head].concat(tail); }, 167 | peg$c10 = "{", 168 | peg$c11 = peg$literalExpectation("{", false), 169 | peg$c12 = "}", 170 | peg$c13 = peg$literalExpectation("}", false), 171 | peg$c14 = ":", 172 | peg$c15 = peg$literalExpectation(":", false), 173 | peg$c16 = ",", 174 | peg$c17 = peg$literalExpectation(",", false), 175 | peg$c18 = function(head, tail) { 176 | var result = {}; 177 | [head].concat(tail).forEach(function(element) { 178 | result[element.name] = element.value; 179 | }); 180 | return result; 181 | }, 182 | peg$c19 = function(members) { return members !== null ? members: {}; }, 183 | peg$c20 = "(", 184 | peg$c21 = peg$literalExpectation("(", false), 185 | peg$c22 = ")", 186 | peg$c23 = peg$literalExpectation(")", false), 187 | peg$c24 = function(type, params) { return { type: type, params: params } }, 188 | peg$c25 = "false", 189 | peg$c26 = peg$literalExpectation("false", false), 190 | peg$c27 = function() { return false; }, 191 | peg$c28 = "true", 192 | peg$c29 = peg$literalExpectation("true", false), 193 | peg$c30 = function() { return true; }, 194 | peg$c31 = "null", 195 | peg$c32 = peg$literalExpectation("null", false), 196 | peg$c33 = function() { return null; }, 197 | peg$c34 = "[", 198 | peg$c35 = peg$literalExpectation("[", false), 199 | peg$c36 = "]", 200 | peg$c37 = peg$literalExpectation("]", false), 201 | peg$c38 = "=", 202 | peg$c39 = peg$literalExpectation("=", false), 203 | peg$c40 = peg$otherExpectation("whitespace"), 204 | peg$c41 = /^[ \t\n\r]/, 205 | peg$c42 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false), 206 | peg$c43 = peg$otherExpectation("number"), 207 | peg$c44 = function() { return parseFloat(text()); }, 208 | peg$c45 = ".", 209 | peg$c46 = peg$literalExpectation(".", false), 210 | peg$c47 = /^[1-9]/, 211 | peg$c48 = peg$classExpectation([["1", "9"]], false, false), 212 | peg$c49 = /^[eE]/, 213 | peg$c50 = peg$classExpectation(["e", "E"], false, false), 214 | peg$c51 = "-", 215 | peg$c52 = peg$literalExpectation("-", false), 216 | peg$c53 = "+", 217 | peg$c54 = peg$literalExpectation("+", false), 218 | peg$c55 = "0", 219 | peg$c56 = peg$literalExpectation("0", false), 220 | peg$c57 = /^[\/_a-z0-9\-]/i, 221 | peg$c58 = peg$classExpectation(["/", "_", ["a", "z"], ["0", "9"], "-"], false, true), 222 | peg$c59 = function(chars) { return chars.join(''); }, 223 | peg$c60 = peg$otherExpectation("string"), 224 | peg$c61 = "\"", 225 | peg$c62 = peg$literalExpectation("\"", false), 226 | peg$c63 = "\\", 227 | peg$c64 = peg$literalExpectation("\\", false), 228 | peg$c65 = "/", 229 | peg$c66 = peg$literalExpectation("/", false), 230 | peg$c67 = "b", 231 | peg$c68 = peg$literalExpectation("b", false), 232 | peg$c69 = function() { return "\b"; }, 233 | peg$c70 = "f", 234 | peg$c71 = peg$literalExpectation("f", false), 235 | peg$c72 = function() { return "\f"; }, 236 | peg$c73 = "n", 237 | peg$c74 = peg$literalExpectation("n", false), 238 | peg$c75 = function() { return "\n"; }, 239 | peg$c76 = "r", 240 | peg$c77 = peg$literalExpectation("r", false), 241 | peg$c78 = function() { return "\r"; }, 242 | peg$c79 = "t", 243 | peg$c80 = peg$literalExpectation("t", false), 244 | peg$c81 = function() { return "\t"; }, 245 | peg$c82 = "u", 246 | peg$c83 = peg$literalExpectation("u", false), 247 | peg$c84 = function(digits) { 248 | return String.fromCharCode(parseInt(digits, 16)); 249 | }, 250 | peg$c85 = function(sequence) { return sequence; }, 251 | peg$c86 = /^[^\0-\x1F"\\]/, 252 | peg$c87 = peg$classExpectation([["\0", "\x1F"], "\"", "\\"], true, false), 253 | peg$c88 = /^[0-9]/, 254 | peg$c89 = peg$classExpectation([["0", "9"]], false, false), 255 | peg$c90 = /^[0-9a-f]/i, 256 | peg$c91 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true), 257 | 258 | peg$currPos = 0, 259 | peg$savedPos = 0, 260 | peg$posDetailsCache = [{ line: 1, column: 1 }], 261 | peg$maxFailPos = 0, 262 | peg$maxFailExpected = [], 263 | peg$silentFails = 0, 264 | 265 | peg$result; 266 | 267 | if ("startRule" in options) { 268 | if (!(options.startRule in peg$startRuleFunctions)) { 269 | throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); 270 | } 271 | 272 | peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; 273 | } 274 | 275 | function text() { 276 | return input.substring(peg$savedPos, peg$currPos); 277 | } 278 | 279 | function location() { 280 | return peg$computeLocation(peg$savedPos, peg$currPos); 281 | } 282 | 283 | function expected(description, location) { 284 | location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) 285 | 286 | throw peg$buildStructuredError( 287 | [peg$otherExpectation(description)], 288 | input.substring(peg$savedPos, peg$currPos), 289 | location 290 | ); 291 | } 292 | 293 | function error(message, location) { 294 | location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) 295 | 296 | throw peg$buildSimpleError(message, location); 297 | } 298 | 299 | function peg$literalExpectation(text, ignoreCase) { 300 | return { type: "literal", text: text, ignoreCase: ignoreCase }; 301 | } 302 | 303 | function peg$classExpectation(parts, inverted, ignoreCase) { 304 | return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; 305 | } 306 | 307 | function peg$anyExpectation() { 308 | return { type: "any" }; 309 | } 310 | 311 | function peg$endExpectation() { 312 | return { type: "end" }; 313 | } 314 | 315 | function peg$otherExpectation(description) { 316 | return { type: "other", description: description }; 317 | } 318 | 319 | function peg$computePosDetails(pos) { 320 | var details = peg$posDetailsCache[pos], p; 321 | 322 | if (details) { 323 | return details; 324 | } else { 325 | p = pos - 1; 326 | while (!peg$posDetailsCache[p]) { 327 | p--; 328 | } 329 | 330 | details = peg$posDetailsCache[p]; 331 | details = { 332 | line: details.line, 333 | column: details.column 334 | }; 335 | 336 | while (p < pos) { 337 | if (input.charCodeAt(p) === 10) { 338 | details.line++; 339 | details.column = 1; 340 | } else { 341 | details.column++; 342 | } 343 | 344 | p++; 345 | } 346 | 347 | peg$posDetailsCache[pos] = details; 348 | return details; 349 | } 350 | } 351 | 352 | function peg$computeLocation(startPos, endPos) { 353 | var startPosDetails = peg$computePosDetails(startPos), 354 | endPosDetails = peg$computePosDetails(endPos); 355 | 356 | return { 357 | start: { 358 | offset: startPos, 359 | line: startPosDetails.line, 360 | column: startPosDetails.column 361 | }, 362 | end: { 363 | offset: endPos, 364 | line: endPosDetails.line, 365 | column: endPosDetails.column 366 | } 367 | }; 368 | } 369 | 370 | function peg$fail(expected) { 371 | if (peg$currPos < peg$maxFailPos) { return; } 372 | 373 | if (peg$currPos > peg$maxFailPos) { 374 | peg$maxFailPos = peg$currPos; 375 | peg$maxFailExpected = []; 376 | } 377 | 378 | peg$maxFailExpected.push(expected); 379 | } 380 | 381 | function peg$buildSimpleError(message, location) { 382 | return new peg$SyntaxError(message, null, null, location); 383 | } 384 | 385 | function peg$buildStructuredError(expected, found, location) { 386 | return new peg$SyntaxError( 387 | peg$SyntaxError.buildMessage(expected, found), 388 | expected, 389 | found, 390 | location 391 | ); 392 | } 393 | 394 | function peg$parsescene() { 395 | var s0, s1, s2, s3, s4, s5, s6; 396 | 397 | s0 = peg$currPos; 398 | s1 = peg$parseentity(); 399 | if (s1 !== peg$FAILED) { 400 | s2 = []; 401 | s3 = peg$currPos; 402 | s4 = peg$parsews(); 403 | if (s4 !== peg$FAILED) { 404 | s5 = peg$parseentity(); 405 | if (s5 !== peg$FAILED) { 406 | s6 = peg$parsews(); 407 | if (s6 !== peg$FAILED) { 408 | peg$savedPos = s3; 409 | s4 = peg$c0(s1, s5); 410 | s3 = s4; 411 | } else { 412 | peg$currPos = s3; 413 | s3 = peg$FAILED; 414 | } 415 | } else { 416 | peg$currPos = s3; 417 | s3 = peg$FAILED; 418 | } 419 | } else { 420 | peg$currPos = s3; 421 | s3 = peg$FAILED; 422 | } 423 | while (s3 !== peg$FAILED) { 424 | s2.push(s3); 425 | s3 = peg$currPos; 426 | s4 = peg$parsews(); 427 | if (s4 !== peg$FAILED) { 428 | s5 = peg$parseentity(); 429 | if (s5 !== peg$FAILED) { 430 | s6 = peg$parsews(); 431 | if (s6 !== peg$FAILED) { 432 | peg$savedPos = s3; 433 | s4 = peg$c0(s1, s5); 434 | s3 = s4; 435 | } else { 436 | peg$currPos = s3; 437 | s3 = peg$FAILED; 438 | } 439 | } else { 440 | peg$currPos = s3; 441 | s3 = peg$FAILED; 442 | } 443 | } else { 444 | peg$currPos = s3; 445 | s3 = peg$FAILED; 446 | } 447 | } 448 | if (s2 !== peg$FAILED) { 449 | peg$savedPos = s0; 450 | s1 = peg$c1(s1, s2); 451 | s0 = s1; 452 | } else { 453 | peg$currPos = s0; 454 | s0 = peg$FAILED; 455 | } 456 | } else { 457 | peg$currPos = s0; 458 | s0 = peg$FAILED; 459 | } 460 | 461 | return s0; 462 | } 463 | 464 | function peg$parseentity() { 465 | var s0, s1, s2, s3, s4, s5, s6, s7, s8; 466 | 467 | s0 = peg$currPos; 468 | s1 = peg$parsebegin_entity(); 469 | if (s1 !== peg$FAILED) { 470 | s2 = peg$parsews(); 471 | if (s2 !== peg$FAILED) { 472 | s3 = peg$parsename(); 473 | if (s3 !== peg$FAILED) { 474 | s4 = peg$parsews(); 475 | if (s4 !== peg$FAILED) { 476 | s5 = peg$parseprops(); 477 | if (s5 !== peg$FAILED) { 478 | s6 = peg$parseend_entity(); 479 | if (s6 !== peg$FAILED) { 480 | s7 = peg$parsews(); 481 | if (s7 !== peg$FAILED) { 482 | s8 = peg$parseprops(); 483 | if (s8 !== peg$FAILED) { 484 | peg$savedPos = s0; 485 | s1 = peg$c2(s3, s5, s8); 486 | s0 = s1; 487 | } else { 488 | peg$currPos = s0; 489 | s0 = peg$FAILED; 490 | } 491 | } else { 492 | peg$currPos = s0; 493 | s0 = peg$FAILED; 494 | } 495 | } else { 496 | peg$currPos = s0; 497 | s0 = peg$FAILED; 498 | } 499 | } else { 500 | peg$currPos = s0; 501 | s0 = peg$FAILED; 502 | } 503 | } else { 504 | peg$currPos = s0; 505 | s0 = peg$FAILED; 506 | } 507 | } else { 508 | peg$currPos = s0; 509 | s0 = peg$FAILED; 510 | } 511 | } else { 512 | peg$currPos = s0; 513 | s0 = peg$FAILED; 514 | } 515 | } else { 516 | peg$currPos = s0; 517 | s0 = peg$FAILED; 518 | } 519 | 520 | return s0; 521 | } 522 | 523 | function peg$parseprops() { 524 | var s0, s1, s2, s3, s4, s5, s6; 525 | 526 | s0 = peg$currPos; 527 | s1 = peg$currPos; 528 | s2 = peg$parsemember(); 529 | if (s2 !== peg$FAILED) { 530 | s3 = []; 531 | s4 = peg$currPos; 532 | s5 = peg$parsews(); 533 | if (s5 !== peg$FAILED) { 534 | s6 = peg$parsemember(); 535 | if (s6 !== peg$FAILED) { 536 | peg$savedPos = s4; 537 | s5 = peg$c3(s2, s6); 538 | s4 = s5; 539 | } else { 540 | peg$currPos = s4; 541 | s4 = peg$FAILED; 542 | } 543 | } else { 544 | peg$currPos = s4; 545 | s4 = peg$FAILED; 546 | } 547 | while (s4 !== peg$FAILED) { 548 | s3.push(s4); 549 | s4 = peg$currPos; 550 | s5 = peg$parsews(); 551 | if (s5 !== peg$FAILED) { 552 | s6 = peg$parsemember(); 553 | if (s6 !== peg$FAILED) { 554 | peg$savedPos = s4; 555 | s5 = peg$c3(s2, s6); 556 | s4 = s5; 557 | } else { 558 | peg$currPos = s4; 559 | s4 = peg$FAILED; 560 | } 561 | } else { 562 | peg$currPos = s4; 563 | s4 = peg$FAILED; 564 | } 565 | } 566 | if (s3 !== peg$FAILED) { 567 | peg$savedPos = s1; 568 | s2 = peg$c4(s2, s3); 569 | s1 = s2; 570 | } else { 571 | peg$currPos = s1; 572 | s1 = peg$FAILED; 573 | } 574 | } else { 575 | peg$currPos = s1; 576 | s1 = peg$FAILED; 577 | } 578 | if (s1 === peg$FAILED) { 579 | s1 = null; 580 | } 581 | if (s1 !== peg$FAILED) { 582 | peg$savedPos = s0; 583 | s1 = peg$c5(s1); 584 | } 585 | s0 = s1; 586 | 587 | return s0; 588 | } 589 | 590 | function peg$parsemember() { 591 | var s0, s1, s2, s3; 592 | 593 | s0 = peg$currPos; 594 | s1 = peg$parsename(); 595 | if (s1 !== peg$FAILED) { 596 | s2 = peg$parsename_separator(); 597 | if (s2 !== peg$FAILED) { 598 | s3 = peg$parsevalue(); 599 | if (s3 !== peg$FAILED) { 600 | peg$savedPos = s0; 601 | s1 = peg$c6(s1, s3); 602 | s0 = s1; 603 | } else { 604 | peg$currPos = s0; 605 | s0 = peg$FAILED; 606 | } 607 | } else { 608 | peg$currPos = s0; 609 | s0 = peg$FAILED; 610 | } 611 | } else { 612 | peg$currPos = s0; 613 | s0 = peg$FAILED; 614 | } 615 | 616 | return s0; 617 | } 618 | 619 | function peg$parsevalue() { 620 | var s0; 621 | 622 | s0 = peg$parsefalse(); 623 | if (s0 === peg$FAILED) { 624 | s0 = peg$parsenull(); 625 | if (s0 === peg$FAILED) { 626 | s0 = peg$parsetrue(); 627 | if (s0 === peg$FAILED) { 628 | s0 = peg$parsenumber(); 629 | if (s0 === peg$FAILED) { 630 | s0 = peg$parsestring(); 631 | if (s0 === peg$FAILED) { 632 | s0 = peg$parseinternal(); 633 | if (s0 === peg$FAILED) { 634 | s0 = peg$parsearray(); 635 | if (s0 === peg$FAILED) { 636 | s0 = peg$parsejson(); 637 | } 638 | } 639 | } 640 | } 641 | } 642 | } 643 | } 644 | 645 | return s0; 646 | } 647 | 648 | function peg$parsearray() { 649 | var s0, s1, s2, s3; 650 | 651 | s0 = peg$currPos; 652 | s1 = peg$parsebegin_array(); 653 | if (s1 !== peg$FAILED) { 654 | s2 = peg$parsevalue_list(); 655 | if (s2 === peg$FAILED) { 656 | s2 = null; 657 | } 658 | if (s2 !== peg$FAILED) { 659 | s3 = peg$parseend_array(); 660 | if (s3 !== peg$FAILED) { 661 | peg$savedPos = s0; 662 | s1 = peg$c7(s2); 663 | s0 = s1; 664 | } else { 665 | peg$currPos = s0; 666 | s0 = peg$FAILED; 667 | } 668 | } else { 669 | peg$currPos = s0; 670 | s0 = peg$FAILED; 671 | } 672 | } else { 673 | peg$currPos = s0; 674 | s0 = peg$FAILED; 675 | } 676 | 677 | return s0; 678 | } 679 | 680 | function peg$parsevalue_list() { 681 | var s0, s1, s2, s3, s4, s5; 682 | 683 | s0 = peg$currPos; 684 | s1 = peg$parsevalue(); 685 | if (s1 !== peg$FAILED) { 686 | s2 = []; 687 | s3 = peg$currPos; 688 | s4 = peg$parsevalue_separator(); 689 | if (s4 !== peg$FAILED) { 690 | s5 = peg$parsevalue(); 691 | if (s5 !== peg$FAILED) { 692 | peg$savedPos = s3; 693 | s4 = peg$c8(s1, s5); 694 | s3 = s4; 695 | } else { 696 | peg$currPos = s3; 697 | s3 = peg$FAILED; 698 | } 699 | } else { 700 | peg$currPos = s3; 701 | s3 = peg$FAILED; 702 | } 703 | while (s3 !== peg$FAILED) { 704 | s2.push(s3); 705 | s3 = peg$currPos; 706 | s4 = peg$parsevalue_separator(); 707 | if (s4 !== peg$FAILED) { 708 | s5 = peg$parsevalue(); 709 | if (s5 !== peg$FAILED) { 710 | peg$savedPos = s3; 711 | s4 = peg$c8(s1, s5); 712 | s3 = s4; 713 | } else { 714 | peg$currPos = s3; 715 | s3 = peg$FAILED; 716 | } 717 | } else { 718 | peg$currPos = s3; 719 | s3 = peg$FAILED; 720 | } 721 | } 722 | if (s2 !== peg$FAILED) { 723 | peg$savedPos = s0; 724 | s1 = peg$c9(s1, s2); 725 | s0 = s1; 726 | } else { 727 | peg$currPos = s0; 728 | s0 = peg$FAILED; 729 | } 730 | } else { 731 | peg$currPos = s0; 732 | s0 = peg$FAILED; 733 | } 734 | 735 | return s0; 736 | } 737 | 738 | function peg$parsebegin_json() { 739 | var s0, s1, s2, s3; 740 | 741 | s0 = peg$currPos; 742 | s1 = peg$parsews(); 743 | if (s1 !== peg$FAILED) { 744 | if (input.charCodeAt(peg$currPos) === 123) { 745 | s2 = peg$c10; 746 | peg$currPos++; 747 | } else { 748 | s2 = peg$FAILED; 749 | if (peg$silentFails === 0) { peg$fail(peg$c11); } 750 | } 751 | if (s2 !== peg$FAILED) { 752 | s3 = peg$parsews(); 753 | if (s3 !== peg$FAILED) { 754 | s1 = [s1, s2, s3]; 755 | s0 = s1; 756 | } else { 757 | peg$currPos = s0; 758 | s0 = peg$FAILED; 759 | } 760 | } else { 761 | peg$currPos = s0; 762 | s0 = peg$FAILED; 763 | } 764 | } else { 765 | peg$currPos = s0; 766 | s0 = peg$FAILED; 767 | } 768 | 769 | return s0; 770 | } 771 | 772 | function peg$parseend_json() { 773 | var s0, s1, s2, s3; 774 | 775 | s0 = peg$currPos; 776 | s1 = peg$parsews(); 777 | if (s1 !== peg$FAILED) { 778 | if (input.charCodeAt(peg$currPos) === 125) { 779 | s2 = peg$c12; 780 | peg$currPos++; 781 | } else { 782 | s2 = peg$FAILED; 783 | if (peg$silentFails === 0) { peg$fail(peg$c13); } 784 | } 785 | if (s2 !== peg$FAILED) { 786 | s3 = peg$parsews(); 787 | if (s3 !== peg$FAILED) { 788 | s1 = [s1, s2, s3]; 789 | s0 = s1; 790 | } else { 791 | peg$currPos = s0; 792 | s0 = peg$FAILED; 793 | } 794 | } else { 795 | peg$currPos = s0; 796 | s0 = peg$FAILED; 797 | } 798 | } else { 799 | peg$currPos = s0; 800 | s0 = peg$FAILED; 801 | } 802 | 803 | return s0; 804 | } 805 | 806 | function peg$parsejson_name() { 807 | var s0; 808 | 809 | s0 = peg$parsestring(); 810 | if (s0 === peg$FAILED) { 811 | s0 = peg$parsenumber(); 812 | } 813 | 814 | return s0; 815 | } 816 | 817 | function peg$parsejson_name_separator() { 818 | var s0, s1, s2, s3; 819 | 820 | s0 = peg$currPos; 821 | s1 = peg$parsews(); 822 | if (s1 !== peg$FAILED) { 823 | if (input.charCodeAt(peg$currPos) === 58) { 824 | s2 = peg$c14; 825 | peg$currPos++; 826 | } else { 827 | s2 = peg$FAILED; 828 | if (peg$silentFails === 0) { peg$fail(peg$c15); } 829 | } 830 | if (s2 !== peg$FAILED) { 831 | s3 = peg$parsews(); 832 | if (s3 !== peg$FAILED) { 833 | s1 = [s1, s2, s3]; 834 | s0 = s1; 835 | } else { 836 | peg$currPos = s0; 837 | s0 = peg$FAILED; 838 | } 839 | } else { 840 | peg$currPos = s0; 841 | s0 = peg$FAILED; 842 | } 843 | } else { 844 | peg$currPos = s0; 845 | s0 = peg$FAILED; 846 | } 847 | 848 | return s0; 849 | } 850 | 851 | function peg$parsejson_value_separator() { 852 | var s0, s1, s2, s3; 853 | 854 | s0 = peg$currPos; 855 | s1 = peg$parsews(); 856 | if (s1 !== peg$FAILED) { 857 | if (input.charCodeAt(peg$currPos) === 44) { 858 | s2 = peg$c16; 859 | peg$currPos++; 860 | } else { 861 | s2 = peg$FAILED; 862 | if (peg$silentFails === 0) { peg$fail(peg$c17); } 863 | } 864 | if (s2 !== peg$FAILED) { 865 | s3 = peg$parsews(); 866 | if (s3 !== peg$FAILED) { 867 | s1 = [s1, s2, s3]; 868 | s0 = s1; 869 | } else { 870 | peg$currPos = s0; 871 | s0 = peg$FAILED; 872 | } 873 | } else { 874 | peg$currPos = s0; 875 | s0 = peg$FAILED; 876 | } 877 | } else { 878 | peg$currPos = s0; 879 | s0 = peg$FAILED; 880 | } 881 | 882 | return s0; 883 | } 884 | 885 | function peg$parsejson() { 886 | var s0, s1, s2, s3, s4, s5, s6, s7; 887 | 888 | s0 = peg$currPos; 889 | s1 = peg$parsebegin_json(); 890 | if (s1 !== peg$FAILED) { 891 | s2 = peg$currPos; 892 | s3 = peg$parsejson_member(); 893 | if (s3 !== peg$FAILED) { 894 | s4 = []; 895 | s5 = peg$currPos; 896 | s6 = peg$parsejson_value_separator(); 897 | if (s6 !== peg$FAILED) { 898 | s7 = peg$parsejson_member(); 899 | if (s7 !== peg$FAILED) { 900 | peg$savedPos = s5; 901 | s6 = peg$c3(s3, s7); 902 | s5 = s6; 903 | } else { 904 | peg$currPos = s5; 905 | s5 = peg$FAILED; 906 | } 907 | } else { 908 | peg$currPos = s5; 909 | s5 = peg$FAILED; 910 | } 911 | while (s5 !== peg$FAILED) { 912 | s4.push(s5); 913 | s5 = peg$currPos; 914 | s6 = peg$parsejson_value_separator(); 915 | if (s6 !== peg$FAILED) { 916 | s7 = peg$parsejson_member(); 917 | if (s7 !== peg$FAILED) { 918 | peg$savedPos = s5; 919 | s6 = peg$c3(s3, s7); 920 | s5 = s6; 921 | } else { 922 | peg$currPos = s5; 923 | s5 = peg$FAILED; 924 | } 925 | } else { 926 | peg$currPos = s5; 927 | s5 = peg$FAILED; 928 | } 929 | } 930 | if (s4 !== peg$FAILED) { 931 | peg$savedPos = s2; 932 | s3 = peg$c18(s3, s4); 933 | s2 = s3; 934 | } else { 935 | peg$currPos = s2; 936 | s2 = peg$FAILED; 937 | } 938 | } else { 939 | peg$currPos = s2; 940 | s2 = peg$FAILED; 941 | } 942 | if (s2 === peg$FAILED) { 943 | s2 = null; 944 | } 945 | if (s2 !== peg$FAILED) { 946 | s3 = peg$parseend_json(); 947 | if (s3 !== peg$FAILED) { 948 | peg$savedPos = s0; 949 | s1 = peg$c19(s2); 950 | s0 = s1; 951 | } else { 952 | peg$currPos = s0; 953 | s0 = peg$FAILED; 954 | } 955 | } else { 956 | peg$currPos = s0; 957 | s0 = peg$FAILED; 958 | } 959 | } else { 960 | peg$currPos = s0; 961 | s0 = peg$FAILED; 962 | } 963 | 964 | return s0; 965 | } 966 | 967 | function peg$parsejson_member() { 968 | var s0, s1, s2, s3; 969 | 970 | s0 = peg$currPos; 971 | s1 = peg$parsejson_name(); 972 | if (s1 !== peg$FAILED) { 973 | s2 = peg$parsejson_name_separator(); 974 | if (s2 !== peg$FAILED) { 975 | s3 = peg$parsevalue(); 976 | if (s3 !== peg$FAILED) { 977 | peg$savedPos = s0; 978 | s1 = peg$c6(s1, s3); 979 | s0 = s1; 980 | } else { 981 | peg$currPos = s0; 982 | s0 = peg$FAILED; 983 | } 984 | } else { 985 | peg$currPos = s0; 986 | s0 = peg$FAILED; 987 | } 988 | } else { 989 | peg$currPos = s0; 990 | s0 = peg$FAILED; 991 | } 992 | 993 | return s0; 994 | } 995 | 996 | function peg$parseinternal() { 997 | var s0, s1, s2, s3, s4, s5, s6; 998 | 999 | s0 = peg$currPos; 1000 | s1 = peg$parsename(); 1001 | if (s1 !== peg$FAILED) { 1002 | if (input.charCodeAt(peg$currPos) === 40) { 1003 | s2 = peg$c20; 1004 | peg$currPos++; 1005 | } else { 1006 | s2 = peg$FAILED; 1007 | if (peg$silentFails === 0) { peg$fail(peg$c21); } 1008 | } 1009 | if (s2 !== peg$FAILED) { 1010 | s3 = peg$parsews(); 1011 | if (s3 !== peg$FAILED) { 1012 | s4 = peg$parsevalue_list(); 1013 | if (s4 === peg$FAILED) { 1014 | s4 = null; 1015 | } 1016 | if (s4 !== peg$FAILED) { 1017 | s5 = peg$parsews(); 1018 | if (s5 !== peg$FAILED) { 1019 | if (input.charCodeAt(peg$currPos) === 41) { 1020 | s6 = peg$c22; 1021 | peg$currPos++; 1022 | } else { 1023 | s6 = peg$FAILED; 1024 | if (peg$silentFails === 0) { peg$fail(peg$c23); } 1025 | } 1026 | if (s6 !== peg$FAILED) { 1027 | peg$savedPos = s0; 1028 | s1 = peg$c24(s1, s4); 1029 | s0 = s1; 1030 | } else { 1031 | peg$currPos = s0; 1032 | s0 = peg$FAILED; 1033 | } 1034 | } else { 1035 | peg$currPos = s0; 1036 | s0 = peg$FAILED; 1037 | } 1038 | } else { 1039 | peg$currPos = s0; 1040 | s0 = peg$FAILED; 1041 | } 1042 | } else { 1043 | peg$currPos = s0; 1044 | s0 = peg$FAILED; 1045 | } 1046 | } else { 1047 | peg$currPos = s0; 1048 | s0 = peg$FAILED; 1049 | } 1050 | } else { 1051 | peg$currPos = s0; 1052 | s0 = peg$FAILED; 1053 | } 1054 | 1055 | return s0; 1056 | } 1057 | 1058 | function peg$parsefalse() { 1059 | var s0, s1; 1060 | 1061 | s0 = peg$currPos; 1062 | if (input.substr(peg$currPos, 5) === peg$c25) { 1063 | s1 = peg$c25; 1064 | peg$currPos += 5; 1065 | } else { 1066 | s1 = peg$FAILED; 1067 | if (peg$silentFails === 0) { peg$fail(peg$c26); } 1068 | } 1069 | if (s1 !== peg$FAILED) { 1070 | peg$savedPos = s0; 1071 | s1 = peg$c27(); 1072 | } 1073 | s0 = s1; 1074 | 1075 | return s0; 1076 | } 1077 | 1078 | function peg$parsetrue() { 1079 | var s0, s1; 1080 | 1081 | s0 = peg$currPos; 1082 | if (input.substr(peg$currPos, 4) === peg$c28) { 1083 | s1 = peg$c28; 1084 | peg$currPos += 4; 1085 | } else { 1086 | s1 = peg$FAILED; 1087 | if (peg$silentFails === 0) { peg$fail(peg$c29); } 1088 | } 1089 | if (s1 !== peg$FAILED) { 1090 | peg$savedPos = s0; 1091 | s1 = peg$c30(); 1092 | } 1093 | s0 = s1; 1094 | 1095 | return s0; 1096 | } 1097 | 1098 | function peg$parsenull() { 1099 | var s0, s1; 1100 | 1101 | s0 = peg$currPos; 1102 | if (input.substr(peg$currPos, 4) === peg$c31) { 1103 | s1 = peg$c31; 1104 | peg$currPos += 4; 1105 | } else { 1106 | s1 = peg$FAILED; 1107 | if (peg$silentFails === 0) { peg$fail(peg$c32); } 1108 | } 1109 | if (s1 !== peg$FAILED) { 1110 | peg$savedPos = s0; 1111 | s1 = peg$c33(); 1112 | } 1113 | s0 = s1; 1114 | 1115 | return s0; 1116 | } 1117 | 1118 | function peg$parsebegin_array() { 1119 | var s0, s1, s2, s3; 1120 | 1121 | s0 = peg$currPos; 1122 | s1 = peg$parsews(); 1123 | if (s1 !== peg$FAILED) { 1124 | if (input.charCodeAt(peg$currPos) === 91) { 1125 | s2 = peg$c34; 1126 | peg$currPos++; 1127 | } else { 1128 | s2 = peg$FAILED; 1129 | if (peg$silentFails === 0) { peg$fail(peg$c35); } 1130 | } 1131 | if (s2 !== peg$FAILED) { 1132 | s3 = peg$parsews(); 1133 | if (s3 !== peg$FAILED) { 1134 | s1 = [s1, s2, s3]; 1135 | s0 = s1; 1136 | } else { 1137 | peg$currPos = s0; 1138 | s0 = peg$FAILED; 1139 | } 1140 | } else { 1141 | peg$currPos = s0; 1142 | s0 = peg$FAILED; 1143 | } 1144 | } else { 1145 | peg$currPos = s0; 1146 | s0 = peg$FAILED; 1147 | } 1148 | 1149 | return s0; 1150 | } 1151 | 1152 | function peg$parseend_array() { 1153 | var s0, s1, s2, s3; 1154 | 1155 | s0 = peg$currPos; 1156 | s1 = peg$parsews(); 1157 | if (s1 !== peg$FAILED) { 1158 | if (input.charCodeAt(peg$currPos) === 93) { 1159 | s2 = peg$c36; 1160 | peg$currPos++; 1161 | } else { 1162 | s2 = peg$FAILED; 1163 | if (peg$silentFails === 0) { peg$fail(peg$c37); } 1164 | } 1165 | if (s2 !== peg$FAILED) { 1166 | s3 = peg$parsews(); 1167 | if (s3 !== peg$FAILED) { 1168 | s1 = [s1, s2, s3]; 1169 | s0 = s1; 1170 | } else { 1171 | peg$currPos = s0; 1172 | s0 = peg$FAILED; 1173 | } 1174 | } else { 1175 | peg$currPos = s0; 1176 | s0 = peg$FAILED; 1177 | } 1178 | } else { 1179 | peg$currPos = s0; 1180 | s0 = peg$FAILED; 1181 | } 1182 | 1183 | return s0; 1184 | } 1185 | 1186 | function peg$parsebegin_entity() { 1187 | var s0, s1, s2, s3; 1188 | 1189 | s0 = peg$currPos; 1190 | s1 = peg$parsews(); 1191 | if (s1 !== peg$FAILED) { 1192 | if (input.charCodeAt(peg$currPos) === 91) { 1193 | s2 = peg$c34; 1194 | peg$currPos++; 1195 | } else { 1196 | s2 = peg$FAILED; 1197 | if (peg$silentFails === 0) { peg$fail(peg$c35); } 1198 | } 1199 | if (s2 !== peg$FAILED) { 1200 | s3 = peg$parsews(); 1201 | if (s3 !== peg$FAILED) { 1202 | s1 = [s1, s2, s3]; 1203 | s0 = s1; 1204 | } else { 1205 | peg$currPos = s0; 1206 | s0 = peg$FAILED; 1207 | } 1208 | } else { 1209 | peg$currPos = s0; 1210 | s0 = peg$FAILED; 1211 | } 1212 | } else { 1213 | peg$currPos = s0; 1214 | s0 = peg$FAILED; 1215 | } 1216 | 1217 | return s0; 1218 | } 1219 | 1220 | function peg$parseend_entity() { 1221 | var s0, s1, s2, s3; 1222 | 1223 | s0 = peg$currPos; 1224 | s1 = peg$parsews(); 1225 | if (s1 !== peg$FAILED) { 1226 | if (input.charCodeAt(peg$currPos) === 93) { 1227 | s2 = peg$c36; 1228 | peg$currPos++; 1229 | } else { 1230 | s2 = peg$FAILED; 1231 | if (peg$silentFails === 0) { peg$fail(peg$c37); } 1232 | } 1233 | if (s2 !== peg$FAILED) { 1234 | s3 = peg$parsews(); 1235 | if (s3 !== peg$FAILED) { 1236 | s1 = [s1, s2, s3]; 1237 | s0 = s1; 1238 | } else { 1239 | peg$currPos = s0; 1240 | s0 = peg$FAILED; 1241 | } 1242 | } else { 1243 | peg$currPos = s0; 1244 | s0 = peg$FAILED; 1245 | } 1246 | } else { 1247 | peg$currPos = s0; 1248 | s0 = peg$FAILED; 1249 | } 1250 | 1251 | return s0; 1252 | } 1253 | 1254 | function peg$parsename_separator() { 1255 | var s0, s1, s2, s3; 1256 | 1257 | s0 = peg$currPos; 1258 | s1 = peg$parsews(); 1259 | if (s1 !== peg$FAILED) { 1260 | if (input.charCodeAt(peg$currPos) === 61) { 1261 | s2 = peg$c38; 1262 | peg$currPos++; 1263 | } else { 1264 | s2 = peg$FAILED; 1265 | if (peg$silentFails === 0) { peg$fail(peg$c39); } 1266 | } 1267 | if (s2 !== peg$FAILED) { 1268 | s3 = peg$parsews(); 1269 | if (s3 !== peg$FAILED) { 1270 | s1 = [s1, s2, s3]; 1271 | s0 = s1; 1272 | } else { 1273 | peg$currPos = s0; 1274 | s0 = peg$FAILED; 1275 | } 1276 | } else { 1277 | peg$currPos = s0; 1278 | s0 = peg$FAILED; 1279 | } 1280 | } else { 1281 | peg$currPos = s0; 1282 | s0 = peg$FAILED; 1283 | } 1284 | 1285 | return s0; 1286 | } 1287 | 1288 | function peg$parsevalue_separator() { 1289 | var s0, s1, s2, s3; 1290 | 1291 | s0 = peg$currPos; 1292 | s1 = peg$parsews(); 1293 | if (s1 !== peg$FAILED) { 1294 | if (input.charCodeAt(peg$currPos) === 44) { 1295 | s2 = peg$c16; 1296 | peg$currPos++; 1297 | } else { 1298 | s2 = peg$FAILED; 1299 | if (peg$silentFails === 0) { peg$fail(peg$c17); } 1300 | } 1301 | if (s2 !== peg$FAILED) { 1302 | s3 = peg$parsews(); 1303 | if (s3 !== peg$FAILED) { 1304 | s1 = [s1, s2, s3]; 1305 | s0 = s1; 1306 | } else { 1307 | peg$currPos = s0; 1308 | s0 = peg$FAILED; 1309 | } 1310 | } else { 1311 | peg$currPos = s0; 1312 | s0 = peg$FAILED; 1313 | } 1314 | } else { 1315 | peg$currPos = s0; 1316 | s0 = peg$FAILED; 1317 | } 1318 | 1319 | return s0; 1320 | } 1321 | 1322 | function peg$parsews() { 1323 | var s0, s1; 1324 | 1325 | peg$silentFails++; 1326 | s0 = []; 1327 | if (peg$c41.test(input.charAt(peg$currPos))) { 1328 | s1 = input.charAt(peg$currPos); 1329 | peg$currPos++; 1330 | } else { 1331 | s1 = peg$FAILED; 1332 | if (peg$silentFails === 0) { peg$fail(peg$c42); } 1333 | } 1334 | while (s1 !== peg$FAILED) { 1335 | s0.push(s1); 1336 | if (peg$c41.test(input.charAt(peg$currPos))) { 1337 | s1 = input.charAt(peg$currPos); 1338 | peg$currPos++; 1339 | } else { 1340 | s1 = peg$FAILED; 1341 | if (peg$silentFails === 0) { peg$fail(peg$c42); } 1342 | } 1343 | } 1344 | peg$silentFails--; 1345 | if (s0 === peg$FAILED) { 1346 | s1 = peg$FAILED; 1347 | if (peg$silentFails === 0) { peg$fail(peg$c40); } 1348 | } 1349 | 1350 | return s0; 1351 | } 1352 | 1353 | function peg$parsenumber() { 1354 | var s0, s1, s2, s3, s4; 1355 | 1356 | peg$silentFails++; 1357 | s0 = peg$currPos; 1358 | s1 = peg$parseminus(); 1359 | if (s1 === peg$FAILED) { 1360 | s1 = null; 1361 | } 1362 | if (s1 !== peg$FAILED) { 1363 | s2 = peg$parseint(); 1364 | if (s2 !== peg$FAILED) { 1365 | s3 = peg$parsefrac(); 1366 | if (s3 === peg$FAILED) { 1367 | s3 = null; 1368 | } 1369 | if (s3 !== peg$FAILED) { 1370 | s4 = peg$parseexp(); 1371 | if (s4 === peg$FAILED) { 1372 | s4 = null; 1373 | } 1374 | if (s4 !== peg$FAILED) { 1375 | peg$savedPos = s0; 1376 | s1 = peg$c44(); 1377 | s0 = s1; 1378 | } else { 1379 | peg$currPos = s0; 1380 | s0 = peg$FAILED; 1381 | } 1382 | } else { 1383 | peg$currPos = s0; 1384 | s0 = peg$FAILED; 1385 | } 1386 | } else { 1387 | peg$currPos = s0; 1388 | s0 = peg$FAILED; 1389 | } 1390 | } else { 1391 | peg$currPos = s0; 1392 | s0 = peg$FAILED; 1393 | } 1394 | peg$silentFails--; 1395 | if (s0 === peg$FAILED) { 1396 | s1 = peg$FAILED; 1397 | if (peg$silentFails === 0) { peg$fail(peg$c43); } 1398 | } 1399 | 1400 | return s0; 1401 | } 1402 | 1403 | function peg$parsedecimal_point() { 1404 | var s0; 1405 | 1406 | if (input.charCodeAt(peg$currPos) === 46) { 1407 | s0 = peg$c45; 1408 | peg$currPos++; 1409 | } else { 1410 | s0 = peg$FAILED; 1411 | if (peg$silentFails === 0) { peg$fail(peg$c46); } 1412 | } 1413 | 1414 | return s0; 1415 | } 1416 | 1417 | function peg$parsedigit1_9() { 1418 | var s0; 1419 | 1420 | if (peg$c47.test(input.charAt(peg$currPos))) { 1421 | s0 = input.charAt(peg$currPos); 1422 | peg$currPos++; 1423 | } else { 1424 | s0 = peg$FAILED; 1425 | if (peg$silentFails === 0) { peg$fail(peg$c48); } 1426 | } 1427 | 1428 | return s0; 1429 | } 1430 | 1431 | function peg$parsee() { 1432 | var s0; 1433 | 1434 | if (peg$c49.test(input.charAt(peg$currPos))) { 1435 | s0 = input.charAt(peg$currPos); 1436 | peg$currPos++; 1437 | } else { 1438 | s0 = peg$FAILED; 1439 | if (peg$silentFails === 0) { peg$fail(peg$c50); } 1440 | } 1441 | 1442 | return s0; 1443 | } 1444 | 1445 | function peg$parseexp() { 1446 | var s0, s1, s2, s3, s4; 1447 | 1448 | s0 = peg$currPos; 1449 | s1 = peg$parsee(); 1450 | if (s1 !== peg$FAILED) { 1451 | s2 = peg$parseminus(); 1452 | if (s2 === peg$FAILED) { 1453 | s2 = peg$parseplus(); 1454 | } 1455 | if (s2 === peg$FAILED) { 1456 | s2 = null; 1457 | } 1458 | if (s2 !== peg$FAILED) { 1459 | s3 = []; 1460 | s4 = peg$parseDIGIT(); 1461 | if (s4 !== peg$FAILED) { 1462 | while (s4 !== peg$FAILED) { 1463 | s3.push(s4); 1464 | s4 = peg$parseDIGIT(); 1465 | } 1466 | } else { 1467 | s3 = peg$FAILED; 1468 | } 1469 | if (s3 !== peg$FAILED) { 1470 | s1 = [s1, s2, s3]; 1471 | s0 = s1; 1472 | } else { 1473 | peg$currPos = s0; 1474 | s0 = peg$FAILED; 1475 | } 1476 | } else { 1477 | peg$currPos = s0; 1478 | s0 = peg$FAILED; 1479 | } 1480 | } else { 1481 | peg$currPos = s0; 1482 | s0 = peg$FAILED; 1483 | } 1484 | 1485 | return s0; 1486 | } 1487 | 1488 | function peg$parsefrac() { 1489 | var s0, s1, s2, s3; 1490 | 1491 | s0 = peg$currPos; 1492 | s1 = peg$parsedecimal_point(); 1493 | if (s1 !== peg$FAILED) { 1494 | s2 = []; 1495 | s3 = peg$parseDIGIT(); 1496 | if (s3 !== peg$FAILED) { 1497 | while (s3 !== peg$FAILED) { 1498 | s2.push(s3); 1499 | s3 = peg$parseDIGIT(); 1500 | } 1501 | } else { 1502 | s2 = peg$FAILED; 1503 | } 1504 | if (s2 !== peg$FAILED) { 1505 | s1 = [s1, s2]; 1506 | s0 = s1; 1507 | } else { 1508 | peg$currPos = s0; 1509 | s0 = peg$FAILED; 1510 | } 1511 | } else { 1512 | peg$currPos = s0; 1513 | s0 = peg$FAILED; 1514 | } 1515 | 1516 | return s0; 1517 | } 1518 | 1519 | function peg$parseint() { 1520 | var s0, s1, s2, s3; 1521 | 1522 | s0 = peg$parsezero(); 1523 | if (s0 === peg$FAILED) { 1524 | s0 = peg$currPos; 1525 | s1 = peg$parsedigit1_9(); 1526 | if (s1 !== peg$FAILED) { 1527 | s2 = []; 1528 | s3 = peg$parseDIGIT(); 1529 | while (s3 !== peg$FAILED) { 1530 | s2.push(s3); 1531 | s3 = peg$parseDIGIT(); 1532 | } 1533 | if (s2 !== peg$FAILED) { 1534 | s1 = [s1, s2]; 1535 | s0 = s1; 1536 | } else { 1537 | peg$currPos = s0; 1538 | s0 = peg$FAILED; 1539 | } 1540 | } else { 1541 | peg$currPos = s0; 1542 | s0 = peg$FAILED; 1543 | } 1544 | } 1545 | 1546 | return s0; 1547 | } 1548 | 1549 | function peg$parseminus() { 1550 | var s0; 1551 | 1552 | if (input.charCodeAt(peg$currPos) === 45) { 1553 | s0 = peg$c51; 1554 | peg$currPos++; 1555 | } else { 1556 | s0 = peg$FAILED; 1557 | if (peg$silentFails === 0) { peg$fail(peg$c52); } 1558 | } 1559 | 1560 | return s0; 1561 | } 1562 | 1563 | function peg$parseplus() { 1564 | var s0; 1565 | 1566 | if (input.charCodeAt(peg$currPos) === 43) { 1567 | s0 = peg$c53; 1568 | peg$currPos++; 1569 | } else { 1570 | s0 = peg$FAILED; 1571 | if (peg$silentFails === 0) { peg$fail(peg$c54); } 1572 | } 1573 | 1574 | return s0; 1575 | } 1576 | 1577 | function peg$parsezero() { 1578 | var s0; 1579 | 1580 | if (input.charCodeAt(peg$currPos) === 48) { 1581 | s0 = peg$c55; 1582 | peg$currPos++; 1583 | } else { 1584 | s0 = peg$FAILED; 1585 | if (peg$silentFails === 0) { peg$fail(peg$c56); } 1586 | } 1587 | 1588 | return s0; 1589 | } 1590 | 1591 | function peg$parsename() { 1592 | var s0, s1, s2; 1593 | 1594 | s0 = peg$currPos; 1595 | s1 = []; 1596 | if (peg$c57.test(input.charAt(peg$currPos))) { 1597 | s2 = input.charAt(peg$currPos); 1598 | peg$currPos++; 1599 | } else { 1600 | s2 = peg$FAILED; 1601 | if (peg$silentFails === 0) { peg$fail(peg$c58); } 1602 | } 1603 | while (s2 !== peg$FAILED) { 1604 | s1.push(s2); 1605 | if (peg$c57.test(input.charAt(peg$currPos))) { 1606 | s2 = input.charAt(peg$currPos); 1607 | peg$currPos++; 1608 | } else { 1609 | s2 = peg$FAILED; 1610 | if (peg$silentFails === 0) { peg$fail(peg$c58); } 1611 | } 1612 | } 1613 | if (s1 !== peg$FAILED) { 1614 | peg$savedPos = s0; 1615 | s1 = peg$c59(s1); 1616 | } 1617 | s0 = s1; 1618 | 1619 | return s0; 1620 | } 1621 | 1622 | function peg$parsestring() { 1623 | var s0, s1, s2, s3; 1624 | 1625 | peg$silentFails++; 1626 | s0 = peg$currPos; 1627 | s1 = peg$parsequotation_mark(); 1628 | if (s1 !== peg$FAILED) { 1629 | s2 = []; 1630 | s3 = peg$parsechar(); 1631 | while (s3 !== peg$FAILED) { 1632 | s2.push(s3); 1633 | s3 = peg$parsechar(); 1634 | } 1635 | if (s2 !== peg$FAILED) { 1636 | s3 = peg$parsequotation_mark(); 1637 | if (s3 !== peg$FAILED) { 1638 | peg$savedPos = s0; 1639 | s1 = peg$c59(s2); 1640 | s0 = s1; 1641 | } else { 1642 | peg$currPos = s0; 1643 | s0 = peg$FAILED; 1644 | } 1645 | } else { 1646 | peg$currPos = s0; 1647 | s0 = peg$FAILED; 1648 | } 1649 | } else { 1650 | peg$currPos = s0; 1651 | s0 = peg$FAILED; 1652 | } 1653 | peg$silentFails--; 1654 | if (s0 === peg$FAILED) { 1655 | s1 = peg$FAILED; 1656 | if (peg$silentFails === 0) { peg$fail(peg$c60); } 1657 | } 1658 | 1659 | return s0; 1660 | } 1661 | 1662 | function peg$parsechar() { 1663 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; 1664 | 1665 | s0 = peg$parseunescaped(); 1666 | if (s0 === peg$FAILED) { 1667 | s0 = peg$currPos; 1668 | s1 = peg$parseescape(); 1669 | if (s1 !== peg$FAILED) { 1670 | if (input.charCodeAt(peg$currPos) === 34) { 1671 | s2 = peg$c61; 1672 | peg$currPos++; 1673 | } else { 1674 | s2 = peg$FAILED; 1675 | if (peg$silentFails === 0) { peg$fail(peg$c62); } 1676 | } 1677 | if (s2 === peg$FAILED) { 1678 | if (input.charCodeAt(peg$currPos) === 92) { 1679 | s2 = peg$c63; 1680 | peg$currPos++; 1681 | } else { 1682 | s2 = peg$FAILED; 1683 | if (peg$silentFails === 0) { peg$fail(peg$c64); } 1684 | } 1685 | if (s2 === peg$FAILED) { 1686 | if (input.charCodeAt(peg$currPos) === 47) { 1687 | s2 = peg$c65; 1688 | peg$currPos++; 1689 | } else { 1690 | s2 = peg$FAILED; 1691 | if (peg$silentFails === 0) { peg$fail(peg$c66); } 1692 | } 1693 | if (s2 === peg$FAILED) { 1694 | s2 = peg$currPos; 1695 | if (input.charCodeAt(peg$currPos) === 98) { 1696 | s3 = peg$c67; 1697 | peg$currPos++; 1698 | } else { 1699 | s3 = peg$FAILED; 1700 | if (peg$silentFails === 0) { peg$fail(peg$c68); } 1701 | } 1702 | if (s3 !== peg$FAILED) { 1703 | peg$savedPos = s2; 1704 | s3 = peg$c69(); 1705 | } 1706 | s2 = s3; 1707 | if (s2 === peg$FAILED) { 1708 | s2 = peg$currPos; 1709 | if (input.charCodeAt(peg$currPos) === 102) { 1710 | s3 = peg$c70; 1711 | peg$currPos++; 1712 | } else { 1713 | s3 = peg$FAILED; 1714 | if (peg$silentFails === 0) { peg$fail(peg$c71); } 1715 | } 1716 | if (s3 !== peg$FAILED) { 1717 | peg$savedPos = s2; 1718 | s3 = peg$c72(); 1719 | } 1720 | s2 = s3; 1721 | if (s2 === peg$FAILED) { 1722 | s2 = peg$currPos; 1723 | if (input.charCodeAt(peg$currPos) === 110) { 1724 | s3 = peg$c73; 1725 | peg$currPos++; 1726 | } else { 1727 | s3 = peg$FAILED; 1728 | if (peg$silentFails === 0) { peg$fail(peg$c74); } 1729 | } 1730 | if (s3 !== peg$FAILED) { 1731 | peg$savedPos = s2; 1732 | s3 = peg$c75(); 1733 | } 1734 | s2 = s3; 1735 | if (s2 === peg$FAILED) { 1736 | s2 = peg$currPos; 1737 | if (input.charCodeAt(peg$currPos) === 114) { 1738 | s3 = peg$c76; 1739 | peg$currPos++; 1740 | } else { 1741 | s3 = peg$FAILED; 1742 | if (peg$silentFails === 0) { peg$fail(peg$c77); } 1743 | } 1744 | if (s3 !== peg$FAILED) { 1745 | peg$savedPos = s2; 1746 | s3 = peg$c78(); 1747 | } 1748 | s2 = s3; 1749 | if (s2 === peg$FAILED) { 1750 | s2 = peg$currPos; 1751 | if (input.charCodeAt(peg$currPos) === 116) { 1752 | s3 = peg$c79; 1753 | peg$currPos++; 1754 | } else { 1755 | s3 = peg$FAILED; 1756 | if (peg$silentFails === 0) { peg$fail(peg$c80); } 1757 | } 1758 | if (s3 !== peg$FAILED) { 1759 | peg$savedPos = s2; 1760 | s3 = peg$c81(); 1761 | } 1762 | s2 = s3; 1763 | if (s2 === peg$FAILED) { 1764 | s2 = peg$currPos; 1765 | if (input.charCodeAt(peg$currPos) === 117) { 1766 | s3 = peg$c82; 1767 | peg$currPos++; 1768 | } else { 1769 | s3 = peg$FAILED; 1770 | if (peg$silentFails === 0) { peg$fail(peg$c83); } 1771 | } 1772 | if (s3 !== peg$FAILED) { 1773 | s4 = peg$currPos; 1774 | s5 = peg$currPos; 1775 | s6 = peg$parseHEXDIG(); 1776 | if (s6 !== peg$FAILED) { 1777 | s7 = peg$parseHEXDIG(); 1778 | if (s7 !== peg$FAILED) { 1779 | s8 = peg$parseHEXDIG(); 1780 | if (s8 !== peg$FAILED) { 1781 | s9 = peg$parseHEXDIG(); 1782 | if (s9 !== peg$FAILED) { 1783 | s6 = [s6, s7, s8, s9]; 1784 | s5 = s6; 1785 | } else { 1786 | peg$currPos = s5; 1787 | s5 = peg$FAILED; 1788 | } 1789 | } else { 1790 | peg$currPos = s5; 1791 | s5 = peg$FAILED; 1792 | } 1793 | } else { 1794 | peg$currPos = s5; 1795 | s5 = peg$FAILED; 1796 | } 1797 | } else { 1798 | peg$currPos = s5; 1799 | s5 = peg$FAILED; 1800 | } 1801 | if (s5 !== peg$FAILED) { 1802 | s4 = input.substring(s4, peg$currPos); 1803 | } else { 1804 | s4 = s5; 1805 | } 1806 | if (s4 !== peg$FAILED) { 1807 | peg$savedPos = s2; 1808 | s3 = peg$c84(s4); 1809 | s2 = s3; 1810 | } else { 1811 | peg$currPos = s2; 1812 | s2 = peg$FAILED; 1813 | } 1814 | } else { 1815 | peg$currPos = s2; 1816 | s2 = peg$FAILED; 1817 | } 1818 | } 1819 | } 1820 | } 1821 | } 1822 | } 1823 | } 1824 | } 1825 | } 1826 | if (s2 !== peg$FAILED) { 1827 | peg$savedPos = s0; 1828 | s1 = peg$c85(s2); 1829 | s0 = s1; 1830 | } else { 1831 | peg$currPos = s0; 1832 | s0 = peg$FAILED; 1833 | } 1834 | } else { 1835 | peg$currPos = s0; 1836 | s0 = peg$FAILED; 1837 | } 1838 | } 1839 | 1840 | return s0; 1841 | } 1842 | 1843 | function peg$parseescape() { 1844 | var s0; 1845 | 1846 | if (input.charCodeAt(peg$currPos) === 92) { 1847 | s0 = peg$c63; 1848 | peg$currPos++; 1849 | } else { 1850 | s0 = peg$FAILED; 1851 | if (peg$silentFails === 0) { peg$fail(peg$c64); } 1852 | } 1853 | 1854 | return s0; 1855 | } 1856 | 1857 | function peg$parsequotation_mark() { 1858 | var s0; 1859 | 1860 | if (input.charCodeAt(peg$currPos) === 34) { 1861 | s0 = peg$c61; 1862 | peg$currPos++; 1863 | } else { 1864 | s0 = peg$FAILED; 1865 | if (peg$silentFails === 0) { peg$fail(peg$c62); } 1866 | } 1867 | 1868 | return s0; 1869 | } 1870 | 1871 | function peg$parseunescaped() { 1872 | var s0; 1873 | 1874 | if (peg$c86.test(input.charAt(peg$currPos))) { 1875 | s0 = input.charAt(peg$currPos); 1876 | peg$currPos++; 1877 | } else { 1878 | s0 = peg$FAILED; 1879 | if (peg$silentFails === 0) { peg$fail(peg$c87); } 1880 | } 1881 | 1882 | return s0; 1883 | } 1884 | 1885 | function peg$parseDIGIT() { 1886 | var s0; 1887 | 1888 | if (peg$c88.test(input.charAt(peg$currPos))) { 1889 | s0 = input.charAt(peg$currPos); 1890 | peg$currPos++; 1891 | } else { 1892 | s0 = peg$FAILED; 1893 | if (peg$silentFails === 0) { peg$fail(peg$c89); } 1894 | } 1895 | 1896 | return s0; 1897 | } 1898 | 1899 | function peg$parseHEXDIG() { 1900 | var s0; 1901 | 1902 | if (peg$c90.test(input.charAt(peg$currPos))) { 1903 | s0 = input.charAt(peg$currPos); 1904 | peg$currPos++; 1905 | } else { 1906 | s0 = peg$FAILED; 1907 | if (peg$silentFails === 0) { peg$fail(peg$c91); } 1908 | } 1909 | 1910 | return s0; 1911 | } 1912 | 1913 | peg$result = peg$startRuleFunction(); 1914 | 1915 | if (peg$result !== peg$FAILED && peg$currPos === input.length) { 1916 | return peg$result; 1917 | } else { 1918 | if (peg$result !== peg$FAILED && peg$currPos < input.length) { 1919 | peg$fail(peg$endExpectation()); 1920 | } 1921 | 1922 | throw peg$buildStructuredError( 1923 | peg$maxFailExpected, 1924 | peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, 1925 | peg$maxFailPos < input.length 1926 | ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) 1927 | : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) 1928 | ); 1929 | } 1930 | } 1931 | 1932 | module.exports = { 1933 | SyntaxError: peg$SyntaxError, 1934 | parse: peg$parse 1935 | }; 1936 | --------------------------------------------------------------------------------