diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 793e852..0000000 --- a/.eslintrc +++ /dev/null @@ -1,17 +0,0 @@ -{ - "env": { - "mocha": true, - "node": true - }, - - "rules": { - "global-strict": 0, - "quotes": 0, - "no-trailing-spaces": 0, - "eol-last": 0, - "consistent-return": 0, - "no-underscore-dangle": 0, - "yoda": 0, - "no-unused-vars": 0 - } -} \ No newline at end of file diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 412eeda..0000000 --- a/.gitattributes +++ /dev/null @@ -1,22 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp -*.sln merge=union -*.csproj merge=union -*.vbproj merge=union -*.fsproj merge=union -*.dbproj merge=union - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 05380fd..0000000 --- a/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/node_modules/ -coverage/ -npm-debug.log - -test.js -test.spider - -*.map -test.html -parse.js diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 8f7fac6..0000000 --- a/.npmignore +++ /dev/null @@ -1,9 +0,0 @@ -test.js -test.js.map -test.spider -src/ -test/ -coverage/ -.git* -*.map -npm-debug.log \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ff32ef3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: node_js -node_js: - - '0.10' -before_script: - - npm install -g grunt-cli istanbul spider-script -after_success: -- istanbul cover -x lib/parser.js ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage diff --git a/.yo-rc.json b/.yo-rc.json deleted file mode 100644 index 0408dcc..0000000 --- a/.yo-rc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "generator-node": {} -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 91e20ad..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,64 +0,0 @@ -### Changelog - -2014 11 29 - **v0.1.3-alpha** - - * Separate a lot of CLI logic to lib/spider - * Default behaviour for CLI - * Refactor `spider.compile` API - * Fix source map path bug with ES5 target - * Fix "System is not defined" error when using Spider API - -2014 11 29 - **v0.1.2-alpha** - - * CLI bug fixes - -2014 11 27 - **v0.1.1-alpha** - - * [Async/Await](http://spiderlang.org/#async) - * [Channels](http://spiderlang.org/#channels) - * Add undefined keyword - * Fix an undefined bug with destructing patterns - * Fix CLI execute and remove dependency on vm2 - -2014 11 26 - **v0.1.0-alpha** - - * Add a `--target=ES5|ES6` flag (ES5 target uses [Traceur Compiler](https://github.com/google/traceur-compiler)) - * Change `func` keyword to `fn` - * [ES6 Import/Export support](http://spiderlang.org/#modules) - * [Curried Functions](http://spiderlang.org/#functions-curried-functions) - * [Destructring Assignments](http://spiderlang.org/#destructuring) - * [Object Initializer Shorthand](http://spiderlang.org/#shorthand-property-names) - * [Property Method Assignments](http://spiderlang.org/#shorthand-method-names) - * [Multi-line Strings](http://spiderlang.org/#strings-multi-line-strings) - * [Pattern Matching](http://spiderlang.org/#switch-pattern-matching) - * [Do-While Loop](http://spiderlang.org/#do-while-statement) - * Delete Statement - * Add JavaScript core global identifiers to defined identifiers - * Add `__dirname` and `__filename` to `use :node` - * Remove ES6 polyfills (Traceur is now responsible for that) - * Fix CLI execute script - * Fix source maps for function expressions - -2014 11 22 - **v0.0.7-alpha** - - * Fat Arrow (`=>`) Function Expressions - * `not` keyword - * Fix `break` and `return` statements inside `for-in` and `for-of` statements - * Disable source map generation option in CLI - * Fix CLI execute script - * Comma is now optional between switch case clauses - * Regular Expression Literals - -2014 11 20 - **v0.0.6-alpha** - - * Fallthrough Statement - * Fix line endings - -2014 11 20 - **v0.0.5-alpha** - - * Spider is now [self-hosted](http://en.wikipedia.org/wiki/Self-hosting) - * Parenthesis in `while` and `until` statements are now optional - * Massive parsing performance improvements - * Fix "use strict" in compiled JS - * Add `setTimeout` to `use :node` and `use :browser` - * Optimize `!!!` to `!` in compiled JS \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index ce2ecaa..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,97 +0,0 @@ -"use strict"; -(function () { - module.exports = function (grunt) { - require("traceur"); - require("time-grunt")(grunt); - require("load-grunt-tasks")(grunt); - grunt.initConfig({ - nodeunit: { files: ["test/**/*_test.js"] }, - eslint: { - lib: [ - "lib/**/*.js", - "!lib/parser.js" - ], - test: ["test/**/*.js"] - }, - mochacli: { - options: { - reporter: "spec", - bail: true, - timeout: 15000 - }, - all: ["test/*.js"] - }, - watch: { - gruntfile: { - files: "<%= jshint.gruntfile.src %>", - tasks: ["jshint:gruntfile"] - }, - lib: { - files: "<%= jshint.lib.src %>", - tasks: [ - "jshint:lib", - "mochacli" - ] - }, - test: { - files: "<%= jshint.test.src %>", - tasks: [ - "jshint:test", - "mochacli" - ] - } - }, - peg: { - spider: { - src: "src/spider.pegjs", - dest: "lib/parser.js" - } - }, - mocha_istanbul: { - coverage: { - src: "test", - options: { - mask: "*.js", - excludes: ["lib/parser.js"] - } - } - }, - clean: { build: ["lib/"] }, - spider_script: { - options: {}, - build: { - files: [{ - expand: true, - cwd: "src", - src: ["**/*.spider"], - dest: "lib/", - ext: ".js" - }] - } - }, - copy: { - build: { - files: [{ - expand: true, - cwd: "src", - src: ["**/*.js"], - dest: "lib/" - }] - } - } - }); - grunt.registerTask("default", [ - "build", - "mochacli" - ]); - grunt.registerTask("build", [ - "clean:build", - "peg", - "spider_script:build", - "copy:build" - ]); - grunt.registerTask("coverage", ["mocha_istanbul:coverage"]); - }; -}()); - -//# sourceMappingURL=Gruntfile.map \ No newline at end of file diff --git a/Gruntfile.spider b/Gruntfile.spider deleted file mode 100644 index 9b81490..0000000 --- a/Gruntfile.spider +++ /dev/null @@ -1,93 +0,0 @@ -use :node; - -module.exports = fn (grunt) { - require('traceur'); - - // Show elapsed time at the end - require('time-grunt')(grunt); - // Load all grunt tasks - require('load-grunt-tasks')(grunt); - - // Project configuration. - grunt.initConfig({ - nodeunit: { - files: ['test/**/*_test.js'] - }, - eslint: { - lib: [ - 'lib/**/*.js', - '!lib/parser.js' - ], - test: [ - 'test/**/*.js' - ] - }, - mochacli: { - options: { - reporter: 'spec', - bail: true, - timeout: 15000 - }, - all: ['test/*.js'] - }, - watch: { - gruntfile: { - files: '<%= jshint.gruntfile.src %>', - tasks: ['jshint:gruntfile'] - }, - lib: { - files: '<%= jshint.lib.src %>', - tasks: ['jshint:lib', 'mochacli'] - }, - test: { - files: '<%= jshint.test.src %>', - tasks: ['jshint:test', 'mochacli'] - } - }, - peg: { - spider: { - src: "src/spider.pegjs", - dest: "lib/parser.js" - } - }, - mocha_istanbul: { - coverage: { - src: 'test', - options: { - mask: '*.js', - excludes: ['lib/parser.js'] - }, - } - }, - clean: { - build: ["lib/"], - }, - spider_script: { - options: {}, - build: { - files: [{ - expand: true, - cwd: 'src', - src: ['**/*.spider'], - dest: 'lib/', - ext: '.js' - }] - } - }, - copy: { - build: { - files: [{ - expand: true, - cwd: 'src', - src: ['**/*.js'], - dest: 'lib/', - }] - } - } - }); - - // Default task. - grunt.registerTask('default', ['build', 'mochacli']); - grunt.registerTask('build', ['clean:build', 'peg', 'spider_script:build', 'copy:build']); - grunt.registerTask('coverage', ['mocha_istanbul:coverage']); -}; diff --git a/LICENSE b/LICENSE deleted file mode 100644 index ad410e1..0000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md index 2c20a88..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,50 +0,0 @@ -Spider -=== - -[![NPM Version](http://img.shields.io/npm/v/spider-script.svg?style=flat)](https://www.npmjs.org/package/spider-script) [![Build Status](https://img.shields.io/travis/alongubkin/spider.svg?style=flat)](http://travis-ci.org/alongubkin/spider) [![Dependencies](http://img.shields.io/david/alongubkin/spider.svg?style=flat)](https://david-dm.org/alongubkin/spider) [![Test Coverage](http://img.shields.io/coveralls/alongubkin/spider.svg?style=flat)](https://coveralls.io/r/alongubkin/spider) - -The ~~Next-Gen~~ Programming Language for the Web. - -**Note:** This project is no longer active. - -[Documentation](http://spiderlang.org/) - -### Installation - - npm install -g spider-script - -### Usage - -Execute a script: - - spider /path/to/script.spider - -Compile a script: - - spider -c /path/to/script.spider - -### Join the Community - -* Website: http://spiderlang.org -* IRC: [#spiderlang](http://webchat.freenode.net/?channels=spiderlang) on Freenode -* IRC Logs: [#spiderlang](https://botbot.me/freenode/spiderlang/) on BotBot -* Q/A: [spiderlang](http://stackoverflow.com/questions/tagged/spiderlang) tag in StackOverflow -* [Google Group](http://groups.google.com/d/forum/spiderlang?hl=en) - -### Contributing - -We need your help! - -You can browse the [contributing-getting-started](https://github.com/alongubkin/spider/labels/contributing-getting-started) tag to find good issues to get started with. - - 1. [Fork](https://github.com/alongubkin/spider/fork) the project - 2. Clone your forked repo: `git clone git@github.com:githubuser/spider.git` - 3. Create your feature/bugfix branch: `git checkout -b new-operator` - 4. Commit your changes to your new branch: `git commit -am 'Add a new operator'` - 5. Push to the branch: `git push origin new-operator` - 6. Create a new Pull Request! - -Resources: - - * [PEG.js](http://pegjs.majda.cz/) (Used for parsing) - * [Esprima Parser](http://esprima.org/demo/parse.html#]) (Good way to learn the SpiderMonkey AST) diff --git a/cli.js b/cli.js deleted file mode 100755 index 13f1aab..0000000 --- a/cli.js +++ /dev/null @@ -1,130 +0,0 @@ -#! /usr/bin/env node - -"use strict"; - -var fs = require("fs"), - path = require("path"), - vm = require("vm"), - traceur = require("traceur"), - nomnom = require("nomnom"), - chalk = require("chalk"), - spider = require("./lib/spider"); - -var opts = nomnom - .option("files", { - position: 0, - help: "files to compile", - list: true - }) - .option("compile", { - abbr: "c", - flag: true, - help: "compile to JavaScript and save as .js files" - }) - .option("verbose", { - abbr: "v", - flag: true, - help: "verbose mode" - }) - .option("disable-source-map", { - flag: true, - help: "disable source map files (.map) generation" - }) - .option("target", { - choices: ["ES6", "es6", "ES5", "es5"], - default: "ES5", - help: "target" - }) - .option("version", { - flag: true, - help: "display the version number", - callback: function () { - return "version " + require("./package.json").version; - } - }) - .parse(); - -if (!opts.files) { - console.log(nomnom.getUsage()); - process.exit(0); -} - -var generateSourceMap = !opts['disable-source-map'] && opts.compile; -var problems = 0; - -opts.files.forEach(function (fileName, fileIndex) { - var baseName = path.basename(fileName); - - fs.readFile(baseName, "utf-8", function (error, content) { - var compilerOutput = spider.compile({ - text: content, - fileName: baseName, - target: opts.target.toUpperCase(), - generateSourceMap: generateSourceMap, - modules: 'commonjs' - }); - - if (compilerOutput.errors.length > 0) { - console.log(spider.formatErrors(baseName, content, compilerOutput.errors)); - problems += compilerOutput.errors.length; - - if (problems > 0 && - fileIndex === opts.files.length - 1) { - console.log(chalk.red(problems + (problems === 1 ? " problem" : " problems"))); - } - } else { - if (opts.compile) { - var outFileNameWithoutExtension = fileName.substring(0, - fileName.lastIndexOf('.')); - - writeFile(outFileNameWithoutExtension + ".js", - compilerOutput.result); - - if (generateSourceMap) { - writeFile(outFileNameWithoutExtension + ".map", - compilerOutput.result); - } - } else { - var sandbox = {}; - for (var key in global) { - sandbox[key] = global[key]; - } - var Module, _module, _require; - Module = require('module'); - sandbox.module = _module = new Module(outFileNameWithoutExtension || 'eval'); - sandbox.require = _require = function(path) { - return Module._load(path, _module, true); - }; - _module.filename = sandbox.__filename; - Object.getOwnPropertyNames(require).forEach(function(r){ - if (r !== 'paths' && r !== 'arguments' && r !== 'caller') { - _require[r] = require[r]; - } - }) - _require.paths = _module.paths = Module._nodeModulePaths(process.cwd()).concat(process.cwd()); - _require.resolve = function(request) { - return Module._resolveFilename(request, _module); - }; - _require.extensions['.spider'] = function(module, fname){ - var content = require('fs').readFileSync(fname, 'utf8'); - var src = spider.compile({ - modules: 'commonjs', - text: content, - filename: fname, - target: opts.target - }).result; - module._compile(src, fname); - }; - vm.runInNewContext(compilerOutput.result, sandbox, fileName); - } - } - }); -}); - -function writeFile(fileName, content) { - fs.writeFile(fileName, content, function (error) { - if (error) { - return console.log(error); - } - }); -} \ No newline at end of file diff --git a/lib/ast.js b/lib/ast.js deleted file mode 100644 index c52a06c..0000000 --- a/lib/ast.js +++ /dev/null @@ -1,16 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var nodes = ["Node", "Program", "VariableDeclarator", "Property", "Range", "Parameter", "CatchClause", "CaseClause", "ImportSpecifier", "ImportNamespaceSpecifier", "ImportDefaultSpecifier", "ExportSpecifier", "ExportBatchSpecifier", "expressions/AssignmentExpression", "expressions/BinaryExpression", "expressions/CallExpression", "expressions/ExistentialExpression", "expressions/LogicalExpression", "expressions/MemberExpression", "expressions/NullCheckCallExpression", "expressions/NullCoalescingExpression", "expressions/NullPropagatingExpression", "expressions/UnaryExpression", "expressions/ObjectExpression", "expressions/ArrayExpression", "expressions/ObjectPattern", "expressions/ArrayPattern", "expressions/UpdateExpression", "expressions/FunctionExpression", "expressions/RangeMemberExpression", "expressions/NewExpression", "expressions/ThisExpression", "expressions/SuperExpression", "expressions/SplatExpression", "expressions/ConditionalExpression", "expressions/InExpression", "expressions/ForInExpression", "expressions/CurryCallExpression", "statements/BlockStatement", "statements/ExpressionStatement", "statements/IfStatement", "statements/ForStatement", "statements/ForInStatement", "statements/ForOfStatement", "statements/WhileStatement", "statements/UntilStatement", "statements/VariableDeclarationStatement", "statements/FunctionDeclarationStatement", "statements/ReturnStatement", "statements/ThrowStatement", "statements/BreakStatement", "statements/ContinueStatement", "statements/DebuggerStatement", "statements/UseStatement", "statements/TryStatement", "statements/SwitchStatement", "statements/FallthroughStatement", "statements/ImportDeclarationStatement", "statements/ExportDeclarationStatement", "statements/DoWhileStatement", "statements/PushStatement", "statements/GoStatement", "literals/BooleanLiteral", "literals/NumberLiteral", "literals/StringLiteral", "literals/NullLiteral", "literals/UndefinedLiteral", "literals/Identifier", "literals/RegularExpressionLiteral"]; - module.exports = {}; - for (var $__0 = nodes[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var node = $__1.value; - { - var name = node.substring(node.lastIndexOf("/") + 1); - module.exports[name] = module.require("./ast/" + node)[name]; - } - } - return {}; -}); - -//# sourceMappingURL=ast.map diff --git a/lib/ast/CaseClause.js b/lib/ast/CaseClause.js deleted file mode 100644 index 1be0b98..0000000 --- a/lib/ast/CaseClause.js +++ /dev/null @@ -1,179 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("./Node").Node; - function CaseClause(tests, body) { - Node.call(this); - this.type = "CaseClause"; - this.body = body; - this.body.parent = this; - this.tests = tests; - if (typeof this.tests !== "undefined" && this.tests !== null) { - for (var $__0 = this.tests[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var test = $__1.value; - { - test.parent = this; - } - } - } - } - CaseClause.prototype = Object.create(Node); - CaseClause.prototype.codegen = function(branchFallthrough) { - if (!Node.prototype.codegen.call(this)) { - return; - } - if (!(typeof this.tests !== "undefined" && this.tests !== null) && !branchFallthrough) { - return this.body.codegen(); - } - this.type = "IfStatement"; - this.switchCase = true; - var rangeError = false; - if (typeof this.tests !== "undefined" && this.tests !== null) { - for (var $__2 = this.tests[$traceurRuntime.toProperty(Symbol.iterator)](), - $__3; !($__3 = $__2.next()).done; ) { - var test = $__3.value; - { - var equalsToDiscriminant; - if (test.type === "Range") { - var fromCheck; - if (test.start) { - fromCheck = { - "type": "BinaryExpression", - "operator": ">=", - "left": this.parent.discriminant, - "right": test.start - }; - } - var toCheck; - if (test.to) { - toCheck = { - "type": "BinaryExpression", - "operator": "<" + (test.operator === ".." ? "=" : ""), - "left": this.parent.discriminant, - "right": test.to - }; - } - if (!!fromCheck && !!toCheck) { - equalsToDiscriminant = { - "type": "LogicalExpression", - "operator": "&&", - "left": fromCheck, - "right": toCheck - }; - } else { - if (!!fromCheck || !!toCheck) { - equalsToDiscriminant = typeof fromCheck === "undefined" || fromCheck == null ? toCheck : fromCheck; - } else { - rangeError = test; - break; - } - } - } else { - if (test.type === "ArrayExpression") { - test = test.codegen(); - equalsToDiscriminant = { - "type": "BinaryExpression", - "operator": ">=", - "left": { - "type": "MemberExpression", - "computed": false, - "object": this.parent.discriminant, - "property": { - "type": "Identifier", - "name": "length" - } - }, - "right": { - "type": "Literal", - "value": test.elements.length - } - }; - var i = 0; - for (var $__0 = test.elements[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var element = $__1.value; - { - if (typeof element !== "undefined" && element !== null) { - equalsToDiscriminant = { - "type": "LogicalExpression", - "operator": "&&", - "left": equalsToDiscriminant, - "right": { - "type": "BinaryExpression", - "operator": "===", - "left": { - "type": "MemberExpression", - "computed": true, - "object": this.parent.discriminant, - "property": { - "type": "Literal", - "value": i - } - }, - "right": element - } - }; - } - i++; - } - } - } else { - equalsToDiscriminant = { - "type": "BinaryExpression", - "operator": "===", - "left": this.parent.discriminant, - "right": test.codegen() - }; - } - } - if (!this.test) { - this.test = equalsToDiscriminant; - } else { - this.test = { - "type": "LogicalExpression", - "operator": "||", - "left": this.test, - "right": equalsToDiscriminant - }; - } - } - } - } - if (rangeError) { - Node.getErrorManager().error({ - type: "EmptyRange", - message: "empty range in case clause is disallowed.", - loc: rangeError.loc - }); - return null; - } - this.consequent = this.body.codegen(); - if (branchFallthrough) { - var fallthroughTest = { - "type": "BinaryExpression", - "left": this.parent.fallthroughId, - "operator": "<", - "right": { - "type": "Literal", - "value": 2 - } - }; - if (!(typeof this.tests !== "undefined" && this.tests !== null)) { - this.test = fallthroughTest; - } else { - this.test = { - "type": "LogicalExpression", - "operator": "&&", - "left": fallthroughTest, - "right": this.test - }; - } - } - this.alternate = null; - return this; - }; - exports.CaseClause = CaseClause; - return {}; -}); - -//# sourceMappingURL=CaseClause.map diff --git a/lib/ast/CatchClause.js b/lib/ast/CatchClause.js deleted file mode 100644 index 9b79bdf..0000000 --- a/lib/ast/CatchClause.js +++ /dev/null @@ -1,26 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("./Node").Node; - function CatchClause(param, body) { - Node.call(this); - this.type = "CatchClause"; - this.param = param; - this.param.parent = this; - this.body = body; - this.body.parent = this; - } - CatchClause.prototype = Object.create(Node); - CatchClause.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.param = this.param.codegen(false); - this.defineIdentifier(this.param); - this.body = this.body.codegen(); - return this; - }; - exports.CatchClause = CatchClause; - return {}; -}); - -//# sourceMappingURL=CatchClause.map diff --git a/lib/ast/ExportBatchSpecifier.js b/lib/ast/ExportBatchSpecifier.js deleted file mode 100644 index 89c243e..0000000 --- a/lib/ast/ExportBatchSpecifier.js +++ /dev/null @@ -1,19 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("./Node").Node; - function ExportBatchSpecifier() { - Node.call(this); - this.type = "ExportBatchSpecifier"; - } - ExportBatchSpecifier.prototype = Object.create(Node); - ExportBatchSpecifier.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - return this; - }; - exports.ExportBatchSpecifier = ExportBatchSpecifier; - return {}; -}); - -//# sourceMappingURL=ExportBatchSpecifier.map diff --git a/lib/ast/ExportSpecifier.js b/lib/ast/ExportSpecifier.js deleted file mode 100644 index b162907..0000000 --- a/lib/ast/ExportSpecifier.js +++ /dev/null @@ -1,33 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("./Node").Node; - function ExportSpecifier(id, alias) { - Node.call(this); - this.type = "ExportSpecifier"; - this.id = id; - this.id.parent = this; - if (typeof alias !== "undefined" && alias !== null) { - this.alias = alias; - this.alias.parent = this; - } - } - ExportSpecifier.prototype = Object.create(Node); - ExportSpecifier.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.id = this.id.codegen(false); - Object.defineProperty(this, "name", { - value: typeof this.alias !== "undefined" && this.alias !== null ? { - "type": "Identifier", - "name": this.alias.name - } : null, - enumerable: true - }); - return this; - }; - exports.ExportSpecifier = ExportSpecifier; - return {}; -}); - -//# sourceMappingURL=ExportSpecifier.map diff --git a/lib/ast/ImportDefaultSpecifier.js b/lib/ast/ImportDefaultSpecifier.js deleted file mode 100644 index ae68422..0000000 --- a/lib/ast/ImportDefaultSpecifier.js +++ /dev/null @@ -1,23 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("./Node").Node; - function ImportDefaultSpecifier(id) { - Node.call(this); - this.type = "ImportDefaultSpecifier"; - this.id = id; - this.id.parent = this; - } - ImportDefaultSpecifier.prototype = Object.create(Node); - ImportDefaultSpecifier.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.id = this.id.codegen(false); - this.getContext().node.defineIdentifier(this.id); - return this; - }; - exports.ImportDefaultSpecifier = ImportDefaultSpecifier; - return {}; -}); - -//# sourceMappingURL=ImportDefaultSpecifier.map diff --git a/lib/ast/ImportNamespaceSpecifier.js b/lib/ast/ImportNamespaceSpecifier.js deleted file mode 100644 index 6eb0b29..0000000 --- a/lib/ast/ImportNamespaceSpecifier.js +++ /dev/null @@ -1,23 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("./Node").Node; - function ImportNamespaceSpecifier(id) { - Node.call(this); - this.type = "ImportNamespaceSpecifier"; - this.id = id; - this.id.parent = this; - } - ImportNamespaceSpecifier.prototype = Object.create(Node); - ImportNamespaceSpecifier.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.id = this.id.codegen(false); - this.getContext().node.defineIdentifier(this.id); - return this; - }; - exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier; - return {}; -}); - -//# sourceMappingURL=ImportNamespaceSpecifier.map diff --git a/lib/ast/ImportSpecifier.js b/lib/ast/ImportSpecifier.js deleted file mode 100644 index c1e1634..0000000 --- a/lib/ast/ImportSpecifier.js +++ /dev/null @@ -1,40 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("./Node").Node; - function ImportSpecifier(id, alias) { - Node.call(this); - this.type = "ImportSpecifier"; - if (typeof id !== "undefined" && id !== null) { - this.id = id; - this.id.parent = this; - } - if (typeof alias !== "undefined" && alias !== null) { - this.alias = alias; - this.alias.parent = this; - } - } - ImportSpecifier.prototype = Object.create(Node); - ImportSpecifier.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - if (typeof this.id !== "undefined" && this.id !== null) { - this.id = this.id.codegen(false); - } else { - this.type = "ImportNamespaceSpecifier"; - } - Object.defineProperty(this, "name", { - value: typeof this.alias !== "undefined" && this.alias !== null ? { - "type": "Identifier", - "name": this.alias.name - } : null, - enumerable: true - }); - this.getContext().node.defineIdentifier(this.alias == null ? this.id : this.alias); - return this; - }; - exports.ImportSpecifier = ImportSpecifier; - return {}; -}); - -//# sourceMappingURL=ImportSpecifier.map diff --git a/lib/ast/Node.js b/lib/ast/Node.js deleted file mode 100644 index 08aeaa8..0000000 --- a/lib/ast/Node.js +++ /dev/null @@ -1,93 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - function Node() { - var self = this; - self.codeGenerated = false; - self.definedIdentifiers = []; - Object.defineProperty(self, "parent", { - value: null, - writable: true, - configurable: true, - enumerable: false - }); - self.getContext = function() { - if (!!(self.type === "Program") || !!(self.type === "BlockStatement")) { - return { - node: self, - position: -1 - }; - } - if (!(typeof self.parent !== "undefined" && self.parent !== null)) { - return null; - } - var context = self.parent.getContext(); - if (!(typeof context !== "undefined" && context !== null)) { - return null; - } - if (context.position === -1) { - return { - node: context.node, - position: context.node.body.indexOf(self) - }; - } else { - return context; - } - }; - self.defineIdentifier = function(identifier) { - self.definedIdentifiers.push(identifier); - }; - self.isIdentifierDefined = function(name) { - var defined = false; - for (var $__0 = self.definedIdentifiers[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var identifier = $__1.value; - { - if (identifier.name === name) { - defined = true; - } - } - } - return !!defined || !!(!!self.parent && !!self.parent.isIdentifierDefined(name)); - }; - self.getDefinedIdentifier = function(name) { - var id; - for (var $__0 = self.definedIdentifiers[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var identifier = $__1.value; - { - if (identifier.name === name) { - id = identifier; - } - } - } - return typeof id === "undefined" || id == null ? self.parent ? self.parent.getDefinedIdentifier(name) : null : id; - }; - self.blockWrap = function() { - if (self.type === "BlockStatement") { - return self; - } - var myParent = self.parent; - var blockStatement = module.require("./statements/BlockStatement"); - var block = new blockStatement.BlockStatement([self]); - block.parent = myParent; - return block; - }; - } - Node.prototype.codegen = function() { - if (this.codeGenerated) { - return false; - } - this.codeGenerated = true; - return true; - }; - Node.setErrorManager = function(errorManager) { - this.errorManager = errorManager; - }; - Node.getErrorManager = function() { - return this.errorManager; - }; - exports.Node = Node; - return {}; -}); - -//# sourceMappingURL=Node.map diff --git a/lib/ast/Parameter.js b/lib/ast/Parameter.js deleted file mode 100644 index 4a40d19..0000000 --- a/lib/ast/Parameter.js +++ /dev/null @@ -1,229 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("./Node").Node; - function Parameter(id, defaultValue, splat) { - Node.call(this); - this.type = "Parameter"; - this.splat = splat; - this.id = id; - this.id.parent = this; - this.defaultValue = defaultValue; - if (typeof this.defaultValue !== "undefined" && this.defaultValue !== null) { - this.defaultValue.parent = this; - } - } - Parameter.prototype = Object.create(Node); - Parameter.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.id = this.id.codegen(false); - if (typeof this.defaultValue !== "undefined" && this.defaultValue !== null) { - this.defaultValue = this.defaultValue.codegen(); - } - return this; - }; - Parameter.prototype.hasCallExpression = function() { - return false; - }; - Parameter.generateFunctionBody = function(func, params, body, defaults) { - var splatPosition = -1; - var i = 0; - for (var $__0 = params[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var param = $__1.value; - { - if (param.splat) { - if (splatPosition !== -1) { - Node.getErrorManager().error({ - type: "MultipleSplatsDisallowed", - message: "multiple splats are disallowed in a function declaration", - loc: param.loc - }); - } - splatPosition = i; - } - param = param.codegen(); - defaults.push(param.defaultValue); - params[i] = param.id; - func.defineIdentifier(param.id); - i++; - } - } - if (splatPosition !== -1) { - var declarations = [{ - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "__splat" - }, - "init": null - }]; - var i$__4 = 0; - for (var $__2 = params[$traceurRuntime.toProperty(Symbol.iterator)](), - $__3; !($__3 = $__2.next()).done; ) { - var param$__5 = $__3.value; - { - var init; - if (i$__4 < splatPosition) { - init = { - "type": "MemberExpression", - "computed": true, - "object": { - "type": "Identifier", - "name": "arguments" - }, - "property": { - "type": "Literal", - "value": i$__4 - } - }; - } else { - if (i$__4 === splatPosition) { - init = { - "type": "ConditionalExpression", - "test": { - "type": "BinaryExpression", - "operator": "<=", - "left": { - "type": "Literal", - "value": params.length - }, - "right": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "arguments" - }, - "property": { - "type": "Identifier", - "name": "length" - } - } - }, - "consequent": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ArrayExpression", - "elements": [] - }, - "property": { - "type": "Identifier", - "name": "slice" - } - }, - "property": { - "type": "Identifier", - "name": "call" - } - }, - "arguments": [{ - "type": "Identifier", - "name": "arguments" - }, { - "type": "Literal", - "value": splatPosition - }] - }, - "alternate": { - "type": "ArrayExpression", - "elements": [] - } - }; - if (splatPosition < params.length - 1) { - init.consequent.arguments.push({ - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "__splat" - }, - "right": { - "type": "BinaryExpression", - "operator": "-", - "left": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "arguments" - }, - "property": { - "type": "Identifier", - "name": "length" - } - }, - "right": { - "type": "Literal", - "value": params.length - splatPosition - 1 - } - } - }); - init.alternate = { - "type": "SequenceExpression", - "expressions": [{ - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "__splat" - }, - "right": { - "type": "Literal", - "value": splatPosition - } - }, { - "type": "ArrayExpression", - "elements": [] - }] - }; - } - } else { - init = { - "type": "MemberExpression", - "computed": true, - "object": { - "type": "Identifier", - "name": "arguments" - }, - "property": { - "type": "UpdateExpression", - "operator": "++", - "argument": { - "type": "Identifier", - "name": "__splat" - }, - "prefix": false - } - }; - } - } - declarations.push({ - "type": "VariableDeclarator", - "id": param$__5, - "init": init - }); - i$__4++; - } - } - body.body = [{ - "type": "VariableDeclaration", - "codeGenerated": true, - "declarations": declarations, - "kind": "let" - }].concat(body.body); - params.length = 0; - } - }; - exports.Parameter = Parameter; - return {}; -}); - -//# sourceMappingURL=Parameter.map diff --git a/lib/ast/Program.js b/lib/ast/Program.js deleted file mode 100644 index fa27269..0000000 --- a/lib/ast/Program.js +++ /dev/null @@ -1,58 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("./Node").Node; - function Program(body) { - Node.call(this); - this.type = "Program"; - this.body = body; - var i = 0; - for (var $__0 = body[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var statement = $__1.value; - { - if (typeof statement !== "undefined" && statement !== null) { - statement.parent = this; - } else { - body[i] = {type: "EmptyStatement"}; - } - i++; - } - } - this.definedIdentifiers = Program.prototype.generateIdentifiers("Infinity", "NaN", "eval", "uneval", "isFinite", "isNaN", "parseFloat", "parseInt", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "escape", "unescape", "Object", "Function", "Boolean", "Symbol", "Error", "EvalError", "InternalError", "RangeError", "ReferenceError", "StopIteration", "SyntaxError", "TypeError", "URIError", "Number", "Math", "Date", "String", "RegExp", "Array", "Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "Map", "Set", "WeakMap", "WeakSet", "ArrayBuffer", "DataView", "JSON", "Iterator", "Generator", "Promise", "arguments"); - } - Program.prototype = Object.create(Node); - Program.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var i = 0; - while (i < this.body.length) { - var statement = this.body[i]; - if (!statement || !!statement.codeGenerated) { - i++; - continue; - } - if (!!statement.codegen && !!statement.codegen()) { - this.body[this.body.indexOf(statement)] = statement; - i++; - } else { - this.body.splice(i, 1); - } - } - return this; - }; - Program.prototype.generateIdentifiers = function() { - var __splat, - identifiers = 1 <= arguments.length ? [].slice.call(arguments, 0) : []; - return identifiers.map(function(id) { - return { - "type": "Identifier", - "name": id - }; - }); - }; - exports.Program = Program; - return {}; -}); - -//# sourceMappingURL=Program.map diff --git a/lib/ast/Property.js b/lib/ast/Property.js deleted file mode 100644 index b92a7f2..0000000 --- a/lib/ast/Property.js +++ /dev/null @@ -1,32 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("./Node").Node; - function Property(key, value, shorthand, method) { - Node.call(this); - this.type = "Property"; - this.kind = "init"; - this.method = method; - this.shorthand = shorthand; - this.computed = false; - this.key = key; - this.key.parent = this; - this.value = value; - this.value.parent = this; - } - Property.prototype = Object.create(Node); - Property.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.key = this.key.codegen(false); - this.value = this.value.codegen(this.parent.type !== "ObjectPattern"); - return this; - }; - Property.prototype.hasCallExpression = function() { - return this.value.hasCallExpression(); - }; - exports.Property = Property; - return {}; -}); - -//# sourceMappingURL=Property.map diff --git a/lib/ast/Range.js b/lib/ast/Range.js deleted file mode 100644 index 7029d64..0000000 --- a/lib/ast/Range.js +++ /dev/null @@ -1,257 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("./Node").Node; - function Range(start, operator, to) { - Node.call(this); - this.type = "Range"; - this.operator = operator; - this.start = start; - if (typeof this.start !== "undefined" && this.start !== null) { - this.start.parent = this; - } - this.to = to; - if (typeof this.to !== "undefined" && this.to !== null) { - this.to.parent = this; - } - } - Range.prototype = Object.create(Node); - Range.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var isNumber = function(n) { - return !isNaN(parseFloat(n)) && !!isFinite(n); - }; - var isNumeric = !!isNumber(this.start.value) && !!isNumber(this.to.value); - this.start = this.start.codegen(); - this.to = this.to.codegen(); - var updateOperator, - testOperator; - if (isNumeric) { - updateOperator = this.start.value < this.to.value ? "++" : "--"; - testOperator = this.start.value < this.to.value ? "<" : ">"; - if (this.operator === "..") { - testOperator += "="; - } - } - if (!!isNumeric && !!(Math.abs(this.to.value - this.start.value) <= 20)) { - this.type = "ArrayExpression"; - this.elements = []; - var test = function(i) { - if (testOperator === ">") { - return i > this.to.value; - } else if (testOperator === "<") { - return i < this.to.value; - } else if (testOperator === ">=") { - return i >= this.to.value; - } else if (testOperator === "<=") { - return i <= this.to.value; - } - }; - for (var i = this.start.value; test.call(this, i); updateOperator === "++" ? i++ : i--) { - this.elements.push({ - "type": "Literal", - "value": i - }); - } - } else { - var testExpression, - updateExpression; - var declarations = [{ - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "_results" - }, - "init": { - "type": "ArrayExpression", - "elements": [] - } - }]; - if (isNumeric) { - testExpression = { - "type": "BinaryExpression", - "operator": testOperator, - "left": { - "type": "Identifier", - "name": "_i" - }, - "right": this.to - }; - updateExpression = { - "type": "UpdateExpression", - "operator": updateOperator, - "argument": { - "type": "Identifier", - "name": "_i" - }, - "prefix": false - }; - } else { - if (this.start.hasCallExpression()) { - var startId = { - "type": "Identifier", - "name": "_start" - }; - declarations.push({ - "type": "VariableDeclarator", - "id": startId, - "init": this.start - }); - this.start = startId; - } - if (this.to.hasCallExpression()) { - var endId = { - "type": "Identifier", - "name": "_end" - }; - declarations.push({ - "type": "VariableDeclarator", - "id": endId, - "init": this.to - }); - this.to = endId; - } - testExpression = { - "type": "ConditionalExpression", - "test": { - "type": "BinaryExpression", - "operator": "<=", - "left": this.start, - "right": this.to - }, - "consequent": { - "type": "BinaryExpression", - "operator": "<" + (this.operator === ".." ? "=" : ""), - "left": { - "type": "Identifier", - "name": "_i" - }, - "right": this.to - }, - "alternate": { - "type": "BinaryExpression", - "operator": ">" + (this.operator === ".." ? "=" : ""), - "left": { - "type": "Identifier", - "name": "_i" - }, - "right": this.to - } - }; - updateExpression = { - "type": "ConditionalExpression", - "test": { - "type": "BinaryExpression", - "operator": "<=", - "left": this.start, - "right": this.to - }, - "consequent": { - "type": "UpdateExpression", - "operator": "++", - "argument": { - "type": "Identifier", - "name": "_i" - }, - "prefix": false - }, - "alternate": { - "type": "UpdateExpression", - "operator": "--", - "argument": { - "type": "Identifier", - "name": "_i" - }, - "prefix": false - } - }; - } - this.type = "CallExpression"; - this.callee = { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "FunctionExpression", - "id": null, - "params": [], - "defaults": [], - "body": { - "type": "BlockStatement", - "body": [{ - "type": "VariableDeclaration", - "declarations": declarations, - "kind": "let" - }, { - "type": "ForStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "_i" - }, - "init": this.start - }], - "kind": "let" - }, - "test": testExpression, - "update": updateExpression, - "body": { - "type": "BlockStatement", - "body": [{ - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "_results" - }, - "property": { - "type": "Identifier", - "name": "push" - } - }, - "arguments": [{ - "type": "Identifier", - "name": "_i" - }] - } - }] - } - }, { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "_results" - } - }] - }, - "rest": null, - "generator": false, - "expression": false - }, - "property": { - "type": "Identifier", - "name": "apply" - } - }; - Object.defineProperty(this, "arguments", { - value: [{"type": "ThisExpression"}], - enumerable: true - }); - } - return this; - }; - Range.prototype.hasCallExpression = function() { - return true; - }; - exports.Range = Range; - return {}; -}); - -//# sourceMappingURL=Range.map diff --git a/lib/ast/VariableDeclarator.js b/lib/ast/VariableDeclarator.js deleted file mode 100644 index 54350e9..0000000 --- a/lib/ast/VariableDeclarator.js +++ /dev/null @@ -1,29 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("./Node").Node; - function VariableDeclarator(id, init) { - Node.call(this); - this.type = "VariableDeclarator"; - this.id = id; - this.id.parent = this; - this.init = init; - if (typeof this.init !== "undefined" && this.init !== null) { - this.init.parent = this; - } - } - VariableDeclarator.prototype = Object.create(Node); - VariableDeclarator.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - if (typeof this.init !== "undefined" && this.init !== null) { - this.init = this.init.codegen(); - } - this.id = this.id.codegen(); - return this; - }; - exports.VariableDeclarator = VariableDeclarator; - return {}; -}); - -//# sourceMappingURL=VariableDeclarator.map diff --git a/lib/ast/expressions/ArrayExpression.js b/lib/ast/expressions/ArrayExpression.js deleted file mode 100644 index a3e7129..0000000 --- a/lib/ast/expressions/ArrayExpression.js +++ /dev/null @@ -1,41 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ArrayExpression(elements) { - Node.call(this); - this.type = "ArrayExpression"; - this.elements = elements; - for (var $__0 = this.elements[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var element = $__1.value; - { - if (typeof element !== "undefined" && element !== null) { - element.parent = this; - } - } - } - } - ArrayExpression.prototype = Object.create(Node); - ArrayExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var i = 0; - for (var $__0 = this.elements[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var element = $__1.value; - { - this.elements[i] = typeof element !== "undefined" && element !== null ? element.codegen() : void 0; - i++; - } - } - return this; - }; - ArrayExpression.prototype.hasCallExpression = function() { - return true; - }; - exports.ArrayExpression = ArrayExpression; - return {}; -}); - -//# sourceMappingURL=ArrayExpression.map diff --git a/lib/ast/expressions/ArrayPattern.js b/lib/ast/expressions/ArrayPattern.js deleted file mode 100644 index d92560d..0000000 --- a/lib/ast/expressions/ArrayPattern.js +++ /dev/null @@ -1,45 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ArrayPattern(elements) { - Node.call(this); - this.type = "ArrayPattern"; - this.elements = elements; - for (var $__0 = this.elements[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var element = $__1.value; - { - if (typeof element !== "undefined" && element !== null) { - element.parent = this; - } - } - } - } - ArrayPattern.prototype = Object.create(Node); - ArrayPattern.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var context = this.getContext().node; - var i = 0; - for (var $__0 = this.elements[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var element = $__1.value; - { - this.elements[i] = typeof element !== "undefined" && element !== null ? element.codegen(false) : void 0; - if (!!(typeof element !== "undefined" && element !== null) && !!(element.type === "Identifier")) { - context.defineIdentifier(element); - } - i++; - } - } - return this; - }; - ArrayPattern.prototype.hasCallExpression = function() { - return true; - }; - exports.ArrayPattern = ArrayPattern; - return {}; -}); - -//# sourceMappingURL=ArrayPattern.map diff --git a/lib/ast/expressions/AssignmentExpression.js b/lib/ast/expressions/AssignmentExpression.js deleted file mode 100644 index 99d3217..0000000 --- a/lib/ast/expressions/AssignmentExpression.js +++ /dev/null @@ -1,29 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function AssignmentExpression(left, operator, right) { - Node.call(this); - this.type = "AssignmentExpression"; - this.operator = operator; - this.left = left; - this.left.parent = this; - this.right = right; - this.right.parent = this; - } - AssignmentExpression.prototype = Object.create(Node); - AssignmentExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.left = this.left.codegen(); - this.right = this.right.codegen(); - return this; - }; - AssignmentExpression.prototype.hasCallExpression = function() { - return !!(typeof this.left !== "undefined" && this.left !== null ? this.left.hasCallExpression() : void 0) || !!(typeof this.right !== "undefined" && this.right !== null ? this.right.hasCallExpression() : void 0); - }; - exports.AssignmentExpression = AssignmentExpression; - return {}; -}); - -//# sourceMappingURL=AssignmentExpression.map diff --git a/lib/ast/expressions/BinaryExpression.js b/lib/ast/expressions/BinaryExpression.js deleted file mode 100644 index a0b9bb4..0000000 --- a/lib/ast/expressions/BinaryExpression.js +++ /dev/null @@ -1,104 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function BinaryExpression(left, operator, right) { - Node.call(this); - this.type = "BinaryExpression"; - this.operator = operator; - this.left = left; - this.left.parent = this; - this.right = right; - this.right.parent = this; - } - BinaryExpression.prototype = Object.create(Node); - BinaryExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var isRelational = function(operator) { - var inExpression0 = [">", ">=", "<", ">="]; - return inExpression0 instanceof Array ? inExpression0.indexOf(operator) !== -1 : operator in inExpression0; - }; - if (!!isRelational(this.operator) && !!isRelational(this.left.operator)) { - this.type = "LogicalExpression"; - this.right = { - "type": "BinaryExpression", - "operator": this.operator, - "left": this.left.right, - "right": this.right.codegen() - }; - this.left = this.left.codegen(); - this.operator = "&&"; - } else { - this.left = this.left.codegen(); - this.right = this.right.codegen(); - if (this.operator === "==") { - this.operator = "==="; - } else if (this.operator === "!=") { - this.operator = "!=="; - } else if (this.operator === "**") { - this.type = "CallExpression"; - this.callee = { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "Math" - }, - "property": { - "type": "Identifier", - "name": "pow" - } - }; - Object.defineProperty(this, "arguments", { - value: [this.left, this.right], - enumerable: true - }); - } else if (this.operator === "#") { - this.type = "CallExpression"; - this.callee = { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "Math" - }, - "property": { - "type": "Identifier", - "name": "floor" - } - }; - Object.defineProperty(this, "arguments", { - value: [{ - "type": "BinaryExpression", - "operator": "/", - "left": this.left, - "right": this.right - }], - enumerable: true - }); - } else if (this.operator === "%%") { - this.operator = "%"; - this.left = { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "BinaryExpression", - "operator": "%", - "left": this.left, - "right": this.right - }, - "right": this.right - }; - } - } - return this; - }; - BinaryExpression.prototype.hasCallExpression = function() { - return !!(typeof this.left !== "undefined" && this.left !== null ? this.left.hasCallExpression() : void 0) || !!(typeof this.right !== "undefined" && this.right !== null ? this.right.hasCallExpression() : void 0); - }; - exports.BinaryExpression = BinaryExpression; - return {}; -}); - -//# sourceMappingURL=BinaryExpression.map diff --git a/lib/ast/expressions/CallExpression.js b/lib/ast/expressions/CallExpression.js deleted file mode 100644 index f063261..0000000 --- a/lib/ast/expressions/CallExpression.js +++ /dev/null @@ -1,139 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function CallExpression(callee, args) { - Node.call(this); - this.type = "CallExpression"; - this.callee = callee; - this.callee.parent = this; - Object.defineProperty(this, "arguments", { - value: args, - enumerable: true - }); - for (var $__0 = args[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var arg = $__1.value; - { - arg.parent = this; - } - } - } - CallExpression.prototype = Object.create(Node); - CallExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var calleeType = this.callee.type; - if (!this.callee.codeGenerated) { - this.callee = this.callee.codegen(); - } - var args = this.arguments; - var splatPositions = []; - var i = 0; - for (var $__0 = args[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var arg = $__1.value; - { - if (!!(args[i].type === "SplatExpression") || !!args[i].__splat) { - splatPositions.push(i); - } - if (!args[i].codeGenerated) { - args[i] = arg.codegen(); - } - i++; - } - } - if (splatPositions.length > 0) { - var argsClone = args.slice(0); - args.length = 0; - args.push({ - "type": "Literal", - "value": null - }); - if (argsClone.length === 1) { - args.push(argsClone[0].arguments[0]); - } else { - args.push({ - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": splatPositions[0] === 0 ? argsClone[0] : { - "type": "ArrayExpression", - "elements": argsClone.slice(0, splatPositions[0]) - }, - "property": { - "type": "Identifier", - "name": "concat" - } - }, - "arguments": argsClone.slice(splatPositions[0] === 0 ? 1 : splatPositions[0]).map(function(arg, i) { - if (splatPositions.indexOf(i + (splatPositions[0] === 0 ? 1 : splatPositions[0])) !== -1) { - return arg; - } - return { - "type": "ArrayExpression", - "elements": [arg] - }; - }) - }); - } - } - if (!!(this.callee.type === "ConditionalExpression") && !!(!!(calleeType === "NullPropagatingExpression") || !!(calleeType === "MemberExpression"))) { - var parent = this.parent; - var consequent = { - type: "CallExpression", - callee: this.callee.consequent, - arguments: this.arguments - }; - if (splatPositions.length > 0) { - this.callee.consequent = { - "type": "MemberExpression", - "computed": false, - "object": this.callee.consequent, - "property": { - "type": "Identifier", - "name": "apply" - } - }; - } - if (parent.type === "ExpressionStatement") { - parent.type = "IfStatement"; - parent.test = this.callee.test; - parent.consequent = { - type: "BlockStatement", - body: [{ - type: "ExpressionStatement", - expression: consequent - }] - }; - parent.alternate = null; - } else { - this.type = "ConditionalExpression"; - this.test = this.callee.test; - this.consequent = consequent; - this.alternate = this.callee.alternate; - } - } else { - if (splatPositions.length > 0) { - this.callee = { - "type": "MemberExpression", - "computed": false, - "object": this.callee, - "property": { - "type": "Identifier", - "name": "apply" - } - }; - } - } - return this; - }; - CallExpression.prototype.hasCallExpression = function() { - return true; - }; - exports.CallExpression = CallExpression; - return {}; -}); - -//# sourceMappingURL=CallExpression.map diff --git a/lib/ast/expressions/ConditionalExpression.js b/lib/ast/expressions/ConditionalExpression.js deleted file mode 100644 index 49de010..0000000 --- a/lib/ast/expressions/ConditionalExpression.js +++ /dev/null @@ -1,31 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ConditionalExpression(test, consequent, alternate) { - Node.call(this); - this.type = "ConditionalExpression"; - this.test = test; - this.test.parent = this; - this.consequent = consequent; - this.consequent.parent = this; - this.alternate = alternate; - this.alternate.parent = this; - } - ConditionalExpression.prototype = Object.create(Node); - ConditionalExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.test = this.test.codegen(); - this.consequent = this.consequent.codegen(); - this.alternate = this.alternate.codegen(); - return this; - }; - ConditionalExpression.prototype.hasCallExpression = function() { - return true; - }; - exports.ConditionalExpression = ConditionalExpression; - return {}; -}); - -//# sourceMappingURL=ConditionalExpression.map diff --git a/lib/ast/expressions/CurryCallExpression.js b/lib/ast/expressions/CurryCallExpression.js deleted file mode 100644 index 6b70b71..0000000 --- a/lib/ast/expressions/CurryCallExpression.js +++ /dev/null @@ -1,102 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node, - CallExpression = module.require("./CallExpression").CallExpression; - function CurryCallExpression(callee, args) { - Node.call(this); - this.type = "CurryCallExpression"; - this.callee = callee; - this.args = args; - } - CurryCallExpression.prototype = Object.create(Node); - CurryCallExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var call = new CallExpression(this.callee, this.args); - call.parent = this; - call = call.codegen(); - if (!!(call.type !== "CallExpression") || !!(!!((typeof call !== "undefined" && call !== null ? call.callee.type : void 0) === "MemberExpression") && !!((typeof call !== "undefined" && call !== null ? call.callee.property.name : void 0) === "apply"))) { - Node.getErrorManager().error({ - type: "InvalidFunctionCurrying", - message: "currying functions with existential operator or splats is disallowed.", - loc: this.loc - }); - } - this.type = "FunctionExpression"; - this.id = null; - this.params = []; - this.defaults = []; - this.body = { - "type": "BlockStatement", - "body": [{ - "type": "ReturnStatement", - "argument": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": call.callee, - "property": { - "type": "Identifier", - "name": "apply" - } - }, - "arguments": [{"type": "ThisExpression"}, { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ArrayExpression", - "elements": call.arguments - }, - "property": { - "type": "Identifier", - "name": "concat" - } - }, - "arguments": [{ - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ArrayExpression", - "elements": [] - }, - "property": { - "type": "Identifier", - "name": "slice" - } - }, - "property": { - "type": "Identifier", - "name": "apply" - } - }, - "arguments": [{ - "type": "Identifier", - "name": "arguments" - }] - }] - }] - } - }] - }; - this.rest = null; - this.generator = false; - this.expression = false; - return this; - }; - CurryCallExpression.prototype.hasCallExpression = function() { - return true; - }; - exports.CurryCallExpression = CurryCallExpression; - return {}; -}); - -//# sourceMappingURL=CurryCallExpression.map diff --git a/lib/ast/expressions/ExistentialExpression.js b/lib/ast/expressions/ExistentialExpression.js deleted file mode 100644 index 163cba1..0000000 --- a/lib/ast/expressions/ExistentialExpression.js +++ /dev/null @@ -1,83 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ExistentialExpression(argument) { - Node.call(this); - this.type = "ExistentialExpression"; - this.argument = argument; - this.argument.parent = this; - } - ExistentialExpression.prototype = Object.create(Node); - ExistentialExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var nullCoalescing0 = typeof this.argument.hasCallExpression === "function" ? this.argument.hasCallExpression() : void 0; - var isArgumentCallExpression = nullCoalescing0 == null ? false : nullCoalescing0; - this.argument = this.argument.codegen(); - if (isArgumentCallExpression) { - var context = this.getContext(); - var id = { - "type": "Identifier", - "name": ExistentialExpression.getNextVariableName() - }; - context.node.body.splice(context.position + (ExistentialExpression.existentialIndex - 2), 0, { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": id, - "init": this.argument - }], - "kind": "let", - "codeGenerated": true - }); - this.argument = id; - } - var nullCheck = { - "type": "BinaryExpression", - "operator": "!==", - "left": this.argument, - "right": { - "type": "Literal", - "value": null, - "raw": "null" - } - }; - this.type = "LogicalExpression"; - this.operator = "&&"; - this.left = { - "type": "BinaryExpression", - "operator": "!==", - "left": { - "type": "UnaryExpression", - "operator": "typeof", - "argument": this.argument, - "prefix": true - }, - "right": { - "type": "Literal", - "value": "undefined", - "raw": "'undefined'" - } - }; - this.right = nullCheck; - return this; - }; - ExistentialExpression.prototype.hasCallExpression = function() { - var nullCoalescing1 = typeof this.argument !== "undefined" && this.argument !== null && typeof this.argument.hasCallExpression === "function" ? this.argument.hasCallExpression() : void 0; - return nullCoalescing1 == null ? false : nullCoalescing1; - }; - ExistentialExpression.getNextVariableName = function() { - if (!(typeof this.existentialIndex !== "undefined" && this.existentialIndex !== null)) { - this.existentialIndex = 0; - } - return "existential" + this.existentialIndex++; - }; - ExistentialExpression.resetVariableNames = function() { - this.existentialIndex = 0; - }; - exports.ExistentialExpression = ExistentialExpression; - return {}; -}); - -//# sourceMappingURL=ExistentialExpression.map diff --git a/lib/ast/expressions/ForInExpression.js b/lib/ast/expressions/ForInExpression.js deleted file mode 100644 index cadd264..0000000 --- a/lib/ast/expressions/ForInExpression.js +++ /dev/null @@ -1,116 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node, - ForInStatement = module.require("../statements/ForInStatement").ForInStatement, - BlockStatement = module.require("../statements/BlockStatement").BlockStatement; - function ForInExpression(expression, item, index, array, condition) { - Node.call(this); - this.type = "ForInExpression"; - this.expression = expression; - this.expression.parent = this; - this.item = item; - this.item.parent = this; - this.index = index; - if (typeof this.index !== "undefined" && this.index !== null) { - this.index.parent = this; - } - this.array = array; - this.array.parent = this; - this.condition = condition; - if (typeof this.condition !== "undefined" && this.condition !== null) { - this.condition.parent = this; - } - } - ForInExpression.prototype = Object.create(Node); - ForInExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.defineIdentifier(this.item); - if (typeof this.index !== "undefined" && this.index !== null) { - this.defineIdentifier(this.index); - } - var id = { - "type": "Identifier", - "name": ForInExpression.getNextVariableName(), - "codeGenerated": true - }; - var pushStatement = { - "type": "ExpressionStatement", - "codeGenerated": true, - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": id, - "property": { - "type": "Identifier", - "name": "push" - } - }, - "arguments": [this.expression.codegen()] - } - }; - if (typeof this.condition !== "undefined" && this.condition !== null) { - pushStatement = { - "type": "IfStatement", - "codeGenerated": true, - "test": this.condition.codegen(), - "consequent": { - "type": "BlockStatement", - "body": [pushStatement] - }, - "alternate": null - }; - } - var forInStatement = new ForInStatement(this.item, this.index, this.array, new BlockStatement([pushStatement])); - var fnBlock = new BlockStatement([{ - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": id, - "init": { - "type": "ArrayExpression", - "elements": [] - } - }], - "kind": "let", - "codeGenerated": true - }, forInStatement, { - "type": "ReturnStatement", - "codeGenerated": true, - "argument": id - }]); - forInStatement.parent = fnBlock; - this.type = "CallExpression"; - this.callee = { - "type": "FunctionExpression", - "id": null, - "params": [], - "defaults": [], - "body": fnBlock.codegen() - }; - Object.defineProperty(this, "arguments", { - value: [], - enumerable: true - }); - return this; - }; - ForInExpression.prototype.hasCallExpression = function() { - return true; - }; - ForInExpression.getNextVariableName = function() { - if (!(typeof this.forInIndex !== "undefined" && this.forInIndex !== null)) { - this.forInIndex = 0; - } - return "forIn" + this.forInIndex++; - }; - ForInExpression.resetVariableNames = function() { - this.forInIndex = 0; - }; - exports.ForInExpression = ForInExpression; - return {}; -}); - -//# sourceMappingURL=ForInExpression.map diff --git a/lib/ast/expressions/FunctionExpression.js b/lib/ast/expressions/FunctionExpression.js deleted file mode 100644 index 20bf109..0000000 --- a/lib/ast/expressions/FunctionExpression.js +++ /dev/null @@ -1,157 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node, - Parameter = module.require("../Parameter").Parameter, - CallExpression = module.require("../expressions/CallExpression").CallExpression; - function FunctionExpression(id, params, body, inheritsFrom, operator) { - Node.call(this); - if (operator === "=>") { - this.type = "ArrowFunctionExpression"; - } else { - this.type = "FunctionExpression"; - } - this.defaults = []; - this.rest = null; - this.generator = false; - this.expression = false; - this.operator = operator; - this.id = id; - if (typeof this.id !== "undefined" && this.id !== null) { - this.id.parent = this; - } - this.body = body; - this.params = params; - body.parent = this; - for (var $__0 = params[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var param = $__1.value; - { - param.parent = this; - } - } - this.inheritsFrom = inheritsFrom; - if (typeof this.inheritsFrom !== "undefined" && this.inheritsFrom !== null) { - this.inheritsFrom.parent = this; - } - if (this.body.type !== "BlockStatement") { - this.autoBlock = true; - this.body = { - "type": "BlockStatement", - "body": [{ - "type": "ReturnStatement", - "argument": this.body - }] - }; - var self = this; - this.getContext = function() { - return { - node: self.body, - position: -1 - }; - }; - } - } - FunctionExpression.prototype = Object.create(Node); - FunctionExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - if (typeof this.id !== "undefined" && this.id !== null) { - this.id = this.id.codegen(false); - } - Parameter.generateFunctionBody(this, this.params, this.body, this.defaults); - if (this.autoBlock) { - this.body.body[0].argument = this.body.body[this.body.body.length - 1].argument.codegen(); - } else { - this.body = this.body.codegen(); - } - if (typeof this.inheritsFrom !== "undefined" && this.inheritsFrom !== null) { - if (this.inheritsFrom.type !== "CallExpression") { - this.inheritsFrom = new CallExpression(this.inheritsFrom, []); - this.inheritsFrom.parent = this; - } - var context = this.getContext(); - this.body.body.splice(0, 0, { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": this.inheritsFrom.callee, - "property": { - "type": "Identifier", - "name": "call" - } - }, - "arguments": [{"type": "ThisExpression"}].concat(this.inheritsFrom.arguments) - } - }); - var id = { - "type": "Identifier", - "name": FunctionExpression.getNextVariableName() - }; - context.node.body.splice(context.position, 0, { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": id, - "init": this - }], - "kind": "let", - "codeGenerated": true - }); - context.node.body.splice(context.position + 1, 0, { - "type": "ExpressionStatement", - "codeGenerated": "true", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "computed": false, - "object": id, - "property": { - "type": "Identifier", - "name": "prototype" - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "Object" - }, - "property": { - "type": "Identifier", - "name": "create" - } - }, - "arguments": [this.inheritsFrom.callee] - } - } - }); - return id; - } - return this; - }; - FunctionExpression.prototype.hasCallExpression = function() { - return true; - }; - FunctionExpression.getNextVariableName = function() { - if (!(typeof this.functionExpressionIndex !== "undefined" && this.functionExpressionIndex !== null)) { - this.functionExpressionIndex = 0; - } - return "functionExpression" + this.functionExpressionIndex++; - }; - FunctionExpression.resetVariableNames = function() { - this.functionExpressionIndex = 0; - }; - exports.FunctionExpression = FunctionExpression; - return {}; -}); - -//# sourceMappingURL=FunctionExpression.map diff --git a/lib/ast/expressions/InExpression.js b/lib/ast/expressions/InExpression.js deleted file mode 100644 index 02ebe16..0000000 --- a/lib/ast/expressions/InExpression.js +++ /dev/null @@ -1,99 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function InExpression(left, right) { - Node.call(this); - this.type = "InExpression"; - this.left = left; - this.left.parent = this; - this.right = right; - this.right.parent = this; - } - InExpression.prototype = Object.create(Node); - InExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.left = this.left.codegen(); - this.right = this.right.codegen(); - if (typeof this.right.hasCallExpression === "function" ? this.right.hasCallExpression() : void 0) { - var context = this.getContext(); - var id = { - "type": "Identifier", - "name": InExpression.getNextVariableName(), - "codeGenerated": true - }; - context.node.body.splice(context.position + (InExpression.inExpressionIndex - 2), 0, { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": id, - "init": this.right - }], - "kind": "let", - "codeGenerated": true - }); - this.right = id; - } - this.type = "ConditionalExpression"; - this.test = { - "type": "BinaryExpression", - "operator": "instanceof", - "left": this.right, - "right": { - "type": "Identifier", - "name": "Array" - } - }; - this.consequent = { - "type": "BinaryExpression", - "operator": "!==", - "left": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": this.right, - "property": { - "type": "Identifier", - "name": "indexOf" - } - }, - "arguments": [this.left] - }, - "right": { - "type": "UnaryExpression", - "operator": "-", - "argument": { - "type": "Literal", - "value": 1, - "raw": "1" - }, - "prefix": true - } - }; - this.alternate = { - "type": "BinaryExpression", - "operator": "in", - "left": this.left, - "right": this.right - }; - return this; - }; - InExpression.prototype.hasCallExpression = function() { - return true; - }; - InExpression.getNextVariableName = function() { - if (!(typeof this.inExpressionIndex !== "undefined" && this.inExpressionIndex !== null)) { - this.inExpressionIndex = 0; - } - return "inExpression" + this.inExpressionIndex++; - }; - InExpression.resetVariableNames = function() { - this.inExpressionIndex = 0; - }; - exports.InExpression = InExpression; - return {}; -}); - -//# sourceMappingURL=InExpression.map diff --git a/lib/ast/expressions/LogicalExpression.js b/lib/ast/expressions/LogicalExpression.js deleted file mode 100644 index f7a49d5..0000000 --- a/lib/ast/expressions/LogicalExpression.js +++ /dev/null @@ -1,50 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function LogicalExpression(left, operator, right) { - Node.call(this); - this.type = "LogicalExpression"; - this.operator = operator; - if (this.operator === "and") { - this.operator = "&&"; - } else if (this.operator === "or") { - this.operator = "||"; - } - this.left = left; - this.left.parent = this; - this.right = right; - this.right.parent = this; - } - LogicalExpression.prototype = Object.create(Node); - LogicalExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var enforceBooleanExpression = function(o) { - if (!!(o.type === "UnaryExpression") && !!(o.operator === "!")) { - return o; - } - return { - "type": "UnaryExpression", - "operator": "!", - "argument": { - "type": "UnaryExpression", - "operator": "!", - "argument": o, - "prefix": true - }, - "prefix": true - }; - }; - this.left = enforceBooleanExpression(this.left.codegen()); - this.right = enforceBooleanExpression(this.right.codegen()); - return this; - }; - LogicalExpression.prototype.hasCallExpression = function() { - return !!(typeof this.left !== "undefined" && this.left !== null ? this.left.hasCallExpression() : void 0) || !!(typeof this.right !== "undefined" && this.right !== null ? this.right.hasCallExpression() : void 0); - }; - exports.LogicalExpression = LogicalExpression; - return {}; -}); - -//# sourceMappingURL=LogicalExpression.map diff --git a/lib/ast/expressions/MemberExpression.js b/lib/ast/expressions/MemberExpression.js deleted file mode 100644 index 27a665e..0000000 --- a/lib/ast/expressions/MemberExpression.js +++ /dev/null @@ -1,43 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function MemberExpression(left, right, computed) { - Node.call(this); - this.type = "MemberExpression"; - this.computed = computed; - this.object = left; - this.object.parent = this; - this.property = right; - this.property.parent = this; - } - MemberExpression.prototype = Object.create(Node); - MemberExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var objectType = this.object.type; - this.object = this.object.codegen(); - if (!this.property.codeGenerated) { - this.property = this.property.codegen(false); - } - if (!!(this.object.type === "ConditionalExpression") && !!(!!(!!(!!(objectType === "NullPropagatingExpression") || !!(objectType === "MemberExpression")) || !!(objectType === "CallExpression")) || !!(objectType === "NullCheckCallExpression"))) { - this.type = this.object.type; - this.test = this.object.test; - this.alternate = this.object.alternate; - this.consequent = { - type: "MemberExpression", - object: this.object.consequent, - property: this.property, - computed: this.computed - }; - } - return this; - }; - MemberExpression.prototype.hasCallExpression = function() { - return !!(!!this.object.__null_propagating || !!(typeof this.object !== "undefined" && this.object !== null && typeof this.object.hasCallExpression === "function" ? this.object.hasCallExpression() : void 0)) || !!(typeof this.property !== "undefined" && this.property !== null ? this.property.hasCallExpression() : void 0); - }; - exports.MemberExpression = MemberExpression; - return {}; -}); - -//# sourceMappingURL=MemberExpression.map diff --git a/lib/ast/expressions/NewExpression.js b/lib/ast/expressions/NewExpression.js deleted file mode 100644 index c9303d2..0000000 --- a/lib/ast/expressions/NewExpression.js +++ /dev/null @@ -1,46 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function NewExpression(callee, args) { - Node.call(this); - this.type = "NewExpression"; - this.callee = callee; - this.callee.parent = this; - Object.defineProperty(this, "arguments", { - value: args, - enumerable: true - }); - for (var $__0 = args[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var arg = $__1.value; - { - arg.parent = this; - } - } - } - NewExpression.prototype = Object.create(Node); - NewExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.callee = this.callee.codegen(); - var args = this.arguments; - var i = 0; - for (var $__0 = args[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var arg = $__1.value; - { - args[i] = arg.codegen(); - i++; - } - } - return this; - }; - NewExpression.prototype.hasCallExpression = function() { - return true; - }; - exports.NewExpression = NewExpression; - return {}; -}); - -//# sourceMappingURL=NewExpression.map diff --git a/lib/ast/expressions/NullCheckCallExpression.js b/lib/ast/expressions/NullCheckCallExpression.js deleted file mode 100644 index be034ef..0000000 --- a/lib/ast/expressions/NullCheckCallExpression.js +++ /dev/null @@ -1,132 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node, - CallExpression = module.require("./CallExpression").CallExpression; - function NullCheckCallExpression(callee, args) { - Node.call(this); - this.type = "NullCheckCallExpression"; - this.callee = callee; - this.callee.parent = this; - this.args = args; - for (var $__0 = args[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var arg = $__1.value; - { - arg.parent = this; - } - } - } - NullCheckCallExpression.prototype = Object.create(Node); - NullCheckCallExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var calleeType = this.callee.type; - this.callee = this.callee.codegen(); - var args = this.args; - var i = 0; - for (var $__0 = args[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var arg = $__1.value; - { - var isSplat = args[i].type === "SplatExpression"; - args[i] = arg.codegen(); - args[i].codeGenerated = true; - if (isSplat) { - args[i].__splat = true; - } - i++; - } - } - if (typeof this.callee.hasCallExpression === "function" ? this.callee.hasCallExpression() : void 0) { - var context = this.getContext(); - var id = { - "type": "Identifier", - "name": NullCheckCallExpression.getNextVariableName(), - "codeGenerated": true - }; - context.node.body.splice(context.position + (NullCheckCallExpression.nullCheckIndex - 2), 0, { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": id, - "init": this.callee - }], - "kind": "let", - "codeGenerated": true - }); - this.callee = id; - } - var test = { - "type": "BinaryExpression", - "operator": "===", - "left": { - "type": "UnaryExpression", - "operator": "typeof", - "argument": this.callee, - "prefix": true - }, - "right": { - "type": "Literal", - "value": "function", - "raw": "\"function\"" - } - }; - var argument = test.left.argument; - if (calleeType === "NullPropagatingExpression") { - argument = argument.consequent; - test.left.argument = argument; - test = { - "type": "LogicalExpression", - "operator": "&&", - "left": this.callee.test, - "right": test - }; - } - argument.codeGenerated = true; - var consequent = new CallExpression(argument, args).codegen(); - if (this.parent.type === "ExpressionStatement") { - this.parent.type = "IfStatement"; - this.parent.test = test; - this.parent.consequent = { - type: "BlockStatement", - body: [{ - type: "ExpressionStatement", - expression: consequent - }] - }; - this.parent.alternate = null; - } else { - this.type = "ConditionalExpression"; - this.test = test; - this.consequent = consequent; - this.alternate = { - "type": "UnaryExpression", - "operator": "void", - "argument": { - "type": "Literal", - "value": 0, - "raw": "0" - }, - "prefix": true - }; - } - return this; - }; - NullCheckCallExpression.prototype.hasCallExpression = function() { - return true; - }; - NullCheckCallExpression.getNextVariableName = function() { - if (!(typeof this.nullCheckIndex !== "undefined" && this.nullCheckIndex !== null)) { - this.nullCheckIndex = 0; - } - return "nullCheck" + this.nullCheckIndex++; - }; - NullCheckCallExpression.resetVariableNames = function() { - this.nullCheckIndex = 0; - }; - exports.NullCheckCallExpression = NullCheckCallExpression; - return {}; -}); - -//# sourceMappingURL=NullCheckCallExpression.map diff --git a/lib/ast/expressions/NullCoalescingExpression.js b/lib/ast/expressions/NullCoalescingExpression.js deleted file mode 100644 index c717686..0000000 --- a/lib/ast/expressions/NullCoalescingExpression.js +++ /dev/null @@ -1,114 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function NullCoalescingExpression(left, right) { - Node.call(this); - this.type = "NullCoalescingExpression"; - this.left = left; - this.left.parent = this; - this.right = right; - this.right.parent = this; - } - NullCoalescingExpression.prototype = Object.create(Node); - NullCoalescingExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var leftType = this.left.type; - this.left = this.left.codegen(); - this.right = this.right.codegen(); - var context = this.getContext(); - var addUndefinedCheck = true; - if (!!(!!(leftType === "NullPropagatingExpression") || !!(leftType === "NullCoalescingExpression")) || !!(typeof this.left.hasCallExpression === "function" ? this.left.hasCallExpression() : void 0)) { - var id = { - "type": "Identifier", - "name": NullCoalescingExpression.getNextLeftName() - }; - context.node.body.splice(context.position, 0, { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": id, - "init": this.left - }], - "kind": "let", - "codeGenerated": true - }); - this.left = id; - addUndefinedCheck = false; - } - var test = { - "type": "BinaryExpression", - "operator": "==", - "left": this.left, - "right": { - "type": "Literal", - "value": null, - "raw": "null" - } - }; - if (this.left.type !== "Identifier") { - addUndefinedCheck = false; - } - if (addUndefinedCheck) { - test = { - "type": "LogicalExpression", - "operator": "||", - "left": { - "type": "BinaryExpression", - "operator": "===", - "left": { - "type": "UnaryExpression", - "operator": "typeof", - "argument": this.left, - "prefix": true - }, - "right": { - "type": "Literal", - "value": "undefined", - "raw": "'undefined'" - } - }, - "right": test - }; - } - if ((typeof this.parent !== "undefined" && this.parent !== null ? this.parent.type : void 0) === "ExpressionStatement") { - if (!this.right.hasCallExpression()) { - this.parent.type = "EmptyStatement"; - return this; - } - this.parent.type = "IfStatement"; - this.parent.test = test; - this.parent.consequent = { - "type": "BlockStatement", - "body": [{ - "type": "ExpressionStatement", - "expression": this.right - }] - }; - } else { - return { - "type": "ConditionalExpression", - "test": test, - "consequent": this.right, - "alternate": this.left - }; - } - }; - NullCoalescingExpression.prototype.hasCallExpression = function() { - return !!(typeof this.left !== "undefined" && this.left !== null ? this.left.hasCallExpression() : void 0) || !!(typeof this.right !== "undefined" && this.right !== null ? this.right.hasCallExpression() : void 0); - }; - NullCoalescingExpression.getNextLeftName = function() { - if (!(typeof this.nullCoalescingIndex !== "undefined" && this.nullCoalescingIndex !== null)) { - this.nullCoalescingIndex = 0; - } - return "nullCoalescing" + this.nullCoalescingIndex++; - }; - NullCoalescingExpression.resetVariableNames = function() { - this.nullCoalescingIndex = 0; - }; - exports.NullCoalescingExpression = NullCoalescingExpression; - return {}; -}); - -//# sourceMappingURL=NullCoalescingExpression.map diff --git a/lib/ast/expressions/NullPropagatingExpression.js b/lib/ast/expressions/NullPropagatingExpression.js deleted file mode 100644 index 81cf906..0000000 --- a/lib/ast/expressions/NullPropagatingExpression.js +++ /dev/null @@ -1,161 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function NullPropagatingExpression(left, right) { - Node.call(this); - this.type = "NullPropagatingExpression"; - this.computed = false; - this.object = left; - this.object.parent = this; - this.property = right; - this.property.parent = this; - } - NullPropagatingExpression.prototype = Object.create(Node); - NullPropagatingExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var context = this.getContext(); - var childType = this.object.type; - this.object = this.object.codegen(); - this.property = this.property.codegen(false); - if (typeof this.object.hasCallExpression === "function" ? this.object.hasCallExpression() : void 0) { - var id = { - "type": "Identifier", - "name": NullPropagatingExpression.getNextObjectName(), - "__member_expression": { - "type": "MemberExpression", - "object": this.object, - "property": this.property, - "computed": false - } - }; - context.node.body.splice(context.position + (NullPropagatingExpression.nullPropagatingIndex - 1), 0, { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": id, - "init": this.object - }], - "kind": "let", - "codeGenerated": true - }); - this.object = id; - } - var condition; - if (childType !== "NullPropagatingExpression") { - condition = { - "type": "BinaryExpression", - "operator": "!==", - "left": this.object, - "right": { - "type": "Literal", - "value": null, - "raw": "null" - }, - "__member_expression": { - "type": "MemberExpression", - "object": this.object, - "property": this.property, - "computed": false - }, - "__first_object": this.object - }; - } else { - condition = { - "type": "LogicalExpression", - "operator": "&&", - "left": this.object, - "right": { - "type": "BinaryExpression", - "operator": "!==", - "left": { - "type": "MemberExpression", - "object": this.object.__member_expression.object, - "property": this.object.__member_expression.property, - "computed": false - }, - "right": { - "type": "Literal", - "value": null, - "raw": "null" - } - }, - "__member_expression": { - "type": "MemberExpression", - "object": this.object.__member_expression, - "property": this.property, - "computed": false - }, - "__first_object": this.object.__first_object - }; - } - if ((typeof this.parent !== "undefined" && this.parent !== null ? this.parent.type : void 0) === "NullPropagatingExpression") { - return condition; - } - condition = { - "type": "LogicalExpression", - "operator": "&&", - "left": { - "type": "BinaryExpression", - "operator": "!==", - "left": { - "type": "UnaryExpression", - "operator": "typeof", - "argument": this.object.__first_object == null ? this.object : this.object.__first_object - }, - "right": { - "type": "Literal", - "value": "undefined", - "raw": "\"undefined\"" - } - }, - "right": condition - }; - condition = { - "type": "ConditionalExpression", - "test": condition, - "consequent": { - "type": "MemberExpression", - "object": !!(this.object.type === "Identifier") || !this.object.__member_expression ? this.object : this.object.__member_expression, - "property": this.property, - "computed": false - }, - "alternate": { - "type": "UnaryExpression", - "operator": "void", - "argument": { - "type": "Literal", - "value": 0, - "raw": "0" - }, - "prefix": true - }, - "__null_propagating": true - }; - return condition; - }; - NullPropagatingExpression.prototype.hasCallExpression = function() { - return true; - }; - NullPropagatingExpression.getNextObjectName = function() { - if (!(typeof this.nullPropagatingIndex !== "undefined" && this.nullPropagatingIndex !== null)) { - this.nullPropagatingIndex = 0; - this.definedObjectNames = []; - } - var name = "nullPropagating" + this.nullPropagatingIndex++; - this.definedObjectNames.push(name); - return name; - }; - NullPropagatingExpression.isObjectNameDefined = function(name) { - return this.definedObjectNames.indexOf(name) !== -1; - }; - NullPropagatingExpression.resetVariableNames = function() { - this.nullPropagatingIndex = 0; - this.definedObjectNames = []; - }; - exports.NullPropagatingExpression = NullPropagatingExpression; - return {}; -}); - -//# sourceMappingURL=NullPropagatingExpression.map diff --git a/lib/ast/expressions/ObjectExpression.js b/lib/ast/expressions/ObjectExpression.js deleted file mode 100644 index a748de8..0000000 --- a/lib/ast/expressions/ObjectExpression.js +++ /dev/null @@ -1,39 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ObjectExpression(properties) { - Node.call(this); - this.type = "ObjectExpression"; - this.properties = properties; - for (var $__0 = this.properties[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var property = $__1.value; - { - property.parent = this; - } - } - } - ObjectExpression.prototype = Object.create(Node); - ObjectExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var i = 0; - for (var $__0 = this.properties[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var property = $__1.value; - { - this.properties[i] = property.codegen(); - i++; - } - } - return this; - }; - ObjectExpression.prototype.hasCallExpression = function() { - return true; - }; - exports.ObjectExpression = ObjectExpression; - return {}; -}); - -//# sourceMappingURL=ObjectExpression.map diff --git a/lib/ast/expressions/ObjectPattern.js b/lib/ast/expressions/ObjectPattern.js deleted file mode 100644 index 41f8d95..0000000 --- a/lib/ast/expressions/ObjectPattern.js +++ /dev/null @@ -1,49 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ObjectPattern(properties) { - Node.call(this); - this.type = "ObjectPattern"; - this.properties = properties; - for (var $__0 = this.properties[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var property = $__1.value; - { - property.parent = this; - } - } - } - ObjectPattern.prototype = Object.create(Node); - ObjectPattern.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var context = this.getContext().node; - var i = 0; - for (var $__0 = this.properties[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var property = $__1.value; - { - this.properties[i] = property.codegen(); - if (typeof property.value !== "undefined" && property.value !== null) { - if (property.value.type === "Identifier") { - context.defineIdentifier(property.value); - } - } else { - if (property.key.type === "Identifier") { - context.defineIdentifier(property.key); - } - } - i++; - } - } - return this; - }; - ObjectPattern.prototype.hasCallExpression = function() { - return true; - }; - exports.ObjectPattern = ObjectPattern; - return {}; -}); - -//# sourceMappingURL=ObjectPattern.map diff --git a/lib/ast/expressions/RangeMemberExpression.js b/lib/ast/expressions/RangeMemberExpression.js deleted file mode 100644 index 3bc9751..0000000 --- a/lib/ast/expressions/RangeMemberExpression.js +++ /dev/null @@ -1,157 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function RangeMemberExpression(object, range) { - Node.call(this); - this.type = "RangeMemberExpression"; - this.object = object; - this.object.parent = this; - this.range = range; - this.range.parent = this; - } - RangeMemberExpression.prototype = Object.create(Node); - RangeMemberExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var isNumber = function(n) { - return !isNaN(parseFloat(n)) && !!isFinite(n); - }; - if (!!(this.parent.type === "AssignmentExpression") && !!(this.parent.left === this)) { - this.parent.type = "CallExpression"; - this.parent.callee = { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ArrayExpression", - "elements": [] - }, - "property": { - "type": "Identifier", - "name": "splice" - } - }, - "property": { - "type": "Identifier", - "name": "apply" - } - }; - var to; - var start = this.range.start ? this.range.start.codegen() : { - "type": "Literal", - "value": 0 - }; - if (typeof this.range.to !== "undefined" && this.range.to !== null) { - if (!!isNumber(start.value) && !!isNumber(this.range.to.value)) { - to = { - "type": "Literal", - "value": this.range.to.value - start.value + (this.range.operator === ".." ? 1 : 0) - }; - } else { - to = this.range.to.codegen(); - if (start.value !== 0) { - to = { - "type": "BinaryExpression", - "operator": "-", - "left": to, - "right": start - }; - } - if (this.range.operator === "..") { - to = { - "type": "BinaryExpression", - "operator": "+", - "left": to, - "right": { - "type": "Literal", - "value": 1 - } - }; - } - } - } else { - to = { - "type": "Literal", - "value": 9000000000, - "raw": "9e9" - }; - } - Object.defineProperty(this.parent, "arguments", { - value: [this.object.codegen(), { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ArrayExpression", - "elements": [start, to] - }, - "property": { - "type": "Identifier", - "name": "concat" - } - }, - "arguments": [this.parent.right] - }], - enumerable: true - }); - } else { - this.type = "CallExpression"; - this.callee = { - "type": "MemberExpression", - "computed": false, - "object": this.object.codegen(), - "property": { - "type": "Identifier", - "name": "slice" - } - }; - var args = []; - if (!(typeof this.range.start !== "undefined" && this.range.start !== null)) { - args.push({ - "type": "Literal", - "value": 0 - }); - } else { - args.push(this.range.start.codegen()); - } - if (typeof this.range.to !== "undefined" && this.range.to !== null) { - if (this.range.operator === "...") { - args.push(this.range.to.codegen()); - } else { - if (!!this.range.to.value && !!isNumber(this.range.to.value)) { - args.push({ - "type": "Literal", - "value": this.range.to.value + 1 - }); - } else { - args.push({ - "type": "BinaryExpression", - "operator": "+", - "left": this.range.to.codegen(), - "right": { - "type": "Literal", - "value": 1 - } - }); - } - } - } - Object.defineProperty(this, "arguments", { - value: args, - enumerable: true - }); - } - return this; - }; - RangeMemberExpression.prototype.hasCallExpression = function() { - return true; - }; - exports.RangeMemberExpression = RangeMemberExpression; - return {}; -}); - -//# sourceMappingURL=RangeMemberExpression.map diff --git a/lib/ast/expressions/SplatExpression.js b/lib/ast/expressions/SplatExpression.js deleted file mode 100644 index 97270a4..0000000 --- a/lib/ast/expressions/SplatExpression.js +++ /dev/null @@ -1,48 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function SplatExpression(expression) { - Node.call(this); - this.type = "SplatExpression"; - this.expression = expression; - this.expression.parent = this; - } - SplatExpression.prototype = Object.create(Node); - SplatExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.expression = this.expression.codegen(); - return { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ArrayExpression", - "elements": [] - }, - "property": { - "type": "Identifier", - "name": "slice" - } - }, - "property": { - "type": "Identifier", - "name": "call" - } - }, - "arguments": [this.expression] - }; - }; - SplatExpression.prototype.hasCallExpression = function() { - return true; - }; - exports.SplatExpression = SplatExpression; - return {}; -}); - -//# sourceMappingURL=SplatExpression.map diff --git a/lib/ast/expressions/SuperExpression.js b/lib/ast/expressions/SuperExpression.js deleted file mode 100644 index 371d02a..0000000 --- a/lib/ast/expressions/SuperExpression.js +++ /dev/null @@ -1,170 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - var extend = require("util")._extend; - function SuperExpression() { - Node.call(this); - this.type = "SuperExpression"; - } - SuperExpression.prototype = Object.create(Node); - SuperExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - if (this.parent.type === "NullPropagatingExpression") { - Node.getErrorManager().error({ - type: "InvalidSuperReference", - message: "cannot refer to super before the ?. operator", - loc: this.loc - }); - return {type: "ThisExpression"}; - } - if (this.parent.type !== "MemberExpression") { - Node.getErrorManager().error({ - type: "InvalidUsageForSuper", - message: "invalid usage of super keyword", - loc: this.loc - }); - return {type: "ThisExpression"}; - } - var parentNode = this; - var node = this; - while (!!(!!node && !node.inheritsFrom) && !!(!!(node.type !== "AssignmentExpression") || !!(!!(!node.left.property || !!(node.left.property.name !== "prototype")) && !!(!node.left.object.property || !!(node.left.object.property.name !== "prototype"))))) { - parentNode = node; - node = node.parent; - } - if (!node) { - Node.getErrorManager().error({ - type: "InvalidContextForSuper", - message: "invalid context for super keyword", - loc: this.loc - }); - return {type: "ThisExpression"}; - } - var addSelf = function(context) { - var selfId = { - "type": "Identifier", - "name": "_self", - "codeGenerated": "true" - }; - if (!context.node.__isSelfDefined) { - context.node.body.splice(0, 0, { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": selfId, - "init": {type: "ThisExpression"} - }], - "kind": "let" - }); - context.node.__isSelfDefined = true; - } - return selfId; - }; - var mutateCallExpression = function(id, parent, selfNode) { - selfNode.codeGenerated = true; - parent.object = id; - parent.property = Object.create({ - "codeGenerated": "true", - "type": "Identifier", - "name": "call" - }); - parent.parent.arguments.splice(0, 0, selfNode); - }; - if (node.type === "AssignmentExpression") { - var identifier = node.left.object; - var context; - if (node.left.property.name !== "prototype") { - identifier = identifier.object; - context = {node: node.right.body}; - } else { - if (node.right.type !== "ObjectExpression") { - Node.getErrorManager().error({ - type: "InvalidUsageForSuper", - message: "invalid usage of super keyword", - loc: this.loc - }); - return {type: "ThisExpression"}; - } - var contextNode = this; - while (!!(typeof contextNode.parent !== "undefined" && contextNode.parent !== null) && !!(contextNode.parent !== node.right)) { - contextNode = contextNode.parent; - } - if (!!((typeof contextNode !== "undefined" && contextNode !== null ? contextNode.type : void 0) !== "Property") || !!((typeof contextNode !== "undefined" && (contextNode !== null && contextNode.value !== null) ? contextNode.value.type : void 0) !== "FunctionExpression")) { - Node.getErrorManager().error({ - type: "InvalidUsageForSuper", - message: "invalid usage of super keyword", - loc: this.loc - }); - return {type: "ThisExpression"}; - } - context = {node: contextNode.value.body}; - } - var selfNode; - if (context.node === this.getContext().node) { - selfNode = {type: "ThisExpression"}; - } else { - selfNode = addSelf(context); - } - if (this.parent.parent.type === "CallExpression") { - var memberExpression = { - type: "MemberExpression", - computed: false, - object: { - type: "MemberExpression", - computed: false, - object: this.parent.getDefinedIdentifier(identifier.name).parent.inheritsFrom.callee, - property: { - type: "Identifier", - name: "prototype" - } - }, - property: this.parent.parent.callee.property - }; - mutateCallExpression(memberExpression, this.parent, selfNode); - return memberExpression; - } - return selfNode; - } - var superContext = parentNode.getContext(); - var lastObject = this.parent; - while (lastObject.object.type === "MemberExpression") { - lastObject = lastObject.object; - } - lastObject.object = {type: "ThisExpression"}; - var id = { - "type": "Identifier", - "name": "_" + this.parent.property.name - }; - if (!this.parent.isIdentifierDefined(id.name)) { - superContext.node.body.splice(superContext.position, 0, { - "codeGenerated": "true", - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": id, - "init": extend({}, lastObject) - }], - "kind": "let" - }); - superContext.node.defineIdentifier(id); - } - if (this.parent.parent.type === "CallExpression") { - mutateCallExpression(id, this.parent, addSelf(superContext)); - } else { - this.parent.type = "Identifier"; - Object.defineProperty(this.parent, "name", { - value: id.name, - enumerable: true - }); - } - return id; - }; - SuperExpression.prototype.hasCallExpression = function() { - return false; - }; - exports.SuperExpression = SuperExpression; - return {}; -}); - -//# sourceMappingURL=SuperExpression.map diff --git a/lib/ast/expressions/ThisExpression.js b/lib/ast/expressions/ThisExpression.js deleted file mode 100644 index 3a10a25..0000000 --- a/lib/ast/expressions/ThisExpression.js +++ /dev/null @@ -1,22 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ThisExpression() { - Node.call(this); - this.type = "ThisExpression"; - } - ThisExpression.prototype = Object.create(Node); - ThisExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - return this; - }; - ThisExpression.prototype.hasCallExpression = function() { - return false; - }; - exports.ThisExpression = ThisExpression; - return {}; -}); - -//# sourceMappingURL=ThisExpression.map diff --git a/lib/ast/expressions/UnaryExpression.js b/lib/ast/expressions/UnaryExpression.js deleted file mode 100644 index 9fe12b1..0000000 --- a/lib/ast/expressions/UnaryExpression.js +++ /dev/null @@ -1,147 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function UnaryExpression(operator, argument) { - Node.call(this); - this.type = "UnaryExpression"; - this.operator = operator; - this.argument = argument; - this.argument.parent = this; - this.prefix = true; - } - UnaryExpression.prototype = Object.create(Node); - UnaryExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.argument = this.argument.codegen(); - if (this.operator === "typeof") { - var typeofExpression = { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "MemberExpression", - "computed": true, - "object": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ObjectExpression", - "properties": [] - }, - "property": { - "type": "Identifier", - "name": "toString" - } - }, - "property": { - "type": "Identifier", - "name": "call" - } - }, - "arguments": [this.argument] - }, - "property": { - "type": "Identifier", - "name": "match" - } - }, - "arguments": [{ - "type": "Literal", - "value": new RegExp("\\s([a-zA-Z]+)") - }] - }, - "property": { - "type": "Literal", - "value": 1, - "raw": "1" - } - }, - "property": { - "type": "Identifier", - "name": "toLowerCase" - } - }, - "arguments": [] - }; - if (!this.argument.hasCallExpression()) { - this.type = "ConditionalExpression"; - this.test = { - "type": "BinaryExpression", - "operator": "===", - "left": { - "type": "UnaryExpression", - "operator": "typeof", - "argument": this.argument, - "prefix": true - }, - "right": { - "type": "Literal", - "value": "undefined", - "raw": "'undefined'" - } - }; - this.consequent = { - "type": "Literal", - "value": "undefined" - }; - this.alternate = typeofExpression; - } else { - this.type = typeofExpression.type; - this.callee = typeofExpression.callee; - Object.defineProperty(this, "arguments", { - value: typeofExpression.arguments, - enumerable: true - }); - } - } else { - if (this.operator === "<-") { - var parent = this.parent; - while (!!(!!(typeof parent !== "undefined" && parent !== null) && !!(parent.type !== "FunctionExpression")) && !!(parent.type !== "GoStatement")) { - parent = parent.parent; - } - if (!(typeof parent !== "undefined" && parent !== null) || !!(!!(parent.type !== "GoStatement") && !!(!!(parent.parent.type !== "UnaryExpression") || !!(parent.parent.operator !== "async")))) { - Node.getErrorManager().error({ - type: "GetExpressionRequiresAsync", - message: "unary <- must be in a go statement or an async function", - loc: this.loc - }); - } - this.operator = "await"; - this.argument = { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": this.argument, - "property": { - "type": "Identifier", - "name": "get" - }, - "computed": false - }, - "arguments": [] - }; - } - } - return this; - }; - UnaryExpression.prototype.hasCallExpression = function() { - return typeof this.argument !== "undefined" && this.argument !== null ? this.argument.hasCallExpression() : void 0; - }; - exports.UnaryExpression = UnaryExpression; - return {}; -}); - -//# sourceMappingURL=UnaryExpression.map diff --git a/lib/ast/expressions/UpdateExpression.js b/lib/ast/expressions/UpdateExpression.js deleted file mode 100644 index d9bddd0..0000000 --- a/lib/ast/expressions/UpdateExpression.js +++ /dev/null @@ -1,26 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function UpdateExpression(argument, operator, prefix) { - Node.call(this); - this.type = "UpdateExpression"; - this.operator = operator; - this.prefix = prefix; - this.argument = argument; - this.argument.parent = this; - } - UpdateExpression.prototype = Object.create(Node); - UpdateExpression.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - return this; - }; - UpdateExpression.prototype.hasCallExpression = function() { - return !!(this.argument !== null) && !!this.left.hasCallExpression(); - }; - exports.UpdateExpression = UpdateExpression; - return {}; -}); - -//# sourceMappingURL=UpdateExpression.map diff --git a/lib/ast/literals/BooleanLiteral.js b/lib/ast/literals/BooleanLiteral.js deleted file mode 100644 index a56bd78..0000000 --- a/lib/ast/literals/BooleanLiteral.js +++ /dev/null @@ -1,24 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function BooleanLiteral(text) { - Node.call(this); - this.type = "Literal"; - this.value = text === "true"; - this.raw = text; - } - BooleanLiteral.prototype = Object.create(Node); - BooleanLiteral.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - return this; - }; - BooleanLiteral.prototype.hasCallExpression = function() { - return false; - }; - exports.BooleanLiteral = BooleanLiteral; - return {}; -}); - -//# sourceMappingURL=BooleanLiteral.map diff --git a/lib/ast/literals/Identifier.js b/lib/ast/literals/Identifier.js deleted file mode 100644 index 722b030..0000000 --- a/lib/ast/literals/Identifier.js +++ /dev/null @@ -1,60 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function Identifier(name) { - Node.call(this); - this.type = "Identifier"; - this.global = false; - Object.defineProperty(this, "name", { - value: name, - enumerable: true - }); - } - Identifier.prototype = Object.create(Node); - Identifier.prototype.codegen = function() { - var undefinedCheck = arguments[0] !== (void 0) ? arguments[0] : true; - if (!Node.prototype.codegen.call(this)) { - return; - } - if (!!undefinedCheck && !this.global) { - var inExpression1 = ["FunctionDeclaration", "VariableDeclarator"]; - if (!(!!(inExpression1 instanceof Array ? inExpression1.indexOf(typeof this.parent !== "undefined" && this.parent !== null ? this.parent.type : void 0) !== -1 : (typeof this.parent !== "undefined" && this.parent !== null ? this.parent.type : void 0) in inExpression1) && !!(this.parent.id === this))) { - if (!this.parent.isIdentifierDefined(this.name)) { - Node.getErrorManager().error({ - type: "UndefinedIdentifier", - identifier: this.name, - message: "undefined " + this.name, - loc: this.loc - }); - } - } else { - if (this.parent.isIdentifierDefined(this.name)) { - Node.getErrorManager().error({ - type: "AlreadyDefinedIdentifier", - identifier: this.name, - message: this.name + " is already defined", - loc: this.loc - }); - } else { - this.parent.getContext().node.defineIdentifier(this); - } - } - } - return this; - }; - Identifier.prototype.hasCallExpression = function() { - return false; - }; - Identifier.prototype.asGlobal = function() { - this.global = true; - return this; - }; - Identifier.prototype.asPredefinedCollection = function() { - this.predefinedCollection = true; - return this; - }; - exports.Identifier = Identifier; - return {}; -}); - -//# sourceMappingURL=Identifier.map diff --git a/lib/ast/literals/NullLiteral.js b/lib/ast/literals/NullLiteral.js deleted file mode 100644 index 742ed77..0000000 --- a/lib/ast/literals/NullLiteral.js +++ /dev/null @@ -1,24 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function NullLiteral() { - Node.call(this); - this.type = "Literal"; - this.value = null; - this.raw = "null"; - } - NullLiteral.prototype = Object.create(Node); - NullLiteral.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - return this; - }; - NullLiteral.prototype.hasCallExpression = function() { - return false; - }; - exports.NullLiteral = NullLiteral; - return {}; -}); - -//# sourceMappingURL=NullLiteral.map diff --git a/lib/ast/literals/NumberLiteral.js b/lib/ast/literals/NumberLiteral.js deleted file mode 100644 index b2246a4..0000000 --- a/lib/ast/literals/NumberLiteral.js +++ /dev/null @@ -1,24 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function NumberLiteral(text) { - Node.call(this); - this.type = "Literal"; - this.value = Number(text); - this.raw = text; - } - NumberLiteral.prototype = Object.create(Node); - NumberLiteral.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - return this; - }; - NumberLiteral.prototype.hasCallExpression = function() { - return false; - }; - exports.NumberLiteral = NumberLiteral; - return {}; -}); - -//# sourceMappingURL=NumberLiteral.map diff --git a/lib/ast/literals/RegularExpressionLiteral.js b/lib/ast/literals/RegularExpressionLiteral.js deleted file mode 100644 index ac24453..0000000 --- a/lib/ast/literals/RegularExpressionLiteral.js +++ /dev/null @@ -1,25 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function RegularExpressionLiteral(pattern, flags) { - Node.call(this); - this.type = "Literal"; - this.pattern = pattern; - this.flags = flags; - } - RegularExpressionLiteral.prototype = Object.create(Node); - RegularExpressionLiteral.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.value = new RegExp(this.pattern, this.flags); - return this; - }; - RegularExpressionLiteral.prototype.hasCallExpression = function() { - return false; - }; - exports.RegularExpressionLiteral = RegularExpressionLiteral; - return {}; -}); - -//# sourceMappingURL=RegularExpressionLiteral.map diff --git a/lib/ast/literals/StringLiteral.js b/lib/ast/literals/StringLiteral.js deleted file mode 100644 index ba1f195..0000000 --- a/lib/ast/literals/StringLiteral.js +++ /dev/null @@ -1,90 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function StringLiteral(chars, column) { - Node.call(this); - this.type = "StringLiteral"; - this.chars = chars; - this.column = column; - } - StringLiteral.prototype = Object.create(Node); - StringLiteral.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var elements = []; - for (var $__0 = this.chars[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var value = $__1.value; - { - var lastElement; - if ((typeof value === "undefined" ? "undefined" : {}.toString.call(value).match(/\s([a-zA-Z]+)/)[1].toLowerCase()) === "string") { - lastElement = elements[elements.length - 1]; - if ((typeof lastElement !== "undefined" && lastElement !== null ? lastElement.type : void 0) === "Literal") { - lastElement.value += value; - } else { - elements.push({ - type: "Literal", - value: value - }); - } - } else { - if ((typeof value !== "undefined" && value !== null ? value.type : void 0) === "StringLiteralNewLine") { - lastElement = elements[elements.length - 1]; - if ((typeof lastElement !== "undefined" && lastElement !== null ? lastElement.type : void 0) === "Literal") { - lastElement.value += value.toString(this.column - 1); - } else { - elements.push({ - type: "Literal", - value: value.toString(this.column - 1) - }); - } - } else { - value.parent = this; - elements.push(value.codegen()); - } - } - } - } - if (elements.length === 0) { - return { - "type": "Literal", - "value": "" - }; - } else { - if (elements.length === 1) { - return elements[0]; - } - } - var reduced = elements.reduce(function(left, right) { - return { - type: "BinaryExpression", - operator: "+", - left: left, - right: right - }; - }); - this.type = reduced.type; - this.operator = reduced.operator; - this.left = reduced.left; - this.right = reduced.right; - return this; - }; - StringLiteral.prototype.hasCallExpression = function() { - return false; - }; - StringLiteral.NewLine = function(text) { - this.type = "StringLiteralNewLine"; - this.toString = function(column) { - var t = text.replace(/\r\n/g, "").replace(/\t/g, " "); - if (t.length < column) { - return ""; - } - return t.substring(column); - }; - }; - exports.StringLiteral = StringLiteral; - return {}; -}); - -//# sourceMappingURL=StringLiteral.map diff --git a/lib/ast/literals/UndefinedLiteral.js b/lib/ast/literals/UndefinedLiteral.js deleted file mode 100644 index 5dd0c0f..0000000 --- a/lib/ast/literals/UndefinedLiteral.js +++ /dev/null @@ -1,30 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function UndefinedLiteral() { - Node.call(this); - this.type = "UndefinedLiteral"; - } - UndefinedLiteral.prototype = Object.create(Node); - UndefinedLiteral.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.type = "UnaryExpression"; - this.operator = "void"; - this.argument = { - "type": "Literal", - "value": 0, - "raw": "0" - }; - this.prefix = true; - return this; - }; - UndefinedLiteral.prototype.hasCallExpression = function() { - return false; - }; - exports.UndefinedLiteral = UndefinedLiteral; - return {}; -}); - -//# sourceMappingURL=UndefinedLiteral.map diff --git a/lib/ast/statements/BlockStatement.js b/lib/ast/statements/BlockStatement.js deleted file mode 100644 index 9f3fbf8..0000000 --- a/lib/ast/statements/BlockStatement.js +++ /dev/null @@ -1,47 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function BlockStatement(body) { - Node.call(this); - this.type = "BlockStatement"; - this.body = body; - var i = 0; - for (var $__0 = body[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var statement = $__1.value; - { - if (statement) { - statement.parent = this; - } else { - body[i] = {type: "EmptyStatement"}; - } - i++; - } - } - } - BlockStatement.prototype = Object.create(Node); - BlockStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var i = 0; - while (i < this.body.length) { - var statement = this.body[i]; - if (!statement || !!statement.codeGenerated) { - i++; - continue; - } - if (typeof statement.codegen === "function" ? statement.codegen() : void 0) { - this.body[this.body.indexOf(statement)] = statement; - i++; - } else { - this.body.splice(i, 1); - } - } - return this; - }; - exports.BlockStatement = BlockStatement; - return {}; -}); - -//# sourceMappingURL=BlockStatement.map diff --git a/lib/ast/statements/BreakStatement.js b/lib/ast/statements/BreakStatement.js deleted file mode 100644 index ea95498..0000000 --- a/lib/ast/statements/BreakStatement.js +++ /dev/null @@ -1,19 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function BreakStatement() { - Node.call(this); - this.type = "BreakStatement"; - } - BreakStatement.prototype = Object.create(Node); - BreakStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - return this; - }; - exports.BreakStatement = BreakStatement; - return {}; -}); - -//# sourceMappingURL=BreakStatement.map diff --git a/lib/ast/statements/ContinueStatement.js b/lib/ast/statements/ContinueStatement.js deleted file mode 100644 index d24ae1c..0000000 --- a/lib/ast/statements/ContinueStatement.js +++ /dev/null @@ -1,19 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ContinueStatement() { - Node.call(this); - this.type = "ContinueStatement"; - } - ContinueStatement.prototype = Object.create(Node); - ContinueStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - return this; - }; - exports.ContinueStatement = ContinueStatement; - return {}; -}); - -//# sourceMappingURL=ContinueStatement.map diff --git a/lib/ast/statements/DebuggerStatement.js b/lib/ast/statements/DebuggerStatement.js deleted file mode 100644 index 1260922..0000000 --- a/lib/ast/statements/DebuggerStatement.js +++ /dev/null @@ -1,19 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function DebuggerStatement() { - Node.call(this); - this.type = "DebuggerStatement"; - } - DebuggerStatement.prototype = Object.create(Node); - DebuggerStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - return this; - }; - exports.DebuggerStatement = DebuggerStatement; - return {}; -}); - -//# sourceMappingURL=DebuggerStatement.map diff --git a/lib/ast/statements/DoWhileStatement.js b/lib/ast/statements/DoWhileStatement.js deleted file mode 100644 index 567aace..0000000 --- a/lib/ast/statements/DoWhileStatement.js +++ /dev/null @@ -1,25 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function DoWhileStatement(test, body) { - Node.call(this); - this.type = "DoWhileStatement"; - this.test = test; - this.test.parent = this; - this.body = body; - this.body.parent = this; - } - DoWhileStatement.prototype = Object.create(Node); - DoWhileStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.test = this.test.codegen(); - this.body = this.body.blockWrap().codegen(); - return this; - }; - exports.DoWhileStatement = DoWhileStatement; - return {}; -}); - -//# sourceMappingURL=DoWhileStatement.map diff --git a/lib/ast/statements/ExportDeclarationStatement.js b/lib/ast/statements/ExportDeclarationStatement.js deleted file mode 100644 index 48b91e3..0000000 --- a/lib/ast/statements/ExportDeclarationStatement.js +++ /dev/null @@ -1,51 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ExportDeclarationStatement(specifiers, source, declaration, isDefault) { - Node.call(this); - this.type = "ExportDeclaration"; - this["default"] = isDefault; - this.specifiers = specifiers; - if (typeof specifiers !== "undefined" && specifiers !== null) { - for (var $__0 = this.specifiers[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var specifier = $__1.value; - { - specifier.parent = this; - } - } - } - this.source = source; - if (typeof source !== "undefined" && source !== null) { - this.source.parent = this; - } - this.declaration = declaration; - if (typeof declaration !== "undefined" && declaration !== null) { - this.declaration.parent = this; - } - } - ExportDeclarationStatement.prototype = Object.create(Node); - ExportDeclarationStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - if (typeof this.specifiers !== "undefined" && this.specifiers !== null) { - var i = 0; - for (var $__0 = this.specifiers[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var specifier = $__1.value; - { - this.specifiers[i] = specifier.codegen(); - i++; - } - } - } - this.source = typeof this.source !== "undefined" && this.source !== null ? this.source.codegen() : void 0; - this.declaration = typeof this.declaration !== "undefined" && this.declaration !== null ? this.declaration.codegen() : void 0; - return this; - }; - exports.ExportDeclarationStatement = ExportDeclarationStatement; - return {}; -}); - -//# sourceMappingURL=ExportDeclarationStatement.map diff --git a/lib/ast/statements/ExpressionStatement.js b/lib/ast/statements/ExpressionStatement.js deleted file mode 100644 index 7f43851..0000000 --- a/lib/ast/statements/ExpressionStatement.js +++ /dev/null @@ -1,22 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ExpressionStatement(expression) { - Node.call(this); - this.type = "ExpressionStatement"; - this.expression = expression; - this.expression.parent = this; - } - ExpressionStatement.prototype = Object.create(Node); - ExpressionStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.expression = this.expression.codegen(); - return this; - }; - exports.ExpressionStatement = ExpressionStatement; - return {}; -}); - -//# sourceMappingURL=ExpressionStatement.map diff --git a/lib/ast/statements/FallthroughStatement.js b/lib/ast/statements/FallthroughStatement.js deleted file mode 100644 index 8899703..0000000 --- a/lib/ast/statements/FallthroughStatement.js +++ /dev/null @@ -1,74 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function FallthroughStatement() { - Node.call(this); - this.type = "FallthroughStatement"; - } - FallthroughStatement.prototype = Object.create(Node); - FallthroughStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var parent = this.parent; - var iterations = 0; - while (!!(typeof parent !== "undefined" && parent !== null) && !parent.switchCase) { - parent = parent.parent; - iterations++; - } - if (typeof parent !== "undefined" && parent !== null) { - parent.fallthrough = true; - } else { - Node.getErrorManager().error({ - type: "InvalidFallthroughContext", - message: "fallthrough statement is only allowed in a switch case clause.", - loc: this.loc - }); - } - var switchStatement = parent.parent; - if (!switchStatement.fallthroughId) { - switchStatement.fallthroughId = { - "type": "Identifier", - "name": FallthroughStatement.getNextVariableName() - }; - } - switchStatement.branchFallthrough = true; - parent.body.body = [{ - "type": "ExpressionStatement", - "codeGenerated": true, - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": switchStatement.fallthroughId, - "right": { - "type": "Literal", - "value": 2 - } - } - }].concat(parent.body.body); - this.type = "ExpressionStatement"; - this.expression = { - "type": "AssignmentExpression", - "operator": "=", - "left": switchStatement.fallthroughId, - "right": { - "type": "Literal", - "value": 1 - } - }; - return this; - }; - FallthroughStatement.getNextVariableName = function() { - if (!(typeof this.fallthroughIndex !== "undefined" && this.fallthroughIndex !== null)) { - this.fallthroughIndex = 0; - } - return "fallthrough" + this.fallthroughIndex++; - }; - FallthroughStatement.resetVariableNames = function() { - this.fallthroughIndex = 0; - }; - exports.FallthroughStatement = FallthroughStatement; - return {}; -}); - -//# sourceMappingURL=FallthroughStatement.map diff --git a/lib/ast/statements/ForInStatement.js b/lib/ast/statements/ForInStatement.js deleted file mode 100644 index 6cef72c..0000000 --- a/lib/ast/statements/ForInStatement.js +++ /dev/null @@ -1,79 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ForInStatement(item, index, array, body) { - Node.call(this); - this.type = "ForInStatement"; - this.item = item; - this.item.parent = this; - this.index = index; - if (typeof this.index !== "undefined" && this.index !== null) { - this.index.parent = this; - } - this.array = array; - this.array.parent = this; - this.body = body; - this.body.parent = this; - } - ForInStatement.prototype = Object.create(Node); - ForInStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.item = this.item.codegen(false); - if (typeof this.index !== "undefined" && this.index !== null) { - var context = this.getContext(); - this.index = this.index.codegen(false); - context.node.body.splice(context.position, 0, { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": this.index, - "init": { - "type": "Literal", - "value": 0 - } - }], - "kind": "let" - }); - } - if (!this.array.codeGenerated) { - this.array = this.array.codegen(); - } - this.body = this.body.blockWrap(); - this.body.defineIdentifier(this.item); - if (typeof this.index !== "undefined" && this.index !== null) { - this.body.defineIdentifier(this.index); - } - this.body = this.body.codegen(); - if (typeof this.index !== "undefined" && this.index !== null) { - this.body.body.push({ - "type": "ExpressionStatement", - "codeGenerated": true, - "expression": { - "type": "UpdateExpression", - "operator": "++", - "argument": this.index, - "prefix": false - } - }); - } - this.type = "ForOfStatement"; - this.right = this.array; - this.left = { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": this.item, - "init": null - }], - "kind": "let" - }; - this.each = false; - return this; - }; - exports.ForInStatement = ForInStatement; - return {}; -}); - -//# sourceMappingURL=ForInStatement.map diff --git a/lib/ast/statements/ForOfStatement.js b/lib/ast/statements/ForOfStatement.js deleted file mode 100644 index adf5970..0000000 --- a/lib/ast/statements/ForOfStatement.js +++ /dev/null @@ -1,98 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node, - ForInStatement = module.require("./ForInStatement").ForInStatement; - function ForOfStatement(key, value, object, body) { - Node.call(this); - this.type = "ForOfStatement"; - this.key = key; - this.key.parent = this; - this.value = value; - if (typeof this.value !== "undefined" && this.value !== null) { - this.value.parent = this; - } - this.object = object; - this.object.parent = this; - this.body = body; - this.body.parent = this; - } - ForOfStatement.prototype = Object.create(Node); - ForOfStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.object = this.object.codegen(); - if (typeof this.value !== "undefined" && this.value !== null) { - this.value = this.value.codegen(false); - this.body.defineIdentifier(this.value); - if (this.object.hasCallExpression()) { - var id = { - "type": "Identifier", - "name": exports.ForOfStatement.getNextVariableName() - }; - var context = this.getContext(); - context.node.body.splice(context.position, 0, { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": id, - "init": this.object - }], - "kind": "let", - "codeGenerated": true - }); - this.object = id; - } - this.body.body = [{ - "type": "VariableDeclaration", - "codeGenerated": true, - "declarations": [{ - "type": "VariableDeclarator", - "id": this.value, - "init": { - "type": "MemberExpression", - "computed": "true", - "object": this.object, - "property": this.key - } - }], - "kind": "let" - }].concat(this.body.body); - } - var forInLoop = new ForInStatement(this.key, null, { - "type": "CallExpression", - "codeGenerated": true, - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "Object" - }, - "property": { - "type": "Identifier", - "name": "keys" - } - }, - "arguments": [this.object] - }, this.body).codegen(); - this.type = forInLoop.type; - this.right = forInLoop.right; - this.left = forInLoop.left; - this.each = forInLoop.each; - return this; - }; - ForOfStatement.getNextVariableName = function() { - if (!this.forOfIndex) { - this.forOfIndex = 0; - } - return "forOf" + this.forOfIndex++; - }; - ForOfStatement.resetVariableNames = function() { - this.forOfIndex = 0; - }; - exports.ForOfStatement = ForOfStatement; - return {}; -}); - -//# sourceMappingURL=ForOfStatement.map diff --git a/lib/ast/statements/ForStatement.js b/lib/ast/statements/ForStatement.js deleted file mode 100644 index 0b982ef..0000000 --- a/lib/ast/statements/ForStatement.js +++ /dev/null @@ -1,43 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ForStatement(init, test, update, body) { - Node.call(this); - this.type = "ForStatement"; - this.init = init; - if (typeof this.init !== "undefined" && this.init !== null) { - this.init.parent = this; - } - this.test = test; - if (typeof this.test !== "undefined" && this.test !== null) { - this.test.parent = this; - } - this.update = update; - if (typeof this.update !== "undefined" && this.update !== null) { - this.update.parent = this; - } - this.body = body; - this.body.parent = this; - } - ForStatement.prototype = Object.create(Node); - ForStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - if (typeof this.init !== "undefined" && this.init !== null) { - this.init = this.init.codegen(); - } - if (typeof this.test !== "undefined" && this.test !== null) { - this.test = this.test.codegen(); - } - if (typeof this.update !== "undefined" && this.update !== null) { - this.update = this.update.codegen(); - } - this.body = this.body.blockWrap().codegen(); - return this; - }; - exports.ForStatement = ForStatement; - return {}; -}); - -//# sourceMappingURL=ForStatement.map diff --git a/lib/ast/statements/FunctionDeclarationStatement.js b/lib/ast/statements/FunctionDeclarationStatement.js deleted file mode 100644 index 889488b..0000000 --- a/lib/ast/statements/FunctionDeclarationStatement.js +++ /dev/null @@ -1,104 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node, - Parameter = module.require("../Parameter").Parameter, - CallExpression = module.require("../expressions/CallExpression").CallExpression; - function FunctionDeclarationStatement(id, params, body, inheritsFrom) { - Node.call(this); - this.type = "FunctionDeclaration"; - this.defaults = []; - this.rest = null; - this.generator = false; - this.expression = false; - this.id = id; - this.id.parent = this; - this.body = body; - this.body.parent = this; - this.params = params; - for (var $__0 = params[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var param = $__1.value; - { - param.parent = this; - } - } - this.inheritsFrom = inheritsFrom; - if (typeof this.inheritsFrom !== "undefined" && this.inheritsFrom !== null) { - this.inheritsFrom.parent = this; - } - } - FunctionDeclarationStatement.prototype = Object.create(Node); - FunctionDeclarationStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.id = this.id.codegen(); - Parameter.generateFunctionBody(this, this.params, this.body, this.defaults); - this.body = this.body.codegen(); - if (typeof this.inheritsFrom !== "undefined" && this.inheritsFrom !== null) { - if (this.inheritsFrom.type !== "CallExpression") { - this.inheritsFrom = new CallExpression(this.inheritsFrom, []); - this.inheritsFrom.parent = this; - } - this.inheritsFrom = this.inheritsFrom.codegen(); - this.body.body.splice(0, 0, { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": this.inheritsFrom.callee, - "property": { - "type": "Identifier", - "name": "call" - } - }, - "arguments": [{"type": "ThisExpression"}].concat(this.inheritsFrom.arguments) - } - }); - var context = this.getContext(); - context.node.body.splice(context.position + 1, 0, { - "type": "ExpressionStatement", - "codeGenerated": "true", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "computed": false, - "object": this.id, - "property": { - "type": "Identifier", - "name": "prototype" - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "Object" - }, - "property": { - "type": "Identifier", - "name": "create" - } - }, - "arguments": [this.inheritsFrom.callee] - } - } - }); - } - return this; - }; - FunctionDeclarationStatement.prototype.hasCallExpression = function() { - return true; - }; - exports.FunctionDeclarationStatement = FunctionDeclarationStatement; - return {}; -}); - -//# sourceMappingURL=FunctionDeclarationStatement.map diff --git a/lib/ast/statements/GoStatement.js b/lib/ast/statements/GoStatement.js deleted file mode 100644 index 32be7eb..0000000 --- a/lib/ast/statements/GoStatement.js +++ /dev/null @@ -1,41 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function GoStatement(body) { - Node.call(this); - this.type = "GoStatement"; - this.body = body; - this.body.parent = this; - } - GoStatement.prototype = Object.create(Node); - GoStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.body = this.body.codegen(); - this.type = "ExpressionStatement"; - this.expression = { - "type": "CallExpression", - "callee": { - "type": "UnaryExpression", - "operator": "async", - "argument": { - "type": "FunctionExpression", - "id": null, - "params": [], - "defaults": [], - "body": this.body, - "rest": null, - "generator": false, - "expression": false - } - }, - "arguments": [] - }; - return this; - }; - exports.GoStatement = GoStatement; - return {}; -}); - -//# sourceMappingURL=GoStatement.map diff --git a/lib/ast/statements/IfStatement.js b/lib/ast/statements/IfStatement.js deleted file mode 100644 index 3e0ad44..0000000 --- a/lib/ast/statements/IfStatement.js +++ /dev/null @@ -1,32 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function IfStatement(test, consequent, alternate) { - Node.call(this); - this.type = "IfStatement"; - this.test = test; - this.test.parent = this; - this.consequent = consequent; - this.consequent.parent = this; - this.alternate = alternate; - if (typeof this.alternate !== "undefined" && this.alternate !== null) { - this.alternate.parent = this; - } - } - IfStatement.prototype = Object.create(Node); - IfStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.test = this.test.codegen(); - this.consequent = this.consequent.blockWrap().codegen(); - if (typeof this.alternate !== "undefined" && this.alternate !== null) { - this.alternate = this.alternate.blockWrap().codegen(); - } - return this; - }; - exports.IfStatement = IfStatement; - return {}; -}); - -//# sourceMappingURL=IfStatement.map diff --git a/lib/ast/statements/ImportDeclarationStatement.js b/lib/ast/statements/ImportDeclarationStatement.js deleted file mode 100644 index ae012b4..0000000 --- a/lib/ast/statements/ImportDeclarationStatement.js +++ /dev/null @@ -1,40 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ImportDeclarationStatement(specifiers, source, kind) { - Node.call(this); - this.type = "ImportDeclaration"; - this.kind = kind; - this.specifiers = specifiers; - for (var $__0 = this.specifiers[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var specifier = $__1.value; - { - specifier.parent = this; - } - } - this.source = source; - this.source.parent = this; - } - ImportDeclarationStatement.prototype = Object.create(Node); - ImportDeclarationStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var i = 0; - for (var $__0 = this.specifiers[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var specifier = $__1.value; - { - this.specifiers[i] = specifier.codegen(); - i++; - } - } - this.source = this.source.codegen(); - return this; - }; - exports.ImportDeclarationStatement = ImportDeclarationStatement; - return {}; -}); - -//# sourceMappingURL=ImportDeclarationStatement.map diff --git a/lib/ast/statements/PushStatement.js b/lib/ast/statements/PushStatement.js deleted file mode 100644 index dac89b4..0000000 --- a/lib/ast/statements/PushStatement.js +++ /dev/null @@ -1,37 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function PushStatement(left, right) { - Node.call(this); - this.type = "PushStatement"; - this.left = left; - this.left.parent = this; - this.right = right; - this.right.parent = this; - } - PushStatement.prototype = Object.create(Node); - PushStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.type = "ExpressionStatement"; - this.expression = { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": this.left.codegen(), - "property": { - "type": "Identifier", - "name": "push" - }, - "computed": false - }, - "arguments": [this.right.codegen()] - }; - return this; - }; - exports.PushStatement = PushStatement; - return {}; -}); - -//# sourceMappingURL=PushStatement.map diff --git a/lib/ast/statements/ReturnStatement.js b/lib/ast/statements/ReturnStatement.js deleted file mode 100644 index 1bed0ae..0000000 --- a/lib/ast/statements/ReturnStatement.js +++ /dev/null @@ -1,26 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ReturnStatement(argument) { - Node.call(this); - this.type = "ReturnStatement"; - this.argument = argument; - if (typeof this.argument !== "undefined" && this.argument !== null) { - this.argument.parent = this; - } - } - ReturnStatement.prototype = Object.create(Node); - ReturnStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - if (typeof this.argument !== "undefined" && this.argument !== null) { - this.argument = this.argument.codegen(); - } - return this; - }; - exports.ReturnStatement = ReturnStatement; - return {}; -}); - -//# sourceMappingURL=ReturnStatement.map diff --git a/lib/ast/statements/SwitchStatement.js b/lib/ast/statements/SwitchStatement.js deleted file mode 100644 index 32cace1..0000000 --- a/lib/ast/statements/SwitchStatement.js +++ /dev/null @@ -1,159 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function SwitchStatement(discriminant, cases) { - Node.call(this); - this.type = "SwitchStatement"; - this.discriminant = discriminant; - this.discriminant.parent = this; - this.cases = cases; - for (var $__0 = this.cases[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var caseClause = $__1.value; - { - caseClause.parent = this; - } - } - } - SwitchStatement.prototype = Object.create(Node); - SwitchStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var context = this.getContext(); - var firstCase, - currentCase, - defaultCase; - var fallthroughPosition = 1; - this.discriminant = this.discriminant.codegen(); - if (this.discriminant.hasCallExpression()) { - var id = { - "type": "Identifier", - "name": SwitchStatement.getNextVariableName() - }; - context.node.body.splice(context.position, 0, { - "type": "VariableDeclaration", - "codeGenerated": true, - "declarations": [{ - "type": "VariableDeclarator", - "id": id, - "init": this.discriminant - }], - "kind": "let" - }); - this.discriminant = id; - } - var hasFallthrough = false; - for (var $__0 = this.cases[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var caseClause = $__1.value; - { - if (!caseClause.tests) { - defaultCase = caseClause; - break; - } - if (!(typeof firstCase !== "undefined" && firstCase !== null)) { - firstCase = caseClause.codegen(); - currentCase = firstCase; - } else { - if (currentCase.fallthrough) { - hasFallthrough = true; - currentCase = caseClause.codegen(this.branchFallthrough); - context.node.body.splice(context.position + fallthroughPosition++, 0, currentCase); - } else { - currentCase.alternate = caseClause.codegen(typeof this.fallthroughId !== "undefined" && this.fallthroughId !== null); - currentCase = currentCase.alternate; - } - } - } - } - if (hasFallthrough) { - for (var $__2 = this.cases[$traceurRuntime.toProperty(Symbol.iterator)](), - $__3; !($__3 = $__2.next()).done; ) { - var caseClause$__6 = $__3.value; - { - if (!caseClause$__6.fallthrough && !!(caseClause$__6 !== defaultCase)) { - caseClause$__6.body.body = [{ - "type": "ExpressionStatement", - "codeGenerated": true, - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": this.fallthroughId, - "right": { - "type": "Literal", - "value": 2 - } - } - }].concat(caseClause$__6.body.body); - } - } - } - } - if (typeof defaultCase !== "undefined" && defaultCase !== null) { - if (!(typeof firstCase !== "undefined" && firstCase !== null)) { - Node.getErrorManager().error({ - type: "SingleDefaultClause", - message: "default clause without other case clauses is disallowed.", - loc: defaultCase.loc - }); - } else { - if (currentCase.fallthrough) { - defaultCase = defaultCase.codegen(typeof this.fallthroughId !== "undefined" && this.fallthroughId !== null); - defaultCase.codeGenerated = true; - if (typeof this.fallthroughId !== "undefined" && this.fallthroughId !== null) { - context.node.body.splice(context.position + fallthroughPosition++, 0, defaultCase); - } else { - for (var $__4 = defaultCase.body[$traceurRuntime.toProperty(Symbol.iterator)](), - $__5; !($__5 = $__4.next()).done; ) { - var statement = $__5.value; - { - context.node.body.splice(context.position + fallthroughPosition++, 0, statement); - } - } - } - } else { - currentCase.alternate = defaultCase.codegen(typeof this.fallthroughId !== "undefined" && this.fallthroughId !== null); - } - } - } - if (typeof this.fallthroughId !== "undefined" && this.fallthroughId !== null) { - context.node.body.splice(context.position, 0, { - "type": "VariableDeclaration", - "codeGenerated": true, - "declarations": [{ - "type": "VariableDeclarator", - "id": this.fallthroughId, - "init": { - "type": "Literal", - "value": 0 - } - }], - "kind": "let" - }); - } - if (!(typeof firstCase !== "undefined" && firstCase !== null)) { - this.type = "ExpressionStatement"; - this.expression = this.discriminant; - } else { - this.type = firstCase.type; - this.test = firstCase.test; - this.consequent = firstCase.consequent; - this.alternate = firstCase.alternate; - } - return this; - }; - SwitchStatement.getNextVariableName = function() { - if (!(typeof this.switchStatementIndex !== "undefined" && this.switchStatementIndex !== null)) { - this.switchStatementIndex = 0; - } - return "switchStatement" + this.switchStatementIndex++; - }; - SwitchStatement.resetVariableNames = function() { - this.switchStatementIndex = 0; - }; - exports.SwitchStatement = SwitchStatement; - return {}; -}); - -//# sourceMappingURL=SwitchStatement.map diff --git a/lib/ast/statements/ThrowStatement.js b/lib/ast/statements/ThrowStatement.js deleted file mode 100644 index a15649f..0000000 --- a/lib/ast/statements/ThrowStatement.js +++ /dev/null @@ -1,22 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function ThrowStatement(argument) { - Node.call(this); - this.type = "ThrowStatement"; - this.argument = argument; - this.argument.parent = this; - } - ThrowStatement.prototype = Object.create(Node); - ThrowStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.argument = this.argument.codegen(); - return this; - }; - exports.ThrowStatement = ThrowStatement; - return {}; -}); - -//# sourceMappingURL=ThrowStatement.map diff --git a/lib/ast/statements/TryStatement.js b/lib/ast/statements/TryStatement.js deleted file mode 100644 index 07a799d..0000000 --- a/lib/ast/statements/TryStatement.js +++ /dev/null @@ -1,36 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function TryStatement(block, handler, finalizer) { - Node.call(this); - this.type = "TryStatement"; - this.block = block; - this.block.parent = this; - this.handler = handler; - if (typeof this.handler !== "undefined" && this.handler !== null) { - this.handler.parent = this; - } - this.finalizer = finalizer; - if (typeof this.finalizer !== "undefined" && this.finalizer !== null) { - this.finalizer.parent = this; - } - } - TryStatement.prototype = Object.create(Node); - TryStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.block = this.block.codegen(); - if (typeof this.handler !== "undefined" && this.handler !== null) { - this.handler = this.handler.codegen(); - } - if (typeof this.finalizer !== "undefined" && this.finalizer !== null) { - this.finalizer = this.finalizer.codegen(); - } - return this; - }; - exports.TryStatement = TryStatement; - return {}; -}); - -//# sourceMappingURL=TryStatement.map diff --git a/lib/ast/statements/UntilStatement.js b/lib/ast/statements/UntilStatement.js deleted file mode 100644 index dd95639..0000000 --- a/lib/ast/statements/UntilStatement.js +++ /dev/null @@ -1,31 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function UntilStatement(test, body) { - Node.call(this); - this.type = "UntilStatement"; - this.test = test; - this.test.parent = this; - this.body = body; - this.body.parent = this; - } - UntilStatement.prototype = Object.create(Node); - UntilStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.type = "WhileStatement"; - this.test = { - "type": "UnaryExpression", - "operator": "!", - "argument": this.test.codegen(), - "prefix": true - }; - this.body = this.body.blockWrap().codegen(); - return this; - }; - exports.UntilStatement = UntilStatement; - return {}; -}); - -//# sourceMappingURL=UntilStatement.map diff --git a/lib/ast/statements/UseStatement.js b/lib/ast/statements/UseStatement.js deleted file mode 100644 index 8e0138c..0000000 --- a/lib/ast/statements/UseStatement.js +++ /dev/null @@ -1,49 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function UseStatement(identifiers) { - Node.call(this); - this.type = "UseStatement"; - this.identifiers = identifiers; - for (var $__0 = this.identifiers[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var id = $__1.value; - { - id.parent = this; - } - } - } - UseStatement.prototype = Object.create(Node); - UseStatement.predefinedCollections = { - "browser": ["document", "window", "screen", "location", "navigator", "alert", "console", "setTimeout"], - "node": ["require", "exports", "module", "global", "console", "process", "setTimeout", "__dirname", "__filename"] - }; - UseStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var context = this.getContext().node; - for (var $__2 = this.identifiers[$traceurRuntime.toProperty(Symbol.iterator)](), - $__3; !($__3 = $__2.next()).done; ) { - var id = $__3.value; - { - if (id.predefinedCollection) { - for (var $__0 = exports.UseStatement.predefinedCollections[id.name][$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var p = $__1.value; - { - context.defineIdentifier({name: p}); - } - } - } else { - context.defineIdentifier(id); - } - } - } - return null; - }; - exports.UseStatement = UseStatement; - return {}; -}); - -//# sourceMappingURL=UseStatement.map diff --git a/lib/ast/statements/VariableDeclarationStatement.js b/lib/ast/statements/VariableDeclarationStatement.js deleted file mode 100644 index 6734f8b..0000000 --- a/lib/ast/statements/VariableDeclarationStatement.js +++ /dev/null @@ -1,36 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function VariableDeclarationStatement(declarations) { - Node.call(this); - this.type = "VariableDeclaration"; - this.declarations = declarations; - this.kind = "let"; - for (var $__0 = declarations[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var decl = $__1.value; - { - decl.parent = this; - } - } - } - VariableDeclarationStatement.prototype = Object.create(Node); - VariableDeclarationStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - var i = 0; - while (i < this.declarations.length) { - var statement = this.declarations[i].codegen(); - if (typeof statement !== "undefined" && statement !== null) { - this.declarations[this.declarations.indexOf(statement)] = statement; - } - i++; - } - return this; - }; - exports.VariableDeclarationStatement = VariableDeclarationStatement; - return {}; -}); - -//# sourceMappingURL=VariableDeclarationStatement.map diff --git a/lib/ast/statements/WhileStatement.js b/lib/ast/statements/WhileStatement.js deleted file mode 100644 index d5ff15e..0000000 --- a/lib/ast/statements/WhileStatement.js +++ /dev/null @@ -1,25 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var Node = module.require("../Node").Node; - function WhileStatement(test, body) { - Node.call(this); - this.type = "WhileStatement"; - this.test = test; - this.test.parent = this; - this.body = body; - this.body.parent = this; - } - WhileStatement.prototype = Object.create(Node); - WhileStatement.prototype.codegen = function() { - if (!Node.prototype.codegen.call(this)) { - return; - } - this.test = this.test.codegen(); - this.body = this.body.blockWrap().codegen(); - return this; - }; - exports.WhileStatement = WhileStatement; - return {}; -}); - -//# sourceMappingURL=WhileStatement.map diff --git a/lib/parser.js b/lib/parser.js deleted file mode 100644 index 9b2385c..0000000 --- a/lib/parser.js +++ /dev/null @@ -1,14878 +0,0 @@ -module.exports = (function() { - /* - * Generated by PEG.js 0.8.0. - * - * http://pegjs.majda.cz/ - */ - - function peg$subclass(child, parent) { - function ctor() { this.constructor = child; } - ctor.prototype = parent.prototype; - child.prototype = new ctor(); - } - - function SyntaxError(message, expected, found, offset, line, column) { - this.message = message; - this.expected = expected; - this.found = found; - this.offset = offset; - this.line = line; - this.column = column; - - this.name = "SyntaxError"; - } - - peg$subclass(SyntaxError, Error); - - function parse(input) { - var options = arguments.length > 1 ? arguments[1] : {}, - - peg$FAILED = {}, - - peg$startRuleFunctions = { Start: peg$parseStart }, - peg$startRuleFunction = peg$parseStart, - - peg$c0 = peg$FAILED, - peg$c1 = function(program) { return program; }, - peg$c2 = { type: "any", description: "any character" }, - peg$c3 = { type: "other", description: "whitespace" }, - peg$c4 = "\t", - peg$c5 = { type: "literal", value: "\t", description: "\"\\t\"" }, - peg$c6 = "\x0B", - peg$c7 = { type: "literal", value: "\x0B", description: "\"\\x0B\"" }, - peg$c8 = "\f", - peg$c9 = { type: "literal", value: "\f", description: "\"\\f\"" }, - peg$c10 = " ", - peg$c11 = { type: "literal", value: " ", description: "\" \"" }, - peg$c12 = "\xA0", - peg$c13 = { type: "literal", value: "\xA0", description: "\"\\xA0\"" }, - peg$c14 = "\uFEFF", - peg$c15 = { type: "literal", value: "\uFEFF", description: "\"\\uFEFF\"" }, - peg$c16 = /^[\n\r\u2028\u2029]/, - peg$c17 = { type: "class", value: "[\\n\\r\\u2028\\u2029]", description: "[\\n\\r\\u2028\\u2029]" }, - peg$c18 = { type: "other", description: "end of line" }, - peg$c19 = "\n", - peg$c20 = { type: "literal", value: "\n", description: "\"\\n\"" }, - peg$c21 = "\r\n", - peg$c22 = { type: "literal", value: "\r\n", description: "\"\\r\\n\"" }, - peg$c23 = "\r", - peg$c24 = { type: "literal", value: "\r", description: "\"\\r\"" }, - peg$c25 = "\u2028", - peg$c26 = { type: "literal", value: "\u2028", description: "\"\\u2028\"" }, - peg$c27 = "\u2029", - peg$c28 = { type: "literal", value: "\u2029", description: "\"\\u2029\"" }, - peg$c29 = { type: "other", description: "comment" }, - peg$c30 = "/*", - peg$c31 = { type: "literal", value: "/*", description: "\"/*\"" }, - peg$c32 = [], - peg$c33 = void 0, - peg$c34 = "*/", - peg$c35 = { type: "literal", value: "*/", description: "\"*/\"" }, - peg$c36 = "//", - peg$c37 = { type: "literal", value: "//", description: "\"//\"" }, - peg$c38 = function(name) { return name; }, - peg$c39 = { type: "other", description: "identifier" }, - peg$c40 = function(first, rest) { - return insertLocationData(new ast.Identifier(first + rest.join("")), text(), line(), column()); - }, - peg$c41 = "$", - peg$c42 = { type: "literal", value: "$", description: "\"$\"" }, - peg$c43 = "_", - peg$c44 = { type: "literal", value: "_", description: "\"_\"" }, - peg$c45 = "\\", - peg$c46 = { type: "literal", value: "\\", description: "\"\\\\\"" }, - peg$c47 = function(sequence) { return sequence; }, - peg$c48 = "\u200C", - peg$c49 = { type: "literal", value: "\u200C", description: "\"\\u200C\"" }, - peg$c50 = "\u200D", - peg$c51 = { type: "literal", value: "\u200D", description: "\"\\u200D\"" }, - peg$c52 = function() { return insertLocationData(new ast.NullLiteral(), text(), line(), column()); }, - peg$c53 = function() { return insertLocationData(new ast.UndefinedLiteral(), text(), line(), column()); }, - peg$c54 = function() { return insertLocationData(new ast.BooleanLiteral("true"), text(), line(), column()); }, - peg$c55 = function() { return insertLocationData(new ast.BooleanLiteral("false"), text(), line(), column()); }, - peg$c56 = { type: "other", description: "number" }, - peg$c57 = function(literal) { - return literal; - }, - peg$c58 = ".", - peg$c59 = { type: "literal", value: ".", description: "\".\"" }, - peg$c60 = null, - peg$c61 = function() { - return insertLocationData(new ast.NumberLiteral(text()), text(), line(), column()); - }, - peg$c62 = "0", - peg$c63 = { type: "literal", value: "0", description: "\"0\"" }, - peg$c64 = /^[0-9]/, - peg$c65 = { type: "class", value: "[0-9]", description: "[0-9]" }, - peg$c66 = /^[1-9]/, - peg$c67 = { type: "class", value: "[1-9]", description: "[1-9]" }, - peg$c68 = "e", - peg$c69 = { type: "literal", value: "e", description: "\"e\"" }, - peg$c70 = /^[+\-]/, - peg$c71 = { type: "class", value: "[+\\-]", description: "[+\\-]" }, - peg$c72 = "0x", - peg$c73 = { type: "literal", value: "0x", description: "\"0x\"" }, - peg$c74 = function(digits) { - return insertLocationData(new ast.NumberLiteral(text(), 16), text(), line(), column()); - }, - peg$c75 = /^[0-9a-f]/i, - peg$c76 = { type: "class", value: "[0-9a-f]i", description: "[0-9a-f]i" }, - peg$c77 = { type: "other", description: "string" }, - peg$c78 = "\"", - peg$c79 = { type: "literal", value: "\"", description: "\"\\\"\"" }, - peg$c80 = function(chars) { - return insertLocationData(new ast.StringLiteral(chars, column()), text(), line(), column()); - }, - peg$c81 = "'", - peg$c82 = { type: "literal", value: "'", description: "\"'\"" }, - peg$c83 = function() { return text(); }, - peg$c84 = function() { return new ast.StringLiteral.NewLine(text()); }, - peg$c85 = function() { return ""; }, - peg$c86 = function() { return "\0"; }, - peg$c87 = "b", - peg$c88 = { type: "literal", value: "b", description: "\"b\"" }, - peg$c89 = function() { return "\b"; }, - peg$c90 = "f", - peg$c91 = { type: "literal", value: "f", description: "\"f\"" }, - peg$c92 = function() { return "\f"; }, - peg$c93 = "n", - peg$c94 = { type: "literal", value: "n", description: "\"n\"" }, - peg$c95 = function() { return "\n"; }, - peg$c96 = "r", - peg$c97 = { type: "literal", value: "r", description: "\"r\"" }, - peg$c98 = function() { return "\r"; }, - peg$c99 = "t", - peg$c100 = { type: "literal", value: "t", description: "\"t\"" }, - peg$c101 = function() { return "\t"; }, - peg$c102 = "v", - peg$c103 = { type: "literal", value: "v", description: "\"v\"" }, - peg$c104 = function() { return "\x0B"; }, - peg$c105 = "x", - peg$c106 = { type: "literal", value: "x", description: "\"x\"" }, - peg$c107 = "u", - peg$c108 = { type: "literal", value: "u", description: "\"u\"" }, - peg$c109 = function(digits) { - return String.fromCharCode(parseInt(digits, 16)); - }, - peg$c110 = "(", - peg$c111 = { type: "literal", value: "(", description: "\"(\"" }, - peg$c112 = ")", - peg$c113 = { type: "literal", value: ")", description: "\")\"" }, - peg$c114 = function(expression) { - return expression; - }, - peg$c115 = { type: "other", description: "regular expression" }, - peg$c116 = "/", - peg$c117 = { type: "literal", value: "/", description: "\"/\"" }, - peg$c118 = function(pattern, flags) { - return insertLocationData(new ast.RegularExpressionLiteral(pattern, flags), text(), line(), column()); - }, - peg$c119 = /^[*\\\/[]/, - peg$c120 = { type: "class", value: "[*\\\\\\/[]", description: "[*\\\\\\/[]" }, - peg$c121 = /^[\\\/[]/, - peg$c122 = { type: "class", value: "[\\\\\\/[]", description: "[\\\\\\/[]" }, - peg$c123 = "[", - peg$c124 = { type: "literal", value: "[", description: "\"[\"" }, - peg$c125 = "]", - peg$c126 = { type: "literal", value: "]", description: "\"]\"" }, - peg$c127 = /^[\]\\]/, - peg$c128 = { type: "class", value: "[\\]\\\\]", description: "[\\]\\\\]" }, - peg$c129 = /^[a-z\xB5\xDF-\xF6\xF8-\xFF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137-\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148-\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C-\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA-\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9-\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC-\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF-\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F-\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0-\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB-\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE-\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0561-\u0587\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6-\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FC7\u1FD0-\u1FD3\u1FD6-\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6-\u1FF7\u210A\u210E-\u210F\u2113\u212F\u2134\u2139\u213C-\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65-\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73-\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3-\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7FA\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A]/, - peg$c130 = { type: "class", value: "[a-z\\xB5\\xDF-\\xF6\\xF8-\\xFF\\u0101\\u0103\\u0105\\u0107\\u0109\\u010B\\u010D\\u010F\\u0111\\u0113\\u0115\\u0117\\u0119\\u011B\\u011D\\u011F\\u0121\\u0123\\u0125\\u0127\\u0129\\u012B\\u012D\\u012F\\u0131\\u0133\\u0135\\u0137-\\u0138\\u013A\\u013C\\u013E\\u0140\\u0142\\u0144\\u0146\\u0148-\\u0149\\u014B\\u014D\\u014F\\u0151\\u0153\\u0155\\u0157\\u0159\\u015B\\u015D\\u015F\\u0161\\u0163\\u0165\\u0167\\u0169\\u016B\\u016D\\u016F\\u0171\\u0173\\u0175\\u0177\\u017A\\u017C\\u017E-\\u0180\\u0183\\u0185\\u0188\\u018C-\\u018D\\u0192\\u0195\\u0199-\\u019B\\u019E\\u01A1\\u01A3\\u01A5\\u01A8\\u01AA-\\u01AB\\u01AD\\u01B0\\u01B4\\u01B6\\u01B9-\\u01BA\\u01BD-\\u01BF\\u01C6\\u01C9\\u01CC\\u01CE\\u01D0\\u01D2\\u01D4\\u01D6\\u01D8\\u01DA\\u01DC-\\u01DD\\u01DF\\u01E1\\u01E3\\u01E5\\u01E7\\u01E9\\u01EB\\u01ED\\u01EF-\\u01F0\\u01F3\\u01F5\\u01F9\\u01FB\\u01FD\\u01FF\\u0201\\u0203\\u0205\\u0207\\u0209\\u020B\\u020D\\u020F\\u0211\\u0213\\u0215\\u0217\\u0219\\u021B\\u021D\\u021F\\u0221\\u0223\\u0225\\u0227\\u0229\\u022B\\u022D\\u022F\\u0231\\u0233-\\u0239\\u023C\\u023F-\\u0240\\u0242\\u0247\\u0249\\u024B\\u024D\\u024F-\\u0293\\u0295-\\u02AF\\u0371\\u0373\\u0377\\u037B-\\u037D\\u0390\\u03AC-\\u03CE\\u03D0-\\u03D1\\u03D5-\\u03D7\\u03D9\\u03DB\\u03DD\\u03DF\\u03E1\\u03E3\\u03E5\\u03E7\\u03E9\\u03EB\\u03ED\\u03EF-\\u03F3\\u03F5\\u03F8\\u03FB-\\u03FC\\u0430-\\u045F\\u0461\\u0463\\u0465\\u0467\\u0469\\u046B\\u046D\\u046F\\u0471\\u0473\\u0475\\u0477\\u0479\\u047B\\u047D\\u047F\\u0481\\u048B\\u048D\\u048F\\u0491\\u0493\\u0495\\u0497\\u0499\\u049B\\u049D\\u049F\\u04A1\\u04A3\\u04A5\\u04A7\\u04A9\\u04AB\\u04AD\\u04AF\\u04B1\\u04B3\\u04B5\\u04B7\\u04B9\\u04BB\\u04BD\\u04BF\\u04C2\\u04C4\\u04C6\\u04C8\\u04CA\\u04CC\\u04CE-\\u04CF\\u04D1\\u04D3\\u04D5\\u04D7\\u04D9\\u04DB\\u04DD\\u04DF\\u04E1\\u04E3\\u04E5\\u04E7\\u04E9\\u04EB\\u04ED\\u04EF\\u04F1\\u04F3\\u04F5\\u04F7\\u04F9\\u04FB\\u04FD\\u04FF\\u0501\\u0503\\u0505\\u0507\\u0509\\u050B\\u050D\\u050F\\u0511\\u0513\\u0515\\u0517\\u0519\\u051B\\u051D\\u051F\\u0521\\u0523\\u0525\\u0527\\u0561-\\u0587\\u1D00-\\u1D2B\\u1D6B-\\u1D77\\u1D79-\\u1D9A\\u1E01\\u1E03\\u1E05\\u1E07\\u1E09\\u1E0B\\u1E0D\\u1E0F\\u1E11\\u1E13\\u1E15\\u1E17\\u1E19\\u1E1B\\u1E1D\\u1E1F\\u1E21\\u1E23\\u1E25\\u1E27\\u1E29\\u1E2B\\u1E2D\\u1E2F\\u1E31\\u1E33\\u1E35\\u1E37\\u1E39\\u1E3B\\u1E3D\\u1E3F\\u1E41\\u1E43\\u1E45\\u1E47\\u1E49\\u1E4B\\u1E4D\\u1E4F\\u1E51\\u1E53\\u1E55\\u1E57\\u1E59\\u1E5B\\u1E5D\\u1E5F\\u1E61\\u1E63\\u1E65\\u1E67\\u1E69\\u1E6B\\u1E6D\\u1E6F\\u1E71\\u1E73\\u1E75\\u1E77\\u1E79\\u1E7B\\u1E7D\\u1E7F\\u1E81\\u1E83\\u1E85\\u1E87\\u1E89\\u1E8B\\u1E8D\\u1E8F\\u1E91\\u1E93\\u1E95-\\u1E9D\\u1E9F\\u1EA1\\u1EA3\\u1EA5\\u1EA7\\u1EA9\\u1EAB\\u1EAD\\u1EAF\\u1EB1\\u1EB3\\u1EB5\\u1EB7\\u1EB9\\u1EBB\\u1EBD\\u1EBF\\u1EC1\\u1EC3\\u1EC5\\u1EC7\\u1EC9\\u1ECB\\u1ECD\\u1ECF\\u1ED1\\u1ED3\\u1ED5\\u1ED7\\u1ED9\\u1EDB\\u1EDD\\u1EDF\\u1EE1\\u1EE3\\u1EE5\\u1EE7\\u1EE9\\u1EEB\\u1EED\\u1EEF\\u1EF1\\u1EF3\\u1EF5\\u1EF7\\u1EF9\\u1EFB\\u1EFD\\u1EFF-\\u1F07\\u1F10-\\u1F15\\u1F20-\\u1F27\\u1F30-\\u1F37\\u1F40-\\u1F45\\u1F50-\\u1F57\\u1F60-\\u1F67\\u1F70-\\u1F7D\\u1F80-\\u1F87\\u1F90-\\u1F97\\u1FA0-\\u1FA7\\u1FB0-\\u1FB4\\u1FB6-\\u1FB7\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FC7\\u1FD0-\\u1FD3\\u1FD6-\\u1FD7\\u1FE0-\\u1FE7\\u1FF2-\\u1FF4\\u1FF6-\\u1FF7\\u210A\\u210E-\\u210F\\u2113\\u212F\\u2134\\u2139\\u213C-\\u213D\\u2146-\\u2149\\u214E\\u2184\\u2C30-\\u2C5E\\u2C61\\u2C65-\\u2C66\\u2C68\\u2C6A\\u2C6C\\u2C71\\u2C73-\\u2C74\\u2C76-\\u2C7B\\u2C81\\u2C83\\u2C85\\u2C87\\u2C89\\u2C8B\\u2C8D\\u2C8F\\u2C91\\u2C93\\u2C95\\u2C97\\u2C99\\u2C9B\\u2C9D\\u2C9F\\u2CA1\\u2CA3\\u2CA5\\u2CA7\\u2CA9\\u2CAB\\u2CAD\\u2CAF\\u2CB1\\u2CB3\\u2CB5\\u2CB7\\u2CB9\\u2CBB\\u2CBD\\u2CBF\\u2CC1\\u2CC3\\u2CC5\\u2CC7\\u2CC9\\u2CCB\\u2CCD\\u2CCF\\u2CD1\\u2CD3\\u2CD5\\u2CD7\\u2CD9\\u2CDB\\u2CDD\\u2CDF\\u2CE1\\u2CE3-\\u2CE4\\u2CEC\\u2CEE\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\uA641\\uA643\\uA645\\uA647\\uA649\\uA64B\\uA64D\\uA64F\\uA651\\uA653\\uA655\\uA657\\uA659\\uA65B\\uA65D\\uA65F\\uA661\\uA663\\uA665\\uA667\\uA669\\uA66B\\uA66D\\uA681\\uA683\\uA685\\uA687\\uA689\\uA68B\\uA68D\\uA68F\\uA691\\uA693\\uA695\\uA697\\uA723\\uA725\\uA727\\uA729\\uA72B\\uA72D\\uA72F-\\uA731\\uA733\\uA735\\uA737\\uA739\\uA73B\\uA73D\\uA73F\\uA741\\uA743\\uA745\\uA747\\uA749\\uA74B\\uA74D\\uA74F\\uA751\\uA753\\uA755\\uA757\\uA759\\uA75B\\uA75D\\uA75F\\uA761\\uA763\\uA765\\uA767\\uA769\\uA76B\\uA76D\\uA76F\\uA771-\\uA778\\uA77A\\uA77C\\uA77F\\uA781\\uA783\\uA785\\uA787\\uA78C\\uA78E\\uA791\\uA793\\uA7A1\\uA7A3\\uA7A5\\uA7A7\\uA7A9\\uA7FA\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFF41-\\uFF5A]", description: "[a-z\\xB5\\xDF-\\xF6\\xF8-\\xFF\\u0101\\u0103\\u0105\\u0107\\u0109\\u010B\\u010D\\u010F\\u0111\\u0113\\u0115\\u0117\\u0119\\u011B\\u011D\\u011F\\u0121\\u0123\\u0125\\u0127\\u0129\\u012B\\u012D\\u012F\\u0131\\u0133\\u0135\\u0137-\\u0138\\u013A\\u013C\\u013E\\u0140\\u0142\\u0144\\u0146\\u0148-\\u0149\\u014B\\u014D\\u014F\\u0151\\u0153\\u0155\\u0157\\u0159\\u015B\\u015D\\u015F\\u0161\\u0163\\u0165\\u0167\\u0169\\u016B\\u016D\\u016F\\u0171\\u0173\\u0175\\u0177\\u017A\\u017C\\u017E-\\u0180\\u0183\\u0185\\u0188\\u018C-\\u018D\\u0192\\u0195\\u0199-\\u019B\\u019E\\u01A1\\u01A3\\u01A5\\u01A8\\u01AA-\\u01AB\\u01AD\\u01B0\\u01B4\\u01B6\\u01B9-\\u01BA\\u01BD-\\u01BF\\u01C6\\u01C9\\u01CC\\u01CE\\u01D0\\u01D2\\u01D4\\u01D6\\u01D8\\u01DA\\u01DC-\\u01DD\\u01DF\\u01E1\\u01E3\\u01E5\\u01E7\\u01E9\\u01EB\\u01ED\\u01EF-\\u01F0\\u01F3\\u01F5\\u01F9\\u01FB\\u01FD\\u01FF\\u0201\\u0203\\u0205\\u0207\\u0209\\u020B\\u020D\\u020F\\u0211\\u0213\\u0215\\u0217\\u0219\\u021B\\u021D\\u021F\\u0221\\u0223\\u0225\\u0227\\u0229\\u022B\\u022D\\u022F\\u0231\\u0233-\\u0239\\u023C\\u023F-\\u0240\\u0242\\u0247\\u0249\\u024B\\u024D\\u024F-\\u0293\\u0295-\\u02AF\\u0371\\u0373\\u0377\\u037B-\\u037D\\u0390\\u03AC-\\u03CE\\u03D0-\\u03D1\\u03D5-\\u03D7\\u03D9\\u03DB\\u03DD\\u03DF\\u03E1\\u03E3\\u03E5\\u03E7\\u03E9\\u03EB\\u03ED\\u03EF-\\u03F3\\u03F5\\u03F8\\u03FB-\\u03FC\\u0430-\\u045F\\u0461\\u0463\\u0465\\u0467\\u0469\\u046B\\u046D\\u046F\\u0471\\u0473\\u0475\\u0477\\u0479\\u047B\\u047D\\u047F\\u0481\\u048B\\u048D\\u048F\\u0491\\u0493\\u0495\\u0497\\u0499\\u049B\\u049D\\u049F\\u04A1\\u04A3\\u04A5\\u04A7\\u04A9\\u04AB\\u04AD\\u04AF\\u04B1\\u04B3\\u04B5\\u04B7\\u04B9\\u04BB\\u04BD\\u04BF\\u04C2\\u04C4\\u04C6\\u04C8\\u04CA\\u04CC\\u04CE-\\u04CF\\u04D1\\u04D3\\u04D5\\u04D7\\u04D9\\u04DB\\u04DD\\u04DF\\u04E1\\u04E3\\u04E5\\u04E7\\u04E9\\u04EB\\u04ED\\u04EF\\u04F1\\u04F3\\u04F5\\u04F7\\u04F9\\u04FB\\u04FD\\u04FF\\u0501\\u0503\\u0505\\u0507\\u0509\\u050B\\u050D\\u050F\\u0511\\u0513\\u0515\\u0517\\u0519\\u051B\\u051D\\u051F\\u0521\\u0523\\u0525\\u0527\\u0561-\\u0587\\u1D00-\\u1D2B\\u1D6B-\\u1D77\\u1D79-\\u1D9A\\u1E01\\u1E03\\u1E05\\u1E07\\u1E09\\u1E0B\\u1E0D\\u1E0F\\u1E11\\u1E13\\u1E15\\u1E17\\u1E19\\u1E1B\\u1E1D\\u1E1F\\u1E21\\u1E23\\u1E25\\u1E27\\u1E29\\u1E2B\\u1E2D\\u1E2F\\u1E31\\u1E33\\u1E35\\u1E37\\u1E39\\u1E3B\\u1E3D\\u1E3F\\u1E41\\u1E43\\u1E45\\u1E47\\u1E49\\u1E4B\\u1E4D\\u1E4F\\u1E51\\u1E53\\u1E55\\u1E57\\u1E59\\u1E5B\\u1E5D\\u1E5F\\u1E61\\u1E63\\u1E65\\u1E67\\u1E69\\u1E6B\\u1E6D\\u1E6F\\u1E71\\u1E73\\u1E75\\u1E77\\u1E79\\u1E7B\\u1E7D\\u1E7F\\u1E81\\u1E83\\u1E85\\u1E87\\u1E89\\u1E8B\\u1E8D\\u1E8F\\u1E91\\u1E93\\u1E95-\\u1E9D\\u1E9F\\u1EA1\\u1EA3\\u1EA5\\u1EA7\\u1EA9\\u1EAB\\u1EAD\\u1EAF\\u1EB1\\u1EB3\\u1EB5\\u1EB7\\u1EB9\\u1EBB\\u1EBD\\u1EBF\\u1EC1\\u1EC3\\u1EC5\\u1EC7\\u1EC9\\u1ECB\\u1ECD\\u1ECF\\u1ED1\\u1ED3\\u1ED5\\u1ED7\\u1ED9\\u1EDB\\u1EDD\\u1EDF\\u1EE1\\u1EE3\\u1EE5\\u1EE7\\u1EE9\\u1EEB\\u1EED\\u1EEF\\u1EF1\\u1EF3\\u1EF5\\u1EF7\\u1EF9\\u1EFB\\u1EFD\\u1EFF-\\u1F07\\u1F10-\\u1F15\\u1F20-\\u1F27\\u1F30-\\u1F37\\u1F40-\\u1F45\\u1F50-\\u1F57\\u1F60-\\u1F67\\u1F70-\\u1F7D\\u1F80-\\u1F87\\u1F90-\\u1F97\\u1FA0-\\u1FA7\\u1FB0-\\u1FB4\\u1FB6-\\u1FB7\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FC7\\u1FD0-\\u1FD3\\u1FD6-\\u1FD7\\u1FE0-\\u1FE7\\u1FF2-\\u1FF4\\u1FF6-\\u1FF7\\u210A\\u210E-\\u210F\\u2113\\u212F\\u2134\\u2139\\u213C-\\u213D\\u2146-\\u2149\\u214E\\u2184\\u2C30-\\u2C5E\\u2C61\\u2C65-\\u2C66\\u2C68\\u2C6A\\u2C6C\\u2C71\\u2C73-\\u2C74\\u2C76-\\u2C7B\\u2C81\\u2C83\\u2C85\\u2C87\\u2C89\\u2C8B\\u2C8D\\u2C8F\\u2C91\\u2C93\\u2C95\\u2C97\\u2C99\\u2C9B\\u2C9D\\u2C9F\\u2CA1\\u2CA3\\u2CA5\\u2CA7\\u2CA9\\u2CAB\\u2CAD\\u2CAF\\u2CB1\\u2CB3\\u2CB5\\u2CB7\\u2CB9\\u2CBB\\u2CBD\\u2CBF\\u2CC1\\u2CC3\\u2CC5\\u2CC7\\u2CC9\\u2CCB\\u2CCD\\u2CCF\\u2CD1\\u2CD3\\u2CD5\\u2CD7\\u2CD9\\u2CDB\\u2CDD\\u2CDF\\u2CE1\\u2CE3-\\u2CE4\\u2CEC\\u2CEE\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\uA641\\uA643\\uA645\\uA647\\uA649\\uA64B\\uA64D\\uA64F\\uA651\\uA653\\uA655\\uA657\\uA659\\uA65B\\uA65D\\uA65F\\uA661\\uA663\\uA665\\uA667\\uA669\\uA66B\\uA66D\\uA681\\uA683\\uA685\\uA687\\uA689\\uA68B\\uA68D\\uA68F\\uA691\\uA693\\uA695\\uA697\\uA723\\uA725\\uA727\\uA729\\uA72B\\uA72D\\uA72F-\\uA731\\uA733\\uA735\\uA737\\uA739\\uA73B\\uA73D\\uA73F\\uA741\\uA743\\uA745\\uA747\\uA749\\uA74B\\uA74D\\uA74F\\uA751\\uA753\\uA755\\uA757\\uA759\\uA75B\\uA75D\\uA75F\\uA761\\uA763\\uA765\\uA767\\uA769\\uA76B\\uA76D\\uA76F\\uA771-\\uA778\\uA77A\\uA77C\\uA77F\\uA781\\uA783\\uA785\\uA787\\uA78C\\uA78E\\uA791\\uA793\\uA7A1\\uA7A3\\uA7A5\\uA7A7\\uA7A9\\uA7FA\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFF41-\\uFF5A]" }, - peg$c131 = /^[\u02B0-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0374\u037A\u0559\u0640\u06E5-\u06E6\u07F4-\u07F5\u07FA\u081A\u0824\u0828\u0971\u0E46\u0EC6\u10FC\u17D7\u1843\u1AA7\u1C78-\u1C7D\u1D2C-\u1D6A\u1D78\u1D9B-\u1DBF\u2071\u207F\u2090-\u209C\u2C7C-\u2C7D\u2D6F\u2E2F\u3005\u3031-\u3035\u303B\u309D-\u309E\u30FC-\u30FE\uA015\uA4F8-\uA4FD\uA60C\uA67F\uA717-\uA71F\uA770\uA788\uA7F8-\uA7F9\uA9CF\uAA70\uAADD\uAAF3-\uAAF4\uFF70\uFF9E-\uFF9F]/, - peg$c132 = { type: "class", value: "[\\u02B0-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0374\\u037A\\u0559\\u0640\\u06E5-\\u06E6\\u07F4-\\u07F5\\u07FA\\u081A\\u0824\\u0828\\u0971\\u0E46\\u0EC6\\u10FC\\u17D7\\u1843\\u1AA7\\u1C78-\\u1C7D\\u1D2C-\\u1D6A\\u1D78\\u1D9B-\\u1DBF\\u2071\\u207F\\u2090-\\u209C\\u2C7C-\\u2C7D\\u2D6F\\u2E2F\\u3005\\u3031-\\u3035\\u303B\\u309D-\\u309E\\u30FC-\\u30FE\\uA015\\uA4F8-\\uA4FD\\uA60C\\uA67F\\uA717-\\uA71F\\uA770\\uA788\\uA7F8-\\uA7F9\\uA9CF\\uAA70\\uAADD\\uAAF3-\\uAAF4\\uFF70\\uFF9E-\\uFF9F]", description: "[\\u02B0-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0374\\u037A\\u0559\\u0640\\u06E5-\\u06E6\\u07F4-\\u07F5\\u07FA\\u081A\\u0824\\u0828\\u0971\\u0E46\\u0EC6\\u10FC\\u17D7\\u1843\\u1AA7\\u1C78-\\u1C7D\\u1D2C-\\u1D6A\\u1D78\\u1D9B-\\u1DBF\\u2071\\u207F\\u2090-\\u209C\\u2C7C-\\u2C7D\\u2D6F\\u2E2F\\u3005\\u3031-\\u3035\\u303B\\u309D-\\u309E\\u30FC-\\u30FE\\uA015\\uA4F8-\\uA4FD\\uA60C\\uA67F\\uA717-\\uA71F\\uA770\\uA788\\uA7F8-\\uA7F9\\uA9CF\\uAA70\\uAADD\\uAAF3-\\uAAF4\\uFF70\\uFF9E-\\uFF9F]" }, - peg$c133 = /^[\xAA\xBA\u01BB\u01C0-\u01C3\u0294\u05D0-\u05EA\u05F0-\u05F2\u0620-\u063F\u0641-\u064A\u066E-\u066F\u0671-\u06D3\u06D5\u06EE-\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u0800-\u0815\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0972-\u0977\u0979-\u097F\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0-\u0AE1\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58-\u0C59\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0-\u0CE1\u0CF1-\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E45\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065-\u1066\u106E-\u1070\u1075-\u1081\u108E\u10D0-\u10FA\u10FD-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17DC\u1820-\u1842\u1844-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE-\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C77\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5-\u1CF6\u2135-\u2138\u2D30-\u2D67\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3006\u303C\u3041-\u3096\u309F\u30A1-\u30FA\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA014\uA016-\uA48C\uA4D0-\uA4F7\uA500-\uA60B\uA610-\uA61F\uA62A-\uA62B\uA66E\uA6A0-\uA6E5\uA7FB-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA6F\uAA71-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADC\uAAE0-\uAAEA\uAAF2\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40-\uFB41\uFB43-\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF66-\uFF6F\uFF71-\uFF9D\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/, - peg$c134 = { type: "class", value: "[\\xAA\\xBA\\u01BB\\u01C0-\\u01C3\\u0294\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u063F\\u0641-\\u064A\\u066E-\\u066F\\u0671-\\u06D3\\u06D5\\u06EE-\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u0800-\\u0815\\u0840-\\u0858\\u08A0\\u08A2-\\u08AC\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0972-\\u0977\\u0979-\\u097F\\u0985-\\u098C\\u098F-\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC-\\u09DD\\u09DF-\\u09E1\\u09F0-\\u09F1\\u0A05-\\u0A0A\\u0A0F-\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32-\\u0A33\\u0A35-\\u0A36\\u0A38-\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2-\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0-\\u0AE1\\u0B05-\\u0B0C\\u0B0F-\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32-\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C-\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99-\\u0B9A\\u0B9C\\u0B9E-\\u0B9F\\u0BA3-\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58-\\u0C59\\u0C60-\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0-\\u0CE1\\u0CF1-\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60-\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32-\\u0E33\\u0E40-\\u0E45\\u0E81-\\u0E82\\u0E84\\u0E87-\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA-\\u0EAB\\u0EAD-\\u0EB0\\u0EB2-\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065-\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10D0-\\u10FA\\u10FD-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17DC\\u1820-\\u1842\\u1844-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE-\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C77\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5-\\u1CF6\\u2135-\\u2138\\u2D30-\\u2D67\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u3006\\u303C\\u3041-\\u3096\\u309F\\u30A1-\\u30FA\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA014\\uA016-\\uA48C\\uA4D0-\\uA4F7\\uA500-\\uA60B\\uA610-\\uA61F\\uA62A-\\uA62B\\uA66E\\uA6A0-\\uA6E5\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA6F\\uAA71-\\uAA76\\uAA7A\\uAA80-\\uAAAF\\uAAB1\\uAAB5-\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADC\\uAAE0-\\uAAEA\\uAAF2\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40-\\uFB41\\uFB43-\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF66-\\uFF6F\\uFF71-\\uFF9D\\uFFA0-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]", description: "[\\xAA\\xBA\\u01BB\\u01C0-\\u01C3\\u0294\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u063F\\u0641-\\u064A\\u066E-\\u066F\\u0671-\\u06D3\\u06D5\\u06EE-\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u0800-\\u0815\\u0840-\\u0858\\u08A0\\u08A2-\\u08AC\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0972-\\u0977\\u0979-\\u097F\\u0985-\\u098C\\u098F-\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC-\\u09DD\\u09DF-\\u09E1\\u09F0-\\u09F1\\u0A05-\\u0A0A\\u0A0F-\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32-\\u0A33\\u0A35-\\u0A36\\u0A38-\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2-\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0-\\u0AE1\\u0B05-\\u0B0C\\u0B0F-\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32-\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C-\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99-\\u0B9A\\u0B9C\\u0B9E-\\u0B9F\\u0BA3-\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58-\\u0C59\\u0C60-\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0-\\u0CE1\\u0CF1-\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60-\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32-\\u0E33\\u0E40-\\u0E45\\u0E81-\\u0E82\\u0E84\\u0E87-\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA-\\u0EAB\\u0EAD-\\u0EB0\\u0EB2-\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065-\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10D0-\\u10FA\\u10FD-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17DC\\u1820-\\u1842\\u1844-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE-\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C77\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5-\\u1CF6\\u2135-\\u2138\\u2D30-\\u2D67\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u3006\\u303C\\u3041-\\u3096\\u309F\\u30A1-\\u30FA\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA014\\uA016-\\uA48C\\uA4D0-\\uA4F7\\uA500-\\uA60B\\uA610-\\uA61F\\uA62A-\\uA62B\\uA66E\\uA6A0-\\uA6E5\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA6F\\uAA71-\\uAA76\\uAA7A\\uAA80-\\uAAAF\\uAAB1\\uAAB5-\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADC\\uAAE0-\\uAAEA\\uAAF2\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40-\\uFB41\\uFB43-\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF66-\\uFF6F\\uFF71-\\uFF9D\\uFFA0-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]" }, - peg$c135 = /^[\u01C5\u01C8\u01CB\u01F2\u1F88-\u1F8F\u1F98-\u1F9F\u1FA8-\u1FAF\u1FBC\u1FCC\u1FFC]/, - peg$c136 = { type: "class", value: "[\\u01C5\\u01C8\\u01CB\\u01F2\\u1F88-\\u1F8F\\u1F98-\\u1F9F\\u1FA8-\\u1FAF\\u1FBC\\u1FCC\\u1FFC]", description: "[\\u01C5\\u01C8\\u01CB\\u01F2\\u1F88-\\u1F8F\\u1F98-\\u1F9F\\u1FA8-\\u1FAF\\u1FBC\\u1FCC\\u1FFC]" }, - peg$c137 = /^[A-Z\xC0-\xD6\xD8-\xDE\u0100\u0102\u0104\u0106\u0108\u010A\u010C\u010E\u0110\u0112\u0114\u0116\u0118\u011A\u011C\u011E\u0120\u0122\u0124\u0126\u0128\u012A\u012C\u012E\u0130\u0132\u0134\u0136\u0139\u013B\u013D\u013F\u0141\u0143\u0145\u0147\u014A\u014C\u014E\u0150\u0152\u0154\u0156\u0158\u015A\u015C\u015E\u0160\u0162\u0164\u0166\u0168\u016A\u016C\u016E\u0170\u0172\u0174\u0176\u0178-\u0179\u017B\u017D\u0181-\u0182\u0184\u0186-\u0187\u0189-\u018B\u018E-\u0191\u0193-\u0194\u0196-\u0198\u019C-\u019D\u019F-\u01A0\u01A2\u01A4\u01A6-\u01A7\u01A9\u01AC\u01AE-\u01AF\u01B1-\u01B3\u01B5\u01B7-\u01B8\u01BC\u01C4\u01C7\u01CA\u01CD\u01CF\u01D1\u01D3\u01D5\u01D7\u01D9\u01DB\u01DE\u01E0\u01E2\u01E4\u01E6\u01E8\u01EA\u01EC\u01EE\u01F1\u01F4\u01F6-\u01F8\u01FA\u01FC\u01FE\u0200\u0202\u0204\u0206\u0208\u020A\u020C\u020E\u0210\u0212\u0214\u0216\u0218\u021A\u021C\u021E\u0220\u0222\u0224\u0226\u0228\u022A\u022C\u022E\u0230\u0232\u023A-\u023B\u023D-\u023E\u0241\u0243-\u0246\u0248\u024A\u024C\u024E\u0370\u0372\u0376\u0386\u0388-\u038A\u038C\u038E-\u038F\u0391-\u03A1\u03A3-\u03AB\u03CF\u03D2-\u03D4\u03D8\u03DA\u03DC\u03DE\u03E0\u03E2\u03E4\u03E6\u03E8\u03EA\u03EC\u03EE\u03F4\u03F7\u03F9-\u03FA\u03FD-\u042F\u0460\u0462\u0464\u0466\u0468\u046A\u046C\u046E\u0470\u0472\u0474\u0476\u0478\u047A\u047C\u047E\u0480\u048A\u048C\u048E\u0490\u0492\u0494\u0496\u0498\u049A\u049C\u049E\u04A0\u04A2\u04A4\u04A6\u04A8\u04AA\u04AC\u04AE\u04B0\u04B2\u04B4\u04B6\u04B8\u04BA\u04BC\u04BE\u04C0-\u04C1\u04C3\u04C5\u04C7\u04C9\u04CB\u04CD\u04D0\u04D2\u04D4\u04D6\u04D8\u04DA\u04DC\u04DE\u04E0\u04E2\u04E4\u04E6\u04E8\u04EA\u04EC\u04EE\u04F0\u04F2\u04F4\u04F6\u04F8\u04FA\u04FC\u04FE\u0500\u0502\u0504\u0506\u0508\u050A\u050C\u050E\u0510\u0512\u0514\u0516\u0518\u051A\u051C\u051E\u0520\u0522\u0524\u0526\u0531-\u0556\u10A0-\u10C5\u10C7\u10CD\u1E00\u1E02\u1E04\u1E06\u1E08\u1E0A\u1E0C\u1E0E\u1E10\u1E12\u1E14\u1E16\u1E18\u1E1A\u1E1C\u1E1E\u1E20\u1E22\u1E24\u1E26\u1E28\u1E2A\u1E2C\u1E2E\u1E30\u1E32\u1E34\u1E36\u1E38\u1E3A\u1E3C\u1E3E\u1E40\u1E42\u1E44\u1E46\u1E48\u1E4A\u1E4C\u1E4E\u1E50\u1E52\u1E54\u1E56\u1E58\u1E5A\u1E5C\u1E5E\u1E60\u1E62\u1E64\u1E66\u1E68\u1E6A\u1E6C\u1E6E\u1E70\u1E72\u1E74\u1E76\u1E78\u1E7A\u1E7C\u1E7E\u1E80\u1E82\u1E84\u1E86\u1E88\u1E8A\u1E8C\u1E8E\u1E90\u1E92\u1E94\u1E9E\u1EA0\u1EA2\u1EA4\u1EA6\u1EA8\u1EAA\u1EAC\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u1EB8\u1EBA\u1EBC\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1EC8\u1ECA\u1ECC\u1ECE\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2\u1EE4\u1EE6\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0\u1EF2\u1EF4\u1EF6\u1EF8\u1EFA\u1EFC\u1EFE\u1F08-\u1F0F\u1F18-\u1F1D\u1F28-\u1F2F\u1F38-\u1F3F\u1F48-\u1F4D\u1F59\u1F5B\u1F5D\u1F5F\u1F68-\u1F6F\u1FB8-\u1FBB\u1FC8-\u1FCB\u1FD8-\u1FDB\u1FE8-\u1FEC\u1FF8-\u1FFB\u2102\u2107\u210B-\u210D\u2110-\u2112\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u2130-\u2133\u213E-\u213F\u2145\u2183\u2C00-\u2C2E\u2C60\u2C62-\u2C64\u2C67\u2C69\u2C6B\u2C6D-\u2C70\u2C72\u2C75\u2C7E-\u2C80\u2C82\u2C84\u2C86\u2C88\u2C8A\u2C8C\u2C8E\u2C90\u2C92\u2C94\u2C96\u2C98\u2C9A\u2C9C\u2C9E\u2CA0\u2CA2\u2CA4\u2CA6\u2CA8\u2CAA\u2CAC\u2CAE\u2CB0\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC2\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CEB\u2CED\u2CF2\uA640\uA642\uA644\uA646\uA648\uA64A\uA64C\uA64E\uA650\uA652\uA654\uA656\uA658\uA65A\uA65C\uA65E\uA660\uA662\uA664\uA666\uA668\uA66A\uA66C\uA680\uA682\uA684\uA686\uA688\uA68A\uA68C\uA68E\uA690\uA692\uA694\uA696\uA722\uA724\uA726\uA728\uA72A\uA72C\uA72E\uA732\uA734\uA736\uA738\uA73A\uA73C\uA73E\uA740\uA742\uA744\uA746\uA748\uA74A\uA74C\uA74E\uA750\uA752\uA754\uA756\uA758\uA75A\uA75C\uA75E\uA760\uA762\uA764\uA766\uA768\uA76A\uA76C\uA76E\uA779\uA77B\uA77D-\uA77E\uA780\uA782\uA784\uA786\uA78B\uA78D\uA790\uA792\uA7A0\uA7A2\uA7A4\uA7A6\uA7A8\uA7AA\uFF21-\uFF3A]/, - peg$c138 = { type: "class", value: "[A-Z\\xC0-\\xD6\\xD8-\\xDE\\u0100\\u0102\\u0104\\u0106\\u0108\\u010A\\u010C\\u010E\\u0110\\u0112\\u0114\\u0116\\u0118\\u011A\\u011C\\u011E\\u0120\\u0122\\u0124\\u0126\\u0128\\u012A\\u012C\\u012E\\u0130\\u0132\\u0134\\u0136\\u0139\\u013B\\u013D\\u013F\\u0141\\u0143\\u0145\\u0147\\u014A\\u014C\\u014E\\u0150\\u0152\\u0154\\u0156\\u0158\\u015A\\u015C\\u015E\\u0160\\u0162\\u0164\\u0166\\u0168\\u016A\\u016C\\u016E\\u0170\\u0172\\u0174\\u0176\\u0178-\\u0179\\u017B\\u017D\\u0181-\\u0182\\u0184\\u0186-\\u0187\\u0189-\\u018B\\u018E-\\u0191\\u0193-\\u0194\\u0196-\\u0198\\u019C-\\u019D\\u019F-\\u01A0\\u01A2\\u01A4\\u01A6-\\u01A7\\u01A9\\u01AC\\u01AE-\\u01AF\\u01B1-\\u01B3\\u01B5\\u01B7-\\u01B8\\u01BC\\u01C4\\u01C7\\u01CA\\u01CD\\u01CF\\u01D1\\u01D3\\u01D5\\u01D7\\u01D9\\u01DB\\u01DE\\u01E0\\u01E2\\u01E4\\u01E6\\u01E8\\u01EA\\u01EC\\u01EE\\u01F1\\u01F4\\u01F6-\\u01F8\\u01FA\\u01FC\\u01FE\\u0200\\u0202\\u0204\\u0206\\u0208\\u020A\\u020C\\u020E\\u0210\\u0212\\u0214\\u0216\\u0218\\u021A\\u021C\\u021E\\u0220\\u0222\\u0224\\u0226\\u0228\\u022A\\u022C\\u022E\\u0230\\u0232\\u023A-\\u023B\\u023D-\\u023E\\u0241\\u0243-\\u0246\\u0248\\u024A\\u024C\\u024E\\u0370\\u0372\\u0376\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u038F\\u0391-\\u03A1\\u03A3-\\u03AB\\u03CF\\u03D2-\\u03D4\\u03D8\\u03DA\\u03DC\\u03DE\\u03E0\\u03E2\\u03E4\\u03E6\\u03E8\\u03EA\\u03EC\\u03EE\\u03F4\\u03F7\\u03F9-\\u03FA\\u03FD-\\u042F\\u0460\\u0462\\u0464\\u0466\\u0468\\u046A\\u046C\\u046E\\u0470\\u0472\\u0474\\u0476\\u0478\\u047A\\u047C\\u047E\\u0480\\u048A\\u048C\\u048E\\u0490\\u0492\\u0494\\u0496\\u0498\\u049A\\u049C\\u049E\\u04A0\\u04A2\\u04A4\\u04A6\\u04A8\\u04AA\\u04AC\\u04AE\\u04B0\\u04B2\\u04B4\\u04B6\\u04B8\\u04BA\\u04BC\\u04BE\\u04C0-\\u04C1\\u04C3\\u04C5\\u04C7\\u04C9\\u04CB\\u04CD\\u04D0\\u04D2\\u04D4\\u04D6\\u04D8\\u04DA\\u04DC\\u04DE\\u04E0\\u04E2\\u04E4\\u04E6\\u04E8\\u04EA\\u04EC\\u04EE\\u04F0\\u04F2\\u04F4\\u04F6\\u04F8\\u04FA\\u04FC\\u04FE\\u0500\\u0502\\u0504\\u0506\\u0508\\u050A\\u050C\\u050E\\u0510\\u0512\\u0514\\u0516\\u0518\\u051A\\u051C\\u051E\\u0520\\u0522\\u0524\\u0526\\u0531-\\u0556\\u10A0-\\u10C5\\u10C7\\u10CD\\u1E00\\u1E02\\u1E04\\u1E06\\u1E08\\u1E0A\\u1E0C\\u1E0E\\u1E10\\u1E12\\u1E14\\u1E16\\u1E18\\u1E1A\\u1E1C\\u1E1E\\u1E20\\u1E22\\u1E24\\u1E26\\u1E28\\u1E2A\\u1E2C\\u1E2E\\u1E30\\u1E32\\u1E34\\u1E36\\u1E38\\u1E3A\\u1E3C\\u1E3E\\u1E40\\u1E42\\u1E44\\u1E46\\u1E48\\u1E4A\\u1E4C\\u1E4E\\u1E50\\u1E52\\u1E54\\u1E56\\u1E58\\u1E5A\\u1E5C\\u1E5E\\u1E60\\u1E62\\u1E64\\u1E66\\u1E68\\u1E6A\\u1E6C\\u1E6E\\u1E70\\u1E72\\u1E74\\u1E76\\u1E78\\u1E7A\\u1E7C\\u1E7E\\u1E80\\u1E82\\u1E84\\u1E86\\u1E88\\u1E8A\\u1E8C\\u1E8E\\u1E90\\u1E92\\u1E94\\u1E9E\\u1EA0\\u1EA2\\u1EA4\\u1EA6\\u1EA8\\u1EAA\\u1EAC\\u1EAE\\u1EB0\\u1EB2\\u1EB4\\u1EB6\\u1EB8\\u1EBA\\u1EBC\\u1EBE\\u1EC0\\u1EC2\\u1EC4\\u1EC6\\u1EC8\\u1ECA\\u1ECC\\u1ECE\\u1ED0\\u1ED2\\u1ED4\\u1ED6\\u1ED8\\u1EDA\\u1EDC\\u1EDE\\u1EE0\\u1EE2\\u1EE4\\u1EE6\\u1EE8\\u1EEA\\u1EEC\\u1EEE\\u1EF0\\u1EF2\\u1EF4\\u1EF6\\u1EF8\\u1EFA\\u1EFC\\u1EFE\\u1F08-\\u1F0F\\u1F18-\\u1F1D\\u1F28-\\u1F2F\\u1F38-\\u1F3F\\u1F48-\\u1F4D\\u1F59\\u1F5B\\u1F5D\\u1F5F\\u1F68-\\u1F6F\\u1FB8-\\u1FBB\\u1FC8-\\u1FCB\\u1FD8-\\u1FDB\\u1FE8-\\u1FEC\\u1FF8-\\u1FFB\\u2102\\u2107\\u210B-\\u210D\\u2110-\\u2112\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u2130-\\u2133\\u213E-\\u213F\\u2145\\u2183\\u2C00-\\u2C2E\\u2C60\\u2C62-\\u2C64\\u2C67\\u2C69\\u2C6B\\u2C6D-\\u2C70\\u2C72\\u2C75\\u2C7E-\\u2C80\\u2C82\\u2C84\\u2C86\\u2C88\\u2C8A\\u2C8C\\u2C8E\\u2C90\\u2C92\\u2C94\\u2C96\\u2C98\\u2C9A\\u2C9C\\u2C9E\\u2CA0\\u2CA2\\u2CA4\\u2CA6\\u2CA8\\u2CAA\\u2CAC\\u2CAE\\u2CB0\\u2CB2\\u2CB4\\u2CB6\\u2CB8\\u2CBA\\u2CBC\\u2CBE\\u2CC0\\u2CC2\\u2CC4\\u2CC6\\u2CC8\\u2CCA\\u2CCC\\u2CCE\\u2CD0\\u2CD2\\u2CD4\\u2CD6\\u2CD8\\u2CDA\\u2CDC\\u2CDE\\u2CE0\\u2CE2\\u2CEB\\u2CED\\u2CF2\\uA640\\uA642\\uA644\\uA646\\uA648\\uA64A\\uA64C\\uA64E\\uA650\\uA652\\uA654\\uA656\\uA658\\uA65A\\uA65C\\uA65E\\uA660\\uA662\\uA664\\uA666\\uA668\\uA66A\\uA66C\\uA680\\uA682\\uA684\\uA686\\uA688\\uA68A\\uA68C\\uA68E\\uA690\\uA692\\uA694\\uA696\\uA722\\uA724\\uA726\\uA728\\uA72A\\uA72C\\uA72E\\uA732\\uA734\\uA736\\uA738\\uA73A\\uA73C\\uA73E\\uA740\\uA742\\uA744\\uA746\\uA748\\uA74A\\uA74C\\uA74E\\uA750\\uA752\\uA754\\uA756\\uA758\\uA75A\\uA75C\\uA75E\\uA760\\uA762\\uA764\\uA766\\uA768\\uA76A\\uA76C\\uA76E\\uA779\\uA77B\\uA77D-\\uA77E\\uA780\\uA782\\uA784\\uA786\\uA78B\\uA78D\\uA790\\uA792\\uA7A0\\uA7A2\\uA7A4\\uA7A6\\uA7A8\\uA7AA\\uFF21-\\uFF3A]", description: "[A-Z\\xC0-\\xD6\\xD8-\\xDE\\u0100\\u0102\\u0104\\u0106\\u0108\\u010A\\u010C\\u010E\\u0110\\u0112\\u0114\\u0116\\u0118\\u011A\\u011C\\u011E\\u0120\\u0122\\u0124\\u0126\\u0128\\u012A\\u012C\\u012E\\u0130\\u0132\\u0134\\u0136\\u0139\\u013B\\u013D\\u013F\\u0141\\u0143\\u0145\\u0147\\u014A\\u014C\\u014E\\u0150\\u0152\\u0154\\u0156\\u0158\\u015A\\u015C\\u015E\\u0160\\u0162\\u0164\\u0166\\u0168\\u016A\\u016C\\u016E\\u0170\\u0172\\u0174\\u0176\\u0178-\\u0179\\u017B\\u017D\\u0181-\\u0182\\u0184\\u0186-\\u0187\\u0189-\\u018B\\u018E-\\u0191\\u0193-\\u0194\\u0196-\\u0198\\u019C-\\u019D\\u019F-\\u01A0\\u01A2\\u01A4\\u01A6-\\u01A7\\u01A9\\u01AC\\u01AE-\\u01AF\\u01B1-\\u01B3\\u01B5\\u01B7-\\u01B8\\u01BC\\u01C4\\u01C7\\u01CA\\u01CD\\u01CF\\u01D1\\u01D3\\u01D5\\u01D7\\u01D9\\u01DB\\u01DE\\u01E0\\u01E2\\u01E4\\u01E6\\u01E8\\u01EA\\u01EC\\u01EE\\u01F1\\u01F4\\u01F6-\\u01F8\\u01FA\\u01FC\\u01FE\\u0200\\u0202\\u0204\\u0206\\u0208\\u020A\\u020C\\u020E\\u0210\\u0212\\u0214\\u0216\\u0218\\u021A\\u021C\\u021E\\u0220\\u0222\\u0224\\u0226\\u0228\\u022A\\u022C\\u022E\\u0230\\u0232\\u023A-\\u023B\\u023D-\\u023E\\u0241\\u0243-\\u0246\\u0248\\u024A\\u024C\\u024E\\u0370\\u0372\\u0376\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u038F\\u0391-\\u03A1\\u03A3-\\u03AB\\u03CF\\u03D2-\\u03D4\\u03D8\\u03DA\\u03DC\\u03DE\\u03E0\\u03E2\\u03E4\\u03E6\\u03E8\\u03EA\\u03EC\\u03EE\\u03F4\\u03F7\\u03F9-\\u03FA\\u03FD-\\u042F\\u0460\\u0462\\u0464\\u0466\\u0468\\u046A\\u046C\\u046E\\u0470\\u0472\\u0474\\u0476\\u0478\\u047A\\u047C\\u047E\\u0480\\u048A\\u048C\\u048E\\u0490\\u0492\\u0494\\u0496\\u0498\\u049A\\u049C\\u049E\\u04A0\\u04A2\\u04A4\\u04A6\\u04A8\\u04AA\\u04AC\\u04AE\\u04B0\\u04B2\\u04B4\\u04B6\\u04B8\\u04BA\\u04BC\\u04BE\\u04C0-\\u04C1\\u04C3\\u04C5\\u04C7\\u04C9\\u04CB\\u04CD\\u04D0\\u04D2\\u04D4\\u04D6\\u04D8\\u04DA\\u04DC\\u04DE\\u04E0\\u04E2\\u04E4\\u04E6\\u04E8\\u04EA\\u04EC\\u04EE\\u04F0\\u04F2\\u04F4\\u04F6\\u04F8\\u04FA\\u04FC\\u04FE\\u0500\\u0502\\u0504\\u0506\\u0508\\u050A\\u050C\\u050E\\u0510\\u0512\\u0514\\u0516\\u0518\\u051A\\u051C\\u051E\\u0520\\u0522\\u0524\\u0526\\u0531-\\u0556\\u10A0-\\u10C5\\u10C7\\u10CD\\u1E00\\u1E02\\u1E04\\u1E06\\u1E08\\u1E0A\\u1E0C\\u1E0E\\u1E10\\u1E12\\u1E14\\u1E16\\u1E18\\u1E1A\\u1E1C\\u1E1E\\u1E20\\u1E22\\u1E24\\u1E26\\u1E28\\u1E2A\\u1E2C\\u1E2E\\u1E30\\u1E32\\u1E34\\u1E36\\u1E38\\u1E3A\\u1E3C\\u1E3E\\u1E40\\u1E42\\u1E44\\u1E46\\u1E48\\u1E4A\\u1E4C\\u1E4E\\u1E50\\u1E52\\u1E54\\u1E56\\u1E58\\u1E5A\\u1E5C\\u1E5E\\u1E60\\u1E62\\u1E64\\u1E66\\u1E68\\u1E6A\\u1E6C\\u1E6E\\u1E70\\u1E72\\u1E74\\u1E76\\u1E78\\u1E7A\\u1E7C\\u1E7E\\u1E80\\u1E82\\u1E84\\u1E86\\u1E88\\u1E8A\\u1E8C\\u1E8E\\u1E90\\u1E92\\u1E94\\u1E9E\\u1EA0\\u1EA2\\u1EA4\\u1EA6\\u1EA8\\u1EAA\\u1EAC\\u1EAE\\u1EB0\\u1EB2\\u1EB4\\u1EB6\\u1EB8\\u1EBA\\u1EBC\\u1EBE\\u1EC0\\u1EC2\\u1EC4\\u1EC6\\u1EC8\\u1ECA\\u1ECC\\u1ECE\\u1ED0\\u1ED2\\u1ED4\\u1ED6\\u1ED8\\u1EDA\\u1EDC\\u1EDE\\u1EE0\\u1EE2\\u1EE4\\u1EE6\\u1EE8\\u1EEA\\u1EEC\\u1EEE\\u1EF0\\u1EF2\\u1EF4\\u1EF6\\u1EF8\\u1EFA\\u1EFC\\u1EFE\\u1F08-\\u1F0F\\u1F18-\\u1F1D\\u1F28-\\u1F2F\\u1F38-\\u1F3F\\u1F48-\\u1F4D\\u1F59\\u1F5B\\u1F5D\\u1F5F\\u1F68-\\u1F6F\\u1FB8-\\u1FBB\\u1FC8-\\u1FCB\\u1FD8-\\u1FDB\\u1FE8-\\u1FEC\\u1FF8-\\u1FFB\\u2102\\u2107\\u210B-\\u210D\\u2110-\\u2112\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u2130-\\u2133\\u213E-\\u213F\\u2145\\u2183\\u2C00-\\u2C2E\\u2C60\\u2C62-\\u2C64\\u2C67\\u2C69\\u2C6B\\u2C6D-\\u2C70\\u2C72\\u2C75\\u2C7E-\\u2C80\\u2C82\\u2C84\\u2C86\\u2C88\\u2C8A\\u2C8C\\u2C8E\\u2C90\\u2C92\\u2C94\\u2C96\\u2C98\\u2C9A\\u2C9C\\u2C9E\\u2CA0\\u2CA2\\u2CA4\\u2CA6\\u2CA8\\u2CAA\\u2CAC\\u2CAE\\u2CB0\\u2CB2\\u2CB4\\u2CB6\\u2CB8\\u2CBA\\u2CBC\\u2CBE\\u2CC0\\u2CC2\\u2CC4\\u2CC6\\u2CC8\\u2CCA\\u2CCC\\u2CCE\\u2CD0\\u2CD2\\u2CD4\\u2CD6\\u2CD8\\u2CDA\\u2CDC\\u2CDE\\u2CE0\\u2CE2\\u2CEB\\u2CED\\u2CF2\\uA640\\uA642\\uA644\\uA646\\uA648\\uA64A\\uA64C\\uA64E\\uA650\\uA652\\uA654\\uA656\\uA658\\uA65A\\uA65C\\uA65E\\uA660\\uA662\\uA664\\uA666\\uA668\\uA66A\\uA66C\\uA680\\uA682\\uA684\\uA686\\uA688\\uA68A\\uA68C\\uA68E\\uA690\\uA692\\uA694\\uA696\\uA722\\uA724\\uA726\\uA728\\uA72A\\uA72C\\uA72E\\uA732\\uA734\\uA736\\uA738\\uA73A\\uA73C\\uA73E\\uA740\\uA742\\uA744\\uA746\\uA748\\uA74A\\uA74C\\uA74E\\uA750\\uA752\\uA754\\uA756\\uA758\\uA75A\\uA75C\\uA75E\\uA760\\uA762\\uA764\\uA766\\uA768\\uA76A\\uA76C\\uA76E\\uA779\\uA77B\\uA77D-\\uA77E\\uA780\\uA782\\uA784\\uA786\\uA78B\\uA78D\\uA790\\uA792\\uA7A0\\uA7A2\\uA7A4\\uA7A6\\uA7A8\\uA7AA\\uFF21-\\uFF3A]" }, - peg$c139 = /^[\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0982-\u0983\u09BE-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u09D7\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0B02-\u0B03\u0B3E\u0B40\u0B47-\u0B48\u0B4B-\u0B4C\u0B57\u0BBE-\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0BD7\u0C01-\u0C03\u0C41-\u0C44\u0C82-\u0C83\u0CBE\u0CC0-\u0CC4\u0CC7-\u0CC8\u0CCA-\u0CCB\u0CD5-\u0CD6\u0D02-\u0D03\u0D3E-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D57\u0D82-\u0D83\u0DCF-\u0DD1\u0DD8-\u0DDF\u0DF2-\u0DF3\u0F3E-\u0F3F\u0F7F\u102B-\u102C\u1031\u1038\u103B-\u103C\u1056-\u1057\u1062-\u1064\u1067-\u106D\u1083-\u1084\u1087-\u108C\u108F\u109A-\u109C\u17B6\u17BE-\u17C5\u17C7-\u17C8\u1923-\u1926\u1929-\u192B\u1930-\u1931\u1933-\u1938\u19B0-\u19C0\u19C8-\u19C9\u1A19-\u1A1A\u1A55\u1A57\u1A61\u1A63-\u1A64\u1A6D-\u1A72\u1B04\u1B35\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B82\u1BA1\u1BA6-\u1BA7\u1BAA\u1BAC-\u1BAD\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1C24-\u1C2B\u1C34-\u1C35\u1CE1\u1CF2-\u1CF3\u302E-\u302F\uA823-\uA824\uA827\uA880-\uA881\uA8B4-\uA8C3\uA952-\uA953\uA983\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BD-\uA9C0\uAA2F-\uAA30\uAA33-\uAA34\uAA4D\uAA7B\uAAEB\uAAEE-\uAAEF\uAAF5\uABE3-\uABE4\uABE6-\uABE7\uABE9-\uABEA\uABEC]/, - peg$c140 = { type: "class", value: "[\\u0903\\u093B\\u093E-\\u0940\\u0949-\\u094C\\u094E-\\u094F\\u0982-\\u0983\\u09BE-\\u09C0\\u09C7-\\u09C8\\u09CB-\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB-\\u0ACC\\u0B02-\\u0B03\\u0B3E\\u0B40\\u0B47-\\u0B48\\u0B4B-\\u0B4C\\u0B57\\u0BBE-\\u0BBF\\u0BC1-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82-\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7-\\u0CC8\\u0CCA-\\u0CCB\\u0CD5-\\u0CD6\\u0D02-\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82-\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2-\\u0DF3\\u0F3E-\\u0F3F\\u0F7F\\u102B-\\u102C\\u1031\\u1038\\u103B-\\u103C\\u1056-\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083-\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7-\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930-\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8-\\u19C9\\u1A19-\\u1A1A\\u1A55\\u1A57\\u1A61\\u1A63-\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43-\\u1B44\\u1B82\\u1BA1\\u1BA6-\\u1BA7\\u1BAA\\u1BAC-\\u1BAD\\u1BE7\\u1BEA-\\u1BEC\\u1BEE\\u1BF2-\\u1BF3\\u1C24-\\u1C2B\\u1C34-\\u1C35\\u1CE1\\u1CF2-\\u1CF3\\u302E-\\u302F\\uA823-\\uA824\\uA827\\uA880-\\uA881\\uA8B4-\\uA8C3\\uA952-\\uA953\\uA983\\uA9B4-\\uA9B5\\uA9BA-\\uA9BB\\uA9BD-\\uA9C0\\uAA2F-\\uAA30\\uAA33-\\uAA34\\uAA4D\\uAA7B\\uAAEB\\uAAEE-\\uAAEF\\uAAF5\\uABE3-\\uABE4\\uABE6-\\uABE7\\uABE9-\\uABEA\\uABEC]", description: "[\\u0903\\u093B\\u093E-\\u0940\\u0949-\\u094C\\u094E-\\u094F\\u0982-\\u0983\\u09BE-\\u09C0\\u09C7-\\u09C8\\u09CB-\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB-\\u0ACC\\u0B02-\\u0B03\\u0B3E\\u0B40\\u0B47-\\u0B48\\u0B4B-\\u0B4C\\u0B57\\u0BBE-\\u0BBF\\u0BC1-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82-\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7-\\u0CC8\\u0CCA-\\u0CCB\\u0CD5-\\u0CD6\\u0D02-\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82-\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2-\\u0DF3\\u0F3E-\\u0F3F\\u0F7F\\u102B-\\u102C\\u1031\\u1038\\u103B-\\u103C\\u1056-\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083-\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7-\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930-\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8-\\u19C9\\u1A19-\\u1A1A\\u1A55\\u1A57\\u1A61\\u1A63-\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43-\\u1B44\\u1B82\\u1BA1\\u1BA6-\\u1BA7\\u1BAA\\u1BAC-\\u1BAD\\u1BE7\\u1BEA-\\u1BEC\\u1BEE\\u1BF2-\\u1BF3\\u1C24-\\u1C2B\\u1C34-\\u1C35\\u1CE1\\u1CF2-\\u1CF3\\u302E-\\u302F\\uA823-\\uA824\\uA827\\uA880-\\uA881\\uA8B4-\\uA8C3\\uA952-\\uA953\\uA983\\uA9B4-\\uA9B5\\uA9BA-\\uA9BB\\uA9BD-\\uA9C0\\uAA2F-\\uAA30\\uAA33-\\uAA34\\uAA4D\\uAA7B\\uAAEB\\uAAEE-\\uAAEF\\uAAF5\\uABE3-\\uABE4\\uABE6-\\uABE7\\uABE9-\\uABEA\\uABEC]" }, - peg$c141 = /^[\u0300-\u036F\u0483-\u0487\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08E4-\u08FE\u0900-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962-\u0963\u0981\u09BC\u09C1-\u09C4\u09CD\u09E2-\u09E3\u0A01-\u0A02\u0A3C\u0A41-\u0A42\u0A47-\u0A48\u0A4B-\u0A4D\u0A51\u0A70-\u0A71\u0A75\u0A81-\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7-\u0AC8\u0ACD\u0AE2-\u0AE3\u0B01\u0B3C\u0B3F\u0B41-\u0B44\u0B4D\u0B56\u0B62-\u0B63\u0B82\u0BC0\u0BCD\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55-\u0C56\u0C62-\u0C63\u0CBC\u0CBF\u0CC6\u0CCC-\u0CCD\u0CE2-\u0CE3\u0D41-\u0D44\u0D4D\u0D62-\u0D63\u0DCA\u0DD2-\u0DD4\u0DD6\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB-\u0EBC\u0EC8-\u0ECD\u0F18-\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86-\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039-\u103A\u103D-\u103E\u1058-\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085-\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17B4-\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u1922\u1927-\u1928\u1932\u1939-\u193B\u1A17-\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1B00-\u1B03\u1B34\u1B36-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80-\u1B81\u1BA2-\u1BA5\u1BA8-\u1BA9\u1BAB\u1BE6\u1BE8-\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1DC0-\u1DE6\u1DFC-\u1DFF\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302D\u3099-\u309A\uA66F\uA674-\uA67D\uA69F\uA6F0-\uA6F1\uA802\uA806\uA80B\uA825-\uA826\uA8C4\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uAA29-\uAA2E\uAA31-\uAA32\uAA35-\uAA36\uAA43\uAA4C\uAAB0\uAAB2-\uAAB4\uAAB7-\uAAB8\uAABE-\uAABF\uAAC1\uAAEC-\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE26]/, - peg$c142 = { type: "class", value: "[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1-\\u05C2\\u05C4-\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065F\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7-\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0859-\\u085B\\u08E4-\\u08FE\\u0900-\\u0902\\u093A\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0957\\u0962-\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2-\\u09E3\\u0A01-\\u0A02\\u0A3C\\u0A41-\\u0A42\\u0A47-\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70-\\u0A71\\u0A75\\u0A81-\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7-\\u0AC8\\u0ACD\\u0AE2-\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62-\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55-\\u0C56\\u0C62-\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC-\\u0CCD\\u0CE2-\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62-\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB-\\u0EBC\\u0EC8-\\u0ECD\\u0F18-\\u0F19\\u0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86-\\u0F87\\u0F8D-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039-\\u103A\\u103D-\\u103E\\u1058-\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085-\\u1086\\u108D\\u109D\\u135D-\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752-\\u1753\\u1772-\\u1773\\u17B4-\\u17B5\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927-\\u1928\\u1932\\u1939-\\u193B\\u1A17-\\u1A18\\u1A1B\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80-\\u1B81\\u1BA2-\\u1BA5\\u1BA8-\\u1BA9\\u1BAB\\u1BE6\\u1BE8-\\u1BE9\\u1BED\\u1BEF-\\u1BF1\\u1C2C-\\u1C33\\u1C36-\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1CF4\\u1DC0-\\u1DE6\\u1DFC-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2D7F\\u2DE0-\\u2DFF\\u302A-\\u302D\\u3099-\\u309A\\uA66F\\uA674-\\uA67D\\uA69F\\uA6F0-\\uA6F1\\uA802\\uA806\\uA80B\\uA825-\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\uAA2E\\uAA31-\\uAA32\\uAA35-\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7-\\uAAB8\\uAABE-\\uAABF\\uAAC1\\uAAEC-\\uAAED\\uAAF6\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]", description: "[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1-\\u05C2\\u05C4-\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065F\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7-\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0859-\\u085B\\u08E4-\\u08FE\\u0900-\\u0902\\u093A\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0957\\u0962-\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2-\\u09E3\\u0A01-\\u0A02\\u0A3C\\u0A41-\\u0A42\\u0A47-\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70-\\u0A71\\u0A75\\u0A81-\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7-\\u0AC8\\u0ACD\\u0AE2-\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62-\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55-\\u0C56\\u0C62-\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC-\\u0CCD\\u0CE2-\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62-\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB-\\u0EBC\\u0EC8-\\u0ECD\\u0F18-\\u0F19\\u0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86-\\u0F87\\u0F8D-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039-\\u103A\\u103D-\\u103E\\u1058-\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085-\\u1086\\u108D\\u109D\\u135D-\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752-\\u1753\\u1772-\\u1773\\u17B4-\\u17B5\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927-\\u1928\\u1932\\u1939-\\u193B\\u1A17-\\u1A18\\u1A1B\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80-\\u1B81\\u1BA2-\\u1BA5\\u1BA8-\\u1BA9\\u1BAB\\u1BE6\\u1BE8-\\u1BE9\\u1BED\\u1BEF-\\u1BF1\\u1C2C-\\u1C33\\u1C36-\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1CF4\\u1DC0-\\u1DE6\\u1DFC-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2D7F\\u2DE0-\\u2DFF\\u302A-\\u302D\\u3099-\\u309A\\uA66F\\uA674-\\uA67D\\uA69F\\uA6F0-\\uA6F1\\uA802\\uA806\\uA80B\\uA825-\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\uAA2E\\uAA31-\\uAA32\\uAA35-\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7-\\uAAB8\\uAABE-\\uAABF\\uAAC1\\uAAEC-\\uAAED\\uAAF6\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]" }, - peg$c143 = /^[0-9\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]/, - peg$c144 = { type: "class", value: "[0-9\\u0660-\\u0669\\u06F0-\\u06F9\\u07C0-\\u07C9\\u0966-\\u096F\\u09E6-\\u09EF\\u0A66-\\u0A6F\\u0AE6-\\u0AEF\\u0B66-\\u0B6F\\u0BE6-\\u0BEF\\u0C66-\\u0C6F\\u0CE6-\\u0CEF\\u0D66-\\u0D6F\\u0E50-\\u0E59\\u0ED0-\\u0ED9\\u0F20-\\u0F29\\u1040-\\u1049\\u1090-\\u1099\\u17E0-\\u17E9\\u1810-\\u1819\\u1946-\\u194F\\u19D0-\\u19D9\\u1A80-\\u1A89\\u1A90-\\u1A99\\u1B50-\\u1B59\\u1BB0-\\u1BB9\\u1C40-\\u1C49\\u1C50-\\u1C59\\uA620-\\uA629\\uA8D0-\\uA8D9\\uA900-\\uA909\\uA9D0-\\uA9D9\\uAA50-\\uAA59\\uABF0-\\uABF9\\uFF10-\\uFF19]", description: "[0-9\\u0660-\\u0669\\u06F0-\\u06F9\\u07C0-\\u07C9\\u0966-\\u096F\\u09E6-\\u09EF\\u0A66-\\u0A6F\\u0AE6-\\u0AEF\\u0B66-\\u0B6F\\u0BE6-\\u0BEF\\u0C66-\\u0C6F\\u0CE6-\\u0CEF\\u0D66-\\u0D6F\\u0E50-\\u0E59\\u0ED0-\\u0ED9\\u0F20-\\u0F29\\u1040-\\u1049\\u1090-\\u1099\\u17E0-\\u17E9\\u1810-\\u1819\\u1946-\\u194F\\u19D0-\\u19D9\\u1A80-\\u1A89\\u1A90-\\u1A99\\u1B50-\\u1B59\\u1BB0-\\u1BB9\\u1C40-\\u1C49\\u1C50-\\u1C59\\uA620-\\uA629\\uA8D0-\\uA8D9\\uA900-\\uA909\\uA9D0-\\uA9D9\\uAA50-\\uAA59\\uABF0-\\uABF9\\uFF10-\\uFF19]" }, - peg$c145 = /^[\u16EE-\u16F0\u2160-\u2182\u2185-\u2188\u3007\u3021-\u3029\u3038-\u303A\uA6E6-\uA6EF]/, - peg$c146 = { type: "class", value: "[\\u16EE-\\u16F0\\u2160-\\u2182\\u2185-\\u2188\\u3007\\u3021-\\u3029\\u3038-\\u303A\\uA6E6-\\uA6EF]", description: "[\\u16EE-\\u16F0\\u2160-\\u2182\\u2185-\\u2188\\u3007\\u3021-\\u3029\\u3038-\\u303A\\uA6E6-\\uA6EF]" }, - peg$c147 = /^[_\u203F-\u2040\u2054\uFE33-\uFE34\uFE4D-\uFE4F\uFF3F]/, - peg$c148 = { type: "class", value: "[_\\u203F-\\u2040\\u2054\\uFE33-\\uFE34\\uFE4D-\\uFE4F\\uFF3F]", description: "[_\\u203F-\\u2040\\u2054\\uFE33-\\uFE34\\uFE4D-\\uFE4F\\uFF3F]" }, - peg$c149 = /^[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/, - peg$c150 = { type: "class", value: "[ \\xA0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]", description: "[ \\xA0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]" }, - peg$c151 = "and", - peg$c152 = { type: "literal", value: "and", description: "\"and\"" }, - peg$c153 = "or", - peg$c154 = { type: "literal", value: "or", description: "\"or\"" }, - peg$c155 = "return", - peg$c156 = { type: "literal", value: "return", description: "\"return\"" }, - peg$c157 = "fn", - peg$c158 = { type: "literal", value: "fn", description: "\"fn\"" }, - peg$c159 = "var", - peg$c160 = { type: "literal", value: "var", description: "\"var\"" }, - peg$c161 = "if", - peg$c162 = { type: "literal", value: "if", description: "\"if\"" }, - peg$c163 = "else", - peg$c164 = { type: "literal", value: "else", description: "\"else\"" }, - peg$c165 = "for", - peg$c166 = { type: "literal", value: "for", description: "\"for\"" }, - peg$c167 = "true", - peg$c168 = { type: "literal", value: "true", description: "\"true\"" }, - peg$c169 = "false", - peg$c170 = { type: "literal", value: "false", description: "\"false\"" }, - peg$c171 = "null", - peg$c172 = { type: "literal", value: "null", description: "\"null\"" }, - peg$c173 = "new", - peg$c174 = { type: "literal", value: "new", description: "\"new\"" }, - peg$c175 = "use", - peg$c176 = { type: "literal", value: "use", description: "\"use\"" }, - peg$c177 = "this", - peg$c178 = { type: "literal", value: "this", description: "\"this\"" }, - peg$c179 = "super", - peg$c180 = { type: "literal", value: "super", description: "\"super\"" }, - peg$c181 = "throw", - peg$c182 = { type: "literal", value: "throw", description: "\"throw\"" }, - peg$c183 = "break", - peg$c184 = { type: "literal", value: "break", description: "\"break\"" }, - peg$c185 = "continue", - peg$c186 = { type: "literal", value: "continue", description: "\"continue\"" }, - peg$c187 = "debugger", - peg$c188 = { type: "literal", value: "debugger", description: "\"debugger\"" }, - peg$c189 = "while", - peg$c190 = { type: "literal", value: "while", description: "\"while\"" }, - peg$c191 = "until", - peg$c192 = { type: "literal", value: "until", description: "\"until\"" }, - peg$c193 = "typeof", - peg$c194 = { type: "literal", value: "typeof", description: "\"typeof\"" }, - peg$c195 = "in", - peg$c196 = { type: "literal", value: "in", description: "\"in\"" }, - peg$c197 = "of", - peg$c198 = { type: "literal", value: "of", description: "\"of\"" }, - peg$c199 = "try", - peg$c200 = { type: "literal", value: "try", description: "\"try\"" }, - peg$c201 = "finally", - peg$c202 = { type: "literal", value: "finally", description: "\"finally\"" }, - peg$c203 = "catch", - peg$c204 = { type: "literal", value: "catch", description: "\"catch\"" }, - peg$c205 = "instanceof", - peg$c206 = { type: "literal", value: "instanceof", description: "\"instanceof\"" }, - peg$c207 = "switch", - peg$c208 = { type: "literal", value: "switch", description: "\"switch\"" }, - peg$c209 = "case", - peg$c210 = { type: "literal", value: "case", description: "\"case\"" }, - peg$c211 = "default", - peg$c212 = { type: "literal", value: "default", description: "\"default\"" }, - peg$c213 = "fallthrough", - peg$c214 = { type: "literal", value: "fallthrough", description: "\"fallthrough\"" }, - peg$c215 = "not", - peg$c216 = { type: "literal", value: "not", description: "\"not\"" }, - peg$c217 = "import", - peg$c218 = { type: "literal", value: "import", description: "\"import\"" }, - peg$c219 = "from", - peg$c220 = { type: "literal", value: "from", description: "\"from\"" }, - peg$c221 = "as", - peg$c222 = { type: "literal", value: "as", description: "\"as\"" }, - peg$c223 = "export", - peg$c224 = { type: "literal", value: "export", description: "\"export\"" }, - peg$c225 = "delete", - peg$c226 = { type: "literal", value: "delete", description: "\"delete\"" }, - peg$c227 = "do", - peg$c228 = { type: "literal", value: "do", description: "\"do\"" }, - peg$c229 = "async", - peg$c230 = { type: "literal", value: "async", description: "\"async\"" }, - peg$c231 = "await", - peg$c232 = { type: "literal", value: "await", description: "\"await\"" }, - peg$c233 = "go", - peg$c234 = { type: "literal", value: "go", description: "\"go\"" }, - peg$c235 = "undefined", - peg$c236 = { type: "literal", value: "undefined", description: "\"undefined\"" }, - peg$c237 = ";", - peg$c238 = { type: "literal", value: ";", description: "\";\"" }, - peg$c239 = function(body) { - return insertLocationData(new ast.Program(optionalList(body)), text(), line(), column()); - }, - peg$c240 = function(first, rest) { - return buildList(first, rest, 1); - }, - peg$c241 = "{", - peg$c242 = { type: "literal", value: "{", description: "\"{\"" }, - peg$c243 = "}", - peg$c244 = { type: "literal", value: "}", description: "\"}\"" }, - peg$c245 = function(body) { - return insertLocationData(new ast.BlockStatement(optionalList(extractOptional(body, 0))), text(), line(), column()); - }, - peg$c246 = function(declarations) { - return insertLocationData(new ast.VariableDeclarationStatement(declarations), text(), line(), column()); - }, - peg$c247 = ",", - peg$c248 = { type: "literal", value: ",", description: "\",\"" }, - peg$c249 = function(first, rest) { - return buildList(first, rest, 3); - }, - peg$c250 = function(id, init) { - return insertLocationData(new ast.VariableDeclarator(id, extractOptional(init, 1)), text(), line(), column()); - }, - peg$c251 = function(id, init) { - return insertLocationData(new ast.VariableDeclarator(id, extractOptional(init, 1)), text(), line(), column()); - }, - peg$c252 = "=", - peg$c253 = { type: "literal", value: "=", description: "\"=\"" }, - peg$c254 = function(expression) { return expression; }, - peg$c255 = function(id, params, inheritsFrom, body) { - return insertLocationData( - new ast.VariableDeclarationStatement( - [new ast.VariableDeclarator(id, - new ast.UnaryExpression("async", - new ast.FunctionExpression( - null, - optionalList(extractOptional(params, 0)), - body, - inheritsFrom - ) - ) - )] - ), - text(), line(), column()); - }, - peg$c256 = function(id, params, inheritsFrom, body) { - return insertLocationData( - new ast.FunctionDeclarationStatement(id, optionalList(extractOptional(params, 0)), body, inheritsFrom), - text(), line(), column()); - }, - peg$c257 = "extends", - peg$c258 = { type: "literal", value: "extends", description: "\"extends\"" }, - peg$c259 = function(call) { - return call; - }, - peg$c260 = function(id, defaultValue) { - return insertLocationData(new ast.Parameter(id, defaultValue, false), text(), line(), column()); - }, - peg$c261 = "...", - peg$c262 = { type: "literal", value: "...", description: "\"...\"" }, - peg$c263 = function(id) { - return insertLocationData(new ast.Parameter(id, null, true), text(), line(), column()); - }, - peg$c264 = function(id) { - return insertLocationData(new ast.Parameter(id, null, false), text(), line(), column()); - }, - peg$c265 = function(test, consequent, alternate) { - return insertLocationData(new ast.IfStatement(test, consequent, alternate), text(), line(), column()); - }, - peg$c266 = function(test, consequent) { - return insertLocationData(new ast.IfStatement(test, consequent, null), text(), line(), column()); - }, - peg$c267 = function() { - return insertLocationData(new ast.ReturnStatement(null), text(), line(), column()); - }, - peg$c268 = function(argument) { - return insertLocationData(new ast.ReturnStatement(argument), text(), line(), column()); - }, - peg$c269 = function(argument) { - return insertLocationData(new ast.ThrowStatement(argument), text(), line(), column()); - }, - peg$c270 = function(block, handler, finalizer) { - return insertLocationData(new ast.TryStatement(block, handler, finalizer), text(), line(), column()); - }, - peg$c271 = function(block, handler) { - return insertLocationData(new ast.TryStatement(block, handler, null), text(), line(), column()); - }, - peg$c272 = function(block, finalizer) { - return insertLocationData(new ast.TryStatement(block, null, finalizer), text(), line(), column()); - }, - peg$c273 = function(param, body) { - return insertLocationData(new ast.CatchClause(param, body), text(), line(), column()); - }, - peg$c274 = function(block) { return block; }, - peg$c275 = function() { - return insertLocationData(new ast.BreakStatement(), text(), line(), column()); - }, - peg$c276 = function() { - return insertLocationData(new ast.ContinueStatement(), text(), line(), column()); - }, - peg$c277 = function() { - return insertLocationData(new ast.FallthroughStatement(), text(), line(), column()); - }, - peg$c278 = function(specifiers, source) { - return insertLocationData(new ast.ImportDeclarationStatement(specifiers, source, "named"), text(), line(), column()); - }, - peg$c279 = "*", - peg$c280 = { type: "literal", value: "*", description: "\"*\"" }, - peg$c281 = function(id, source) { - return insertLocationData(new ast.ImportDeclarationStatement([ - new ast.ImportNamespaceSpecifier(id) - ], source, "named"), text(), line(), column()); - }, - peg$c282 = function(source, id) { - return insertLocationData(new ast.ImportDeclarationStatement([ - new ast.ImportDefaultSpecifier(id) - ], source, "default"), text(), line(), column()); - }, - peg$c283 = function(first, rest) { - return buildList(first, rest, 2); - }, - peg$c284 = function(id, alias) { - return insertLocationData(new ast.ImportSpecifier(id, alias), text(), line(), column()); - }, - peg$c285 = function(id) { - return insertLocationData(new ast.ImportSpecifier(id, null), text(), line(), column()); - }, - peg$c286 = function(specifiers, source) { - return insertLocationData(new ast.ExportDeclarationStatement(specifiers, extractOptional(source, 3), null, false), text(), line(), column()); - }, - peg$c287 = function(source) { - return insertLocationData(new ast.ExportDeclarationStatement([ - new ast.ExportBatchSpecifier() - ], source, null, false), text(), line(), column()); - }, - peg$c288 = function(statement) { - return insertLocationData(new ast.ExportDeclarationStatement(null, null, statement, false), text(), line(), column()); - }, - peg$c289 = function(expression) { - return insertLocationData(new ast.ExportDeclarationStatement(null, null, expression, true), text(), line(), column()); - }, - peg$c290 = function(id, alias) { - return insertLocationData(new ast.ExportSpecifier(id, alias), text(), line(), column()); - }, - peg$c291 = function(id) { - return insertLocationData(new ast.ExportSpecifier(id, null), text(), line(), column()); - }, - peg$c292 = function(body, test) { - return insertLocationData(new ast.DoWhileStatement(test, body), text(), line(), column()); - }, - peg$c293 = "<-", - peg$c294 = { type: "literal", value: "<-", description: "\"<-\"" }, - peg$c295 = function(left, right) { - return insertLocationData(new ast.PushStatement(left, right), text(), line(), column()); - }, - peg$c296 = function(body) { - return insertLocationData(new ast.GoStatement(body), text(), line(), column()); - }, - peg$c297 = function() { - return insertLocationData(new ast.DebuggerStatement(), text(), line(), column()); - }, - peg$c298 = function(test, body) { - return insertLocationData(new ast.WhileStatement(test, body), text(), line(), column()); - }, - peg$c299 = function(test, body) { - return insertLocationData(new ast.UntilStatement(test, body), text(), line(), column()); - }, - peg$c300 = function(discriminant, cases) { - return insertLocationData(new ast.SwitchStatement(discriminant, cases), text(), line(), column()); - }, - peg$c301 = function(first, rest) { - return buildList(first, rest, 3); - }, - peg$c302 = ":", - peg$c303 = { type: "literal", value: ":", description: "\":\"" }, - peg$c304 = function(tests, body) { - return insertLocationData(new ast.CaseClause(tests, body), text(), line(), column()); - }, - peg$c305 = function(body) { - return insertLocationData(new ast.CaseClause(null, body), text(), line(), column()); - }, - peg$c306 = function(item, index, array, body) { - return insertLocationData(new ast.ForInStatement( - item, - extractOptional(index, 2), - array, - body - ), text(), line(), column()); - }, - peg$c307 = function(key, value, object, body) { - return insertLocationData(new ast.ForOfStatement( - key, - extractOptional(value, 2), - object, - body - ), text(), line(), column()); - }, - peg$c308 = function(declarations, test, update, body) { - return insertLocationData(new ast.ForStatement( - new ast.VariableDeclarationStatement(declarations), - extractOptional(test, 0), - extractOptional(update, 1), - body - ), text(), line(), column()); - }, - peg$c309 = function(init, test, update, body) { - return insertLocationData(new ast.ForStatement( - extractOptional(init, 0), - extractOptional(test, 0), - extractOptional(update, 1), - body - ), text(), line(), column()); - }, - peg$c310 = function(identifiers) { return new ast.UseStatement(identifiers) }, - peg$c311 = function(id) { - return id.asPredefinedCollection(); - }, - peg$c312 = function(expression) { - return insertLocationData(new ast.ExpressionStatement(expression), text(), line(), column()); - }, - peg$c313 = function(left, right) { - return insertLocationData(new ast.AssignmentExpression( - left, "=", right), text(), line(), column()); - }, - peg$c314 = function(left, assignment) { - if (!assignment) { - return left; - } - - return insertLocationData(new ast.AssignmentExpression( - left, - extractOptional(assignment, 1), - extractOptional(assignment, 3)), text(), line(), column()); - }, - peg$c315 = function() { return "=" }, - peg$c316 = "*=", - peg$c317 = { type: "literal", value: "*=", description: "\"*=\"" }, - peg$c318 = "/=", - peg$c319 = { type: "literal", value: "/=", description: "\"/=\"" }, - peg$c320 = "%=", - peg$c321 = { type: "literal", value: "%=", description: "\"%=\"" }, - peg$c322 = "+=", - peg$c323 = { type: "literal", value: "+=", description: "\"+=\"" }, - peg$c324 = "-=", - peg$c325 = { type: "literal", value: "-=", description: "\"-=\"" }, - peg$c326 = "<<=", - peg$c327 = { type: "literal", value: "<<=", description: "\"<<=\"" }, - peg$c328 = ">>=", - peg$c329 = { type: "literal", value: ">>=", description: "\">>=\"" }, - peg$c330 = ">>>=", - peg$c331 = { type: "literal", value: ">>>=", description: "\">>>=\"" }, - peg$c332 = "&=", - peg$c333 = { type: "literal", value: "&=", description: "\"&=\"" }, - peg$c334 = "^=", - peg$c335 = { type: "literal", value: "^=", description: "\"^=\"" }, - peg$c336 = "|=", - peg$c337 = { type: "literal", value: "|=", description: "\"|=\"" }, - peg$c338 = function(consequent, condition) { - if (condition) { - var test = extractOptional(condition, 2); - var alternate = extractOptional(condition, 6); - - return insertLocationData(new ast.ConditionalExpression(test, consequent, alternate), text(), line(), column()); - } else { - return consequent; - } - }, - peg$c339 = function(first, rest) { return buildLogicalExpression(first, rest); }, - peg$c340 = "||", - peg$c341 = { type: "literal", value: "||", description: "\"||\"" }, - peg$c342 = function() { return "||"; }, - peg$c343 = "&&", - peg$c344 = { type: "literal", value: "&&", description: "\"&&\"" }, - peg$c345 = function() { return "&&"; }, - peg$c346 = function(first, rest) { return buildBinaryExpression(first, rest); }, - peg$c347 = "|", - peg$c348 = { type: "literal", value: "|", description: "\"|\"" }, - peg$c349 = /^[|=]/, - peg$c350 = { type: "class", value: "[|=]", description: "[|=]" }, - peg$c351 = "^", - peg$c352 = { type: "literal", value: "^", description: "\"^\"" }, - peg$c353 = "&", - peg$c354 = { type: "literal", value: "&", description: "\"&\"" }, - peg$c355 = /^[&=]/, - peg$c356 = { type: "class", value: "[&=]", description: "[&=]" }, - peg$c357 = "==", - peg$c358 = { type: "literal", value: "==", description: "\"==\"" }, - peg$c359 = "!=", - peg$c360 = { type: "literal", value: "!=", description: "\"!=\"" }, - peg$c361 = "<=", - peg$c362 = { type: "literal", value: "<=", description: "\"<=\"" }, - peg$c363 = ">=", - peg$c364 = { type: "literal", value: ">=", description: "\">=\"" }, - peg$c365 = "<", - peg$c366 = { type: "literal", value: "<", description: "\"<\"" }, - peg$c367 = ">", - peg$c368 = { type: "literal", value: ">", description: "\">\"" }, - peg$c369 = function(left, right) { - if (!right) { - return left; - } - return insertLocationData(new ast.InExpression(left, extractOptional(right, 3)), text(), line(), column()); - }, - peg$c370 = "??", - peg$c371 = { type: "literal", value: "??", description: "\"??\"" }, - peg$c372 = function(first, rest) { return buildNullCoalescingExpression(first, rest); }, - peg$c373 = "<<", - peg$c374 = { type: "literal", value: "<<", description: "\"<<\"" }, - peg$c375 = ">>>", - peg$c376 = { type: "literal", value: ">>>", description: "\">>>\"" }, - peg$c377 = ">>", - peg$c378 = { type: "literal", value: ">>", description: "\">>\"" }, - peg$c379 = "+", - peg$c380 = { type: "literal", value: "+", description: "\"+\"" }, - peg$c381 = /^[+=]/, - peg$c382 = { type: "class", value: "[+=]", description: "[+=]" }, - peg$c383 = "-", - peg$c384 = { type: "literal", value: "-", description: "\"-\"" }, - peg$c385 = /^[\-=]/, - peg$c386 = { type: "class", value: "[\\-=]", description: "[\\-=]" }, - peg$c387 = /^[*=]/, - peg$c388 = { type: "class", value: "[*=]", description: "[*=]" }, - peg$c389 = "#", - peg$c390 = { type: "literal", value: "#", description: "\"#\"" }, - peg$c391 = "%", - peg$c392 = { type: "literal", value: "%", description: "\"%\"" }, - peg$c393 = /^[%=]/, - peg$c394 = { type: "class", value: "[%=]", description: "[%=]" }, - peg$c395 = "%%", - peg$c396 = { type: "literal", value: "%%", description: "\"%%\"" }, - peg$c397 = "**", - peg$c398 = { type: "literal", value: "**", description: "\"**\"" }, - peg$c399 = function(operator, argument) { - if (operator === "++" || operator === "--") { - return insertLocationData(new ast.UpdateExpression(argument, operator, true), text(), line(), column()); - } else { - return insertLocationData(new ast.UnaryExpression(operator, argument), text(), line(), column()); - } - }, - peg$c400 = function() { return "!" }, - peg$c401 = "++", - peg$c402 = { type: "literal", value: "++", description: "\"++\"" }, - peg$c403 = "--", - peg$c404 = { type: "literal", value: "--", description: "\"--\"" }, - peg$c405 = "!", - peg$c406 = { type: "literal", value: "!", description: "\"!\"" }, - peg$c407 = function(argument, operator) { - if (operator) { - return insertLocationData(new ast.UpdateExpression(argument, operator, false), text(), line(), column()); - } else { - return argument; - } - }, - peg$c408 = "?", - peg$c409 = { type: "literal", value: "?", description: "\"?\"" }, - peg$c410 = function(argument, operator) { - if (operator) { - return insertLocationData(new ast.ExistentialExpression(argument), text(), line(), column()); - } else { - return argument; - } - }, - peg$c411 = function(callee, call) { - if (!call) { - return callee; - } - - var op = extractOptional(call, 1); - if (op === "?") { - return insertLocationData(new ast.NullCheckCallExpression(callee, extractOptional(call, 3)), text(), line(), column()); - } else if (op === "^") { - return insertLocationData(new ast.CurryCallExpression(callee, extractOptional(call, 3)), text(), line(), column()); - } else { - return insertLocationData(new ast.CallExpression(callee, extractOptional(call, 3)), text(), line(), column()); - } - }, - peg$c412 = function(operator, args) { - var type = "CallExpression"; - if (operator === "?") { - type = "NullCheckCallExpression"; - } else if (operator === "^") { - type = "CurryCallExpression"; - } - - return { - type: type, - arguments: args - }; - }, - peg$c413 = function(property) { - return { - type: "MemberExpression", - property: property, - computed: true - }; - }, - peg$c414 = function(range) { - return { - type: "RangeMemberExpression", - range: range - } - }, - peg$c415 = function(nullPropagatingOperator, property) { - return { - type: nullPropagatingOperator === "?" ? "NullPropagatingExpression" : "MemberExpression", - property: property, - computed: false - }; - }, - peg$c416 = function(first, rest) { - return buildTree(first, rest, function(result, element) { - if (element.type === "MemberExpression") { - return insertLocationData(new ast.MemberExpression(result, element.property, element.computed), text(), line(), column()); - } if (element.type === "NullPropagatingExpression") { - return insertLocationData(new ast.NullPropagatingExpression(result, element.property, element.computed), text(), line(), column()); - } else if (element.type === "CallExpression") { - return insertLocationData(new ast.CallExpression(result, element.arguments), text(), line(), column()); - } else if (element.type === "CurryCallExpression") { - return insertLocationData(new ast.CurryCallExpression(result, element.arguments), text(), line(), column()); - } else if (element.type === "NullCheckCallExpression") { - return insertLocationData(new ast.NullCheckCallExpression(result, element.arguments), text(), line(), column()); - } else if (element.type === "RangeMemberExpression") { - return insertLocationData(new ast.RangeMemberExpression(result, element.range), text(), line(), column()); - } - }); - }, - peg$c417 = function(callee, args) { - return insertLocationData(new ast.NewExpression(callee, args), text(), line(), column()); - }, - peg$c418 = function(property) { - return { - type: "MemberExpression", - property: property, - computed: true - }; - }, - peg$c419 = function(nullPropagatingOperator, property) { - return { - type: nullPropagatingOperator === "?" ? "NullPropagatingExpression" : "MemberExpression", - property: property, - computed: false - }; - }, - peg$c420 = function(first, rest) { - return buildTree(first, rest, function (result, element) { - if (element.type === "NullPropagatingExpression") { - return insertLocationData(new ast.NullPropagatingExpression(result, element.property, element.computed), text(), line(), column()); - } else if (element.type === "MemberExpression") { - return insertLocationData(new ast.MemberExpression(result, element.property, element.computed), text(), line(), column()); - } else if (element.type === "RangeMemberExpression") { - return insertLocationData(new ast.RangeMemberExpression(result, element.range), text(), line(), column()); - } - }); - }, - peg$c421 = function(args) { - return optionalList(extractOptional(args, 0)); - }, - peg$c422 = function(expression) { - return insertLocationData(new ast.SplatExpression(expression), text(), line(), column()); - }, - peg$c423 = function(id, params, inheritsFrom, body) { - return insertLocationData(new ast.FunctionExpression( - extractOptional(id, 0), - optionalList(extractOptional(params, 0)), - body, - inheritsFrom - ), text(), line(), column()); - }, - peg$c424 = function(params, operator, body) { - return insertLocationData(new ast.FunctionExpression( - null, - optionalList(extractOptional(params, 0)), - body, - null, - operator - ), text(), line(), column()); - }, - peg$c425 = function(params, operator, body) { - return insertLocationData(new ast.FunctionExpression( - null, - optionalList(extractOptional(params, 0)), - body, - null, - operator - ), text(), line(), column()); - }, - peg$c426 = "->", - peg$c427 = { type: "literal", value: "->", description: "\"->\"" }, - peg$c428 = "=>", - peg$c429 = { type: "literal", value: "=>", description: "\"=>\"" }, - peg$c430 = function(expression, item, index, array, condition) { - return insertLocationData(new ast.ForInExpression( - expression, - item, - index ? extractOptional(index, 2) : null, - array, - condition ? extractOptional(condition, 2) : null - ), text(), line(), column()); - }, - peg$c431 = "::", - peg$c432 = { type: "literal", value: "::", description: "\"::\"" }, - peg$c433 = function(id) { return id.asGlobal(); }, - peg$c434 = function() { - return insertLocationData(new ast.ThisExpression(), text(), line(), column()); - }, - peg$c435 = function() { - return insertLocationData(new ast.SuperExpression(), text(), line(), column()); - }, - peg$c436 = function(range) { - return range; - }, - peg$c437 = function(from, operator, to) { - return insertLocationData(new ast.Range(from, operator, to), text(), line(), column()); - }, - peg$c438 = "..", - peg$c439 = { type: "literal", value: "..", description: "\"..\"" }, - peg$c440 = function() { return ".."; }, - peg$c441 = function(elision) { - return insertLocationData(new ast.ArrayExpression(optionalList(extractOptional(elision, 0))), text(), line(), column()); - }, - peg$c442 = function(elements) { - return insertLocationData(new ast.ArrayExpression(elements), text(), line(), column()); - }, - peg$c443 = function(elements, elision) { - return insertLocationData(new ast.ArrayExpression(elements.concat(optionalList(extractOptional(elision, 0)))), text(), line(), column()); - }, - peg$c444 = function(elision, element) { - return optionalList(extractOptional(elision, 0)).concat(element); - }, - peg$c445 = function(first, rest) { return Array.prototype.concat.apply(first, rest); }, - peg$c446 = function(elision) { - return insertLocationData(new ast.ArrayPattern(optionalList(extractOptional(elision, 0))), text(), line(), column()); - }, - peg$c447 = function(elements) { - return insertLocationData(new ast.ArrayPattern(elements), text(), line(), column()); - }, - peg$c448 = function(elements, elision) { - return insertLocationData(new ast.ArrayPattern(elements.concat(optionalList(extractOptional(elision, 0)))), text(), line(), column()); - }, - peg$c449 = function(commas) { return filledArray(commas.length + 1, null); }, - peg$c450 = function() { - return new ast.ObjectExpression([]); - }, - peg$c451 = function(properties) { - return insertLocationData(new ast.ObjectExpression(properties), text(), line(), column()); - }, - peg$c452 = function(key, value) { - return insertLocationData(new ast.Property(key, value, false, false), text(), line(), column()); - }, - peg$c453 = function(key, params, body) { - return insertLocationData(new ast.Property(key, new ast.FunctionExpression( - null, - optionalList(extractOptional(params, 0)), - body, - null - ), false, true), text(), line(), column()); - }, - peg$c454 = function(key) { - return insertLocationData(new ast.Property(key, key, true, false), text(), line(), column()); - }, - peg$c455 = function() { - return new ast.ObjectPattern([]); - }, - peg$c456 = function(properties) { - return insertLocationData(new ast.ObjectPattern(properties), text(), line(), column()); - }, - - peg$currPos = 0, - peg$reportedPos = 0, - peg$cachedPos = 0, - peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }, - peg$maxFailPos = 0, - peg$maxFailExpected = [], - peg$silentFails = 0, - - peg$result; - - if ("startRule" in options) { - if (!(options.startRule in peg$startRuleFunctions)) { - throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); - } - - peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; - } - - function text() { - return input.substring(peg$reportedPos, peg$currPos); - } - - function offset() { - return peg$reportedPos; - } - - function line() { - return peg$computePosDetails(peg$reportedPos).line; - } - - function column() { - return peg$computePosDetails(peg$reportedPos).column; - } - - function expected(description) { - throw peg$buildException( - null, - [{ type: "other", description: description }], - peg$reportedPos - ); - } - - function error(message) { - throw peg$buildException(message, null, peg$reportedPos); - } - - function peg$computePosDetails(pos) { - function advance(details, startPos, endPos) { - var p, ch; - - for (p = startPos; p < endPos; p++) { - ch = input.charAt(p); - if (ch === "\n") { - if (!details.seenCR) { details.line++; } - details.column = 1; - details.seenCR = false; - } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { - details.line++; - details.column = 1; - details.seenCR = true; - } else { - details.column++; - details.seenCR = false; - } - } - } - - if (peg$cachedPos !== pos) { - if (peg$cachedPos > pos) { - peg$cachedPos = 0; - peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }; - } - advance(peg$cachedPosDetails, peg$cachedPos, pos); - peg$cachedPos = pos; - } - - return peg$cachedPosDetails; - } - - function peg$fail(expected) { - if (peg$currPos < peg$maxFailPos) { return; } - - if (peg$currPos > peg$maxFailPos) { - peg$maxFailPos = peg$currPos; - peg$maxFailExpected = []; - } - - peg$maxFailExpected.push(expected); - } - - function peg$buildException(message, expected, pos) { - function cleanupExpected(expected) { - var i = 1; - - expected.sort(function(a, b) { - if (a.description < b.description) { - return -1; - } else if (a.description > b.description) { - return 1; - } else { - return 0; - } - }); - - while (i < expected.length) { - if (expected[i - 1] === expected[i]) { - expected.splice(i, 1); - } else { - i++; - } - } - } - - function buildMessage(expected, found) { - function stringEscape(s) { - function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } - - return s - .replace(/\\/g, '\\\\') - .replace(/"/g, '\\"') - .replace(/\x08/g, '\\b') - .replace(/\t/g, '\\t') - .replace(/\n/g, '\\n') - .replace(/\f/g, '\\f') - .replace(/\r/g, '\\r') - .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) - .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) - .replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) - .replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); - } - - var expectedDescs = new Array(expected.length), - expectedDesc, foundDesc, i; - - for (i = 0; i < expected.length; i++) { - expectedDescs[i] = expected[i].description; - } - - expectedDesc = expected.length > 1 - ? expectedDescs.slice(0, -1).join(", ") - + " or " - + expectedDescs[expected.length - 1] - : expectedDescs[0]; - - foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input"; - - return "Expected " + expectedDesc + " but " + foundDesc + " found."; - } - - var posDetails = peg$computePosDetails(pos), - found = pos < input.length ? input.charAt(pos) : null; - - if (expected !== null) { - cleanupExpected(expected); - } - - return new SyntaxError( - message !== null ? message : buildMessage(expected, found), - expected, - found, - pos, - posDetails.line, - posDetails.column - ); - } - - function peg$parseStart() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parse__(); - if (s1 !== peg$FAILED) { - s2 = peg$parseProgram(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c1(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseSourceCharacter() { - var s0; - - if (input.length > peg$currPos) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c2); } - } - - return s0; - } - - function peg$parseWhiteSpace() { - var s0, s1; - - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 9) { - s0 = peg$c4; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c5); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 11) { - s0 = peg$c6; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c7); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 12) { - s0 = peg$c8; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c9); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 32) { - s0 = peg$c10; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c11); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 160) { - s0 = peg$c12; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c13); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 65279) { - s0 = peg$c14; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c15); } - } - if (s0 === peg$FAILED) { - s0 = peg$parseZs(); - } - } - } - } - } - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c3); } - } - - return s0; - } - - function peg$parseLineTerminator() { - var s0; - - if (peg$c16.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c17); } - } - - return s0; - } - - function peg$parseLineTerminatorSequence() { - var s0, s1; - - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 10) { - s0 = peg$c19; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c20); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c21) { - s0 = peg$c21; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c22); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 13) { - s0 = peg$c23; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c24); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 8232) { - s0 = peg$c25; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c26); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 8233) { - s0 = peg$c27; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c28); } - } - } - } - } - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c18); } - } - - return s0; - } - - function peg$parseComment() { - var s0, s1; - - peg$silentFails++; - s0 = peg$parseMultiLineComment(); - if (s0 === peg$FAILED) { - s0 = peg$parseSingleLineComment(); - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c29); } - } - - return s0; - } - - function peg$parseMultiLineComment() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c30) { - s1 = peg$c30; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c31); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - if (input.substr(peg$currPos, 2) === peg$c34) { - s5 = peg$c34; - peg$currPos += 2; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } - } - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = peg$c33; - } else { - peg$currPos = s4; - s4 = peg$c0; - } - if (s4 !== peg$FAILED) { - s5 = peg$parseSourceCharacter(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - if (input.substr(peg$currPos, 2) === peg$c34) { - s5 = peg$c34; - peg$currPos += 2; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } - } - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = peg$c33; - } else { - peg$currPos = s4; - s4 = peg$c0; - } - if (s4 !== peg$FAILED) { - s5 = peg$parseSourceCharacter(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c34) { - s3 = peg$c34; - peg$currPos += 2; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } - } - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseMultiLineCommentNoLineTerminator() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c30) { - s1 = peg$c30; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c31); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - if (input.substr(peg$currPos, 2) === peg$c34) { - s5 = peg$c34; - peg$currPos += 2; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } - } - if (s5 === peg$FAILED) { - s5 = peg$parseLineTerminator(); - } - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = peg$c33; - } else { - peg$currPos = s4; - s4 = peg$c0; - } - if (s4 !== peg$FAILED) { - s5 = peg$parseSourceCharacter(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - if (input.substr(peg$currPos, 2) === peg$c34) { - s5 = peg$c34; - peg$currPos += 2; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } - } - if (s5 === peg$FAILED) { - s5 = peg$parseLineTerminator(); - } - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = peg$c33; - } else { - peg$currPos = s4; - s4 = peg$c0; - } - if (s4 !== peg$FAILED) { - s5 = peg$parseSourceCharacter(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c34) { - s3 = peg$c34; - peg$currPos += 2; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } - } - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseSingleLineComment() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c36) { - s1 = peg$c36; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c37); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parseLineTerminator(); - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = peg$c33; - } else { - peg$currPos = s4; - s4 = peg$c0; - } - if (s4 !== peg$FAILED) { - s5 = peg$parseSourceCharacter(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parseLineTerminator(); - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = peg$c33; - } else { - peg$currPos = s4; - s4 = peg$c0; - } - if (s4 !== peg$FAILED) { - s5 = peg$parseSourceCharacter(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseIdentifier() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - s2 = peg$parseReservedWord(); - peg$silentFails--; - if (s2 === peg$FAILED) { - s1 = peg$c33; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s2 = peg$parseIdentifierName(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c38(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseIdentifierName() { - var s0, s1, s2, s3; - - peg$silentFails++; - s0 = peg$currPos; - s1 = peg$parseIdentifierStart(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parseIdentifierPart(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parseIdentifierPart(); - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c40(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c39); } - } - - return s0; - } - - function peg$parseIdentifierStart() { - var s0, s1, s2; - - s0 = peg$parseUnicodeLetter(); - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 36) { - s0 = peg$c41; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c42); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 95) { - s0 = peg$c43; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c44); } - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c45; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c46); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseUnicodeEscapeSequence(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c47(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - } - - return s0; - } - - function peg$parseIdentifierPart() { - var s0; - - s0 = peg$parseIdentifierStart(); - if (s0 === peg$FAILED) { - s0 = peg$parseUnicodeCombiningMark(); - if (s0 === peg$FAILED) { - s0 = peg$parseNd(); - if (s0 === peg$FAILED) { - s0 = peg$parsePc(); - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 8204) { - s0 = peg$c48; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c49); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 8205) { - s0 = peg$c50; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c51); } - } - } - } - } - } - } - - return s0; - } - - function peg$parseUnicodeLetter() { - var s0; - - s0 = peg$parseLu(); - if (s0 === peg$FAILED) { - s0 = peg$parseLl(); - if (s0 === peg$FAILED) { - s0 = peg$parseLt(); - if (s0 === peg$FAILED) { - s0 = peg$parseLm(); - if (s0 === peg$FAILED) { - s0 = peg$parseLo(); - if (s0 === peg$FAILED) { - s0 = peg$parseNl(); - } - } - } - } - } - - return s0; - } - - function peg$parseUnicodeCombiningMark() { - var s0; - - s0 = peg$parseMn(); - if (s0 === peg$FAILED) { - s0 = peg$parseMc(); - } - - return s0; - } - - function peg$parseReservedWord() { - var s0; - - s0 = peg$parseKeyword(); - if (s0 === peg$FAILED) { - s0 = peg$parseNullLiteral(); - if (s0 === peg$FAILED) { - s0 = peg$parseBooleanLiteral(); - } - } - - return s0; - } - - function peg$parseKeyword() { - var s0; - - s0 = peg$parseAndToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseOrToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseReturnToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseVarToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseIfToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseElseToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseForToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseFnToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseNewToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseUseToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseThisToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseSuperToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseThrowToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseBreakToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseContinueToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseDebuggerToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseWhileToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseUntilToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseTypeofToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseInToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseOfToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseTryToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseCatchToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseFinallyToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseInstanceofToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseSwitchToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseCaseToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseDefaultToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseFallthroughToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseNotToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseImportToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseFromToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseAsToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseExportToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseDeleteToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseAsyncToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseAwaitToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseGoToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseNullToken(); - if (s0 === peg$FAILED) { - s0 = peg$parseUndefinedToken(); - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseLiteral() { - var s0; - - s0 = peg$parseNullLiteral(); - if (s0 === peg$FAILED) { - s0 = peg$parseUndefinedLiteral(); - if (s0 === peg$FAILED) { - s0 = peg$parseBooleanLiteral(); - if (s0 === peg$FAILED) { - s0 = peg$parseNumericLiteral(); - if (s0 === peg$FAILED) { - s0 = peg$parseStringLiteral(); - if (s0 === peg$FAILED) { - s0 = peg$parseRegularExpressionLiteral(); - } - } - } - } - } - - return s0; - } - - function peg$parseNullLiteral() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseNullToken(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c52(); - } - s0 = s1; - - return s0; - } - - function peg$parseUndefinedLiteral() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseUndefinedToken(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c53(); - } - s0 = s1; - - return s0; - } - - function peg$parseBooleanLiteral() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseTrueToken(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c54(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseFalseToken(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c55(); - } - s0 = s1; - } - - return s0; - } - - function peg$parseNumericLiteral() { - var s0, s1, s2, s3; - - peg$silentFails++; - s0 = peg$currPos; - s1 = peg$parseHexIntegerLiteral(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierStart(); - if (s3 === peg$FAILED) { - s3 = peg$parseDecimalDigit(); - } - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c57(s1); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseDecimalLiteral(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierStart(); - if (s3 === peg$FAILED) { - s3 = peg$parseDecimalDigit(); - } - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c57(s1); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c56); } - } - - return s0; - } - - function peg$parseDecimalLiteral() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseDecimalIntegerLiteral(); - if (s1 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 46) { - s2 = peg$c58; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 46) { - s4 = peg$c58; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$parseDecimalDigit(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parseDecimalDigit(); - } - if (s4 !== peg$FAILED) { - s5 = peg$parseExponentPart(); - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c61(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 46) { - s1 = peg$c58; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 46) { - s3 = peg$c58; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s3 = []; - s4 = peg$parseDecimalDigit(); - if (s4 !== peg$FAILED) { - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parseDecimalDigit(); - } - } else { - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s4 = peg$parseExponentPart(); - if (s4 === peg$FAILED) { - s4 = peg$c60; - } - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c61(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseDecimalIntegerLiteral(); - if (s1 !== peg$FAILED) { - s2 = peg$parseExponentPart(); - if (s2 === peg$FAILED) { - s2 = peg$c60; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c61(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - - return s0; - } - - function peg$parseDecimalIntegerLiteral() { - var s0, s1, s2, s3; - - if (input.charCodeAt(peg$currPos) === 48) { - s0 = peg$c62; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c63); } - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseNonZeroDigit(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parseDecimalDigit(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parseDecimalDigit(); - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parseDecimalDigit() { - var s0; - - if (peg$c64.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c65); } - } - - return s0; - } - - function peg$parseNonZeroDigit() { - var s0; - - if (peg$c66.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c67); } - } - - return s0; - } - - function peg$parseExponentPart() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parseExponentIndicator(); - if (s1 !== peg$FAILED) { - s2 = peg$parseSignedInteger(); - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseExponentIndicator() { - var s0; - - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c68) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c69); } - } - - return s0; - } - - function peg$parseSignedInteger() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (peg$c70.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c71); } - } - if (s1 === peg$FAILED) { - s1 = peg$c60; - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parseDecimalDigit(); - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parseDecimalDigit(); - } - } else { - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseHexIntegerLiteral() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c72) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c73); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = []; - s4 = peg$parseHexDigit(); - if (s4 !== peg$FAILED) { - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parseHexDigit(); - } - } else { - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s3 = input.substring(s2, peg$currPos); - } - s2 = s3; - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c74(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseHexDigit() { - var s0; - - if (peg$c75.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c76); } - } - - return s0; - } - - function peg$parseStringLiteral() { - var s0, s1, s2, s3; - - peg$silentFails++; - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c78; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c79); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parseDoubleStringCharacter(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parseDoubleStringCharacter(); - } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c78; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c79); } - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c80(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { - s1 = peg$c81; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c82); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parseSingleStringCharacter(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parseSingleStringCharacter(); - } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 39) { - s3 = peg$c81; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c82); } - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c80(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c77); } - } - - return s0; - } - - function peg$parseDoubleStringCharacter() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 34) { - s2 = peg$c78; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c79); } - } - if (s2 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 92) { - s2 = peg$c45; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c46); } - } - if (s2 === peg$FAILED) { - s2 = peg$parseLineTerminator(); - } - } - peg$silentFails--; - if (s2 === peg$FAILED) { - s1 = peg$c33; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s2 = peg$parseSourceCharacter(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c83(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c45; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c46); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseEscapeSequence(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c47(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parseLineContinuation(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseLineTerminator(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c84(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - } - - return s0; - } - - function peg$parseSingleStringCharacter() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 39) { - s2 = peg$c81; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c82); } - } - if (s2 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 92) { - s2 = peg$c45; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c46); } - } - if (s2 === peg$FAILED) { - s2 = peg$parseLineTerminator(); - } - } - peg$silentFails--; - if (s2 === peg$FAILED) { - s1 = peg$c33; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s2 = peg$parseSourceCharacter(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c83(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c45; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c46); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseEscapeSequence(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c47(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parseLineContinuation(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseLineTerminator(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c84(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - } - - return s0; - } - - function peg$parseLineContinuation() { - var s0, s1, s2; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c45; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c46); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseLineTerminatorSequence(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c85(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseEscapeSequence() { - var s0, s1, s2, s3; - - s0 = peg$parseExpressionSequence(); - if (s0 === peg$FAILED) { - s0 = peg$parseCharacterEscapeSequence(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 48) { - s1 = peg$c62; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c63); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseDecimalDigit(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c86(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parseHexEscapeSequence(); - if (s0 === peg$FAILED) { - s0 = peg$parseUnicodeEscapeSequence(); - } - } - } - } - - return s0; - } - - function peg$parseCharacterEscapeSequence() { - var s0; - - s0 = peg$parseSingleEscapeCharacter(); - if (s0 === peg$FAILED) { - s0 = peg$parseNonEscapeCharacter(); - } - - return s0; - } - - function peg$parseSingleEscapeCharacter() { - var s0, s1; - - if (input.charCodeAt(peg$currPos) === 39) { - s0 = peg$c81; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c82); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 34) { - s0 = peg$c78; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c79); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 92) { - s0 = peg$c45; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c46); } - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 98) { - s1 = peg$c87; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c88); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c89(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 102) { - s1 = peg$c90; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c91); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c92(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 110) { - s1 = peg$c93; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c94); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c95(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 114) { - s1 = peg$c96; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c97); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c98(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 116) { - s1 = peg$c99; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c100); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c101(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 118) { - s1 = peg$c102; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c103); } - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c104(); - } - s0 = s1; - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseNonEscapeCharacter() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - s2 = peg$parseEscapeCharacter(); - if (s2 === peg$FAILED) { - s2 = peg$parseLineTerminator(); - } - peg$silentFails--; - if (s2 === peg$FAILED) { - s1 = peg$c33; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s2 = peg$parseSourceCharacter(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c83(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseEscapeCharacter() { - var s0; - - s0 = peg$parseSingleEscapeCharacter(); - if (s0 === peg$FAILED) { - s0 = peg$parseDecimalDigit(); - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 120) { - s0 = peg$c105; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c106); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 117) { - s0 = peg$c107; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c108); } - } - } - } - } - - return s0; - } - - function peg$parseHexEscapeSequence() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 120) { - s1 = peg$c105; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c106); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$currPos; - s4 = peg$parseHexDigit(); - if (s4 !== peg$FAILED) { - s5 = peg$parseHexDigit(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s3 = input.substring(s2, peg$currPos); - } - s2 = s3; - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c109(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseUnicodeEscapeSequence() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 117) { - s1 = peg$c107; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c108); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$currPos; - s4 = peg$parseHexDigit(); - if (s4 !== peg$FAILED) { - s5 = peg$parseHexDigit(); - if (s5 !== peg$FAILED) { - s6 = peg$parseHexDigit(); - if (s6 !== peg$FAILED) { - s7 = peg$parseHexDigit(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s3 = input.substring(s2, peg$currPos); - } - s2 = s3; - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c109(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseExpressionSequence() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 40) { - s1 = peg$c110; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c111); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseExpression(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s3 = peg$c112; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c114(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseRegularExpressionLiteral() { - var s0, s1, s2, s3, s4, s5; - - peg$silentFails++; - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 47) { - s1 = peg$c116; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c117); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$parseRegularExpressionBody(); - if (s3 !== peg$FAILED) { - s3 = input.substring(s2, peg$currPos); - } - s2 = s3; - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 47) { - s3 = peg$c116; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c117); } - } - if (s3 !== peg$FAILED) { - s4 = peg$currPos; - s5 = peg$parseRegularExpressionFlags(); - if (s5 !== peg$FAILED) { - s5 = input.substring(s4, peg$currPos); - } - s4 = s5; - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c118(s2, s4); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c115); } - } - - return s0; - } - - function peg$parseRegularExpressionBody() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseRegularExpressionFirstChar(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parseRegularExpressionChar(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parseRegularExpressionChar(); - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseRegularExpressionFirstChar() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - if (peg$c119.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c120); } - } - peg$silentFails--; - if (s2 === peg$FAILED) { - s1 = peg$c33; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s2 = peg$parseRegularExpressionNonTerminator(); - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parseRegularExpressionBackslashSequence(); - if (s0 === peg$FAILED) { - s0 = peg$parseRegularExpressionClass(); - } - } - - return s0; - } - - function peg$parseRegularExpressionChar() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - if (peg$c121.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c122); } - } - peg$silentFails--; - if (s2 === peg$FAILED) { - s1 = peg$c33; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s2 = peg$parseRegularExpressionNonTerminator(); - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parseRegularExpressionBackslashSequence(); - if (s0 === peg$FAILED) { - s0 = peg$parseRegularExpressionClass(); - } - } - - return s0; - } - - function peg$parseRegularExpressionBackslashSequence() { - var s0, s1, s2; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c45; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c46); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseRegularExpressionNonTerminator(); - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseRegularExpressionNonTerminator() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - s2 = peg$parseLineTerminator(); - peg$silentFails--; - if (s2 === peg$FAILED) { - s1 = peg$c33; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s2 = peg$parseSourceCharacter(); - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseRegularExpressionClass() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 91) { - s1 = peg$c123; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parseRegularExpressionClassChar(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parseRegularExpressionClassChar(); - } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s3 = peg$c125; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseRegularExpressionClassChar() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - if (peg$c127.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c128); } - } - peg$silentFails--; - if (s2 === peg$FAILED) { - s1 = peg$c33; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s2 = peg$parseRegularExpressionNonTerminator(); - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parseRegularExpressionBackslashSequence(); - } - - return s0; - } - - function peg$parseRegularExpressionFlags() { - var s0, s1; - - s0 = []; - s1 = peg$parseIdentifierPart(); - while (s1 !== peg$FAILED) { - s0.push(s1); - s1 = peg$parseIdentifierPart(); - } - - return s0; - } - - function peg$parseLl() { - var s0; - - if (peg$c129.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c130); } - } - - return s0; - } - - function peg$parseLm() { - var s0; - - if (peg$c131.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c132); } - } - - return s0; - } - - function peg$parseLo() { - var s0; - - if (peg$c133.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c134); } - } - - return s0; - } - - function peg$parseLt() { - var s0; - - if (peg$c135.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c136); } - } - - return s0; - } - - function peg$parseLu() { - var s0; - - if (peg$c137.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c138); } - } - - return s0; - } - - function peg$parseMc() { - var s0; - - if (peg$c139.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c140); } - } - - return s0; - } - - function peg$parseMn() { - var s0; - - if (peg$c141.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c142); } - } - - return s0; - } - - function peg$parseNd() { - var s0; - - if (peg$c143.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c144); } - } - - return s0; - } - - function peg$parseNl() { - var s0; - - if (peg$c145.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c146); } - } - - return s0; - } - - function peg$parsePc() { - var s0; - - if (peg$c147.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c148); } - } - - return s0; - } - - function peg$parseZs() { - var s0; - - if (peg$c149.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c150); } - } - - return s0; - } - - function peg$parseAndToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3) === peg$c151) { - s1 = peg$c151; - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c152); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseOrToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c153) { - s1 = peg$c153; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c154); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseReturnToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6) === peg$c155) { - s1 = peg$c155; - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c156); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseFnToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c157) { - s1 = peg$c157; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c158); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseVarToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3) === peg$c159) { - s1 = peg$c159; - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c160); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseIfToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c161) { - s1 = peg$c161; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c162); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseElseToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c163) { - s1 = peg$c163; - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c164); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseForToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3) === peg$c165) { - s1 = peg$c165; - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c166); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseTrueToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c167) { - s1 = peg$c167; - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c168); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseFalseToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c169) { - s1 = peg$c169; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c170); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseNullToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c171) { - s1 = peg$c171; - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c172); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseNewToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3) === peg$c173) { - s1 = peg$c173; - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c174); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseUseToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3) === peg$c175) { - s1 = peg$c175; - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c176); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseThisToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c177) { - s1 = peg$c177; - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c178); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseSuperToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c179) { - s1 = peg$c179; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c180); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseThrowToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c181) { - s1 = peg$c181; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c182); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseBreakToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c183) { - s1 = peg$c183; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c184); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseContinueToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8) === peg$c185) { - s1 = peg$c185; - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c186); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseDebuggerToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8) === peg$c187) { - s1 = peg$c187; - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c188); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseWhileToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c189) { - s1 = peg$c189; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c190); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseUntilToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c191) { - s1 = peg$c191; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c192); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseTypeofToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6) === peg$c193) { - s1 = peg$c193; - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c194); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseInToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c195) { - s1 = peg$c195; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c196); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseOfToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c197) { - s1 = peg$c197; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c198); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseTryToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3) === peg$c199) { - s1 = peg$c199; - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c200); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseFinallyToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7) === peg$c201) { - s1 = peg$c201; - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c202); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseCatchToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c203) { - s1 = peg$c203; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c204); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseInstanceofToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 10) === peg$c205) { - s1 = peg$c205; - peg$currPos += 10; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c206); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseSwitchToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6) === peg$c207) { - s1 = peg$c207; - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c208); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseCaseToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c209) { - s1 = peg$c209; - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c210); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseDefaultToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7) === peg$c211) { - s1 = peg$c211; - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c212); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseFallthroughToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 11) === peg$c213) { - s1 = peg$c213; - peg$currPos += 11; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c214); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseNotToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3) === peg$c215) { - s1 = peg$c215; - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c216); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseImportToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6) === peg$c217) { - s1 = peg$c217; - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c218); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseFromToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c219) { - s1 = peg$c219; - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c220); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseAsToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c221) { - s1 = peg$c221; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c222); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseExportToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6) === peg$c223) { - s1 = peg$c223; - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c224); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseDeleteToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6) === peg$c225) { - s1 = peg$c225; - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c226); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseDoToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c227) { - s1 = peg$c227; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c228); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseAsyncToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c229) { - s1 = peg$c229; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c230); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseAwaitToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c231) { - s1 = peg$c231; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c232); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseGoToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c233) { - s1 = peg$c233; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c234); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseUndefinedToken() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9) === peg$c235) { - s1 = peg$c235; - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c236); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseIdentifierPart(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parse__() { - var s0, s1; - - s0 = []; - s1 = peg$parseWhiteSpace(); - if (s1 === peg$FAILED) { - s1 = peg$parseLineTerminatorSequence(); - if (s1 === peg$FAILED) { - s1 = peg$parseComment(); - } - } - while (s1 !== peg$FAILED) { - s0.push(s1); - s1 = peg$parseWhiteSpace(); - if (s1 === peg$FAILED) { - s1 = peg$parseLineTerminatorSequence(); - if (s1 === peg$FAILED) { - s1 = peg$parseComment(); - } - } - } - - return s0; - } - - function peg$parse_() { - var s0, s1; - - s0 = []; - s1 = peg$parseWhiteSpace(); - if (s1 === peg$FAILED) { - s1 = peg$parseMultiLineCommentNoLineTerminator(); - } - while (s1 !== peg$FAILED) { - s0.push(s1); - s1 = peg$parseWhiteSpace(); - if (s1 === peg$FAILED) { - s1 = peg$parseMultiLineCommentNoLineTerminator(); - } - } - - return s0; - } - - function peg$parseEOS() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parse__(); - if (s1 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s2 = peg$c237; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c238); } - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseEOF() { - var s0, s1; - - s0 = peg$currPos; - peg$silentFails++; - if (input.length > peg$currPos) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c2); } - } - peg$silentFails--; - if (s1 === peg$FAILED) { - s0 = peg$c33; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseProgram() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseStatementList(); - if (s1 === peg$FAILED) { - s1 = peg$c60; - } - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c239(s1); - } - s0 = s1; - - return s0; - } - - function peg$parseStatementList() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseStatement(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseStatement(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseStatement(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c240(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseStatement() { - var s0; - - s0 = peg$parseBlock(); - if (s0 === peg$FAILED) { - s0 = peg$parseVariableStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseFunctionDeclaration(); - if (s0 === peg$FAILED) { - s0 = peg$parseIfStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parsePushStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseExpressionStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseReturnStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseForStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseUseStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseThrowStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseTryStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseBreakStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseContinueStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseDebuggerStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseWhileStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseUntilStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseSwitchStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseFallthroughStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseImportDeclarationStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseExportDeclarationStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseDoWhileStatement(); - if (s0 === peg$FAILED) { - s0 = peg$parseGoStatement(); - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseBlock() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 123) { - s1 = peg$c241; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c242); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parseStatementList(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$c60; - } - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s4 = peg$c243; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c244); } - } - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c245(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseVariableStatement() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseVarToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseVariableDeclarationList(); - if (s3 !== peg$FAILED) { - s4 = peg$parseEOS(); - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c246(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseVariableDeclarationList() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseVariableDeclaration(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseVariableDeclaration(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseVariableDeclaration(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c249(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseVariableDeclaration() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseIdentifier(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parseInitialiser(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 === peg$FAILED) { - s2 = peg$c60; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c250(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsePattern(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parseInitialiser(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 === peg$FAILED) { - s2 = peg$c60; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c251(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parseInitialiser() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 61) { - s1 = peg$c252; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s3 = peg$c252; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parseAssignmentExpression(); - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c254(s4); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseFunctionDeclaration() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15; - - s0 = peg$currPos; - s1 = peg$parseAsyncToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseFnToken(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseIdentifier(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 40) { - s7 = peg$c110; - peg$currPos++; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c111); } - } - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s9 = peg$currPos; - s10 = peg$parseFormalParameterList(); - if (s10 !== peg$FAILED) { - s11 = peg$parse__(); - if (s11 !== peg$FAILED) { - s10 = [s10, s11]; - s9 = s10; - } else { - peg$currPos = s9; - s9 = peg$c0; - } - } else { - peg$currPos = s9; - s9 = peg$c0; - } - if (s9 === peg$FAILED) { - s9 = peg$c60; - } - if (s9 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s10 = peg$c112; - peg$currPos++; - } else { - s10 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } - } - if (s10 !== peg$FAILED) { - s11 = peg$parse__(); - if (s11 !== peg$FAILED) { - s12 = peg$parseInheritsFrom(); - if (s12 === peg$FAILED) { - s12 = peg$c60; - } - if (s12 !== peg$FAILED) { - s13 = peg$parse__(); - if (s13 !== peg$FAILED) { - s14 = peg$parseBlock(); - if (s14 !== peg$FAILED) { - s15 = peg$parse__(); - if (s15 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c255(s5, s9, s12, s14); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseFnToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseIdentifier(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 40) { - s5 = peg$c110; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c111); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$currPos; - s8 = peg$parseFormalParameterList(); - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - s8 = [s8, s9]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$c0; - } - } else { - peg$currPos = s7; - s7 = peg$c0; - } - if (s7 === peg$FAILED) { - s7 = peg$c60; - } - if (s7 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s8 = peg$c112; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } - } - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - s10 = peg$parseInheritsFrom(); - if (s10 === peg$FAILED) { - s10 = peg$c60; - } - if (s10 !== peg$FAILED) { - s11 = peg$parse__(); - if (s11 !== peg$FAILED) { - s12 = peg$parseBlock(); - if (s12 !== peg$FAILED) { - s13 = peg$parse__(); - if (s13 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c256(s3, s7, s10, s12); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parseInheritsFrom() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7) === peg$c257) { - s1 = peg$c257; - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c258); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseCallExpression(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c259(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseFormalParameterList() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseFormalParameter(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseFormalParameter(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseFormalParameter(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c249(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseFormalParameter() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseIdentifier(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 61) { - s3 = peg$c252; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseExpression(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c260(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseIdentifier(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.substr(peg$currPos, 3) === peg$c261) { - s3 = peg$c261; - peg$currPos += 3; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c262); } - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c263(s1); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseIdentifier(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c264(s1); - } - s0 = s1; - } - } - - return s0; - } - - function peg$parseIfStatement() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseIfToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseExpression(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseStatement(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseElseToken(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s9 = peg$parseStatement(); - if (s9 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c265(s3, s5, s9); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseIfToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseExpression(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseStatement(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c266(s3, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parseReturnStatement() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseReturnToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parseEOS(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c267(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseReturnToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse_(); - if (s2 !== peg$FAILED) { - s3 = peg$parseExpression(); - if (s3 !== peg$FAILED) { - s4 = peg$parseEOS(); - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c268(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parseThrowStatement() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseThrowToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse_(); - if (s2 !== peg$FAILED) { - s3 = peg$parseExpression(); - if (s3 !== peg$FAILED) { - s4 = peg$parseEOS(); - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c269(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseTryStatement() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseTryToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseBlock(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCatch(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseFinally(); - if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c270(s3, s5, s7); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseTryToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseBlock(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCatch(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c271(s3, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseTryToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseBlock(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseFinally(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c272(s3, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - - return s0; - } - - function peg$parseCatch() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseCatchToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseIdentifier(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseBlock(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c273(s3, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseFinally() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseFinallyToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseBlock(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c274(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseBreakStatement() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parseBreakToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parseEOS(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c275(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseContinueStatement() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parseContinueToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parseEOS(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c276(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseFallthroughStatement() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parseFallthroughToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parseEOS(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c277(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseImportDeclarationStatement() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12; - - s0 = peg$currPos; - s1 = peg$parseImportToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseImportSpecifierList(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseFromToken(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseStringLiteral(); - if (s7 !== peg$FAILED) { - s8 = peg$parseEOS(); - if (s8 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c278(s3, s7); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseImportToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 42) { - s3 = peg$c279; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c280); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseAsToken(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseIdentifier(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s9 = peg$parseFromToken(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - if (s10 !== peg$FAILED) { - s11 = peg$parseStringLiteral(); - if (s11 !== peg$FAILED) { - s12 = peg$parseEOS(); - if (s12 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c281(s7, s11); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseImportToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseStringLiteral(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseAsToken(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseIdentifier(); - if (s7 !== peg$FAILED) { - s8 = peg$parseEOS(); - if (s8 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c282(s3, s7); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - - return s0; - } - - function peg$parseImportSpecifierList() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parseImportSpecifier(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 44) { - s4 = peg$c247; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseImportSpecifier(); - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 44) { - s4 = peg$c247; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseImportSpecifier(); - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c283(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseImportSpecifier() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseIdentifier(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseAsToken(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseIdentifier(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c284(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseIdentifier(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c285(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parseExportDeclarationStatement() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - s1 = peg$parseExportToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseExportSpecifierList(); - if (s3 !== peg$FAILED) { - s4 = peg$currPos; - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseFromToken(); - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - if (s7 !== peg$FAILED) { - s8 = peg$parseStringLiteral(); - if (s8 !== peg$FAILED) { - s5 = [s5, s6, s7, s8]; - s4 = s5; - } else { - peg$currPos = s4; - s4 = peg$c0; - } - } else { - peg$currPos = s4; - s4 = peg$c0; - } - } else { - peg$currPos = s4; - s4 = peg$c0; - } - } else { - peg$currPos = s4; - s4 = peg$c0; - } - if (s4 === peg$FAILED) { - s4 = peg$c60; - } - if (s4 !== peg$FAILED) { - s5 = peg$parseEOS(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c286(s3, s4); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseExportToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 42) { - s3 = peg$c279; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c280); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseFromToken(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseStringLiteral(); - if (s7 !== peg$FAILED) { - s8 = peg$parseEOS(); - if (s8 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c287(s7); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseExportToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseVariableStatement(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c288(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseExportToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseFunctionDeclaration(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c288(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseExportToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseDefaultToken(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseExpression(); - if (s5 !== peg$FAILED) { - s6 = peg$parseEOS(); - if (s6 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c289(s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - } - } - - return s0; - } - - function peg$parseExportSpecifierList() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parseExportSpecifier(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 44) { - s4 = peg$c247; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseExportSpecifier(); - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 44) { - s4 = peg$c247; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseExportSpecifier(); - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c283(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseExportSpecifier() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseIdentifier(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseAsToken(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseIdentifier(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c290(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseIdentifier(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c291(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parseDoWhileStatement() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - s1 = peg$parseDoToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseStatement(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseWhileToken(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseExpression(); - if (s7 !== peg$FAILED) { - s8 = peg$parseEOS(); - if (s8 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c292(s3, s7); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsePushStatement() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parseCallExpression(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c293) { - s3 = peg$c293; - peg$currPos += 2; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c294); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseAssignmentExpression(); - if (s5 !== peg$FAILED) { - s6 = peg$parseEOS(); - if (s6 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c295(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseGoStatement() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseGoToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseBlock(); - if (s3 !== peg$FAILED) { - s4 = peg$parseEOS(); - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c296(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseDebuggerStatement() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parseDebuggerToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parseEOS(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c297(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseWhileStatement() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseWhileToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseExpression(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseStatement(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c298(s3, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseUntilStatement() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseUntilToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseExpression(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseStatement(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c299(s3, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseSwitchStatement() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseSwitchToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseExpression(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 123) { - s5 = peg$c241; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c242); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseCaseClauseList(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s9 = peg$c243; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c244); } - } - if (s9 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c300(s3, s7); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseCaseClauseList() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseCaseClause(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseCaseClause(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseCaseClause(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c301(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseCaseClause() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseCaseToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseCaseClauseTestList(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 58) { - s5 = peg$c302; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c303); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseStatement(); - if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c304(s3, s7); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseDefaultToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 58) { - s3 = peg$c302; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c303); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseStatement(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c305(s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parseCaseClauseTestList() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parseCaseClauseTest(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 44) { - s4 = peg$c247; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseCaseClauseTest(); - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 44) { - s4 = peg$c247; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseCaseClauseTest(); - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c283(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseCaseClauseTest() { - var s0; - - s0 = peg$parseOptionalRange(); - if (s0 === peg$FAILED) { - s0 = peg$parseExpression(); - } - - return s0; - } - - function peg$parseForStatement() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17; - - s0 = peg$currPos; - s1 = peg$parseForToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseIdentifier(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 44) { - s6 = peg$c247; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - if (s7 !== peg$FAILED) { - s8 = peg$parseIdentifier(); - if (s8 !== peg$FAILED) { - s6 = [s6, s7, s8]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$c0; - } - } else { - peg$currPos = s5; - s5 = peg$c0; - } - } else { - peg$currPos = s5; - s5 = peg$c0; - } - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseInToken(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s9 = peg$parseExpression(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - if (s10 !== peg$FAILED) { - s11 = peg$parseStatement(); - if (s11 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c306(s3, s5, s9, s11); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseForToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseIdentifier(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 44) { - s6 = peg$c247; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - if (s7 !== peg$FAILED) { - s8 = peg$parseIdentifier(); - if (s8 !== peg$FAILED) { - s6 = [s6, s7, s8]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$c0; - } - } else { - peg$currPos = s5; - s5 = peg$c0; - } - } else { - peg$currPos = s5; - s5 = peg$c0; - } - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseOfToken(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s9 = peg$parseExpression(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - if (s10 !== peg$FAILED) { - s11 = peg$parseStatement(); - if (s11 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c307(s3, s5, s9, s11); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseForToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseVarToken(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseVariableDeclarationList(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s7 = peg$c237; - peg$currPos++; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c238); } - } - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s9 = peg$currPos; - s10 = peg$parseExpression(); - if (s10 !== peg$FAILED) { - s11 = peg$parse__(); - if (s11 !== peg$FAILED) { - s10 = [s10, s11]; - s9 = s10; - } else { - peg$currPos = s9; - s9 = peg$c0; - } - } else { - peg$currPos = s9; - s9 = peg$c0; - } - if (s9 === peg$FAILED) { - s9 = peg$c60; - } - if (s9 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s10 = peg$c237; - peg$currPos++; - } else { - s10 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c238); } - } - if (s10 !== peg$FAILED) { - s11 = peg$parse__(); - if (s11 !== peg$FAILED) { - s12 = peg$currPos; - s13 = peg$currPos; - peg$silentFails++; - s14 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 123) { - s15 = peg$c241; - peg$currPos++; - } else { - s15 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c242); } - } - if (s15 !== peg$FAILED) { - s16 = peg$parse__(); - if (s16 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s17 = peg$c243; - peg$currPos++; - } else { - s17 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c244); } - } - if (s17 !== peg$FAILED) { - s15 = [s15, s16, s17]; - s14 = s15; - } else { - peg$currPos = s14; - s14 = peg$c0; - } - } else { - peg$currPos = s14; - s14 = peg$c0; - } - } else { - peg$currPos = s14; - s14 = peg$c0; - } - peg$silentFails--; - if (s14 === peg$FAILED) { - s13 = peg$c33; - } else { - peg$currPos = s13; - s13 = peg$c0; - } - if (s13 !== peg$FAILED) { - s14 = peg$parseExpression(); - if (s14 !== peg$FAILED) { - s15 = peg$parse__(); - if (s15 !== peg$FAILED) { - s13 = [s13, s14, s15]; - s12 = s13; - } else { - peg$currPos = s12; - s12 = peg$c0; - } - } else { - peg$currPos = s12; - s12 = peg$c0; - } - } else { - peg$currPos = s12; - s12 = peg$c0; - } - if (s12 === peg$FAILED) { - s12 = peg$c60; - } - if (s12 !== peg$FAILED) { - s13 = peg$parse__(); - if (s13 !== peg$FAILED) { - s14 = peg$parseStatement(); - if (s14 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c308(s5, s9, s12, s14); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseForToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parseExpression(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$c60; - } - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s4 = peg$c237; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c238); } - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$currPos; - s7 = peg$parseExpression(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s7 = [s7, s8]; - s6 = s7; - } else { - peg$currPos = s6; - s6 = peg$c0; - } - } else { - peg$currPos = s6; - s6 = peg$c0; - } - if (s6 === peg$FAILED) { - s6 = peg$c60; - } - if (s6 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s7 = peg$c237; - peg$currPos++; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c238); } - } - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s9 = peg$currPos; - s10 = peg$currPos; - peg$silentFails++; - s11 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 123) { - s12 = peg$c241; - peg$currPos++; - } else { - s12 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c242); } - } - if (s12 !== peg$FAILED) { - s13 = peg$parse__(); - if (s13 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s14 = peg$c243; - peg$currPos++; - } else { - s14 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c244); } - } - if (s14 !== peg$FAILED) { - s12 = [s12, s13, s14]; - s11 = s12; - } else { - peg$currPos = s11; - s11 = peg$c0; - } - } else { - peg$currPos = s11; - s11 = peg$c0; - } - } else { - peg$currPos = s11; - s11 = peg$c0; - } - peg$silentFails--; - if (s11 === peg$FAILED) { - s10 = peg$c33; - } else { - peg$currPos = s10; - s10 = peg$c0; - } - if (s10 !== peg$FAILED) { - s11 = peg$parseExpression(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - if (s12 !== peg$FAILED) { - s10 = [s10, s11, s12]; - s9 = s10; - } else { - peg$currPos = s9; - s9 = peg$c0; - } - } else { - peg$currPos = s9; - s9 = peg$c0; - } - } else { - peg$currPos = s9; - s9 = peg$c0; - } - if (s9 === peg$FAILED) { - s9 = peg$c60; - } - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - if (s10 !== peg$FAILED) { - s11 = peg$parseStatement(); - if (s11 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c309(s3, s6, s9, s11); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - } - - return s0; - } - - function peg$parseUseStatement() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseUseToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseUseIdentifierList(); - if (s3 !== peg$FAILED) { - s4 = peg$parseEOS(); - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c310(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseUseIdentifierList() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseUseIdentifier(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseUseIdentifier(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseUseIdentifier(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c249(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseUseIdentifier() { - var s0, s1, s2; - - s0 = peg$parseIdentifier(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 58) { - s1 = peg$c302; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c303); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseIdentifier(); - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c311(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parseExpressionStatement() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 123) { - s2 = peg$c241; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c242); } - } - if (s2 === peg$FAILED) { - s2 = peg$parseFnToken(); - } - peg$silentFails--; - if (s2 === peg$FAILED) { - s1 = peg$c33; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s2 = peg$parseExpression(); - if (s2 !== peg$FAILED) { - s3 = peg$parseEOS(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c312(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseAssignmentExpression() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsePattern(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 61) { - s3 = peg$c252; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - if (s3 !== peg$FAILED) { - s4 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s5 = peg$c252; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = peg$c33; - } else { - peg$currPos = s4; - s4 = peg$c0; - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseAssignmentExpression(); - if (s6 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c313(s1, s6); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseConditionalExpression(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parseAssignmentOperator(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseAssignmentExpression(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 === peg$FAILED) { - s2 = peg$c60; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c314(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - - return s0; - } - - function peg$parseAssignmentOperator() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 61) { - s1 = peg$c252; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s3 = peg$c252; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c315(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c316) { - s0 = peg$c316; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c317); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c318) { - s0 = peg$c318; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c319); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c320) { - s0 = peg$c320; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c321); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c322) { - s0 = peg$c322; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c323); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c324) { - s0 = peg$c324; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c325); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 3) === peg$c326) { - s0 = peg$c326; - peg$currPos += 3; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c327); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 3) === peg$c328) { - s0 = peg$c328; - peg$currPos += 3; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c329); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c330) { - s0 = peg$c330; - peg$currPos += 4; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c331); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c332) { - s0 = peg$c332; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c333); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c334) { - s0 = peg$c334; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c335); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c336) { - s0 = peg$c336; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c337); } - } - } - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseConditionalExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10; - - s0 = peg$currPos; - s1 = peg$parseLogicalORExpression(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parseIfToken(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseLogicalORExpression(); - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - if (s7 !== peg$FAILED) { - s8 = peg$parseElseToken(); - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - s10 = peg$parseLogicalORExpression(); - if (s10 !== peg$FAILED) { - s4 = [s4, s5, s6, s7, s8, s9, s10]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$c60; - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c338(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseLogicalORExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseLogicalANDExpression(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseLogicalOROperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseLogicalANDExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseLogicalOROperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseLogicalANDExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c339(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseLogicalOROperator() { - var s0, s1; - - if (input.substr(peg$currPos, 2) === peg$c340) { - s0 = peg$c340; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c341); } - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseOrToken(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c342(); - } - s0 = s1; - } - - return s0; - } - - function peg$parseLogicalANDExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseBitwiseORExpression(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseLogicalANDOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseBitwiseORExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseLogicalANDOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseBitwiseORExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c339(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseLogicalANDOperator() { - var s0, s1; - - if (input.substr(peg$currPos, 2) === peg$c343) { - s0 = peg$c343; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c344); } - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseAndToken(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c345(); - } - s0 = s1; - } - - return s0; - } - - function peg$parseBitwiseORExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseBitwiseXORExpression(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseBitwiseOROperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseBitwiseXORExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseBitwiseOROperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseBitwiseXORExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c346(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseBitwiseOROperator() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 124) { - s2 = peg$c347; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c348); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (peg$c349.test(input.charAt(peg$currPos))) { - s4 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c350); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - - return s0; - } - - function peg$parseBitwiseXORExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseBitwiseANDExpression(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseBitwiseXOROperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseBitwiseANDExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseBitwiseXOROperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseBitwiseANDExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c346(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseBitwiseXOROperator() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 94) { - s2 = peg$c351; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c352); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c252; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - - return s0; - } - - function peg$parseBitwiseANDExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseEqualityExpression(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseBitwiseANDOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseEqualityExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseBitwiseANDOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseEqualityExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c346(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseBitwiseANDOperator() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 38) { - s2 = peg$c353; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c354); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (peg$c355.test(input.charAt(peg$currPos))) { - s4 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c356); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - - return s0; - } - - function peg$parseEqualityExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseRelationalExpression(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseEqualityOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseRelationalExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseEqualityOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseRelationalExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c346(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseEqualityOperator() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c357) { - s0 = peg$c357; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c358); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c359) { - s0 = peg$c359; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c360); } - } - } - - return s0; - } - - function peg$parseRelationalExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseInExpression(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseRelationalOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseInExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseRelationalOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseInExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c346(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseRelationalOperator() { - var s0, s1, s2, s3, s4; - - if (input.substr(peg$currPos, 2) === peg$c361) { - s0 = peg$c361; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c362); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c363) { - s0 = peg$c363; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c364); } - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 60) { - s2 = peg$c365; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c366); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 60) { - s4 = peg$c365; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c366); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 62) { - s2 = peg$c367; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c368); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 62) { - s4 = peg$c367; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c368); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseInstanceofToken(); - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - } - } - } - } - - return s0; - } - - function peg$parseInExpression() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parseNullCoalescingExpression(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parseInToken(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseNullCoalescingExpression(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 === peg$FAILED) { - s2 = peg$c60; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c369(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseNullCoalescingExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseShiftExpression(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c370) { - s5 = peg$c370; - peg$currPos += 2; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c371); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseShiftExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c370) { - s5 = peg$c370; - peg$currPos += 2; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c371); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseShiftExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c372(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseShiftExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseAdditiveExpression(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseShiftOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseAdditiveExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseShiftOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseAdditiveExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c346(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseShiftOperator() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c373) { - s2 = peg$c373; - peg$currPos += 2; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c374); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c252; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.substr(peg$currPos, 3) === peg$c375) { - s2 = peg$c375; - peg$currPos += 3; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c376); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c252; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c377) { - s2 = peg$c377; - peg$currPos += 2; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c378); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c252; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - } - } - - return s0; - } - - function peg$parseAdditiveExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseMultiplicativeExpression(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseAdditiveOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseMultiplicativeExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseAdditiveOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseMultiplicativeExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c346(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseAdditiveOperator() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 43) { - s2 = peg$c379; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c380); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (peg$c381.test(input.charAt(peg$currPos))) { - s4 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c382); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 45) { - s2 = peg$c383; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c384); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (peg$c385.test(input.charAt(peg$currPos))) { - s4 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c386); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - } - - return s0; - } - - function peg$parseMultiplicativeExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseExponentiativeExpression(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseMultiplicativeOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseUnaryExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseMultiplicativeOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseUnaryExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c346(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseMultiplicativeOperator() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 42) { - s2 = peg$c279; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c280); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (peg$c387.test(input.charAt(peg$currPos))) { - s4 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c388); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 47) { - s2 = peg$c116; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c117); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c252; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 35) { - s2 = peg$c389; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c390); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c252; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 37) { - s2 = peg$c391; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c392); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (peg$c393.test(input.charAt(peg$currPos))) { - s4 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c394); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c395) { - s2 = peg$c395; - peg$currPos += 2; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c396); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c252; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - } - } - } - } - - return s0; - } - - function peg$parseExponentiativeExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseUnaryExpression(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseExponentiativeOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseUnaryExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseExponentiativeOperator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseUnaryExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c346(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseExponentiativeOperator() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c397) { - s2 = peg$c397; - peg$currPos += 2; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c398); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c252; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - - return s0; - } - - function peg$parseUnaryExpression() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseUnaryOperator(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsePostfixExpression(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c399(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parsePostfixExpression(); - } - - return s0; - } - - function peg$parseUnaryOperator() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseDeleteToken(); - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseTypeofToken(); - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseAsyncToken(); - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseAwaitToken(); - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseNotToken(); - if (s2 !== peg$FAILED) { - s2 = input.substring(s1, peg$currPos); - } - s1 = s2; - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c400(); - } - s0 = s1; - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c293) { - s0 = peg$c293; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c294); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c401) { - s0 = peg$c401; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c402); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c403) { - s0 = peg$c403; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c404); } - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 43) { - s2 = peg$c379; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c380); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c252; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 45) { - s2 = peg$c383; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c384); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c252; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c253); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s1 = input.substring(s0, peg$currPos); - } - s0 = s1; - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 33) { - s0 = peg$c405; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c406); } - } - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parsePostfixExpression() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseExistentialExpression(); - if (s1 !== peg$FAILED) { - s2 = peg$parse_(); - if (s2 !== peg$FAILED) { - s3 = peg$parsePostfixOperator(); - if (s3 === peg$FAILED) { - s3 = peg$c60; - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c407(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsePostfixOperator() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c401) { - s0 = peg$c401; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c402); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c403) { - s0 = peg$c403; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c404); } - } - } - - return s0; - } - - function peg$parseExistentialExpression() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseCallExpression(); - if (s1 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 63) { - s2 = peg$c408; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c409); } - } - if (s2 === peg$FAILED) { - s2 = peg$c60; - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 63) { - s4 = peg$c408; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c409); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = peg$c33; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c410(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseCallExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseMemberExpression(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCallExpressionOperator(); - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseArguments(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$c60; - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s1; - s2 = peg$c411(s2, s3); - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCallExpressionOperator(); - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseArguments(); - if (s7 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c412(s5, s7); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 91) { - s5 = peg$c123; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseExpression(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s9 = peg$c125; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s9 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c413(s7); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 91) { - s5 = peg$c123; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseOptionalRange(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s9 = peg$c125; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s9 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c414(s7); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 63) { - s5 = peg$c408; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c409); } - } - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 46) { - s7 = peg$c58; - peg$currPos++; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } - if (s7 !== peg$FAILED) { - s8 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 46) { - s9 = peg$c58; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } - peg$silentFails--; - if (s9 === peg$FAILED) { - s8 = peg$c33; - } else { - peg$currPos = s8; - s8 = peg$c0; - } - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - s10 = peg$parseIdentifierName(); - if (s10 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c415(s5, s10); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - } - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCallExpressionOperator(); - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseArguments(); - if (s7 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c412(s5, s7); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 91) { - s5 = peg$c123; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseExpression(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s9 = peg$c125; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s9 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c413(s7); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 91) { - s5 = peg$c123; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseOptionalRange(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s9 = peg$c125; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s9 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c414(s7); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 63) { - s5 = peg$c408; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c409); } - } - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 46) { - s7 = peg$c58; - peg$currPos++; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } - if (s7 !== peg$FAILED) { - s8 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 46) { - s9 = peg$c58; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } - peg$silentFails--; - if (s9 === peg$FAILED) { - s8 = peg$c33; - } else { - peg$currPos = s8; - s8 = peg$c0; - } - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - s10 = peg$parseIdentifierName(); - if (s10 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c415(s5, s10); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - } - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c416(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseCallExpressionOperator() { - var s0; - - if (input.charCodeAt(peg$currPos) === 63) { - s0 = peg$c408; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c409); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 94) { - s0 = peg$c351; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c352); } - } - } - - return s0; - } - - function peg$parseMemberExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10; - - s0 = peg$currPos; - s1 = peg$parseFunctionExpression(); - if (s1 === peg$FAILED) { - s1 = peg$currPos; - s2 = peg$parseNewToken(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parseMemberExpression(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseArguments(); - if (s6 !== peg$FAILED) { - peg$reportedPos = s1; - s2 = peg$c417(s4, s6); - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 91) { - s5 = peg$c123; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseExpression(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s9 = peg$c125; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s9 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c418(s7); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 63) { - s5 = peg$c408; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c409); } - } - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 46) { - s7 = peg$c58; - peg$currPos++; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } - if (s7 !== peg$FAILED) { - s8 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 46) { - s9 = peg$c58; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } - peg$silentFails--; - if (s9 === peg$FAILED) { - s8 = peg$c33; - } else { - peg$currPos = s8; - s8 = peg$c0; - } - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - s10 = peg$parseIdentifierName(); - if (s10 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c419(s5, s10); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 91) { - s5 = peg$c123; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseOptionalRange(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s9 = peg$c125; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s9 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c414(s7); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 91) { - s5 = peg$c123; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseExpression(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s9 = peg$c125; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s9 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c418(s7); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 63) { - s5 = peg$c408; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c409); } - } - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 46) { - s7 = peg$c58; - peg$currPos++; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } - if (s7 !== peg$FAILED) { - s8 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 46) { - s9 = peg$c58; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } - peg$silentFails--; - if (s9 === peg$FAILED) { - s8 = peg$c33; - } else { - peg$currPos = s8; - s8 = peg$c0; - } - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - s10 = peg$parseIdentifierName(); - if (s10 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c419(s5, s10); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 91) { - s5 = peg$c123; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseOptionalRange(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s9 = peg$c125; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s9 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c414(s7); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c420(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseArguments() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 40) { - s1 = peg$c110; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c111); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parseArgumentList(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$c60; - } - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s4 = peg$c112; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } - } - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c421(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseArgumentList() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseArgument(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseArgument(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseArgument(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c249(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseArgument() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseAssignmentExpression(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.substr(peg$currPos, 3) === peg$c261) { - s3 = peg$c261; - peg$currPos += 3; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c262); } - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c422(s1); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parseAssignmentExpression(); - } - - return s0; - } - - function peg$parseFunctionExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12; - - s0 = peg$currPos; - s1 = peg$parseFnToken(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parseIdentifier(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$c60; - } - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 40) { - s4 = peg$c110; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c111); } - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$currPos; - s7 = peg$parseFormalParameterList(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s7 = [s7, s8]; - s6 = s7; - } else { - peg$currPos = s6; - s6 = peg$c0; - } - } else { - peg$currPos = s6; - s6 = peg$c0; - } - if (s6 === peg$FAILED) { - s6 = peg$c60; - } - if (s6 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s7 = peg$c112; - peg$currPos++; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } - } - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s9 = peg$parseInheritsFrom(); - if (s9 === peg$FAILED) { - s9 = peg$c60; - } - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - if (s10 !== peg$FAILED) { - s11 = peg$parseBlock(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - if (s12 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c423(s3, s6, s9, s11); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 40) { - s1 = peg$c110; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c111); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parseFormalParameterList(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$c60; - } - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s4 = peg$c112; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseFunctionExpressionOperator(); - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - if (s7 !== peg$FAILED) { - s8 = peg$parseBlock(); - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c424(s3, s6, s8); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 40) { - s1 = peg$c110; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c111); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parseFormalParameterList(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$c60; - } - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s4 = peg$c112; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseFunctionExpressionOperator(); - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - if (s7 !== peg$FAILED) { - s8 = peg$parseExpression(); - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c425(s3, s6, s8); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parseForInExpression(); - } - } - } - - return s0; - } - - function peg$parseFunctionExpressionOperator() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c426) { - s0 = peg$c426; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c427); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c428) { - s0 = peg$c428; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c429); } - } - } - - return s0; - } - - function peg$parseForInExpression() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 91) { - s1 = peg$c123; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseExpression(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseForToken(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseIdentifier(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (s8 !== peg$FAILED) { - s9 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 44) { - s10 = peg$c247; - peg$currPos++; - } else { - s10 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s10 !== peg$FAILED) { - s11 = peg$parse__(); - if (s11 !== peg$FAILED) { - s12 = peg$parseIdentifier(); - if (s12 !== peg$FAILED) { - s13 = peg$parse__(); - if (s13 !== peg$FAILED) { - s10 = [s10, s11, s12, s13]; - s9 = s10; - } else { - peg$currPos = s9; - s9 = peg$c0; - } - } else { - peg$currPos = s9; - s9 = peg$c0; - } - } else { - peg$currPos = s9; - s9 = peg$c0; - } - } else { - peg$currPos = s9; - s9 = peg$c0; - } - if (s9 === peg$FAILED) { - s9 = peg$c60; - } - if (s9 !== peg$FAILED) { - s10 = peg$parseInToken(); - if (s10 !== peg$FAILED) { - s11 = peg$parse__(); - if (s11 !== peg$FAILED) { - s12 = peg$parseExpression(); - if (s12 !== peg$FAILED) { - s13 = peg$parse__(); - if (s13 !== peg$FAILED) { - s14 = peg$currPos; - s15 = peg$parseIfToken(); - if (s15 !== peg$FAILED) { - s16 = peg$parse__(); - if (s16 !== peg$FAILED) { - s17 = peg$parseExpression(); - if (s17 !== peg$FAILED) { - s18 = peg$parse__(); - if (s18 !== peg$FAILED) { - s15 = [s15, s16, s17, s18]; - s14 = s15; - } else { - peg$currPos = s14; - s14 = peg$c0; - } - } else { - peg$currPos = s14; - s14 = peg$c0; - } - } else { - peg$currPos = s14; - s14 = peg$c0; - } - } else { - peg$currPos = s14; - s14 = peg$c0; - } - if (s14 === peg$FAILED) { - s14 = peg$c60; - } - if (s14 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s15 = peg$c125; - peg$currPos++; - } else { - s15 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s15 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c430(s3, s7, s9, s12, s14); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parseGlobalIdentifierExpression(); - } - - return s0; - } - - function peg$parseGlobalIdentifierExpression() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c431) { - s1 = peg$c431; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c432); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseIdentifier(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c433(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$parsePrimaryExpression(); - } - - return s0; - } - - function peg$parsePrimaryExpression() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$parseThisExpression(); - if (s0 === peg$FAILED) { - s0 = peg$parseSuperExpression(); - if (s0 === peg$FAILED) { - s0 = peg$parseRangeExpression(); - if (s0 === peg$FAILED) { - s0 = peg$parseIdentifier(); - if (s0 === peg$FAILED) { - s0 = peg$parseLiteral(); - if (s0 === peg$FAILED) { - s0 = peg$parseArrayLiteral(); - if (s0 === peg$FAILED) { - s0 = peg$parseObjectLiteral(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 40) { - s1 = peg$c110; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c111); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseExpression(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c112; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } - } - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c254(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseThisExpression() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseThisToken(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c434(); - } - s0 = s1; - - return s0; - } - - function peg$parseSuperExpression() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseSuperToken(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c435(); - } - s0 = s1; - - return s0; - } - - function peg$parseRangeExpression() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 91) { - s1 = peg$c123; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseRange(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s5 = peg$c125; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c436(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseRange() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseExpression(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseRangeOperator(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseExpression(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c437(s1, s3, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseOptionalRange() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseExpression(); - if (s1 === peg$FAILED) { - s1 = peg$c60; - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseRangeOperator(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseExpression(); - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c437(s1, s3, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseRangeOperator() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c438) { - s1 = peg$c438; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c439); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 46) { - s3 = peg$c58; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = peg$c33; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c440(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 3) === peg$c261) { - s0 = peg$c261; - peg$currPos += 3; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c262); } - } - } - - return s0; - } - - function peg$parseExpression() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseAssignmentExpression(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c114(s1); - } - s0 = s1; - - return s0; - } - - function peg$parseArrayLiteral() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 91) { - s1 = peg$c123; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parseElision(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$c60; - } - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s4 = peg$c125; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c441(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 91) { - s1 = peg$c123; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseElementList(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s5 = peg$c125; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c442(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 91) { - s1 = peg$c123; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseElementList(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$currPos; - s8 = peg$parseElision(); - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - s8 = [s8, s9]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$c0; - } - } else { - peg$currPos = s7; - s7 = peg$c0; - } - if (s7 === peg$FAILED) { - s7 = peg$c60; - } - if (s7 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s8 = peg$c125; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s8 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c443(s3, s7); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - - return s0; - } - - function peg$parseElementList() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$currPos; - s3 = peg$parseElision(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 === peg$FAILED) { - s2 = peg$c60; - } - if (s2 !== peg$FAILED) { - s3 = peg$parseAssignmentExpression(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s1; - s2 = peg$c444(s2, s3); - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$currPos; - s8 = peg$parseElision(); - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - s8 = [s8, s9]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$c0; - } - } else { - peg$currPos = s7; - s7 = peg$c0; - } - if (s7 === peg$FAILED) { - s7 = peg$c60; - } - if (s7 !== peg$FAILED) { - s8 = peg$parseAssignmentExpression(); - if (s8 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c444(s7, s8); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$currPos; - s8 = peg$parseElision(); - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - s8 = [s8, s9]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$c0; - } - } else { - peg$currPos = s7; - s7 = peg$c0; - } - if (s7 === peg$FAILED) { - s7 = peg$c60; - } - if (s7 !== peg$FAILED) { - s8 = peg$parseAssignmentExpression(); - if (s8 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c444(s7, s8); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c445(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseArrayPattern() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 91) { - s1 = peg$c123; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parseElision(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - if (s3 === peg$FAILED) { - s3 = peg$c60; - } - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s4 = peg$c125; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c446(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 91) { - s1 = peg$c123; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsePatternElementList(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s5 = peg$c125; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c447(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 91) { - s1 = peg$c123; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsePatternElementList(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$currPos; - s8 = peg$parseElision(); - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - s8 = [s8, s9]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$c0; - } - } else { - peg$currPos = s7; - s7 = peg$c0; - } - if (s7 === peg$FAILED) { - s7 = peg$c60; - } - if (s7 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s8 = peg$c125; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c126); } - } - if (s8 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c448(s3, s7); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - - return s0; - } - - function peg$parsePatternElementList() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$currPos; - s3 = peg$parseElision(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$c0; - } - } else { - peg$currPos = s2; - s2 = peg$c0; - } - if (s2 === peg$FAILED) { - s2 = peg$c60; - } - if (s2 !== peg$FAILED) { - s3 = peg$parsePatternElement(); - if (s3 !== peg$FAILED) { - peg$reportedPos = s1; - s2 = peg$c444(s2, s3); - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$c0; - } - } else { - peg$currPos = s1; - s1 = peg$c0; - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$currPos; - s8 = peg$parseElision(); - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - s8 = [s8, s9]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$c0; - } - } else { - peg$currPos = s7; - s7 = peg$c0; - } - if (s7 === peg$FAILED) { - s7 = peg$c60; - } - if (s7 !== peg$FAILED) { - s8 = peg$parsePatternElement(); - if (s8 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c444(s7, s8); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$currPos; - s8 = peg$parseElision(); - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - s8 = [s8, s9]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$c0; - } - } else { - peg$currPos = s7; - s7 = peg$c0; - } - if (s7 === peg$FAILED) { - s7 = peg$c60; - } - if (s7 !== peg$FAILED) { - s8 = peg$parsePatternElement(); - if (s8 !== peg$FAILED) { - peg$reportedPos = s3; - s4 = peg$c444(s7, s8); - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c445(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsePatternElement() { - var s0; - - s0 = peg$parseIdentifier(); - if (s0 === peg$FAILED) { - s0 = peg$parseArrayPattern(); - } - - return s0; - } - - function peg$parseElision() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 44) { - s1 = peg$c247; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c449(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parseObjectLiteral() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 123) { - s1 = peg$c241; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c242); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s3 = peg$c243; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c244); } - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c450(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 123) { - s1 = peg$c241; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c242); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsePropertyNameAndValueList(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s5 = peg$c243; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c244); } - } - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c451(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 123) { - s1 = peg$c241; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c242); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsePropertyNameAndValueList(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s7 = peg$c243; - peg$currPos++; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c244); } - } - if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c451(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - - return s0; - } - - function peg$parsePropertyNameAndValueList() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsePropertyAssignment(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsePropertyAssignment(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsePropertyAssignment(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c249(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsePropertyAssignment() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parsePropertyName(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 58) { - s3 = peg$c302; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c303); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseAssignmentExpression(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c452(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsePropertyName(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 40) { - s3 = peg$c110; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c111); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$currPos; - s6 = peg$parseFormalParameterList(); - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - if (s7 !== peg$FAILED) { - s6 = [s6, s7]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$c0; - } - } else { - peg$currPos = s5; - s5 = peg$c0; - } - if (s5 === peg$FAILED) { - s5 = peg$c60; - } - if (s5 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s6 = peg$c112; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } - } - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - if (s7 !== peg$FAILED) { - s8 = peg$parseBlock(); - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - if (s9 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c453(s1, s5, s8); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseIdentifierName(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c454(s1); - } - s0 = s1; - } - } - - return s0; - } - - function peg$parsePropertyName() { - var s0; - - s0 = peg$parseIdentifierName(); - if (s0 === peg$FAILED) { - s0 = peg$parseStringLiteral(); - if (s0 === peg$FAILED) { - s0 = peg$parseNumericLiteral(); - } - } - - return s0; - } - - function peg$parseObjectPattern() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 123) { - s1 = peg$c241; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c242); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s3 = peg$c243; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c244); } - } - if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c455(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 123) { - s1 = peg$c241; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c242); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsePatternPropertyNameAndValueList(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s5 = peg$c243; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c244); } - } - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c456(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 123) { - s1 = peg$c241; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c242); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsePatternPropertyNameAndValueList(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s7 = peg$c243; - peg$currPos++; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c244); } - } - if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c456(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } - } - - return s0; - } - - function peg$parsePatternPropertyNameAndValueList() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsePatternPropertyAssignment(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsePatternPropertyAssignment(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 44) { - s5 = peg$c247; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c248); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parsePatternPropertyAssignment(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } else { - peg$currPos = s3; - s3 = peg$c0; - } - } - if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c249(s1, s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - - return s0; - } - - function peg$parsePatternPropertyAssignment() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseIdentifierName(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 58) { - s3 = peg$c302; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c303); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseIdentifierName(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c452(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseIdentifierName(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 58) { - s3 = peg$c302; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c303); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseObjectPattern(); - if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c452(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - } else { - peg$currPos = s0; - s0 = peg$c0; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseIdentifierName(); - if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c454(s1); - } - s0 = s1; - } - } - - return s0; - } - - function peg$parsePattern() { - var s0; - - s0 = peg$parseObjectPattern(); - if (s0 === peg$FAILED) { - s0 = peg$parseArrayPattern(); - } - - return s0; - } - - - var ast = module.require('./ast'); - - function filledArray(count, value) { - var result = new Array(count), i; - - for (i = 0; i < count; i++) { - result[i] = value; - } - - return result; - } - - function extractOptional(optional, index) { - return optional ? optional[index] : null; - } - - function extractList(list, index) { - var result = new Array(list.length), i; - - for (i = 0; i < list.length; i++) { - result[i] = list[i][index]; - } - - return result; - } - - function buildList(first, rest, index) { - return [first].concat(extractList(rest, index)); - } - - function buildTree(first, rest, builder) { - var result = first, i; - - for (i = 0; i < rest.length; i++) { - result = builder(result, rest[i]); - } - - return result; - } - - function buildBinaryExpression(first, rest) { - return buildTree(first, rest, function(result, element) { - return insertLocationData(new ast.BinaryExpression(result, element[1], element[3]), text(), line(), column()); - }); - } - - function buildLogicalExpression(first, rest) { - return buildTree(first, rest, function(result, element) { - return insertLocationData(new ast.LogicalExpression(result, element[1], element[3]), text(), line(), column()); - }); - } - - function buildNullCoalescingExpression(first, rest) { - return buildTree(first, rest, function(result, element) { - return insertLocationData(new ast.NullCoalescingExpression(result, element[3]), text(), line(), column()); - }); - } - - function optionalList(value) { - return value !== null ? value : []; - } - - function insertLocationData(node, text, line, column) { - var lines = text.split("\n"); - node.loc = { - "start": { - "line": line, - "column": column - 1 - }, - "end": { - "line": line + lines.length - 1, - "column": (lines.length === 1 ? (column - 1) : 0) + - lines[lines.length - 1].length - } - }; - - return node; - } - - - peg$result = peg$startRuleFunction(); - - if (peg$result !== peg$FAILED && peg$currPos === input.length) { - return peg$result; - } else { - if (peg$result !== peg$FAILED && peg$currPos < input.length) { - peg$fail({ type: "end", description: "end of input" }); - } - - throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos); - } - } - - return { - SyntaxError: SyntaxError, - parse: parse - }; -})(); \ No newline at end of file diff --git a/lib/spider.js b/lib/spider.js deleted file mode 100644 index 84ac849..0000000 --- a/lib/spider.js +++ /dev/null @@ -1,220 +0,0 @@ -$traceurRuntime.ModuleStore.getAnonymousModule(function() { - "use strict"; - var parser = module.require("./parser"), - escodegen = require("escodegen"), - ast = module.require("./ast"), - traceur = require("traceur"), - chalk = require("chalk"), - transfer = require("multi-stage-sourcemap").transfer; - exports.compile = function(options) { - var result = { - errors: [], - result: null, - sourceMap: null - }; - options.fileName = options.fileName == null ? "tmp" : options.fileName; - var outFileNameWithoutExtension = options.fileName.substring(0, options.fileName.lastIndexOf(".")); - var outFileName = outFileNameWithoutExtension + ".js"; - var mapFileName = outFileNameWithoutExtension + ".map"; - resetVariableNames(); - ast.Node.setErrorManager(new ErrorManager(result.errors)); - var parsed; - try { - parsed = parser.parse(options.text); - } catch (e) { - result.errors.push(getParsingError(e)); - } - if (!parsed) { - return result; - } - var tree = parsed.codegen(); - if (options.target !== "ES5") { - tree = wrapCode(tree, options.useStrict == null ? true : options.useStrict, options.iifi == null ? true : options.iifi); - } - var output = escodegen.generate(tree, { - sourceMap: options.generateSourceMap ? options.fileName : null, - sourceMapWithCode: options.generateSourceMap, - format: {quotes: "double"} - }); - if (options.generateSourceMap) { - result.result = output.code; - result.sourceMap = output.map.toString(); - } else { - result.result = output; - } - if (options.target === "ES5") { - var traceurCompiler = new traceur.NodeCompiler({ - sourceMaps: options.generateSourceMap, - modules: options.modules, - asyncFunctions: true - }); - result.result = traceurCompiler.compile(result.result, options.fileName, outFileName); - if (options.generateSourceMap) { - result.sourceMap = transfer({ - toSourceMap: result.sourceMap, - fromSourceMap: traceurCompiler.getSourceMap().toString() - }); - } - } else { - if (options.generateSourceMap) { - result.result = result.result + "\n\n//# sourceMappingURL=" + mapFileName; - } - } - if (options.verbose) { - console.log(JSON.stringify(parsed, null, 4)); - console.log(result.result); - } - return result; - }; - exports.formatErrors = function(fileName, content, errors) { - var output = []; - var maxCol = 0; - var maxLine = 0; - output.push(chalk.white(fileName), "\n"); - var lines = content.split("\n"); - var tabCharacter = "__SPIDER_TAB"; - var errorIndex = 0; - for (var $__0 = errors[$traceurRuntime.toProperty(Symbol.iterator)](), - $__1; !($__1 = $__0.next()).done; ) { - var error = $__1.value; - { - var line = error.loc.start.line; - var column = error.loc.start.column + 1; - var lineCharCount = line.toString().length; - var columnCharCount = column.toString().length; - maxCol = Math.max(maxCol, columnCharCount); - maxLine = Math.max(maxCol, lineCharCount); - output.push(tabCharacter); - output.push(chalk.gray("line", line)); - output.push(tabCharacter, lineCharCount); - output.push(chalk.gray("col", column)); - output.push(tabCharacter, columnCharCount); - output.push(chalk.red(error.message), "\n"); - if (typeof error.loc !== "undefined" && error.loc !== null ? error.loc.start : void 0) { - var start = error.loc.start; - var end = error.loc.end; - if (0 < start.line <= lines.length) { - output.push(tabCharacter, tabCharacter, tabCharacter); - output.push(chalk.green(lines[start.line - 1].replace(/(\r\n|\n|\r)/gm, ""), "\n", tabCharacter, tabCharacter)); - output.push(chalk.red(generateErrorColumnString(start.column, end ? end.column - 1 : 0))); - } - } - output.push("\n"); - errorIndex++; - } - } - var str = output.join(""); - var tabLength = Math.max(maxLine, maxCol); - for (var i = 1; i <= tabLength; i++) { - var regex = new RegExp(tabCharacter + i, "g"); - str = str.replace(regex, generateSpace(Math.max(2 + tabLength - i, 2))); - } - return str.replace(new RegExp(tabCharacter, "g"), generateSpace(2)); - }; - function ErrorManager(errors) { - this.errors = errors; - } - ErrorManager.prototype.error = function(e) { - this.errors.push(e); - }; - function getParsingError(e) { - var message; - if (e.expected) { - if (e.found) { - message = "unexpected " + e.found; - } else { - message = "unexpected end of input"; - } - } else { - message = e.message; - } - return { - type: "SyntaxError", - message: message, - loc: {start: { - line: e.line, - column: e.column - 1 - }} - }; - } - function resetVariableNames() { - ast.NullPropagatingExpression.resetVariableNames(); - ast.NullCoalescingExpression.resetVariableNames(); - ast.NullCheckCallExpression.resetVariableNames(); - ast.ExistentialExpression.resetVariableNames(); - ast.FunctionExpression.resetVariableNames(); - ast.ForOfStatement.resetVariableNames(); - ast.ForInExpression.resetVariableNames(); - ast.FallthroughStatement.resetVariableNames(); - ast.SwitchStatement.resetVariableNames(); - } - function wrapCode(tree) { - var useStrict = arguments[1] !== (void 0) ? arguments[1] : false; - var iifi = arguments[2] !== (void 0) ? arguments[2] : false; - if (!!iifi || !!useStrict) { - var body = []; - if (useStrict) { - body.push({ - "type": "ExpressionStatement", - "expression": { - "type": "Literal", - "value": "use strict" - } - }); - } - if (iifi) { - body.push({ - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "FunctionExpression", - "id": null, - "params": [], - "defaults": [], - "body": { - "type": "BlockStatement", - "body": tree.body - }, - "rest": null, - "generator": false, - "expression": false - }, - "arguments": [] - } - }); - } else { - body = body.concat(tree.body); - } - tree = { - "type": "Program", - "body": body - }; - } - return tree; - } - function generateSpace(len) { - var chars = []; - for (var i = 0; i < len; i++) { - chars.push(" "); - } - return chars.join(""); - } - function generateErrorColumnString(errorStartIndex, errorEndIndex) { - var chars = []; - var i = 0; - if (!errorEndIndex) { - errorEndIndex = errorStartIndex; - } - for (; i < errorStartIndex; i++) { - chars.push(" "); - } - for (i = errorStartIndex; i <= errorEndIndex; i++) { - chars.push("^"); - } - return chars.join(""); - } - return {}; -}); - -//# sourceMappingURL=spider.map diff --git a/package.json b/package.json deleted file mode 100644 index 4cc3a02..0000000 --- a/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "spider-script", - "version": "0.1.5", - "main": "spider-script.js", - "description": "The Next-Gen Programming Language for the Web", - "homepage": "http://spiderlang.org", - "bugs": "https://github.com/alongubkin/spider/issues", - "author": { - "name": "Alon Gubkin", - "email": "alon.gubkin@gmail.com" - }, - "repository": { - "type": "git", - "url": "https://github.com/alongubkin/spider" - }, - "license": "Apache", - "files": [ - "lib", - "cli.js", - "spider-script.js" - ], - "keywords": [ - "spider", - "" - ], - "devDependencies": { - "coveralls": "~2.11.2", - "grunt-contrib-clean": "~0.6.0", - "grunt-contrib-copy": "~0.7.0", - "grunt-contrib-nodeunit": "^0.3.3", - "grunt-contrib-watch": "^0.6.1", - "grunt-eslint": "~2.0.0", - "grunt-mocha-cli": "^1.9.0", - "grunt-mocha-istanbul": "~2.2.0", - "grunt-peg": "~1.5.0", - "grunt-spider-script": "0.0.9", - "istanbul": "~0.3.2", - "load-grunt-tasks": "^0.4.0", - "mocha": "~2.0.1", - "mocha-lcov-reporter": "0.0.1", - "shelljs-nodecli": "~0.1.1", - "should": "~4.1.0", - "time-grunt": "^0.3.1", - "grunt": "~0.4.5" - }, - "scripts": { - "test": "grunt" - }, - "bin": { - "spider": "cli.js" - }, - "preferGlobal": "true", - "dependencies": { - "escodegen": "estools/escodegen#21a9331", - "pegjs": "~0.8.0", - "nomnom": "~1.8.1", - "chalk": "~0.5.1", - "traceur": "0.0.74", - "multi-stage-sourcemap": "~0.2.1" - } -} diff --git a/spider-script.js b/spider-script.js deleted file mode 100644 index de5df02..0000000 --- a/spider-script.js +++ /dev/null @@ -1,6 +0,0 @@ -require("traceur"); - -var spider = require("./lib/spider"); -for (var prop in spider) { - exports[prop] = spider[prop]; -} \ No newline at end of file diff --git a/src/ast.spider b/src/ast.spider deleted file mode 100644 index 3a1ed8e..0000000 --- a/src/ast.spider +++ /dev/null @@ -1,80 +0,0 @@ -use :node; - -var nodes = [ - 'Node', - 'Program', - 'VariableDeclarator', - 'Property', - 'Range', - 'Parameter', - 'CatchClause', - 'CaseClause', - 'ImportSpecifier', - 'ImportNamespaceSpecifier', - 'ImportDefaultSpecifier', - 'ExportSpecifier', - 'ExportBatchSpecifier', - 'expressions/AssignmentExpression', - 'expressions/BinaryExpression', - 'expressions/CallExpression', - 'expressions/ExistentialExpression', - 'expressions/LogicalExpression', - 'expressions/MemberExpression', - 'expressions/NullCheckCallExpression', - 'expressions/NullCoalescingExpression', - 'expressions/NullPropagatingExpression', - 'expressions/UnaryExpression', - 'expressions/ObjectExpression', - 'expressions/ArrayExpression', - 'expressions/ObjectPattern', - 'expressions/ArrayPattern', - 'expressions/UpdateExpression', - 'expressions/FunctionExpression', - 'expressions/RangeMemberExpression', - 'expressions/NewExpression', - 'expressions/ThisExpression', - 'expressions/SuperExpression', - 'expressions/SplatExpression', - 'expressions/ConditionalExpression', - 'expressions/InExpression', - 'expressions/ForInExpression', - 'expressions/CurryCallExpression', - 'statements/BlockStatement', - 'statements/ExpressionStatement', - 'statements/IfStatement', - 'statements/ForStatement', - 'statements/ForInStatement', - 'statements/ForOfStatement', - 'statements/WhileStatement', - 'statements/UntilStatement', - 'statements/VariableDeclarationStatement', - 'statements/FunctionDeclarationStatement', - 'statements/ReturnStatement', - 'statements/ThrowStatement', - 'statements/BreakStatement', - 'statements/ContinueStatement', - 'statements/DebuggerStatement', - 'statements/UseStatement', - 'statements/TryStatement', - 'statements/SwitchStatement', - 'statements/FallthroughStatement', - 'statements/ImportDeclarationStatement', - 'statements/ExportDeclarationStatement', - 'statements/DoWhileStatement', - 'statements/PushStatement', - 'statements/GoStatement', - 'literals/BooleanLiteral', - 'literals/NumberLiteral', - 'literals/StringLiteral', - 'literals/NullLiteral', - 'literals/UndefinedLiteral', - 'literals/Identifier', - 'literals/RegularExpressionLiteral' -]; - -module.exports = {}; - -for node in nodes { - var name = node.substring(node.lastIndexOf('/') + 1); - module.exports[name] = module.require('./ast/' + node)[name]; -} \ No newline at end of file diff --git a/src/ast/CaseClause.spider b/src/ast/CaseClause.spider deleted file mode 100644 index 063c562..0000000 --- a/src/ast/CaseClause.spider +++ /dev/null @@ -1,179 +0,0 @@ -use :node; - -var Node = module.require('./Node').Node; - -fn CaseClause(tests, body) - extends Node { - - this.type = 'CaseClause'; - - this.body = body; - this.body.parent = this; - - this.tests = tests; - if this.tests? { - for test in this.tests { - test.parent = this; - } - } -} - -CaseClause.prototype.codegen = (branchFallthrough) -> { - if !super.codegen() { - return; - } - - if !this.tests? and !branchFallthrough { - return this.body.codegen(); - } - - this.type = "IfStatement"; - this.switchCase = true; - - var rangeError = false; - - if this.tests? { - for test in this.tests { - var equalsToDiscriminant; - - if test.type == "Range" { - var fromCheck; - if test.start { - fromCheck = { - "type": "BinaryExpression", - "operator": ">=", - "left": this.parent.discriminant, - "right": test.start - }; - } - - var toCheck; - if test.to { - toCheck = { - "type": "BinaryExpression", - "operator": "<" + ("=" if test.operator == ".." else ""), - "left": this.parent.discriminant, - "right": test.to - }; - } - - if fromCheck && toCheck { - equalsToDiscriminant = { - "type": "LogicalExpression", - "operator": "&&", - "left": fromCheck, - "right": toCheck - }; - } else if fromCheck || toCheck { - equalsToDiscriminant = fromCheck ?? toCheck; - } else { - rangeError = test; - break; - } - } else if test.type == "ArrayExpression" { - test = test.codegen(); - - equalsToDiscriminant = { - "type": "BinaryExpression", - "operator": ">=", - "left": { - "type": "MemberExpression", - "computed": false, - "object": this.parent.discriminant, - "property": { - "type": "Identifier", - "name": "length" - } - }, - "right": { - "type": "Literal", - "value": test.elements.length - } - }; - - for element, i in test.elements { - if element? { - equalsToDiscriminant = { - "type": "LogicalExpression", - "operator": "&&", - "left": equalsToDiscriminant, - "right": { - "type": "BinaryExpression", - "operator": "===", - "left": { - "type": "MemberExpression", - "computed": true, - "object": this.parent.discriminant, - "property": { - "type": "Literal", - "value": i - } - }, - "right": element - } - }; - } - } - } else { - equalsToDiscriminant = { - "type": "BinaryExpression", - "operator": "===", - "left": this.parent.discriminant, - "right": test.codegen() - }; - } - - if !this.test { - this.test = equalsToDiscriminant; - } else { - this.test = { - "type": "LogicalExpression", - "operator": "||", - "left": this.test, - "right": equalsToDiscriminant - }; - } - } - } - - if rangeError { - Node.getErrorManager().error({ - type: "EmptyRange", - message: "empty range in case clause is disallowed.", - loc: rangeError.loc - }); - - return null; - } - - this.consequent = this.body.codegen(); - - if branchFallthrough { - var fallthroughTest = { - "type": "BinaryExpression", - "left": this.parent.fallthroughId, - "operator": "<", - "right": { - "type": "Literal", - "value": 2 - } - }; - - if !this.tests? { - this.test = fallthroughTest; - } else { - this.test = { - "type": "LogicalExpression", - "operator": "&&", - "left": fallthroughTest, - "right": this.test - }; - } - } - - this.alternate = null; - - return this; -}; - -exports.CaseClause = CaseClause; \ No newline at end of file diff --git a/src/ast/CatchClause.spider b/src/ast/CatchClause.spider deleted file mode 100644 index 9b0a94f..0000000 --- a/src/ast/CatchClause.spider +++ /dev/null @@ -1,30 +0,0 @@ -use :node; - -var Node = module.require('./Node').Node; - -fn CatchClause(param, body) - extends Node { - - this.type = 'CatchClause'; - - this.param = param; - this.param.parent = this; - - this.body = body; - this.body.parent = this; -} - -CatchClause.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.param = this.param.codegen(false); - this.defineIdentifier(this.param); - - this.body = this.body.codegen(); - - return this; -}; - -exports.CatchClause = CatchClause; \ No newline at end of file diff --git a/src/ast/ExportBatchSpecifier.spider b/src/ast/ExportBatchSpecifier.spider deleted file mode 100644 index 9b4e111..0000000 --- a/src/ast/ExportBatchSpecifier.spider +++ /dev/null @@ -1,19 +0,0 @@ -use :node; - -var Node = module.require('./Node').Node; - -fn ExportBatchSpecifier() - extends Node { - - this.type = "ExportBatchSpecifier"; -} - -ExportBatchSpecifier.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - return this; -}; - -exports.ExportBatchSpecifier = ExportBatchSpecifier; \ No newline at end of file diff --git a/src/ast/ExportSpecifier.spider b/src/ast/ExportSpecifier.spider deleted file mode 100644 index ca5beea..0000000 --- a/src/ast/ExportSpecifier.spider +++ /dev/null @@ -1,37 +0,0 @@ -use :node; - -var Node = module.require('./Node').Node; - -fn ExportSpecifier(id, alias) - extends Node { - - this.type = "ExportSpecifier"; - - this.id = id; - this.id.parent = this; - - if alias? { - this.alias = alias; - this.alias.parent = this; - } -} - -ExportSpecifier.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.id = this.id.codegen(false); - - ::Object.defineProperty(this, 'name', { - value: { - "type": "Identifier", - "name": this.alias.name - } if this.alias? else null, - enumerable: true - }); - - return this; -}; - -exports.ExportSpecifier = ExportSpecifier; \ No newline at end of file diff --git a/src/ast/ImportDefaultSpecifier.spider b/src/ast/ImportDefaultSpecifier.spider deleted file mode 100644 index 7b2e7c0..0000000 --- a/src/ast/ImportDefaultSpecifier.spider +++ /dev/null @@ -1,25 +0,0 @@ -use :node; - -var Node = module.require('./Node').Node; - -fn ImportDefaultSpecifier(id) - extends Node { - - this.type = "ImportDefaultSpecifier"; - - this.id = id; - this.id.parent = this; -} - -ImportDefaultSpecifier.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.id = this.id.codegen(false); - this.getContext().node.defineIdentifier(this.id); - - return this; -}; - -exports.ImportDefaultSpecifier = ImportDefaultSpecifier; \ No newline at end of file diff --git a/src/ast/ImportNamespaceSpecifier.spider b/src/ast/ImportNamespaceSpecifier.spider deleted file mode 100644 index 3e84971..0000000 --- a/src/ast/ImportNamespaceSpecifier.spider +++ /dev/null @@ -1,25 +0,0 @@ -use :node; - -var Node = module.require('./Node').Node; - -fn ImportNamespaceSpecifier(id) - extends Node { - - this.type = "ImportNamespaceSpecifier"; - - this.id = id; - this.id.parent = this; -} - -ImportNamespaceSpecifier.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.id = this.id.codegen(false); - this.getContext().node.defineIdentifier(this.id); - - return this; -}; - -exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier; \ No newline at end of file diff --git a/src/ast/ImportSpecifier.spider b/src/ast/ImportSpecifier.spider deleted file mode 100644 index 48039c3..0000000 --- a/src/ast/ImportSpecifier.spider +++ /dev/null @@ -1,44 +0,0 @@ -use :node; - -var Node = module.require('./Node').Node; - -fn ImportSpecifier(id, alias) - extends Node { - - this.type = "ImportSpecifier"; - - if id? { - this.id = id; - this.id.parent = this; - } - - if alias? { - this.alias = alias; - this.alias.parent = this; - } -} - -ImportSpecifier.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - if this.id? { - this.id = this.id.codegen(false); - } else { - this.type = "ImportNamespaceSpecifier"; - } - - ::Object.defineProperty(this, 'name', { - value: { - "type": "Identifier", - "name": this.alias.name - } if this.alias? else null, - enumerable: true - }); - - this.getContext().node.defineIdentifier(this.alias ?? this.id); - return this; -}; - -exports.ImportSpecifier = ImportSpecifier; \ No newline at end of file diff --git a/src/ast/Node.spider b/src/ast/Node.spider deleted file mode 100644 index 4b65b9c..0000000 --- a/src/ast/Node.spider +++ /dev/null @@ -1,104 +0,0 @@ -use :node; - -fn Node() { - var self = this; - self.codeGenerated = false; - self.definedIdentifiers = []; - - ::Object.defineProperty(self, 'parent', { - value: null, - writable: true, - configurable: true, - enumerable: false - }); - - self.getContext = () -> { - if self.type == 'Program' || - self.type == 'BlockStatement' { - return { - node: self, - position: -1 - }; - } - - if !self.parent? { - return null; - } - - var context = self.parent.getContext(); - - if !context? { - return null; - } - - if context.position == -1 { - return { - node: context.node, - position: context.node.body.indexOf(self) - }; - } else { - return context; - } - }; - - self.defineIdentifier = (identifier) -> { - self.definedIdentifiers.push(identifier); - }; - - self.isIdentifierDefined = (name) -> { - var defined = false; - - for identifier in self.definedIdentifiers { - if identifier.name == name { - defined = true; - } - } - - return defined || (self.parent && self.parent.isIdentifierDefined(name)); - }; - - self.getDefinedIdentifier = (name) -> { - var id; - - for identifier in self.definedIdentifiers { - if identifier.name == name { - id = identifier; - } - } - - return id ?? (self.parent.getDefinedIdentifier(name) if self.parent else null); - }; - - self.blockWrap = () -> { - if self.type == 'BlockStatement' { - return self; - } - - var myParent = self.parent; - var blockStatement = module.require('./statements/BlockStatement'); - - var block = new blockStatement.BlockStatement([self]); - block.parent = myParent; - - return block; - }; -} - -Node.prototype.codegen = () -> { - if this.codeGenerated { - return false; - } - - this.codeGenerated = true; - return true; -}; - -Node.setErrorManager = (errorManager) -> { - this.errorManager = errorManager; -}; - -Node.getErrorManager = () -> { - return this.errorManager; -}; - -exports.Node = Node; \ No newline at end of file diff --git a/src/ast/Parameter.spider b/src/ast/Parameter.spider deleted file mode 100644 index f941481..0000000 --- a/src/ast/Parameter.spider +++ /dev/null @@ -1,235 +0,0 @@ -use :node; - -var Node = module.require('./Node').Node; - -fn Parameter(id, defaultValue, splat) - extends Node { - - this.type = 'Parameter'; - this.splat = splat; - - this.id = id; - this.id.parent = this; - - this.defaultValue = defaultValue; - - if this.defaultValue? { - this.defaultValue.parent = this; - } -} - -Parameter.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.id = this.id.codegen(false); - - if this.defaultValue? { - this.defaultValue = this.defaultValue.codegen(); - } - - return this; -}; - - -Parameter.prototype.hasCallExpression = () -> { - return false; -}; - -Parameter.generateFunctionBody = (func, params, body, defaults) -> { - var splatPosition = -1; - - for param, i in params { - if param.splat { - if splatPosition != -1 { - Node.getErrorManager().error({ - type: "MultipleSplatsDisallowed", - message: "multiple splats are disallowed in a function declaration", - loc: param.loc - }); - } - - splatPosition = i; - } - - param = param.codegen(); - defaults.push(param.defaultValue); - params[i] = param.id; - func.defineIdentifier(param.id); - } - - if splatPosition != -1 { - var declarations = [{ - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "__splat" - }, - "init": null - }]; - - for param, i in params { - var init; - if i < splatPosition { - init = { - "type": "MemberExpression", - "computed": true, - "object": { - "type": "Identifier", - "name": "arguments" - }, - "property": { - "type": "Literal", - "value": i - } - }; - } else if i == splatPosition { - init = { - "type": "ConditionalExpression", - "test": { - "type": "BinaryExpression", - "operator": "<=", - "left": { - "type": "Literal", - "value": params.length - }, - "right": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "arguments" - }, - "property": { - "type": "Identifier", - "name": "length" - } - } - }, - "consequent": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ArrayExpression", - "elements": [] - }, - "property": { - "type": "Identifier", - "name": "slice" - } - }, - "property": { - "type": "Identifier", - "name": "call" - } - }, - "arguments": [{ - "type": "Identifier", - "name": "arguments" - }, { - "type": "Literal", - "value": splatPosition - }] - }, - "alternate": { - "type": "ArrayExpression", - "elements": [] - } - }; - - if splatPosition < params.length - 1 { - init.consequent.arguments.push({ - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "__splat" - }, - "right": { - "type": "BinaryExpression", - "operator": "-", - "left": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "arguments" - }, - "property": { - "type": "Identifier", - "name": "length" - } - }, - "right": { - "type": "Literal", - "value": params.length - splatPosition - 1 - } - } - }); - - init.alternate = { - "type": "SequenceExpression", - "expressions": [{ - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "__splat" - }, - "right": { - "type": "Literal", - "value": splatPosition - } - }, { - "type": "ArrayExpression", - "elements": [] - }] - }; - } - } - else - { - init = { - "type": "MemberExpression", - "computed": true, - "object": { - "type": "Identifier", - "name": "arguments" - }, - "property": { - "type": "UpdateExpression", - "operator": "++", - "argument": { - "type": "Identifier", - "name": "__splat" - }, - "prefix": false - } - }; - } - - declarations.push({ - "type": "VariableDeclarator", - "id": param, - "init": init - }); - } - - body.body = [{ - "type": "VariableDeclaration", - "codeGenerated": true, - "declarations": declarations, - "kind": "let" - }].concat(body.body); - - params.length = 0; - } -}; - -exports.Parameter = Parameter; diff --git a/src/ast/Program.spider b/src/ast/Program.spider deleted file mode 100644 index e80fd45..0000000 --- a/src/ast/Program.spider +++ /dev/null @@ -1,109 +0,0 @@ -use :node; - -var Node = module.require('./Node').Node; - -fn Program(body) - extends Node { - - this.type = 'Program'; - this.body = body; - - for statement, i in body { - if statement? { - statement.parent = this; - } else { - body[i] = { type: 'EmptyStatement' }; - } - } - - this.definedIdentifiers = Program.prototype.generateIdentifiers( - 'Infinity', - 'NaN', - 'eval', - 'uneval', - 'isFinite', - 'isNaN', - 'parseFloat', - 'parseInt', - 'decodeURI', - 'decodeURIComponent', - 'encodeURI', - 'encodeURIComponent', - 'escape', - 'unescape', - 'Object', - 'Function', - 'Boolean', - 'Symbol', - 'Error', - 'EvalError', - 'InternalError', - 'RangeError', - 'ReferenceError', - 'StopIteration', - 'SyntaxError', - 'TypeError', - 'URIError', - 'Number', - 'Math', - 'Date', - 'String', - 'RegExp', - 'Array', - 'Int8Array', - 'Uint8Array', - 'Uint8ClampedArray', - 'Int16Array', - 'Uint16Array', - 'Int32Array', - 'Uint32Array', - 'Float32Array', - 'Float64Array', - 'Map', - 'Set', - 'WeakMap', - 'WeakSet', - 'ArrayBuffer', - 'DataView', - 'JSON', - 'Iterator', - 'Generator', - 'Promise', - 'arguments'); -} - -Program.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var i = 0; - while (i < this.body.length) { - var statement = this.body[i]; - - if !statement || statement.codeGenerated { - i++; - continue; - } - - if statement.codegen && statement.codegen() { - this.body[this.body.indexOf(statement)] = statement; - i++; - } else { - this.body.splice(i, 1); - } - } - - return this; -}; - -Program.prototype.generateIdentifiers = (identifiers...) -> { - return identifiers.map((id) -> { - return { - "type": "Identifier", - "name": id - }; - }); -}; - -exports.Program = Program; \ No newline at end of file diff --git a/src/ast/Property.spider b/src/ast/Property.spider deleted file mode 100644 index 5508d73..0000000 --- a/src/ast/Property.spider +++ /dev/null @@ -1,36 +0,0 @@ -use :node; - -var Node = module.require('./Node').Node; - -fn Property(key, value, shorthand, method) - extends Node { - - this.type = 'Property'; - this.kind = 'init'; - this.method = method; - this.shorthand = shorthand; - this.computed = false; - - this.key = key; - this.key.parent = this; - - this.value = value; - this.value.parent = this; -} - -Property.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.key = this.key.codegen(false); - this.value = this.value.codegen(this.parent.type != "ObjectPattern"); - - return this; -}; - -Property.prototype.hasCallExpression = () -> { - return this.value.hasCallExpression(); -}; - -exports.Property = Property; \ No newline at end of file diff --git a/src/ast/Range.spider b/src/ast/Range.spider deleted file mode 100644 index 767dfce..0000000 --- a/src/ast/Range.spider +++ /dev/null @@ -1,291 +0,0 @@ -use :node; - -var Node = module.require('./Node').Node; - -fn Range(start, operator, to) - extends Node { - - this.type = 'Range'; - this.operator = operator; - - this.start = start; - - if this.start? { - this.start.parent = this; - } - - this.to = to; - - if this.to? { - this.to.parent = this; - } -} - -Range.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var isNumber = (n) -> !::isNaN(::parseFloat(n)) && ::isFinite(n); - var isNumeric = isNumber(this.start.value) && isNumber(this.to.value); - - this.start = this.start.codegen(); - this.to = this.to.codegen(); - - var updateOperator, testOperator; - - if isNumeric { - updateOperator = '++' if this.start.value < this.to.value else '--'; - testOperator = '<' if this.start.value < this.to.value else '>'; - - if this.operator == '..' { - testOperator += '='; - } - } - - if isNumeric && ::Math.abs(this.to.value - this.start.value) <= 20 { - this.type = 'ArrayExpression'; - this.elements = []; - - var test = (i) -> { - switch testOperator { - case '>': { - return i > this.to.value; - }, - - case '<': { - return i < this.to.value; - }, - - case '>=': { - return i >= this.to.value; - }, - - case '<=': { - return i <= this.to.value; - } - } - }; - - for var i = this.start.value; - test.call(this, i); - i++ if updateOperator == '++' else i-- { - this.elements.push({ - "type": "Literal", - "value": i - }); - } - } else { - var testExpression, updateExpression; - - var declarations = [{ - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "_results" - }, - "init": { - "type": "ArrayExpression", - "elements": [] - } - }]; - - if isNumeric { - testExpression = { - "type": "BinaryExpression", - "operator": testOperator, - "left": { - "type": "Identifier", - "name": "_i" - }, - "right": this.to - }; - - updateExpression = { - "type": "UpdateExpression", - "operator": updateOperator, - "argument": { - "type": "Identifier", - "name": "_i" - }, - "prefix": false - }; - } else { - if this.start.hasCallExpression() { - var startId = { - "type": "Identifier", - "name": "_start" - }; - - declarations.push({ - "type": "VariableDeclarator", - "id": startId, - "init": this.start - }); - - this.start = startId; - } - - if this.to.hasCallExpression() { - var endId = { - "type": "Identifier", - "name": "_end" - }; - - declarations.push({ - "type": "VariableDeclarator", - "id": endId, - "init": this.to - }); - - this.to = endId; - } - - testExpression = { - "type": "ConditionalExpression", - "test": { - "type": "BinaryExpression", - "operator": "<=", - "left": this.start, - "right": this.to - }, - "consequent": { - "type": "BinaryExpression", - "operator": "<" + ('=' if this.operator == '..' else ''), - "left": { - "type": "Identifier", - "name": "_i" - }, - "right": this.to - }, - "alternate": { - "type": "BinaryExpression", - "operator": ">" + ('=' if this.operator == '..' else ''), - "left": { - "type": "Identifier", - "name": "_i" - }, - "right": this.to - } - }; - - updateExpression = { - "type": "ConditionalExpression", - "test": { - "type": "BinaryExpression", - "operator": "<=", - "left": this.start, - "right": this.to - }, - "consequent": { - "type": "UpdateExpression", - "operator": "++", - "argument": { - "type": "Identifier", - "name": "_i" - }, - "prefix": false - }, - "alternate": { - "type": "UpdateExpression", - "operator": "--", - "argument": { - "type": "Identifier", - "name": "_i" - }, - "prefix": false - } - }; - } - - this.type = 'CallExpression'; - - this.callee = { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "FunctionExpression", - "id": null, - "params": [], - "defaults": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "declarations": declarations, - "kind": "let" - }, - { - "type": "ForStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "_i" - }, - "init": this.start - }], - "kind": "let" - }, - "test": testExpression, - "update": updateExpression, - "body": { - "type": "BlockStatement", - "body": [{ - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "_results" - }, - "property": { - "type": "Identifier", - "name": "push" - } - }, - "arguments": [{ - "type": "Identifier", - "name": "_i" - }] - } - }] - } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "_results" - } - } - ] - }, - "rest": null, - "generator": false, - "expression": false - }, - "property": { - "type": "Identifier", - "name": "apply" - } - }; - - ::Object.defineProperty(this, 'arguments', { - value: [{ "type": "ThisExpression" }], - enumerable: true - }); - } - - return this; -}; - -Range.prototype.hasCallExpression = () -> true; - -exports.Range = Range; \ No newline at end of file diff --git a/src/ast/VariableDeclarator.spider b/src/ast/VariableDeclarator.spider deleted file mode 100644 index b369081..0000000 --- a/src/ast/VariableDeclarator.spider +++ /dev/null @@ -1,33 +0,0 @@ -use :node; - -var Node = module.require('./Node').Node; - -fn VariableDeclarator(id, init) - extends Node { - - this.type = 'VariableDeclarator'; - - this.id = id; - this.id.parent = this; - - this.init = init; - - if this.init? { - this.init.parent = this; - } -} - -VariableDeclarator.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - if this.init? { - this.init = this.init.codegen(); - } - - this.id = this.id.codegen(); - return this; -}; - -exports.VariableDeclarator = VariableDeclarator; \ No newline at end of file diff --git a/src/ast/expressions/ArrayExpression.spider b/src/ast/expressions/ArrayExpression.spider deleted file mode 100644 index fe82417..0000000 --- a/src/ast/expressions/ArrayExpression.spider +++ /dev/null @@ -1,32 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ArrayExpression(elements) - extends Node { - - this.type = 'ArrayExpression'; - this.elements = elements; - - for element in this.elements { - if element? { - element.parent = this; - } - } -} - -ArrayExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - for element, i in this.elements { - this.elements[i] = element?.codegen(); - } - - return this; -}; - -ArrayExpression.prototype.hasCallExpression = () -> true; - -exports.ArrayExpression = ArrayExpression; \ No newline at end of file diff --git a/src/ast/expressions/ArrayPattern.spider b/src/ast/expressions/ArrayPattern.spider deleted file mode 100644 index 5e6d98d..0000000 --- a/src/ast/expressions/ArrayPattern.spider +++ /dev/null @@ -1,37 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ArrayPattern(elements) - extends Node { - - this.type = 'ArrayPattern'; - this.elements = elements; - - for element in this.elements { - if element? { - element.parent = this; - } - } -} - -ArrayPattern.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var context = this.getContext().node; - for element, i in this.elements { - this.elements[i] = element?.codegen(false); - - if element? and element.type == "Identifier" { - context.defineIdentifier(element); - } - } - - return this; -}; - -ArrayPattern.prototype.hasCallExpression = () -> true; - -exports.ArrayPattern = ArrayPattern; \ No newline at end of file diff --git a/src/ast/expressions/AssignmentExpression.spider b/src/ast/expressions/AssignmentExpression.spider deleted file mode 100644 index 6bb229e..0000000 --- a/src/ast/expressions/AssignmentExpression.spider +++ /dev/null @@ -1,35 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn AssignmentExpression(left, operator, right) - extends Node { - - this.type = 'AssignmentExpression'; - this.operator = operator; - - this.left = left; - this.left.parent = this; - - this.right = right; - this.right.parent = this; - -} - -AssignmentExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.left = this.left.codegen(); - this.right = this.right.codegen(); - - return this; -}; - -AssignmentExpression.prototype.hasCallExpression = () -> { - return this.left?.hasCallExpression() || - this.right?.hasCallExpression(); -}; - -exports.AssignmentExpression = AssignmentExpression; diff --git a/src/ast/expressions/BinaryExpression.spider b/src/ast/expressions/BinaryExpression.spider deleted file mode 100644 index 5b48a91..0000000 --- a/src/ast/expressions/BinaryExpression.spider +++ /dev/null @@ -1,125 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn BinaryExpression(left, operator, right) - extends Node { - - this.type = 'BinaryExpression'; - this.operator = operator; - - this.left = left; - this.left.parent = this; - - this.right = right; - this.right.parent = this; -} - -BinaryExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var isRelational = (operator) - -> operator in ['>', '>=', '<', '>=']; - - // If we are dealing with something like a < x < b, - // turn it into: a < x && x < b - if isRelational(this.operator) && - isRelational(this.left.operator) { - this.type = 'LogicalExpression'; - this.right = { - "type": "BinaryExpression", - "operator": this.operator, - "left": this.left.right, - "right": this.right.codegen() - }; - - this.left = this.left.codegen(); - this.operator = '&&'; - } else { - this.left = this.left.codegen(); - this.right = this.right.codegen(); - - switch (this.operator) { - case '==': { - this.operator = '==='; - }, - - case '!=': { - this.operator = '!=='; - }, - - case '**': { - this.type = 'CallExpression'; - this.callee = { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "Math" - }, - "property": { - "type": "Identifier", - "name": "pow" - } - }; - - ::Object.defineProperty(this, 'arguments', { - value: [this.left, this.right], - enumerable: true - }); - }, - - case '#': { - this.type = 'CallExpression'; - this.callee = { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "Math" - }, - "property": { - "type": "Identifier", - "name": "floor" - } - }; - - ::Object.defineProperty(this, 'arguments', { - value: [{ - "type": "BinaryExpression", - "operator": "/", - "left": this.left, - "right": this.right - }], - enumerable: true - }); - }, - - case '%%': { - this.operator = '%'; - this.left = { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "BinaryExpression", - "operator": "%", - "left": this.left, - "right": this.right - }, - "right": this.right - }; - } - } - } - - return this; -}; - -BinaryExpression.prototype.hasCallExpression = () -> { - return this.left?.hasCallExpression() || - this.right?.hasCallExpression(); -}; - -exports.BinaryExpression = BinaryExpression; \ No newline at end of file diff --git a/src/ast/expressions/CallExpression.spider b/src/ast/expressions/CallExpression.spider deleted file mode 100644 index d6822f9..0000000 --- a/src/ast/expressions/CallExpression.spider +++ /dev/null @@ -1,149 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn CallExpression(callee, args) - extends Node { - - this.type = 'CallExpression'; - this.callee = callee; - this.callee.parent = this; - - ::Object.defineProperty(this, 'arguments', { - value: args, - enumerable: true - }); - - for arg in args { - arg.parent = this; - } -} - -CallExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var calleeType = this.callee.type; - - if !this.callee.codeGenerated { - this.callee = this.callee.codegen(); - } - - var args = this.arguments; - var splatPositions = []; - - for arg, i in args { - if args[i].type == "SplatExpression" || args[i].__splat { - splatPositions.push(i); - } - - if !args[i].codeGenerated { - args[i] = arg.codegen(); - } - } - - if splatPositions.length > 0 { - var argsClone = args.slice(0); - args.length = 0; - args.push({ - "type": "Literal", - "value": null - }); - - if argsClone.length == 1 { - args.push(argsClone[0].arguments[0]); - } else { - args.push({ - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": argsClone[0] if splatPositions[0] == 0 else { - "type": "ArrayExpression", - "elements": argsClone[...splatPositions[0]] - }, - "property": { - "type": "Identifier", - "name": "concat" - } - }, - "arguments": argsClone[1 if splatPositions[0] == 0 else splatPositions[0]..] - .map((arg, i) -> { - if splatPositions.indexOf(i + (1 if splatPositions[0] == 0 else splatPositions[0])) != -1 { - return arg; - } - - return { - "type": "ArrayExpression", - "elements": [arg] - }; - }) - }); - } - } - - // If we are null propagating (?.), then turn this - // into a condition and add the null propagating condition. - if this.callee.type == 'ConditionalExpression' && - (calleeType == 'NullPropagatingExpression' || calleeType == 'MemberExpression') { - var parent = this.parent; - - var consequent = { - type: 'CallExpression', - callee: this.callee.consequent, - arguments: this.arguments - }; - - if splatPositions.length > 0 { - this.callee.consequent = { - "type": "MemberExpression", - "computed": false, - "object": this.callee.consequent, - "property": { - "type": "Identifier", - "name": "apply" - } - }; - } - - // If we're inside a statement, then turn this into - // a normal if statement. - if parent.type == 'ExpressionStatement' { - parent.type = 'IfStatement'; - parent.test = this.callee.test; - parent.consequent = { - type: 'BlockStatement', - body: [ - { - type: 'ExpressionStatement', - expression: consequent - } - ] - }; - parent.alternate = null; - } else { - // Otherwise, it should be a conditional expression (?:). - this.type = 'ConditionalExpression'; - this.test = this.callee.test; - this.consequent = consequent; - this.alternate = this.callee.alternate; - } - } else if splatPositions.length > 0 { - this.callee = { - "type": "MemberExpression", - "computed": false, - "object": this.callee, - "property": { - "type": "Identifier", - "name": "apply" - } - }; - } - - return this; -}; - -CallExpression.prototype.hasCallExpression = () -> true; - -exports.CallExpression = CallExpression; \ No newline at end of file diff --git a/src/ast/expressions/ConditionalExpression.spider b/src/ast/expressions/ConditionalExpression.spider deleted file mode 100644 index f1f5462..0000000 --- a/src/ast/expressions/ConditionalExpression.spider +++ /dev/null @@ -1,34 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ConditionalExpression(test, consequent, alternate) - extends Node { - - this.type = 'ConditionalExpression'; - - this.test = test; - this.test.parent = this; - - this.consequent = consequent; - this.consequent.parent = this; - - this.alternate = alternate; - this.alternate.parent = this; -} - -ConditionalExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.test = this.test.codegen(); - this.consequent = this.consequent.codegen(); - this.alternate = this.alternate.codegen(); - - return this; -}; - -ConditionalExpression.prototype.hasCallExpression = () -> true; - -exports.ConditionalExpression = ConditionalExpression; \ No newline at end of file diff --git a/src/ast/expressions/CurryCallExpression.spider b/src/ast/expressions/CurryCallExpression.spider deleted file mode 100644 index d105cf9..0000000 --- a/src/ast/expressions/CurryCallExpression.spider +++ /dev/null @@ -1,109 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node, - CallExpression = module.require('./CallExpression').CallExpression; - -fn CurryCallExpression(callee, args) - extends Node { - - this.type = 'CurryCallExpression'; - - this.callee = callee; - this.args = args; -} - -CurryCallExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var call = new CallExpression(this.callee, this.args); - call.parent = this; - call = call.codegen(); - - if call.type != "CallExpression" or (call?.callee.type == "MemberExpression" and call?.callee.property.name == "apply") { - Node.getErrorManager().error({ - type: "InvalidFunctionCurrying", - message: "currying functions with existential operator or splats is disallowed.", - loc: this.loc - }); - } - - this.type = "FunctionExpression"; - this.id = null; - this.params = []; - this.defaults = []; - this.body = { - "type": "BlockStatement", - "body": [{ - "type": "ReturnStatement", - "argument": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": call.callee, - "property": { - "type": "Identifier", - "name": "apply" - } - }, - "arguments": [ - { "type": "ThisExpression" }, - { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ArrayExpression", - "elements": call.arguments, - }, - "property": { - "type": "Identifier", - "name": "concat" - } - }, - "arguments": [{ - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ArrayExpression", - "elements": [] - }, - "property": { - "type": "Identifier", - "name": "slice" - } - }, - "property": { - "type": "Identifier", - "name": "apply" - } - }, - "arguments": [{ - "type": "Identifier", - "name": "arguments" - }] - }] - } - ] - } - }] - }; - - this.rest = null; - this.generator = false; - this.expression = false; - - return this; -}; - -CurryCallExpression.prototype.hasCallExpression = () -> true; - -exports.CurryCallExpression = CurryCallExpression; \ No newline at end of file diff --git a/src/ast/expressions/ExistentialExpression.spider b/src/ast/expressions/ExistentialExpression.spider deleted file mode 100644 index 053f225..0000000 --- a/src/ast/expressions/ExistentialExpression.spider +++ /dev/null @@ -1,102 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ExistentialExpression(argument) - extends Node { - - this.type = 'ExistentialExpression'; - this.argument = argument; - this.argument.parent = this; -} - -ExistentialExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var isArgumentCallExpression = this.argument.hasCallExpression?() ?? false; - - this.argument = this.argument.codegen(); - - // If the argument has a function call (e.g: a().b) - // then store its value in a separate variable to avoid - // calling the function twice. - if isArgumentCallExpression { - var context = this.getContext(); - - var id = { - "type": "Identifier", - "name": ExistentialExpression.getNextVariableName() - }; - - context.node.body.splice(context.position + - (ExistentialExpression.existentialIndex - 2), 0, { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": id, - "init": this.argument - } - ], - "kind": "let", - "codeGenerated": true - }); - - this.argument = id; - } - - // The generated syntax looks like: - // argument === null - var nullCheck = { - "type": "BinaryExpression", - "operator": "!==", - "left": this.argument, - "right": { - "type": "Literal", - "value": null, - "raw": "null" - } - }; - - // Add undefined check - this.type = 'LogicalExpression'; - this.operator = '&&'; - this.left = { - "type": "BinaryExpression", - "operator": "!==", - "left": { - "type": "UnaryExpression", - "operator": "typeof", - "argument": this.argument, - "prefix": true - }, - "right": { - "type": "Literal", - "value": "undefined", - "raw": "'undefined'" - } - }; - - this.right = nullCheck; - return this; -}; - -ExistentialExpression.prototype.hasCallExpression = () -> { - return this.argument?.hasCallExpression?() ?? false; -}; - -ExistentialExpression.getNextVariableName = () -> { - if !this.existentialIndex? { - this.existentialIndex = 0; - } - - return "existential" + this.existentialIndex++; -}; - -ExistentialExpression.resetVariableNames = () -> { - this.existentialIndex = 0; -}; - -exports.ExistentialExpression = ExistentialExpression; \ No newline at end of file diff --git a/src/ast/expressions/ForInExpression.spider b/src/ast/expressions/ForInExpression.spider deleted file mode 100644 index b68557a..0000000 --- a/src/ast/expressions/ForInExpression.spider +++ /dev/null @@ -1,140 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node, - ForInStatement = module.require('../statements/ForInStatement').ForInStatement, - BlockStatement = module.require('../statements/BlockStatement').BlockStatement; - -fn ForInExpression(expression, item, index, array, condition) - extends Node { - - this.type = 'ForInExpression'; - - this.expression = expression; - this.expression.parent = this; - - this.item = item; - this.item.parent = this; - - this.index = index; - if this.index? { - this.index.parent = this; - } - - this.array = array; - this.array.parent = this; - - this.condition = condition; - if this.condition? { - this.condition.parent = this; - } -} - -ForInExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.defineIdentifier(this.item); - - if this.index? { - this.defineIdentifier(this.index); - } - - var id = { - "type": "Identifier", - "name": ForInExpression.getNextVariableName(), - "codeGenerated": true - }; - - var pushStatement = { - "type": "ExpressionStatement", - "codeGenerated": true, - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": id, - "property": { - "type": "Identifier", - "name": "push" - } - }, - "arguments": [this.expression.codegen()] - } - }; - - if this.condition? { - pushStatement = { - "type": "IfStatement", - "codeGenerated": true, - "test": this.condition.codegen(), - "consequent": { - "type": "BlockStatement", - "body": [pushStatement] - }, - "alternate": null - }; - } - - var forInStatement = new ForInStatement(this.item, this.index, this.array, - new BlockStatement([pushStatement])); - - var fnBlock = new BlockStatement([ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": id, - "init": { - "type": "ArrayExpression", - "elements": [] - } - } - ], - "kind": "let", - "codeGenerated": true - }, - forInStatement, - { - "type": "ReturnStatement", - "codeGenerated": true, - "argument": id - } - ]); - - forInStatement.parent = fnBlock; - - this.type = "CallExpression"; - this.callee = { - "type": "FunctionExpression", - "id": null, - "params": [], - "defaults": [], - "body": fnBlock.codegen() - }; - - ::Object.defineProperty(this, 'arguments', { - value: [], - enumerable: true - }); - - return this; -}; - -ForInExpression.prototype.hasCallExpression = () -> true; - -ForInExpression.getNextVariableName = () -> { - if !this.forInIndex? { - this.forInIndex = 0; - } - - return "forIn" + this.forInIndex++; -}; - -ForInExpression.resetVariableNames = () -> { - this.forInIndex = 0; -}; - -exports.ForInExpression = ForInExpression; \ No newline at end of file diff --git a/src/ast/expressions/FunctionExpression.spider b/src/ast/expressions/FunctionExpression.spider deleted file mode 100644 index 4c2946e..0000000 --- a/src/ast/expressions/FunctionExpression.spider +++ /dev/null @@ -1,183 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node, - Parameter = module.require('../Parameter').Parameter, - CallExpression = module.require('../expressions/CallExpression').CallExpression; - -fn FunctionExpression (id, params, body, inheritsFrom, operator) - extends Node { - - if operator == "=>" { - this.type = "ArrowFunctionExpression"; - } else { - this.type = 'FunctionExpression'; - } - - this.defaults = []; - this.rest = null; - this.generator = false; - this.expression = false; - this.operator = operator; - - this.id = id; - - if this.id? { - this.id.parent = this; - } - - this.body = body; - this.params = params; - - body.parent = this; - - for param in params { - param.parent = this; - } - - this.inheritsFrom = inheritsFrom; - - if this.inheritsFrom? { - this.inheritsFrom.parent = this; - } - - if this.body.type != 'BlockStatement' { - this.autoBlock = true; - this.body = { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": this.body - } - ] - }; - - var self = this; - this.getContext = () -> { - return { - node: self.body, - position: -1 - }; - }; - } -} - -FunctionExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - if this.id? { - this.id = this.id.codegen(false); - } - - Parameter.generateFunctionBody(this, this.params, this.body, this.defaults); - - if this.autoBlock { - this.body.body[0].argument = this.body.body[this.body.body.length - 1].argument.codegen(); - } else { - this.body = this.body.codegen(); - } - - if this.inheritsFrom? { - if this.inheritsFrom.type != 'CallExpression' { - this.inheritsFrom = new CallExpression(this.inheritsFrom, []); - this.inheritsFrom.parent = this; - } - - var context = this.getContext(); - - this.body.body.splice(0, 0, { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": this.inheritsFrom.callee, - "property": { - "type": "Identifier", - "name": "call" - } - }, - "arguments": [ - { "type": "ThisExpression" } - ].concat(this.inheritsFrom.arguments) - } - }); - - var id = { - "type": "Identifier", - "name": FunctionExpression.getNextVariableName() - }; - - context.node.body.splice(context.position, 0, { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": id, - "init": this - } - ], - "kind": "let", - "codeGenerated": true - }); - - context.node.body.splice(context.position + 1, 0, { - "type": "ExpressionStatement", - "codeGenerated": "true", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "computed": false, - "object": id, - "property": { - "type": "Identifier", - "name": "prototype" - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "Object" - }, - "property": { - "type": "Identifier", - "name": "create" - } - }, - "arguments": [ - this.inheritsFrom.callee - ] - } - } - }); - - return id; - } - - return this; -}; - -FunctionExpression.prototype.hasCallExpression = () -> true; - -FunctionExpression.getNextVariableName = () -> { - if !this.functionExpressionIndex? { - this.functionExpressionIndex = 0; - } - - return "functionExpression" + this.functionExpressionIndex++; -}; - -FunctionExpression.resetVariableNames = () -> { - this.functionExpressionIndex = 0; -}; - -exports.FunctionExpression = FunctionExpression; \ No newline at end of file diff --git a/src/ast/expressions/InExpression.spider b/src/ast/expressions/InExpression.spider deleted file mode 100644 index 8ce835b..0000000 --- a/src/ast/expressions/InExpression.spider +++ /dev/null @@ -1,114 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn InExpression(left, right) - extends Node { - - this.type = 'InExpression'; - - this.left = left; - this.left.parent = this; - - this.right = right; - this.right.parent = this; -} - -InExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.left = this.left.codegen(); - this.right = this.right.codegen(); - - if this.right.hasCallExpression?() { - var context = this.getContext(); - - var id = { - "type": "Identifier", - "name": InExpression.getNextVariableName(), - "codeGenerated": true - }; - - context.node.body.splice(context.position + - (InExpression.inExpressionIndex - 2), 0, { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": id, - "init": this.right - } - ], - "kind": "let", - "codeGenerated": true - }); - - this.right = id; - } - - this.type = "ConditionalExpression"; - this.test = { - "type": "BinaryExpression", - "operator": "instanceof", - "left": this.right, - "right": { - "type": "Identifier", - "name": "Array" - } - }; - - this.consequent = { - "type": "BinaryExpression", - "operator": "!==", - "left": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": this.right, - "property": { - "type": "Identifier", - "name": "indexOf" - } - }, - "arguments": [this.left] - }, - "right": { - "type": "UnaryExpression", - "operator": "-", - "argument": { - "type": "Literal", - "value": 1, - "raw": "1" - }, - "prefix": true - } - }; - - this.alternate = { - "type": "BinaryExpression", - "operator": "in", - "left": this.left, - "right": this.right - }; - - return this; -}; - -InExpression.prototype.hasCallExpression = () -> true; - -InExpression.getNextVariableName = () -> { - if !this.inExpressionIndex? { - this.inExpressionIndex = 0; - } - - return "inExpression" + this.inExpressionIndex++; -}; - -InExpression.resetVariableNames = () -> { - this.inExpressionIndex = 0; -}; - -exports.InExpression = InExpression; \ No newline at end of file diff --git a/src/ast/expressions/LogicalExpression.spider b/src/ast/expressions/LogicalExpression.spider deleted file mode 100644 index c9bcc8d..0000000 --- a/src/ast/expressions/LogicalExpression.spider +++ /dev/null @@ -1,62 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn LogicalExpression(left, operator, right) - extends Node { - - this.type = 'LogicalExpression'; - this.operator = operator; - - switch this.operator { - case 'and': { - this.operator = '&&'; - }, - - case 'or': { - this.operator = '||'; - } - } - - this.left = left; - this.left.parent = this; - - this.right = right; - this.right.parent = this; -} - -LogicalExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var enforceBooleanExpression = (o) -> { - if o.type == "UnaryExpression" and o.operator == "!" { - return o; - } - - return { - "type": "UnaryExpression", - "operator": "!", - "argument": { - "type": "UnaryExpression", - "operator": "!", - "argument": o, - "prefix": true - }, - "prefix": true - }; - }; - - this.left = enforceBooleanExpression(this.left.codegen()); - this.right = enforceBooleanExpression(this.right.codegen()); - - return this; -}; - -LogicalExpression.prototype.hasCallExpression = () -> { - return this.left?.hasCallExpression() || - this.right?.hasCallExpression(); -}; - -exports.LogicalExpression = LogicalExpression; \ No newline at end of file diff --git a/src/ast/expressions/MemberExpression.spider b/src/ast/expressions/MemberExpression.spider deleted file mode 100644 index bdeaf8b..0000000 --- a/src/ast/expressions/MemberExpression.spider +++ /dev/null @@ -1,57 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn MemberExpression(left, right, computed) - extends Node { - - this.type = 'MemberExpression'; - this.computed = computed; - - this.object = left; - this.object.parent = this; - - this.property = right; - this.property.parent = this; -} - -MemberExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var objectType = this.object.type; - this.object = this.object.codegen(); - - if !this.property.codeGenerated { - this.property = this.property.codegen(false); - } - - // compile an expression such as: b?.c?.d.e - // to: typeof b !== "undefined" && (b !== null && b.c !== null) ? b.c.d.e : null - // instead of: (typeof b !== "undefined" && (b !== null && b.c !== null) ? b.c.d : null).e; - if (this.object.type == 'ConditionalExpression' && - (objectType == 'NullPropagatingExpression' || objectType == 'MemberExpression' || - objectType == 'CallExpression' || objectType == 'NullCheckCallExpression')) { - this.type = this.object.type; - this.test = this.object.test; - this.alternate = this.object.alternate; - - this.consequent = { - type: 'MemberExpression', - object: this.object.consequent, - property: this.property, - computed: this.computed - }; - } - - return this; -}; - -MemberExpression.prototype.hasCallExpression = () -> { - return this.object.__null_propagating || - this.object?.hasCallExpression?() || - this.property?.hasCallExpression(); -}; - -exports.MemberExpression = MemberExpression; \ No newline at end of file diff --git a/src/ast/expressions/NewExpression.spider b/src/ast/expressions/NewExpression.spider deleted file mode 100644 index a992d6e..0000000 --- a/src/ast/expressions/NewExpression.spider +++ /dev/null @@ -1,40 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn NewExpression(callee, args) - extends Node { - - this.type = 'NewExpression'; - - this.callee = callee; - this.callee.parent = this; - - ::Object.defineProperty(this, 'arguments', { - value: args, - enumerable: true - }); - - for arg in args { - arg.parent = this; - } -} - -NewExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.callee = this.callee.codegen(); - - var args = this.arguments; - for arg, i in args { - args[i] = arg.codegen(); - } - - return this; -}; - -NewExpression.prototype.hasCallExpression = () -> true; - -exports.NewExpression = NewExpression; \ No newline at end of file diff --git a/src/ast/expressions/NullCheckCallExpression.spider b/src/ast/expressions/NullCheckCallExpression.spider deleted file mode 100644 index c5bac10..0000000 --- a/src/ast/expressions/NullCheckCallExpression.spider +++ /dev/null @@ -1,151 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node, - CallExpression = module.require('./CallExpression').CallExpression; - -fn NullCheckCallExpression(callee, args) - extends Node { - - this.type = 'NullCheckCallExpression'; - - this.callee = callee; - this.callee.parent = this; - - this.args = args; - - for arg in args { - arg.parent = this; - } -} - -NullCheckCallExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var calleeType = this.callee.type; - - this.callee = this.callee.codegen(); - - var args = this.args; - for arg, i in args { - var isSplat = args[i].type == "SplatExpression"; - args[i] = arg.codegen(); - args[i].codeGenerated = true; - - if isSplat { - args[i].__splat = true; - } - } - - // If the callee has a function call (e.g: a().b) - // then store its value in a separate variable to avoid - // calling the function twice. - if this.callee.hasCallExpression?() { - var context = this.getContext(); - - var id = { - "type": "Identifier", - "name": NullCheckCallExpression.getNextVariableName(), - "codeGenerated": true - }; - - context.node.body.splice(context.position + - (NullCheckCallExpression.nullCheckIndex - 2), 0, { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": id, - "init": this.callee - } - ], - "kind": "let", - "codeGenerated": true - }); - - this.callee = id; - } - - // Create a basic typeof callee !== "function" check - var test = { - "type": "BinaryExpression", - "operator": "===", - "left": { - "type": "UnaryExpression", - "operator": "typeof", - "argument": this.callee, - "prefix": true - }, - "right": { - "type": "Literal", - "value": "function", - "raw": "\"function\"" - } - }; - - var argument = test.left.argument; - - // If we are null propagating (?.), then make sure to - // add the null propagating condition - if calleeType == 'NullPropagatingExpression' { - argument = argument.consequent; - test.left.argument = argument; - - test = { - "type": "LogicalExpression", - "operator": "&&", - "left": this.callee.test, - "right": test - }; - } - - argument.codeGenerated = true; - var consequent = new CallExpression(argument, args).codegen(); - - if this.parent.type == 'ExpressionStatement' { - this.parent.type = 'IfStatement'; - this.parent.test = test; - this.parent.consequent = { - type: 'BlockStatement', - body: [ - { - type: 'ExpressionStatement', - expression: consequent - } - ] - }; - this.parent.alternate = null; - } else { - this.type = 'ConditionalExpression'; - this.test = test; - this.consequent = consequent; - this.alternate = { - "type": "UnaryExpression", - "operator": "void", - "argument": { - "type": "Literal", - "value": 0, - "raw": "0" - }, - "prefix": true - }; - } - return this; -}; - -NullCheckCallExpression.prototype.hasCallExpression = () -> true; - -NullCheckCallExpression.getNextVariableName = () -> { - if !this.nullCheckIndex? { - this.nullCheckIndex = 0; - } - - return "nullCheck" + this.nullCheckIndex++; -}; - -NullCheckCallExpression.resetVariableNames = () -> { - this.nullCheckIndex = 0; -}; - -exports.NullCheckCallExpression = NullCheckCallExpression; \ No newline at end of file diff --git a/src/ast/expressions/NullCoalescingExpression.spider b/src/ast/expressions/NullCoalescingExpression.spider deleted file mode 100644 index b03315c..0000000 --- a/src/ast/expressions/NullCoalescingExpression.spider +++ /dev/null @@ -1,151 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn NullCoalescingExpression(left, right) - extends Node { - - this.type = 'NullCoalescingExpression'; - - this.left = left; - this.left.parent = this; - - this.right = right; - this.right.parent = this; -} - -NullCoalescingExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var leftType = this.left.type; - - this.left = this.left.codegen(); - this.right = this.right.codegen(); - - var context = this.getContext(); - var addUndefinedCheck = true; - - // If the left expression is a function call (e.g: f() ?? 5) - // then store its value in a separate variable to avoid - // calling the function twice. - if leftType == 'NullPropagatingExpression' || - leftType == 'NullCoalescingExpression' || - this.left.hasCallExpression?() { - - var id = { - "type": "Identifier", - "name": NullCoalescingExpression.getNextLeftName() - }; - - context.node.body.splice(context.position, 0, { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": id, - "init": this.left - } - ], - "kind": "let", - "codeGenerated": true - }); - - this.left = id; - addUndefinedCheck = false; - } - - var test = { - "type": "BinaryExpression", - "operator": "==", - "left": this.left, - "right": { - "type": "Literal", - "value": null, - "raw": "null" - } - }; - - if this.left.type != 'Identifier' { - addUndefinedCheck = false; - } - - if addUndefinedCheck { - test = { - "type": "LogicalExpression", - "operator": "||", - "left": { - "type": "BinaryExpression", - "operator": "===", - "left": { - "type": "UnaryExpression", - "operator": "typeof", - "argument": this.left, - "prefix": true - }, - "right": { - "type": "Literal", - "value": "undefined", - "raw": "'undefined'" - } - }, - "right": test - }; - } - - // If the null coalescing operator is an expression - // statement child, the generated JS should be an if statement. - if this.parent?.type == 'ExpressionStatement' { - - if !this.right.hasCallExpression() { - this.parent.type = 'EmptyStatement'; - return this; - } - - this.parent.type = 'IfStatement'; - this.parent.test = test; - - this.parent.consequent = { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": this.right - } - ] - }; - } else { - // Otherwise - if the null coalescing operator is - // inside an expression, the generated JS should - // look like: - // - // typeof left === 'undefined' || left === null ? right : left - - return { - "type": "ConditionalExpression", - "test": test, - "consequent": this.right, - "alternate": this.left - }; - } -}; - -NullCoalescingExpression.prototype.hasCallExpression = () -> { - return this.left?.hasCallExpression() || - this.right?.hasCallExpression(); -}; - -NullCoalescingExpression.getNextLeftName = () -> { - if (!this.nullCoalescingIndex?) { - this.nullCoalescingIndex = 0; - } - - return "nullCoalescing" + this.nullCoalescingIndex++; -}; - -NullCoalescingExpression.resetVariableNames = () -> { - this.nullCoalescingIndex = 0; -}; - -exports.NullCoalescingExpression = NullCoalescingExpression; \ No newline at end of file diff --git a/src/ast/expressions/NullPropagatingExpression.spider b/src/ast/expressions/NullPropagatingExpression.spider deleted file mode 100644 index a2a18fd..0000000 --- a/src/ast/expressions/NullPropagatingExpression.spider +++ /dev/null @@ -1,190 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn NullPropagatingExpression(left, right) - extends Node { - - this.type = 'NullPropagatingExpression'; - this.computed = false; - - this.object = left; - this.object.parent = this; - - this.property = right; - this.property.parent = this; -} - -NullPropagatingExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var context = this.getContext(); - var childType = this.object.type; - - this.object = this.object.codegen(); - this.property = this.property.codegen(false); - - // If the left expression is a function call (e.g: a()?.b) - // then store its value in a separate variable to avoid - // calling the function twice. - if this.object.hasCallExpression?() { - var id = { - "type": "Identifier", - "name": NullPropagatingExpression.getNextObjectName(), - "__member_expression": { - "type": "MemberExpression", - "object": this.object, - "property": this.property, - "computed": false - }, - }; - - context.node.body.splice(context.position + - (NullPropagatingExpression.nullPropagatingIndex - 1), 0, { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": id, - "init": this.object - } - ], - "kind": "let", - "codeGenerated": true - }); - - this.object = id; - } - - var condition; - - // If this node is the last NullPropagatingExpression in - // the tree, then just create a simple object !== null condition - if childType != 'NullPropagatingExpression' { - condition = { - "type": "BinaryExpression", - "operator": "!==", - "left": this.object, - "right": { - "type": "Literal", - "value": null, - "raw": "null" - }, - "__member_expression": { - "type": "MemberExpression", - "object": this.object, - "property": this.property, - "computed": false - }, - "__first_object": this.object - }; - } else { - // Otherwise create an object !== null condition and add it - // with logical AND to the previous condition - condition = { - "type": 'LogicalExpression', - "operator": '&&', - "left": this.object, - "right": { - "type": "BinaryExpression", - "operator": "!==", - "left": { - "type": "MemberExpression", - "object": this.object.__member_expression.object, - "property": this.object.__member_expression.property, - "computed": false - }, - "right": { - "type": "Literal", - "value": null, - "raw": "null" - }, - }, - "__member_expression": { - "type": "MemberExpression", - "object": this.object.__member_expression, - "property": this.property, - "computed": false - }, - "__first_object": this.object.__first_object - }; - } - - // Return the condition if this isn't the first NullPropagatingExpression - if this.parent?.type == 'NullPropagatingExpression' { - return condition; - } - - // Add typeof object !== undefined check - condition = { - "type": 'LogicalExpression', - "operator": '&&', - "left": { - "type": "BinaryExpression", - "operator": "!==", - "left": { - "type": "UnaryExpression", - "operator": "typeof", - "argument": this.object.__first_object ?? this.object - }, - "right": { - "type": "Literal", - "value": "undefined", - "raw": "\"undefined\"" - }, - }, - "right": condition - }; - - condition = { - "type": "ConditionalExpression", - "test": condition, - "consequent": { - "type": "MemberExpression", - "object": this.object if this.object.type == 'Identifier' || !this.object.__member_expression - else this.object.__member_expression, - "property": this.property, - "computed": false - }, - "alternate": { - "type": "UnaryExpression", - "operator": "void", - "argument": { - "type": "Literal", - "value": 0, - "raw": "0" - }, - "prefix": true - }, - "__null_propagating": true - }; - - return condition; -}; - -NullPropagatingExpression.prototype.hasCallExpression = () -> true; - -NullPropagatingExpression.getNextObjectName = () -> { - if !this.nullPropagatingIndex? { - this.nullPropagatingIndex = 0; - this.definedObjectNames = []; - } - - var name = "nullPropagating" + this.nullPropagatingIndex++; - this.definedObjectNames.push(name); - - return name; -}; - -NullPropagatingExpression.isObjectNameDefined = (name) -> { - return this.definedObjectNames.indexOf(name) != -1; -}; - -NullPropagatingExpression.resetVariableNames = () -> { - this.nullPropagatingIndex = 0; - this.definedObjectNames = []; -}; - -exports.NullPropagatingExpression = NullPropagatingExpression; \ No newline at end of file diff --git a/src/ast/expressions/ObjectExpression.spider b/src/ast/expressions/ObjectExpression.spider deleted file mode 100644 index 8bba549..0000000 --- a/src/ast/expressions/ObjectExpression.spider +++ /dev/null @@ -1,30 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ObjectExpression(properties) - extends Node { - - this.type = 'ObjectExpression'; - this.properties = properties; - - for property in this.properties { - property.parent = this; - } -} - -ObjectExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - for property, i in this.properties { - this.properties[i] = property.codegen(); - } - - return this; -}; - -ObjectExpression.prototype.hasCallExpression = () -> true; - -exports.ObjectExpression = ObjectExpression; \ No newline at end of file diff --git a/src/ast/expressions/ObjectPattern.spider b/src/ast/expressions/ObjectPattern.spider deleted file mode 100644 index 0d2b3d1..0000000 --- a/src/ast/expressions/ObjectPattern.spider +++ /dev/null @@ -1,42 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ObjectPattern(properties) - extends Node { - - this.type = 'ObjectPattern'; - this.properties = properties; - - for property in this.properties { - property.parent = this; - } -} - -ObjectPattern.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var context = this.getContext().node; - for property, i in this.properties { - this.properties[i] = property.codegen(); - - - if property.value? { - if property.value.type == "Identifier" { - context.defineIdentifier(property.value); - } - } else { - if property.key.type == "Identifier" { - context.defineIdentifier(property.key); - } - } - } - - return this; -}; - -ObjectPattern.prototype.hasCallExpression = () -> true; - -exports.ObjectPattern = ObjectPattern; \ No newline at end of file diff --git a/src/ast/expressions/RangeMemberExpression.spider b/src/ast/expressions/RangeMemberExpression.spider deleted file mode 100644 index 74ca447..0000000 --- a/src/ast/expressions/RangeMemberExpression.spider +++ /dev/null @@ -1,179 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn RangeMemberExpression(object, range) - extends Node { - - this.type = 'RangeMemberExpression'; - this.object = object; - this.object.parent = this; - - this.range = range; - this.range.parent = this; -} - -RangeMemberExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var isNumber = (n) -> !::isNaN(::parseFloat(n)) && ::isFinite(n); - - // If this node is the left side of an assignment expression, - // it means we're dealing with splice. For example: - // items[1..2] = [1, 2]; - if this.parent.type == 'AssignmentExpression' && - this.parent.left == this { - this.parent.type = 'CallExpression'; - - this.parent.callee = { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ArrayExpression", - "elements": [] - }, - "property": { - "type": "Identifier", - "name": "splice" - } - }, - "property": { - "type": "Identifier", - "name": "apply" - } - }; - - var to; - var start = this.range.start.codegen() if this.range.start else { - "type": "Literal", - "value": 0 - }; - - if this.range.to? { - if isNumber(start.value) && - isNumber(this.range.to.value) { - to = { - "type": "Literal", - "value": this.range.to.value - start.value + (1 if this.range.operator == '..' else 0) - }; - } else { - to = this.range.to.codegen(); - - if start.value != 0 { - to = { - "type": "BinaryExpression", - "operator": "-", - "left": to, - "right": start, - }; - } - - if this.range.operator == '..' { - to = { - "type": "BinaryExpression", - "operator": "+", - "left": to, - "right": { - "type": "Literal", - "value": 1 - } - }; - } - } - } else { - to = { - "type": "Literal", - "value": 9000000000, - "raw": "9e9" - }; - } - - ::Object.defineProperty(this.parent, 'arguments', { - value: [ - this.object.codegen(), - { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ArrayExpression", - "elements": [start, to] - }, - "property": { - "type": "Identifier", - "name": "concat" - } - }, - "arguments": [ - this.parent.right - ] - } - ], - enumerable: true - }); - } else { - // Otherwise, we're dealing with slice. For example: - // var x = items[1..2]; - this.type = "CallExpression"; - this.callee = { - "type": "MemberExpression", - "computed": false, - "object": this.object.codegen(), - "property": { - "type": "Identifier", - "name": "slice" - } - }; - - var args = []; - - if !this.range.start? { - args.push({ - "type": "Literal", - "value": 0 - }); - } else { - args.push(this.range.start.codegen()); - } - - if this.range.to? { - if this.range.operator == '...' { - args.push(this.range.to.codegen()); - } else { - if this.range.to.value && isNumber(this.range.to.value) { - args.push({ - "type": "Literal", - "value": this.range.to.value + 1 - }); - } else { - args.push({ - "type": "BinaryExpression", - "operator": "+", - "left": this.range.to.codegen(), - "right": { - "type": "Literal", - "value": 1 - } - }); - } - } - } - - ::Object.defineProperty(this, 'arguments', { - value: args, - enumerable: true - }); - } - - return this; -}; - -RangeMemberExpression.prototype.hasCallExpression = () -> true; - -exports.RangeMemberExpression = RangeMemberExpression; \ No newline at end of file diff --git a/src/ast/expressions/SplatExpression.spider b/src/ast/expressions/SplatExpression.spider deleted file mode 100644 index 822cf9e..0000000 --- a/src/ast/expressions/SplatExpression.spider +++ /dev/null @@ -1,49 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn SplatExpression(expression) - extends Node { - - this.type = 'SplatExpression'; - - this.expression = expression; - this.expression.parent = this; -} - -SplatExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.expression = this.expression.codegen(); - - return { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ArrayExpression", - "elements": [] - }, - "property": { - "type": "Identifier", - "name": "slice" - } - }, - "property": { - "type": "Identifier", - "name": "call" - } - }, - "arguments": [this.expression] - }; -}; - -SplatExpression.prototype.hasCallExpression = () -> true; - -exports.SplatExpression = SplatExpression; \ No newline at end of file diff --git a/src/ast/expressions/SuperExpression.spider b/src/ast/expressions/SuperExpression.spider deleted file mode 100644 index 95bbdd9..0000000 --- a/src/ast/expressions/SuperExpression.spider +++ /dev/null @@ -1,235 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; -var extend = require('util')._extend; - -fn SuperExpression() - extends Node { - - this.type = 'SuperExpression'; -} - -SuperExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - // Raise an error if we are getting a syntax - // such as: super?.test - if this.parent.type == 'NullPropagatingExpression' { - Node.getErrorManager().error({ - type: "InvalidSuperReference", - message: "cannot refer to super before the ?. operator", - loc: this.loc - }); - - return { type: 'ThisExpression' }; - } - - // The only supported use case for super is - // member expression (e.g: super.x) - if this.parent.type != 'MemberExpression' { - Node.getErrorManager().error({ - type: "InvalidUsageForSuper", - message: "invalid usage of super keyword", - loc: this.loc - }); - - return { type: 'ThisExpression' }; - } - - // Find a parent function that extends another function - // (has the extends keyword) or a prototype assignment - var parentNode = this; - var node = this; - while (node && !node.inheritsFrom && - (node.type != 'AssignmentExpression' || ((!node.left.property || node.left.property.name != 'prototype') && - (!node.left.object.property || node.left.object.property.name != 'prototype')))) { - parentNode = node; - node = node.parent; - } - - // Raise an error if there's no parent function - if !node { - Node.getErrorManager().error({ - type: "InvalidContextForSuper", - message: "invalid context for super keyword", - loc: this.loc - }); - - return { type: 'ThisExpression' }; - } - - // Add _self variable to a context. - var addSelf = (context) -> { - var selfId = { - "type": "Identifier", - "name": "_self", - "codeGenerated": "true" - }; - - if (!context.node.__isSelfDefined) { - context.node.body.splice(0, 0, { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": selfId, - "init": { - type: "ThisExpression" - } - }], - "kind": "let" - }); - - context.node.__isSelfDefined = true; - } - - return selfId; - }; - - // Modify the call expression to look like: - // _fn.call(_self) - var mutateCallExpression = (id, parent, selfNode) -> { - selfNode.codeGenerated = true; - - parent.object = id; - parent.property = ::Object.create({ - "codeGenerated": "true", - "type": "Identifier", - "name": "call" - }); - - parent.parent.arguments.splice(0, 0, selfNode); - }; - - // If we are inside a prototype function, change - // something like: super.x() to Base.prototype.x.call(_self); - if node.type == 'AssignmentExpression' { - var identifier = node.left.object; - var context; - - if node.left.property.name != 'prototype' { - identifier = identifier.object; - context = { node: node.right.body }; - } else { - // Make sure that the syntax is something like: - // Fn.prototype = { ... } - if node.right.type != 'ObjectExpression' { - Node.getErrorManager().error({ - type: "InvalidUsageForSuper", - message: "invalid usage of super keyword", - loc: this.loc - }); - - return { type: 'ThisExpression' }; - } - - var contextNode = this; - while (contextNode.parent? && contextNode.parent != node.right) { - contextNode = contextNode.parent; - } - - // Make sure that the syntax is something like: - // Fn.prototype = { test: fn () { ... } } - if contextNode?.type != 'Property' || - contextNode?.value?.type != 'FunctionExpression' { - Node.getErrorManager().error({ - type: "InvalidUsageForSuper", - message: "invalid usage of super keyword", - loc: this.loc - }); - - return { type: 'ThisExpression' }; - } - - context = { node: contextNode.value.body }; - } - - var selfNode; - if context.node == this.getContext().node { - selfNode = { type: 'ThisExpression' }; - } else { - selfNode = addSelf(context); - } - - // If this is a call expression, e.g: super.test(), - // Turn this into Base.prototype.test.call(_self) - if this.parent.parent.type == 'CallExpression' { - var memberExpression = { - type: 'MemberExpression', - computed: false, - object: { - type: 'MemberExpression', - computed: false, - object: this.parent.getDefinedIdentifier(identifier.name).parent.inheritsFrom.callee, - property: { - type: 'Identifier', - name: 'prototype' - } - }, - property: this.parent.parent.callee.property - }; - - mutateCallExpression(memberExpression, this.parent, selfNode); - return memberExpression; - } - - // Otherwise, just return (this|_self).property - return selfNode; - } - - var superContext = parentNode.getContext(); - - // Find the most left side in the member expression - // For super.a.b.c.d, the most left side would be super - var lastObject = this.parent; - while (lastObject.object.type == 'MemberExpression') { - lastObject = lastObject.object; - } - - // Change it to a this expression - lastObject.object = { - type: 'ThisExpression' - }; - - var id = { - "type": "Identifier", - "name": "_" + this.parent.property.name - }; - - // Declare a new variable in the function that extends - // with a reference to our property - if !this.parent.isIdentifierDefined(id.name) { - superContext.node.body.splice(superContext.position, 0, { - "codeGenerated": "true", - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": id, - "init": extend({}, lastObject) - }], - "kind": "let" - }); - - superContext.node.defineIdentifier(id); - } - - // If we are in a call expression, change it to: - // _fn.call(_self) - if this.parent.parent.type == 'CallExpression' { - mutateCallExpression(id, this.parent, addSelf(superContext)); - } else { - // Otherwise, just refer to the variable - this.parent.type = 'Identifier'; - ::Object.defineProperty(this.parent, 'name', { - value: id.name, - enumerable: true - }); - } - - return id; -}; - -SuperExpression.prototype.hasCallExpression = () -> false; - -exports.SuperExpression = SuperExpression; \ No newline at end of file diff --git a/src/ast/expressions/ThisExpression.spider b/src/ast/expressions/ThisExpression.spider deleted file mode 100644 index e3a2f69..0000000 --- a/src/ast/expressions/ThisExpression.spider +++ /dev/null @@ -1,21 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ThisExpression() - extends Node { - - this.type = 'ThisExpression'; -} - -ThisExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - return this; -}; - -ThisExpression.prototype.hasCallExpression = () -> false; - -exports.ThisExpression = ThisExpression; \ No newline at end of file diff --git a/src/ast/expressions/UnaryExpression.spider b/src/ast/expressions/UnaryExpression.spider deleted file mode 100644 index 7fb6d00..0000000 --- a/src/ast/expressions/UnaryExpression.spider +++ /dev/null @@ -1,158 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn UnaryExpression(operator, argument) - extends Node { - - this.type = 'UnaryExpression'; - this.operator = operator; - this.argument = argument; - this.argument.parent = this; - this.prefix = true; -} - -UnaryExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.argument = this.argument.codegen(); - - // typeof operator should compile to: - // ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase() - if (this.operator == 'typeof') { - var typeofExpression = { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "MemberExpression", - "computed": true, - "object": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "ObjectExpression", - "properties": [] - }, - "property": { - "type": "Identifier", - "name": "toString" - } - }, - "property": { - "type": "Identifier", - "name": "call" - } - }, - "arguments": [this.argument] - }, - "property": { - "type": "Identifier", - "name": "match" - } - }, - "arguments": [{ - "type": "Literal", - "value": new ::RegExp("\\s([a-zA-Z]+)") - }] - }, - "property": { - "type": "Literal", - "value": 1, - "raw": "1" - } - }, - "property": { - "type": "Identifier", - "name": "toLowerCase" - } - }, - "arguments": [] - }; - - if !this.argument.hasCallExpression() { - this.type = "ConditionalExpression"; - this.test = { - "type": "BinaryExpression", - "operator": "===", - "left": { - "type": "UnaryExpression", - "operator": "typeof", - "argument": this.argument, - "prefix": true - }, - "right": { - "type": "Literal", - "value": "undefined", - "raw": "'undefined'" - } - }; - - this.consequent = { - "type": "Literal", - "value": "undefined" - }; - - this.alternate = typeofExpression; - } else { - this.type = typeofExpression.type; - this.callee = typeofExpression.callee; - ::Object.defineProperty(this, 'arguments', { - value: typeofExpression.arguments, - enumerable: true - }); - } - } else if this.operator == "<-" { - var parent = this.parent; - while parent? and parent.type != "FunctionExpression" and parent.type != "GoStatement" { - parent = parent.parent; - } - - if not parent? or - (parent.type != "GoStatement" and - (parent.parent.type != "UnaryExpression" or - parent.parent.operator != "async")) { - Node.getErrorManager().error({ - type: "GetExpressionRequiresAsync", - message: "unary <- must be in a go statement or an async function", - loc: this.loc - }); - } - - this.operator = "await"; - this.argument = { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": this.argument, - "property": { - "type": "Identifier", - "name": "get" - }, - "computed": false - }, - "arguments": [] - }; - } - - return this; -}; - -UnaryExpression.prototype.hasCallExpression = () -> { - return this.argument?.hasCallExpression(); -}; - -exports.UnaryExpression = UnaryExpression; \ No newline at end of file diff --git a/src/ast/expressions/UpdateExpression.spider b/src/ast/expressions/UpdateExpression.spider deleted file mode 100644 index 4cb8a84..0000000 --- a/src/ast/expressions/UpdateExpression.spider +++ /dev/null @@ -1,28 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn UpdateExpression(argument, operator, prefix) - extends Node { - - this.type = 'UpdateExpression'; - this.operator = operator; - this.prefix = prefix; - - this.argument = argument; - this.argument.parent = this; -} - -UpdateExpression.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - return this; -}; - -UpdateExpression.prototype.hasCallExpression = () -> { - return this.argument != null && this.left.hasCallExpression(); -}; - -exports.UpdateExpression = UpdateExpression; \ No newline at end of file diff --git a/src/ast/literals/BooleanLiteral.spider b/src/ast/literals/BooleanLiteral.spider deleted file mode 100644 index c43093d..0000000 --- a/src/ast/literals/BooleanLiteral.spider +++ /dev/null @@ -1,23 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn BooleanLiteral(text) - extends Node { - - this.type = 'Literal'; - this.value = text == "true"; - this.raw = text; -} - -BooleanLiteral.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - return this; -}; - -BooleanLiteral.prototype.hasCallExpression = () -> false; - -exports.BooleanLiteral = BooleanLiteral; \ No newline at end of file diff --git a/src/ast/literals/Identifier.spider b/src/ast/literals/Identifier.spider deleted file mode 100644 index 9069f9d..0000000 --- a/src/ast/literals/Identifier.spider +++ /dev/null @@ -1,68 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn Identifier(name) - extends Node { - - this.type = 'Identifier'; - this.global = false; - - ::Object.defineProperty(this, 'name', { - value: name, - enumerable: true - }); -} - -Identifier.prototype.codegen = (undefinedCheck = true) -> { - if !super.codegen() { - return; - } - - // Compile-time undefined check - if (undefinedCheck && !this.global) { - // If this is not a new identifier, ... - if !(this.parent?.type in ["FunctionDeclaration", "VariableDeclarator"] && - this.parent.id == this) { - // ... and this identifier is undefined, raise an error - if (!this.parent.isIdentifierDefined(this.name)) { - Node.getErrorManager().error({ - type: "UndefinedIdentifier", - identifier: this.name, - message: "undefined " + this.name, - loc: this.loc - }); - } - } else { - // If this is a new identifier, and this identifier - // is already defined, raise an error - if (this.parent.isIdentifierDefined(this.name)) { - Node.getErrorManager().error({ - type: "AlreadyDefinedIdentifier", - identifier: this.name, - message: this.name + " is already defined", - loc: this.loc - }); - } else { - // otherwise, define this identifier - this.parent.getContext().node.defineIdentifier(this); - } - } - } - - return this; -}; - -Identifier.prototype.hasCallExpression = () -> false; - -Identifier.prototype.asGlobal = () -> { - this.global = true; - return this; -}; - -Identifier.prototype.asPredefinedCollection = () -> { - this.predefinedCollection = true; - return this; -}; - -exports.Identifier = Identifier; \ No newline at end of file diff --git a/src/ast/literals/NullLiteral.spider b/src/ast/literals/NullLiteral.spider deleted file mode 100644 index a145e94..0000000 --- a/src/ast/literals/NullLiteral.spider +++ /dev/null @@ -1,23 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn NullLiteral() - extends Node { - - this.type = 'Literal'; - this.value = null; - this.raw = "null"; -} - -NullLiteral.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - return this; -}; - -NullLiteral.prototype.hasCallExpression = () -> false; - -exports.NullLiteral = NullLiteral; \ No newline at end of file diff --git a/src/ast/literals/NumberLiteral.spider b/src/ast/literals/NumberLiteral.spider deleted file mode 100644 index 27d9933..0000000 --- a/src/ast/literals/NumberLiteral.spider +++ /dev/null @@ -1,23 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn NumberLiteral(text) - extends Node { - - this.type = 'Literal'; - this.value = ::Number(text); - this.raw = text; -} - -NumberLiteral.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - return this; -}; - -NumberLiteral.prototype.hasCallExpression = () -> false; - -exports.NumberLiteral = NumberLiteral; \ No newline at end of file diff --git a/src/ast/literals/RegularExpressionLiteral.spider b/src/ast/literals/RegularExpressionLiteral.spider deleted file mode 100644 index c92c366..0000000 --- a/src/ast/literals/RegularExpressionLiteral.spider +++ /dev/null @@ -1,24 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn RegularExpressionLiteral(pattern, flags) - extends Node { - - this.type = 'Literal'; - this.pattern = pattern; - this.flags = flags; -} - -RegularExpressionLiteral.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.value = new ::RegExp(this.pattern, this.flags); - return this; -}; - -RegularExpressionLiteral.prototype.hasCallExpression = () -> false; - -exports.RegularExpressionLiteral = RegularExpressionLiteral; \ No newline at end of file diff --git a/src/ast/literals/StringLiteral.spider b/src/ast/literals/StringLiteral.spider deleted file mode 100644 index dd57382..0000000 --- a/src/ast/literals/StringLiteral.spider +++ /dev/null @@ -1,91 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn StringLiteral(chars, column) - extends Node { - - this.type = 'StringLiteral'; - this.chars = chars; - this.column = column; -} - -StringLiteral.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var elements = []; - - for value in this.chars { - var lastElement; - - if typeof value == 'string' { - lastElement = elements[elements.length - 1]; - if lastElement?.type == 'Literal' { - lastElement.value += value; - } else { - elements.push({ - type: 'Literal', - value: value - }); - } - } else if value?.type == "StringLiteralNewLine" { - lastElement = elements[elements.length - 1]; - if lastElement?.type == 'Literal' { - lastElement.value += value.toString(this.column - 1); - } else { - elements.push({ - type: 'Literal', - value: value.toString(this.column - 1) - }); - } - } else { - value.parent = this; - elements.push(value.codegen()); - } - } - - if elements.length == 0 { - return { - "type": "Literal", - "value": "" - }; - } else if elements.length == 1 { - return elements[0]; - } - - var reduced = elements.reduce((left, right) -> { - return { - type: 'BinaryExpression', - operator: '+', - left: left, - right: right - }; - }); - - this.type = reduced.type; - this.operator = reduced.operator; - this.left = reduced.left; - this.right = reduced.right; - - return this; -}; - -StringLiteral.prototype.hasCallExpression = () -> false; - -StringLiteral.NewLine = fn (text) { - this.type = "StringLiteralNewLine"; - - this.toString = (column) -> { - var t = text.replace(/\r\n/g, '').replace(/\t/g, ' '); - - if t.length < column { - return ''; - } - - return t.substring(column); - }; -}; - -exports.StringLiteral = StringLiteral; \ No newline at end of file diff --git a/src/ast/literals/UndefinedLiteral.spider b/src/ast/literals/UndefinedLiteral.spider deleted file mode 100644 index f1a04fe..0000000 --- a/src/ast/literals/UndefinedLiteral.spider +++ /dev/null @@ -1,30 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn UndefinedLiteral() - extends Node { - - this.type = 'UndefinedLiteral'; -} - -UndefinedLiteral.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.type = "UnaryExpression"; - this.operator = "void"; - this.argument = { - "type": "Literal", - "value": 0, - "raw": "0" - }; - this.prefix = true; - - return this; -}; - -UndefinedLiteral.prototype.hasCallExpression = () -> false; - -exports.UndefinedLiteral = UndefinedLiteral; \ No newline at end of file diff --git a/src/ast/statements/BlockStatement.spider b/src/ast/statements/BlockStatement.spider deleted file mode 100644 index e8db413..0000000 --- a/src/ast/statements/BlockStatement.spider +++ /dev/null @@ -1,45 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn BlockStatement(body) - extends Node { - - this.type = 'BlockStatement'; - this.body = body; - - for statement, i in body { - if statement { - statement.parent = this; - } else { - body[i] = { type: 'EmptyStatement' }; - } - } -} - -BlockStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var i = 0; - while (i < this.body.length) { - var statement = this.body[i]; - - if !statement || statement.codeGenerated { - i++; - continue; - } - - if statement.codegen?() { - this.body[this.body.indexOf(statement)] = statement; - i++; - } else { - this.body.splice(i, 1); - } - } - - return this; -}; - -exports.BlockStatement = BlockStatement; \ No newline at end of file diff --git a/src/ast/statements/BreakStatement.spider b/src/ast/statements/BreakStatement.spider deleted file mode 100644 index cac4362..0000000 --- a/src/ast/statements/BreakStatement.spider +++ /dev/null @@ -1,19 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn BreakStatement() - extends Node { - - this.type = 'BreakStatement'; -} - -BreakStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - return this; -}; - -exports.BreakStatement = BreakStatement; \ No newline at end of file diff --git a/src/ast/statements/ContinueStatement.spider b/src/ast/statements/ContinueStatement.spider deleted file mode 100644 index 3927eee..0000000 --- a/src/ast/statements/ContinueStatement.spider +++ /dev/null @@ -1,19 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ContinueStatement() - extends Node { - - this.type = 'ContinueStatement'; -} - -ContinueStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - return this; -}; - -exports.ContinueStatement = ContinueStatement; \ No newline at end of file diff --git a/src/ast/statements/DebuggerStatement.spider b/src/ast/statements/DebuggerStatement.spider deleted file mode 100644 index 890cf59..0000000 --- a/src/ast/statements/DebuggerStatement.spider +++ /dev/null @@ -1,19 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn DebuggerStatement() - extends Node { - - this.type = 'DebuggerStatement'; -} - -DebuggerStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - return this; -}; - -exports.DebuggerStatement = DebuggerStatement; \ No newline at end of file diff --git a/src/ast/statements/DoWhileStatement.spider b/src/ast/statements/DoWhileStatement.spider deleted file mode 100644 index f4b7e91..0000000 --- a/src/ast/statements/DoWhileStatement.spider +++ /dev/null @@ -1,28 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn DoWhileStatement(test, body) - extends Node { - - this.type = 'DoWhileStatement'; - - this.test = test; - this.test.parent = this; - - this.body = body; - this.body.parent = this; -} - -DoWhileStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.test = this.test.codegen(); - this.body = this.body.blockWrap().codegen(); - - return this; -}; - -exports.DoWhileStatement = DoWhileStatement; \ No newline at end of file diff --git a/src/ast/statements/ExportDeclarationStatement.spider b/src/ast/statements/ExportDeclarationStatement.spider deleted file mode 100644 index 7d9d797..0000000 --- a/src/ast/statements/ExportDeclarationStatement.spider +++ /dev/null @@ -1,46 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ExportDeclarationStatement(specifiers, source, declaration, isDefault) - extends Node { - - this.type = "ExportDeclaration"; - this['default'] = isDefault; - - this.specifiers = specifiers; - if specifiers? { - for specifier in this.specifiers { - specifier.parent = this; - } - } - - this.source = source; - if source? { - this.source.parent = this; - } - - this.declaration = declaration; - if declaration? { - this.declaration.parent = this; - } -} - -ExportDeclarationStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - if this.specifiers? { - for specifier, i in this.specifiers { - this.specifiers[i] = specifier.codegen(); - } - } - - this.source = this.source?.codegen(); - this.declaration = this.declaration?.codegen(); - - return this; -}; - -exports.ExportDeclarationStatement = ExportDeclarationStatement; \ No newline at end of file diff --git a/src/ast/statements/ExpressionStatement.spider b/src/ast/statements/ExpressionStatement.spider deleted file mode 100644 index 15b4c2b..0000000 --- a/src/ast/statements/ExpressionStatement.spider +++ /dev/null @@ -1,22 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ExpressionStatement(expression) - extends Node { - - this.type = 'ExpressionStatement'; - this.expression = expression; - this.expression.parent = this; -} - -ExpressionStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.expression = this.expression.codegen(); - return this; -}; - -exports.ExpressionStatement = ExpressionStatement; \ No newline at end of file diff --git a/src/ast/statements/FallthroughStatement.spider b/src/ast/statements/FallthroughStatement.spider deleted file mode 100644 index 767b813..0000000 --- a/src/ast/statements/FallthroughStatement.spider +++ /dev/null @@ -1,85 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn FallthroughStatement() - extends Node { - - this.type = 'FallthroughStatement'; -} - -FallthroughStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var parent = this.parent; - var iterations = 0; - - while parent? and !parent.switchCase { - parent = parent.parent; - iterations++; - } - - if parent? { - parent.fallthrough = true; - } else { - Node.getErrorManager().error({ - type: "InvalidFallthroughContext", - message: "fallthrough statement is only allowed in a switch case clause.", - loc: this.loc - }); - } - - var switchStatement = parent.parent; - - if !switchStatement.fallthroughId { - switchStatement.fallthroughId = { - "type": "Identifier", - "name": FallthroughStatement.getNextVariableName() - }; - } - - switchStatement.branchFallthrough = true; - - parent.body.body = [{ - "type": "ExpressionStatement", - "codeGenerated": true, - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": switchStatement.fallthroughId, - "right": { - "type": "Literal", - "value": 2 - } - } - }].concat(parent.body.body); - - this.type = "ExpressionStatement"; - this.expression = { - "type": "AssignmentExpression", - "operator": "=", - "left": switchStatement.fallthroughId, - "right": { - "type": "Literal", - "value": 1 - } - }; - - return this; -}; - -FallthroughStatement.getNextVariableName = () -> { - if (!this.fallthroughIndex?) { - this.fallthroughIndex = 0; - } - - return "fallthrough" + this.fallthroughIndex++; -}; - -FallthroughStatement.resetVariableNames = () -> { - this.fallthroughIndex = 0; -}; - -exports.FallthroughStatement = FallthroughStatement; \ No newline at end of file diff --git a/src/ast/statements/ForInStatement.spider b/src/ast/statements/ForInStatement.spider deleted file mode 100644 index 29b6620..0000000 --- a/src/ast/statements/ForInStatement.spider +++ /dev/null @@ -1,92 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ForInStatement(item, index, array, body) - extends Node { - - this.type = 'ForInStatement'; - - this.item = item; - this.item.parent = this; - - this.index = index; - if this.index? { - this.index.parent = this; - } - - this.array = array; - this.array.parent = this; - - this.body = body; - this.body.parent = this; -} - -ForInStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.item = this.item.codegen(false); - - if this.index? { - var context = this.getContext(); - this.index = this.index.codegen(false); - - context.node.body.splice(context.position, 0, { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": this.index, - "init": { - "type": "Literal", - "value": 0 - } - }], - "kind": "let" - }); - } - - if !this.array.codeGenerated { - this.array = this.array.codegen(); - } - - this.body = this.body.blockWrap(); - this.body.defineIdentifier(this.item); - - if this.index? { - this.body.defineIdentifier(this.index); - } - - this.body = this.body.codegen(); - - if this.index? { - this.body.body.push({ - "type": "ExpressionStatement", - "codeGenerated": true, - "expression": { - "type": "UpdateExpression", - "operator": "++", - "argument": this.index, - "prefix": false - } - }); - } - - this.type = "ForOfStatement"; - this.right = this.array; - this.left = { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": this.item, - "init": null - }], - "kind": "let" - }; - this.each = false; - - return this; -}; - -exports.ForInStatement = ForInStatement; \ No newline at end of file diff --git a/src/ast/statements/ForOfStatement.spider b/src/ast/statements/ForOfStatement.spider deleted file mode 100644 index 106e6a2..0000000 --- a/src/ast/statements/ForOfStatement.spider +++ /dev/null @@ -1,117 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node, - ForInStatement = module.require('./ForInStatement').ForInStatement; - -fn ForOfStatement(key, value, object, body) - extends Node { - - this.type = 'ForOfStatement'; - - this.key = key; - this.key.parent = this; - - this.value = value; - if this.value? { - this.value.parent = this; - } - - this.object = object; - this.object.parent = this; - - this.body = body; - this.body.parent = this; -} - -ForOfStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.object = this.object.codegen(); - - if this.value? { - this.value = this.value.codegen(false); - this.body.defineIdentifier(this.value); - - if this.object.hasCallExpression() { - var id = { - "type": "Identifier", - "name": exports.ForOfStatement.getNextVariableName() - }; - - var context = this.getContext(); - context.node.body.splice(context.position, 0, { - "type": "VariableDeclaration", - "declarations": [{ - "type": "VariableDeclarator", - "id": id, - "init": this.object - }], - "kind": "let", - "codeGenerated": true - }); - - this.object = id; - } - - this.body.body = [{ - "type": "VariableDeclaration", - "codeGenerated": true, - "declarations": [{ - "type": "VariableDeclarator", - "id": this.value, - "init": { - "type": "MemberExpression", - "computed": "true", - "object": this.object, - "property": this.key - } - }], - "kind": "let", - }].concat(this.body.body); - } - - var forInLoop = (new ForInStatement(this.key, - null, - { - "type": "CallExpression", - "codeGenerated": true, - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "Object" - }, - "property": { - "type": "Identifier", - "name": "keys" - } - }, - "arguments": [this.object] - }, - this.body - )).codegen(); - - this.type = forInLoop.type; - this.right = forInLoop.right; - this.left = forInLoop.left; - this.each = forInLoop.each; - - return this; -}; - -ForOfStatement.getNextVariableName = () -> { - if (!this.forOfIndex) { - this.forOfIndex = 0; - } - - return "forOf" + this.forOfIndex++; -}; - -ForOfStatement.resetVariableNames = () -> { - this.forOfIndex = 0; -}; - -exports.ForOfStatement = ForOfStatement; \ No newline at end of file diff --git a/src/ast/statements/ForStatement.spider b/src/ast/statements/ForStatement.spider deleted file mode 100644 index d2c2eec..0000000 --- a/src/ast/statements/ForStatement.spider +++ /dev/null @@ -1,51 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ForStatement(init, test, update, body) - extends Node { - - this.type = 'ForStatement'; - - this.init = init; - if this.init? { - this.init.parent = this; - } - - this.test = test; - if this.test? { - this.test.parent = this; - } - - this.update = update; - if this.update? { - this.update.parent = this; - } - - this.body = body; - this.body.parent = this; -} - -ForStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - if this.init? { - this.init = this.init.codegen(); - } - - if this.test? { - this.test = this.test.codegen(); - } - - if this.update? { - this.update = this.update.codegen(); - } - - this.body = this.body.blockWrap().codegen(); - - return this; -}; - -exports.ForStatement = ForStatement; \ No newline at end of file diff --git a/src/ast/statements/FunctionDeclarationStatement.spider b/src/ast/statements/FunctionDeclarationStatement.spider deleted file mode 100644 index 0903d1c..0000000 --- a/src/ast/statements/FunctionDeclarationStatement.spider +++ /dev/null @@ -1,115 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node, - Parameter = module.require('../Parameter').Parameter, - CallExpression = module.require('../expressions/CallExpression').CallExpression; - -fn FunctionDeclarationStatement(id, params, body, inheritsFrom) - extends Node { - - this.type = 'FunctionDeclaration'; - this.defaults = []; - this.rest = null; - this.generator = false; - this.expression = false; - - this.id = id; - this.id.parent = this; - - this.body = body; - this.body.parent = this; - - this.params = params; - - for param in params { - param.parent = this; - } - - this.inheritsFrom = inheritsFrom; - - if this.inheritsFrom? { - this.inheritsFrom.parent = this; - } -} - -FunctionDeclarationStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.id = this.id.codegen(); - Parameter.generateFunctionBody(this, this.params, this.body, this.defaults); - - this.body = this.body.codegen(); - - if this.inheritsFrom? { - if this.inheritsFrom.type != 'CallExpression' { - this.inheritsFrom = new CallExpression(this.inheritsFrom, []); - this.inheritsFrom.parent = this; - } - - this.inheritsFrom = this.inheritsFrom.codegen(); - - this.body.body.splice(0, 0, { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": this.inheritsFrom.callee, - "property": { - "type": "Identifier", - "name": "call" - } - }, - "arguments": [ - { "type": "ThisExpression" } - ].concat(this.inheritsFrom.arguments) - } - }); - - var context = this.getContext(); - context.node.body.splice(context.position + 1, 0, { - "type": "ExpressionStatement", - "codeGenerated": "true", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "computed": false, - "object": this.id, - "property": { - "type": "Identifier", - "name": "prototype" - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "Object" - }, - "property": { - "type": "Identifier", - "name": "create" - } - }, - "arguments": [ - this.inheritsFrom.callee - ] - } - } - }); - } - - return this; -}; - -FunctionDeclarationStatement.prototype.hasCallExpression = () -> true; - -exports.FunctionDeclarationStatement = FunctionDeclarationStatement; \ No newline at end of file diff --git a/src/ast/statements/GoStatement.spider b/src/ast/statements/GoStatement.spider deleted file mode 100644 index 9727f84..0000000 --- a/src/ast/statements/GoStatement.spider +++ /dev/null @@ -1,44 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn GoStatement(body) - extends Node { - - this.type = 'GoStatement'; - - this.body = body; - this.body.parent = this; -} - -GoStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.body = this.body.codegen(); - - this.type = "ExpressionStatement"; - this.expression = { - "type": "CallExpression", - "callee": { - "type": "UnaryExpression", - "operator": "async", - "argument": { - "type": "FunctionExpression", - "id": null, - "params": [], - "defaults": [], - "body": this.body, - "rest": null, - "generator": false, - "expression": false - } - }, - "arguments": [] - }; - - return this; -}; - -exports.GoStatement = GoStatement; \ No newline at end of file diff --git a/src/ast/statements/IfStatement.spider b/src/ast/statements/IfStatement.spider deleted file mode 100644 index 6f5e5ba..0000000 --- a/src/ast/statements/IfStatement.spider +++ /dev/null @@ -1,38 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn IfStatement(test, consequent, alternate) - extends Node { - - this.type = 'IfStatement'; - - this.test = test; - this.test.parent = this; - - this.consequent = consequent; - this.consequent.parent = this; - - this.alternate = alternate; - - if this.alternate? { - this.alternate.parent = this; - } -} - -IfStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.test = this.test.codegen(); - this.consequent = this.consequent.blockWrap().codegen(); - - if this.alternate? { - this.alternate = this.alternate.blockWrap().codegen(); - } - - return this; -}; - -exports.IfStatement = IfStatement; \ No newline at end of file diff --git a/src/ast/statements/ImportDeclarationStatement.spider b/src/ast/statements/ImportDeclarationStatement.spider deleted file mode 100644 index 7d9f426..0000000 --- a/src/ast/statements/ImportDeclarationStatement.spider +++ /dev/null @@ -1,33 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ImportDeclarationStatement(specifiers, source, kind) - extends Node { - - this.type = "ImportDeclaration"; - this.kind = kind; - - this.specifiers = specifiers; - for specifier in this.specifiers { - specifier.parent = this; - } - - this.source = source; - this.source.parent = this; -} - -ImportDeclarationStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - for specifier, i in this.specifiers { - this.specifiers[i] = specifier.codegen(); - } - - this.source = this.source.codegen(); - return this; -}; - -exports.ImportDeclarationStatement = ImportDeclarationStatement; \ No newline at end of file diff --git a/src/ast/statements/PushStatement.spider b/src/ast/statements/PushStatement.spider deleted file mode 100644 index 56719bc..0000000 --- a/src/ast/statements/PushStatement.spider +++ /dev/null @@ -1,40 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn PushStatement(left, right) - extends Node { - - this.type = 'PushStatement'; - - this.left = left; - this.left.parent = this; - - this.right = right; - this.right.parent = this; -} - -PushStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.type = "ExpressionStatement"; - this.expression = { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": this.left.codegen(), - "property": { - "type": "Identifier", - "name": "push" - }, - "computed": false - }, - "arguments": [this.right.codegen()] - }; - - return this; -}; - -exports.PushStatement = PushStatement; \ No newline at end of file diff --git a/src/ast/statements/ReturnStatement.spider b/src/ast/statements/ReturnStatement.spider deleted file mode 100644 index 6fe3664..0000000 --- a/src/ast/statements/ReturnStatement.spider +++ /dev/null @@ -1,28 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ReturnStatement(argument) - extends Node { - - this.type = 'ReturnStatement'; - this.argument = argument; - - if this.argument? { - this.argument.parent = this; - } -} - -ReturnStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - if this.argument? { - this.argument = this.argument.codegen(); - } - - return this; -}; - -exports.ReturnStatement = ReturnStatement; \ No newline at end of file diff --git a/src/ast/statements/SwitchStatement.spider b/src/ast/statements/SwitchStatement.spider deleted file mode 100644 index 06da54c..0000000 --- a/src/ast/statements/SwitchStatement.spider +++ /dev/null @@ -1,161 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn SwitchStatement(discriminant, cases) - extends Node { - - this.type = 'SwitchStatement'; - - this.discriminant = discriminant; - this.discriminant.parent = this; - - this.cases = cases; - - for caseClause in this.cases { - caseClause.parent = this; - } -} - -SwitchStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var context = this.getContext(); - var firstCase, currentCase, defaultCase; - var fallthroughPosition = 1; - - this.discriminant = this.discriminant.codegen(); - - if this.discriminant.hasCallExpression() { - var id = { - "type": "Identifier", - "name": SwitchStatement.getNextVariableName() - }; - - context.node.body.splice(context.position, 0, { - "type": "VariableDeclaration", - "codeGenerated": true, - "declarations": [{ - "type": "VariableDeclarator", - "id": id, - "init": this.discriminant - }], - "kind": "let" - }); - - this.discriminant = id; - } - - var hasFallthrough = false; - - for caseClause in this.cases { - if (!caseClause.tests) { - defaultCase = caseClause; - break; - } - - if !firstCase? { - firstCase = caseClause.codegen(); - currentCase = firstCase; - } else { - if currentCase.fallthrough { - hasFallthrough = true; - currentCase = caseClause.codegen(this.branchFallthrough); - context.node.body.splice(context.position + fallthroughPosition++, 0, currentCase); - } else { - currentCase.alternate = caseClause.codegen(this.fallthroughId?); - currentCase = currentCase.alternate; - } - } - } - - if hasFallthrough { - for caseClause in this.cases { - if !caseClause.fallthrough and caseClause != defaultCase { - caseClause.body.body = [{ - "type": "ExpressionStatement", - "codeGenerated": true, - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": this.fallthroughId, - "right": { - "type": "Literal", - "value": 2 - } - } - }].concat(caseClause.body.body); - } - } - } - - if defaultCase? { - if !firstCase? { - Node.getErrorManager().error({ - type: "SingleDefaultClause", - message: "default clause without other case clauses is disallowed.", - loc: defaultCase.loc - }); - } else { - if currentCase.fallthrough { - defaultCase = defaultCase.codegen(this.fallthroughId?); - defaultCase.codeGenerated = true; - if this.fallthroughId? { - context.node.body.splice(context.position + fallthroughPosition++, 0, defaultCase); - } else { - for statement in defaultCase.body { - context.node.body.splice(context.position + fallthroughPosition++, 0, statement); - } - } - } else { - currentCase.alternate = defaultCase.codegen(this.fallthroughId?); - } - } - } - - if this.fallthroughId? { - context.node.body.splice(context.position, 0, { - "type": "VariableDeclaration", - "codeGenerated": true, - "declarations": [ - { - "type": "VariableDeclarator", - "id": this.fallthroughId, - "init": { - "type": "Literal", - "value": 0 - } - } - ], - "kind": "let" - }); - } - - if !firstCase? { - this.type = "ExpressionStatement"; - this.expression = this.discriminant; - } else { - this.type = firstCase.type; - this.test = firstCase.test; - this.consequent = firstCase.consequent; - this.alternate = firstCase.alternate; - } - - return this; -}; - -SwitchStatement.getNextVariableName = () -> { - if !this.switchStatementIndex? { - this.switchStatementIndex = 0; - } - - return "switchStatement" + this.switchStatementIndex++; -}; - -SwitchStatement.resetVariableNames = () -> { - this.switchStatementIndex = 0; -}; - -exports.SwitchStatement = SwitchStatement; \ No newline at end of file diff --git a/src/ast/statements/ThrowStatement.spider b/src/ast/statements/ThrowStatement.spider deleted file mode 100644 index cabbbef..0000000 --- a/src/ast/statements/ThrowStatement.spider +++ /dev/null @@ -1,23 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn ThrowStatement(argument) - extends Node { - - this.type = 'ThrowStatement'; - - this.argument = argument; - this.argument.parent = this; -} - -ThrowStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.argument = this.argument.codegen(); - return this; -}; - -exports.ThrowStatement = ThrowStatement; \ No newline at end of file diff --git a/src/ast/statements/TryStatement.spider b/src/ast/statements/TryStatement.spider deleted file mode 100644 index 82c4e02..0000000 --- a/src/ast/statements/TryStatement.spider +++ /dev/null @@ -1,42 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn TryStatement(block, handler, finalizer) - extends Node { - - this.type = 'TryStatement'; - - this.block = block; - this.block.parent = this; - - this.handler = handler; - if this.handler? { - this.handler.parent = this; - } - - this.finalizer = finalizer; - if this.finalizer? { - this.finalizer.parent = this; - } -} - -TryStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.block = this.block.codegen(); - - if this.handler? { - this.handler = this.handler.codegen(); - } - - if this.finalizer? { - this.finalizer = this.finalizer.codegen(); - } - - return this; -}; - -exports.TryStatement = TryStatement; \ No newline at end of file diff --git a/src/ast/statements/UntilStatement.spider b/src/ast/statements/UntilStatement.spider deleted file mode 100644 index ca50b63..0000000 --- a/src/ast/statements/UntilStatement.spider +++ /dev/null @@ -1,36 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn UntilStatement(test, body) - extends Node { - - this.type = 'UntilStatement'; - - this.test = test; - this.test.parent = this; - - this.body = body; - this.body.parent = this; -} - -UntilStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.type = 'WhileStatement'; - - this.test = { - "type": "UnaryExpression", - "operator": "!", - "argument": this.test.codegen(), - "prefix": true - }; - - this.body = this.body.blockWrap().codegen(); - - return this; -}; - -exports.UntilStatement = UntilStatement; \ No newline at end of file diff --git a/src/ast/statements/UseStatement.spider b/src/ast/statements/UseStatement.spider deleted file mode 100644 index 53e857b..0000000 --- a/src/ast/statements/UseStatement.spider +++ /dev/null @@ -1,62 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn UseStatement(identifiers) - extends Node { - - this.type = 'UseStatement'; - - this.identifiers = identifiers; - - for id in this.identifiers { - id.parent = this; - } -} - -UseStatement.predefinedCollections = { - 'browser': [ - 'document', - 'window', - 'screen', - 'location', - 'navigator', - 'alert', - 'console', - 'setTimeout' - ], - - 'node': [ - 'require', - 'exports', - 'module', - 'global', - 'console', - 'process', - 'setTimeout', - '__dirname', - '__filename', - ] -}; - -UseStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var context = this.getContext().node; - - for id in this.identifiers { - if (id.predefinedCollection) { - for p in exports.UseStatement.predefinedCollections[id.name] { - context.defineIdentifier({ name: p }); - } - } else { - context.defineIdentifier(id); - } - } - - return null; -}; - -exports.UseStatement = UseStatement; diff --git a/src/ast/statements/VariableDeclarationStatement.spider b/src/ast/statements/VariableDeclarationStatement.spider deleted file mode 100644 index 4eb1ccf..0000000 --- a/src/ast/statements/VariableDeclarationStatement.spider +++ /dev/null @@ -1,34 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn VariableDeclarationStatement(declarations) - extends Node { - - this.type = 'VariableDeclaration'; - this.declarations = declarations; - this.kind = 'let'; - - for decl in declarations { - decl.parent = this; - } -} - -VariableDeclarationStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - var i = 0; - while (i < this.declarations.length) { - var statement = this.declarations[i].codegen(); - if statement? { - this.declarations[this.declarations.indexOf(statement)] = statement; - } - i++; - } - - return this; -}; - -exports.VariableDeclarationStatement = VariableDeclarationStatement; \ No newline at end of file diff --git a/src/ast/statements/WhileStatement.spider b/src/ast/statements/WhileStatement.spider deleted file mode 100644 index fee03d6..0000000 --- a/src/ast/statements/WhileStatement.spider +++ /dev/null @@ -1,28 +0,0 @@ -use :node; - -var Node = module.require('../Node').Node; - -fn WhileStatement(test, body) - extends Node { - - this.type = 'WhileStatement'; - - this.test = test; - this.test.parent = this; - - this.body = body; - this.body.parent = this; -} - -WhileStatement.prototype.codegen = () -> { - if !super.codegen() { - return; - } - - this.test = this.test.codegen(); - this.body = this.body.blockWrap().codegen(); - - return this; -}; - -exports.WhileStatement = WhileStatement; \ No newline at end of file diff --git a/src/spider.pegjs b/src/spider.pegjs deleted file mode 100644 index 9bf79b9..0000000 --- a/src/spider.pegjs +++ /dev/null @@ -1,1434 +0,0 @@ -{ - var ast = module.require('./ast'); - - function filledArray(count, value) { - var result = new Array(count), i; - - for (i = 0; i < count; i++) { - result[i] = value; - } - - return result; - } - - function extractOptional(optional, index) { - return optional ? optional[index] : null; - } - - function extractList(list, index) { - var result = new Array(list.length), i; - - for (i = 0; i < list.length; i++) { - result[i] = list[i][index]; - } - - return result; - } - - function buildList(first, rest, index) { - return [first].concat(extractList(rest, index)); - } - - function buildTree(first, rest, builder) { - var result = first, i; - - for (i = 0; i < rest.length; i++) { - result = builder(result, rest[i]); - } - - return result; - } - - function buildBinaryExpression(first, rest) { - return buildTree(first, rest, function(result, element) { - return insertLocationData(new ast.BinaryExpression(result, element[1], element[3]), text(), line(), column()); - }); - } - - function buildLogicalExpression(first, rest) { - return buildTree(first, rest, function(result, element) { - return insertLocationData(new ast.LogicalExpression(result, element[1], element[3]), text(), line(), column()); - }); - } - - function buildNullCoalescingExpression(first, rest) { - return buildTree(first, rest, function(result, element) { - return insertLocationData(new ast.NullCoalescingExpression(result, element[3]), text(), line(), column()); - }); - } - - function optionalList(value) { - return value !== null ? value : []; - } - - function insertLocationData(node, text, line, column) { - var lines = text.split("\n"); - node.loc = { - "start": { - "line": line, - "column": column - 1 - }, - "end": { - "line": line + lines.length - 1, - "column": (lines.length === 1 ? (column - 1) : 0) + - lines[lines.length - 1].length - } - }; - - return node; - } -} - -Start - = __ program:Program __ { return program; } - -/* ----- A.1 Lexical Grammar ----- */ - -SourceCharacter - = . - -WhiteSpace "whitespace" - = "\t" - / "\v" - / "\f" - / " " - / "\u00A0" - / "\uFEFF" - / Zs - -LineTerminator - = [\n\r\u2028\u2029] - -LineTerminatorSequence "end of line" - = "\n" - / "\r\n" - / "\r" - / "\u2028" - / "\u2029" - -Comment "comment" - = MultiLineComment - / SingleLineComment - -MultiLineComment - = "/*" (!"*/" SourceCharacter)* "*/" - -MultiLineCommentNoLineTerminator - = "/*" (!("*/" / LineTerminator) SourceCharacter)* "*/" - -SingleLineComment - = "//" (!LineTerminator SourceCharacter)* - -Identifier - = !ReservedWord name:IdentifierName { return name; } - -IdentifierName "identifier" - = first:IdentifierStart rest:IdentifierPart* { - return insertLocationData(new ast.Identifier(first + rest.join("")), text(), line(), column()); - } - -IdentifierStart - = UnicodeLetter - / "$" - / "_" - / "\\" sequence:UnicodeEscapeSequence { return sequence; } - -IdentifierPart - = IdentifierStart - / UnicodeCombiningMark - / UnicodeDigit - / UnicodeConnectorPunctuation - / "\u200C" - / "\u200D" - -UnicodeLetter - = Lu - / Ll - / Lt - / Lm - / Lo - / Nl - -UnicodeCombiningMark - = Mn - / Mc - -UnicodeDigit - = Nd - -UnicodeConnectorPunctuation - = Pc - -ReservedWord - = Keyword - / NullLiteral - / BooleanLiteral - -Keyword - = AndToken - / OrToken - / ReturnToken - / VarToken - / IfToken - / ElseToken - / ForToken - / FnToken - / NewToken - / UseToken - / ThisToken - / SuperToken - / ThrowToken - / BreakToken - / ContinueToken - / DebuggerToken - / WhileToken - / UntilToken - / TypeofToken - / InToken - / OfToken - / TryToken - / CatchToken - / FinallyToken - / InstanceofToken - / SwitchToken - / CaseToken - / DefaultToken - / FallthroughToken - / NotToken - / ImportToken - / FromToken - / AsToken - / ExportToken - / DeleteToken - / AsyncToken - / AwaitToken - / GoToken - / NullToken - / UndefinedToken - -Literal - = NullLiteral - / UndefinedLiteral - / BooleanLiteral - / NumericLiteral - / StringLiteral - / RegularExpressionLiteral - -NullLiteral - = NullToken { return insertLocationData(new ast.NullLiteral(), text(), line(), column()); } - -UndefinedLiteral - = UndefinedToken { return insertLocationData(new ast.UndefinedLiteral(), text(), line(), column()); } - -BooleanLiteral - = TrueToken { return insertLocationData(new ast.BooleanLiteral("true"), text(), line(), column()); } - / FalseToken { return insertLocationData(new ast.BooleanLiteral("false"), text(), line(), column()); } - -NumericLiteral "number" - = literal:HexIntegerLiteral !(IdentifierStart / DecimalDigit) { - return literal; - } - / literal:DecimalLiteral !(IdentifierStart / DecimalDigit) { - return literal; - } - -DecimalLiteral - = DecimalIntegerLiteral "." !"." DecimalDigit* ExponentPart? { - return insertLocationData(new ast.NumberLiteral(text()), text(), line(), column()); - } - / "." !"." DecimalDigit+ ExponentPart? { - return insertLocationData(new ast.NumberLiteral(text()), text(), line(), column()); - } - / DecimalIntegerLiteral ExponentPart? { - return insertLocationData(new ast.NumberLiteral(text()), text(), line(), column()); - } - -DecimalIntegerLiteral - = "0" - / NonZeroDigit DecimalDigit* - -DecimalDigit - = [0-9] - -NonZeroDigit - = [1-9] - -ExponentPart - = ExponentIndicator SignedInteger - -ExponentIndicator - = "e"i - -SignedInteger - = [+-]? DecimalDigit+ - -HexIntegerLiteral - = "0x"i digits:$HexDigit+ { - return insertLocationData(new ast.NumberLiteral(text(), 16), text(), line(), column()); - } - -HexDigit - = [0-9a-f]i - -StringLiteral "string" - = '"' chars:DoubleStringCharacter* '"' { - return insertLocationData(new ast.StringLiteral(chars, column()), text(), line(), column()); - } - / "'" chars:SingleStringCharacter* "'" { - return insertLocationData(new ast.StringLiteral(chars, column()), text(), line(), column()); - } - -DoubleStringCharacter - = !('"' / "\\" / LineTerminator) SourceCharacter { return text(); } - / "\\" sequence:EscapeSequence { return sequence; } - / LineContinuation - / LineTerminator __ { return new ast.StringLiteral.NewLine(text()); } - -SingleStringCharacter - = !("'" / "\\" / LineTerminator) SourceCharacter { return text(); } - / "\\" sequence:EscapeSequence { return sequence; } - / LineContinuation - / LineTerminator __ { return new ast.StringLiteral.NewLine(text()); } - -LineContinuation - = "\\" LineTerminatorSequence { return ""; } - -EscapeSequence - = ExpressionSequence - / CharacterEscapeSequence - / "0" !DecimalDigit { return "\0"; } - / HexEscapeSequence - / UnicodeEscapeSequence - -CharacterEscapeSequence - = SingleEscapeCharacter - / NonEscapeCharacter - -SingleEscapeCharacter - = "'" - / '"' - / "\\" - / "b" { return "\b"; } - / "f" { return "\f"; } - / "n" { return "\n"; } - / "r" { return "\r"; } - / "t" { return "\t"; } - / "v" { return "\x0B"; } - -NonEscapeCharacter - = !(EscapeCharacter / LineTerminator) SourceCharacter { return text(); } - -EscapeCharacter - = SingleEscapeCharacter - / DecimalDigit - / "x" - / "u" - -HexEscapeSequence - = "x" digits:$(HexDigit HexDigit) { - return String.fromCharCode(parseInt(digits, 16)); - } - -UnicodeEscapeSequence - = "u" digits:$(HexDigit HexDigit HexDigit HexDigit) { - return String.fromCharCode(parseInt(digits, 16)); - } - -ExpressionSequence - = "(" expression:Expression ")" { - return expression; - } - -RegularExpressionLiteral "regular expression" - = "/" pattern:$RegularExpressionBody "/" flags:$RegularExpressionFlags { - return insertLocationData(new ast.RegularExpressionLiteral(pattern, flags), text(), line(), column()); - } - -RegularExpressionBody - = RegularExpressionFirstChar RegularExpressionChar* - -RegularExpressionFirstChar - = ![*\\/[] RegularExpressionNonTerminator - / RegularExpressionBackslashSequence - / RegularExpressionClass - -RegularExpressionChar - = ![\\/[] RegularExpressionNonTerminator - / RegularExpressionBackslashSequence - / RegularExpressionClass - -RegularExpressionBackslashSequence - = "\\" RegularExpressionNonTerminator - -RegularExpressionNonTerminator - = !LineTerminator SourceCharacter - -RegularExpressionClass - = "[" RegularExpressionClassChar* "]" - -RegularExpressionClassChar - = ![\]\\] RegularExpressionNonTerminator - / RegularExpressionBackslashSequence - -RegularExpressionFlags - = IdentifierPart* - -/* - * Unicode Character Categories - * - * Extracted from the following Unicode Character Database file: - * - * http://www.unicode.org/Public/6.3.0/ucd/extracted/DerivedGeneralCategory.txt - * - * Unix magic used: - * - * grep "; $CATEGORY" DerivedGeneralCategory.txt | # Filter characters - * cut -f1 -d " " | # Extract code points - * grep -v '[0-9a-fA-F]\{5\}' | # Exclude non-BMP characters - * sed -e 's/\.\./-/' | # Adjust formatting - * sed -e 's/\([0-9a-fA-F]\{4\}\)/\\u\1/g' | # Adjust formatting - * tr -d '\n' # Join lines - * - * ECMA-262 allows using Unicode 3.0 or later, version 6.3.0 was the latest one - * at the time of writing. - * - * Non-BMP characters are completely ignored to avoid surrogate pair handling - * (detecting surrogate pairs isn't possible with a simple character class and - * other methods would degrade performance). I don't consider it a big deal as - * even parsers in JavaScript engines of common browsers seem to ignore them. - */ - -// Letter, Lowercase -Ll = [\u0061-\u007A\u00B5\u00DF-\u00F6\u00F8-\u00FF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137-\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148-\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C-\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA-\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9-\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC-\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF-\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F-\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0-\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB-\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE-\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0561-\u0587\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6-\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FC7\u1FD0-\u1FD3\u1FD6-\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6-\u1FF7\u210A\u210E-\u210F\u2113\u212F\u2134\u2139\u213C-\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65-\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73-\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3-\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7FA\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A] - -// Letter, Modifier -Lm = [\u02B0-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0374\u037A\u0559\u0640\u06E5-\u06E6\u07F4-\u07F5\u07FA\u081A\u0824\u0828\u0971\u0E46\u0EC6\u10FC\u17D7\u1843\u1AA7\u1C78-\u1C7D\u1D2C-\u1D6A\u1D78\u1D9B-\u1DBF\u2071\u207F\u2090-\u209C\u2C7C-\u2C7D\u2D6F\u2E2F\u3005\u3031-\u3035\u303B\u309D-\u309E\u30FC-\u30FE\uA015\uA4F8-\uA4FD\uA60C\uA67F\uA717-\uA71F\uA770\uA788\uA7F8-\uA7F9\uA9CF\uAA70\uAADD\uAAF3-\uAAF4\uFF70\uFF9E-\uFF9F] - -// Letter, Other -Lo = [\u00AA\u00BA\u01BB\u01C0-\u01C3\u0294\u05D0-\u05EA\u05F0-\u05F2\u0620-\u063F\u0641-\u064A\u066E-\u066F\u0671-\u06D3\u06D5\u06EE-\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u0800-\u0815\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0972-\u0977\u0979-\u097F\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0-\u0AE1\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58-\u0C59\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0-\u0CE1\u0CF1-\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E45\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065-\u1066\u106E-\u1070\u1075-\u1081\u108E\u10D0-\u10FA\u10FD-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17DC\u1820-\u1842\u1844-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE-\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C77\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5-\u1CF6\u2135-\u2138\u2D30-\u2D67\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3006\u303C\u3041-\u3096\u309F\u30A1-\u30FA\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA014\uA016-\uA48C\uA4D0-\uA4F7\uA500-\uA60B\uA610-\uA61F\uA62A-\uA62B\uA66E\uA6A0-\uA6E5\uA7FB-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA6F\uAA71-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADC\uAAE0-\uAAEA\uAAF2\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40-\uFB41\uFB43-\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF66-\uFF6F\uFF71-\uFF9D\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC] - -// Letter, Titlecase -Lt = [\u01C5\u01C8\u01CB\u01F2\u1F88-\u1F8F\u1F98-\u1F9F\u1FA8-\u1FAF\u1FBC\u1FCC\u1FFC] - -// Letter, Uppercase -Lu = [\u0041-\u005A\u00C0-\u00D6\u00D8-\u00DE\u0100\u0102\u0104\u0106\u0108\u010A\u010C\u010E\u0110\u0112\u0114\u0116\u0118\u011A\u011C\u011E\u0120\u0122\u0124\u0126\u0128\u012A\u012C\u012E\u0130\u0132\u0134\u0136\u0139\u013B\u013D\u013F\u0141\u0143\u0145\u0147\u014A\u014C\u014E\u0150\u0152\u0154\u0156\u0158\u015A\u015C\u015E\u0160\u0162\u0164\u0166\u0168\u016A\u016C\u016E\u0170\u0172\u0174\u0176\u0178-\u0179\u017B\u017D\u0181-\u0182\u0184\u0186-\u0187\u0189-\u018B\u018E-\u0191\u0193-\u0194\u0196-\u0198\u019C-\u019D\u019F-\u01A0\u01A2\u01A4\u01A6-\u01A7\u01A9\u01AC\u01AE-\u01AF\u01B1-\u01B3\u01B5\u01B7-\u01B8\u01BC\u01C4\u01C7\u01CA\u01CD\u01CF\u01D1\u01D3\u01D5\u01D7\u01D9\u01DB\u01DE\u01E0\u01E2\u01E4\u01E6\u01E8\u01EA\u01EC\u01EE\u01F1\u01F4\u01F6-\u01F8\u01FA\u01FC\u01FE\u0200\u0202\u0204\u0206\u0208\u020A\u020C\u020E\u0210\u0212\u0214\u0216\u0218\u021A\u021C\u021E\u0220\u0222\u0224\u0226\u0228\u022A\u022C\u022E\u0230\u0232\u023A-\u023B\u023D-\u023E\u0241\u0243-\u0246\u0248\u024A\u024C\u024E\u0370\u0372\u0376\u0386\u0388-\u038A\u038C\u038E-\u038F\u0391-\u03A1\u03A3-\u03AB\u03CF\u03D2-\u03D4\u03D8\u03DA\u03DC\u03DE\u03E0\u03E2\u03E4\u03E6\u03E8\u03EA\u03EC\u03EE\u03F4\u03F7\u03F9-\u03FA\u03FD-\u042F\u0460\u0462\u0464\u0466\u0468\u046A\u046C\u046E\u0470\u0472\u0474\u0476\u0478\u047A\u047C\u047E\u0480\u048A\u048C\u048E\u0490\u0492\u0494\u0496\u0498\u049A\u049C\u049E\u04A0\u04A2\u04A4\u04A6\u04A8\u04AA\u04AC\u04AE\u04B0\u04B2\u04B4\u04B6\u04B8\u04BA\u04BC\u04BE\u04C0-\u04C1\u04C3\u04C5\u04C7\u04C9\u04CB\u04CD\u04D0\u04D2\u04D4\u04D6\u04D8\u04DA\u04DC\u04DE\u04E0\u04E2\u04E4\u04E6\u04E8\u04EA\u04EC\u04EE\u04F0\u04F2\u04F4\u04F6\u04F8\u04FA\u04FC\u04FE\u0500\u0502\u0504\u0506\u0508\u050A\u050C\u050E\u0510\u0512\u0514\u0516\u0518\u051A\u051C\u051E\u0520\u0522\u0524\u0526\u0531-\u0556\u10A0-\u10C5\u10C7\u10CD\u1E00\u1E02\u1E04\u1E06\u1E08\u1E0A\u1E0C\u1E0E\u1E10\u1E12\u1E14\u1E16\u1E18\u1E1A\u1E1C\u1E1E\u1E20\u1E22\u1E24\u1E26\u1E28\u1E2A\u1E2C\u1E2E\u1E30\u1E32\u1E34\u1E36\u1E38\u1E3A\u1E3C\u1E3E\u1E40\u1E42\u1E44\u1E46\u1E48\u1E4A\u1E4C\u1E4E\u1E50\u1E52\u1E54\u1E56\u1E58\u1E5A\u1E5C\u1E5E\u1E60\u1E62\u1E64\u1E66\u1E68\u1E6A\u1E6C\u1E6E\u1E70\u1E72\u1E74\u1E76\u1E78\u1E7A\u1E7C\u1E7E\u1E80\u1E82\u1E84\u1E86\u1E88\u1E8A\u1E8C\u1E8E\u1E90\u1E92\u1E94\u1E9E\u1EA0\u1EA2\u1EA4\u1EA6\u1EA8\u1EAA\u1EAC\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u1EB8\u1EBA\u1EBC\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1EC8\u1ECA\u1ECC\u1ECE\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2\u1EE4\u1EE6\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0\u1EF2\u1EF4\u1EF6\u1EF8\u1EFA\u1EFC\u1EFE\u1F08-\u1F0F\u1F18-\u1F1D\u1F28-\u1F2F\u1F38-\u1F3F\u1F48-\u1F4D\u1F59\u1F5B\u1F5D\u1F5F\u1F68-\u1F6F\u1FB8-\u1FBB\u1FC8-\u1FCB\u1FD8-\u1FDB\u1FE8-\u1FEC\u1FF8-\u1FFB\u2102\u2107\u210B-\u210D\u2110-\u2112\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u2130-\u2133\u213E-\u213F\u2145\u2183\u2C00-\u2C2E\u2C60\u2C62-\u2C64\u2C67\u2C69\u2C6B\u2C6D-\u2C70\u2C72\u2C75\u2C7E-\u2C80\u2C82\u2C84\u2C86\u2C88\u2C8A\u2C8C\u2C8E\u2C90\u2C92\u2C94\u2C96\u2C98\u2C9A\u2C9C\u2C9E\u2CA0\u2CA2\u2CA4\u2CA6\u2CA8\u2CAA\u2CAC\u2CAE\u2CB0\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC2\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CEB\u2CED\u2CF2\uA640\uA642\uA644\uA646\uA648\uA64A\uA64C\uA64E\uA650\uA652\uA654\uA656\uA658\uA65A\uA65C\uA65E\uA660\uA662\uA664\uA666\uA668\uA66A\uA66C\uA680\uA682\uA684\uA686\uA688\uA68A\uA68C\uA68E\uA690\uA692\uA694\uA696\uA722\uA724\uA726\uA728\uA72A\uA72C\uA72E\uA732\uA734\uA736\uA738\uA73A\uA73C\uA73E\uA740\uA742\uA744\uA746\uA748\uA74A\uA74C\uA74E\uA750\uA752\uA754\uA756\uA758\uA75A\uA75C\uA75E\uA760\uA762\uA764\uA766\uA768\uA76A\uA76C\uA76E\uA779\uA77B\uA77D-\uA77E\uA780\uA782\uA784\uA786\uA78B\uA78D\uA790\uA792\uA7A0\uA7A2\uA7A4\uA7A6\uA7A8\uA7AA\uFF21-\uFF3A] - -// Mark, Spacing Combining -Mc = [\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0982-\u0983\u09BE-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u09D7\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0B02-\u0B03\u0B3E\u0B40\u0B47-\u0B48\u0B4B-\u0B4C\u0B57\u0BBE-\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0BD7\u0C01-\u0C03\u0C41-\u0C44\u0C82-\u0C83\u0CBE\u0CC0-\u0CC4\u0CC7-\u0CC8\u0CCA-\u0CCB\u0CD5-\u0CD6\u0D02-\u0D03\u0D3E-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D57\u0D82-\u0D83\u0DCF-\u0DD1\u0DD8-\u0DDF\u0DF2-\u0DF3\u0F3E-\u0F3F\u0F7F\u102B-\u102C\u1031\u1038\u103B-\u103C\u1056-\u1057\u1062-\u1064\u1067-\u106D\u1083-\u1084\u1087-\u108C\u108F\u109A-\u109C\u17B6\u17BE-\u17C5\u17C7-\u17C8\u1923-\u1926\u1929-\u192B\u1930-\u1931\u1933-\u1938\u19B0-\u19C0\u19C8-\u19C9\u1A19-\u1A1A\u1A55\u1A57\u1A61\u1A63-\u1A64\u1A6D-\u1A72\u1B04\u1B35\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B82\u1BA1\u1BA6-\u1BA7\u1BAA\u1BAC-\u1BAD\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1C24-\u1C2B\u1C34-\u1C35\u1CE1\u1CF2-\u1CF3\u302E-\u302F\uA823-\uA824\uA827\uA880-\uA881\uA8B4-\uA8C3\uA952-\uA953\uA983\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BD-\uA9C0\uAA2F-\uAA30\uAA33-\uAA34\uAA4D\uAA7B\uAAEB\uAAEE-\uAAEF\uAAF5\uABE3-\uABE4\uABE6-\uABE7\uABE9-\uABEA\uABEC] - -// Mark, Nonspacing -Mn = [\u0300-\u036F\u0483-\u0487\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08E4-\u08FE\u0900-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962-\u0963\u0981\u09BC\u09C1-\u09C4\u09CD\u09E2-\u09E3\u0A01-\u0A02\u0A3C\u0A41-\u0A42\u0A47-\u0A48\u0A4B-\u0A4D\u0A51\u0A70-\u0A71\u0A75\u0A81-\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7-\u0AC8\u0ACD\u0AE2-\u0AE3\u0B01\u0B3C\u0B3F\u0B41-\u0B44\u0B4D\u0B56\u0B62-\u0B63\u0B82\u0BC0\u0BCD\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55-\u0C56\u0C62-\u0C63\u0CBC\u0CBF\u0CC6\u0CCC-\u0CCD\u0CE2-\u0CE3\u0D41-\u0D44\u0D4D\u0D62-\u0D63\u0DCA\u0DD2-\u0DD4\u0DD6\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB-\u0EBC\u0EC8-\u0ECD\u0F18-\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86-\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039-\u103A\u103D-\u103E\u1058-\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085-\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17B4-\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u1922\u1927-\u1928\u1932\u1939-\u193B\u1A17-\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1B00-\u1B03\u1B34\u1B36-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80-\u1B81\u1BA2-\u1BA5\u1BA8-\u1BA9\u1BAB\u1BE6\u1BE8-\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1DC0-\u1DE6\u1DFC-\u1DFF\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302D\u3099-\u309A\uA66F\uA674-\uA67D\uA69F\uA6F0-\uA6F1\uA802\uA806\uA80B\uA825-\uA826\uA8C4\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uAA29-\uAA2E\uAA31-\uAA32\uAA35-\uAA36\uAA43\uAA4C\uAAB0\uAAB2-\uAAB4\uAAB7-\uAAB8\uAABE-\uAABF\uAAC1\uAAEC-\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE26] - -// Number, Decimal Digit -Nd = [\u0030-\u0039\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19] - -// Number, Letter -Nl = [\u16EE-\u16F0\u2160-\u2182\u2185-\u2188\u3007\u3021-\u3029\u3038-\u303A\uA6E6-\uA6EF] - -// Punctuation, Connector -Pc = [\u005F\u203F-\u2040\u2054\uFE33-\uFE34\uFE4D-\uFE4F\uFF3F] - -// Separator, Space -Zs = [\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000] - -/* Tokens */ - -AndToken = "and" !IdentifierPart -OrToken = "or" !IdentifierPart -ReturnToken = "return" !IdentifierPart -FnToken = "fn" !IdentifierPart -VarToken = "var" !IdentifierPart -IfToken = "if" !IdentifierPart -ElseToken = "else" !IdentifierPart -ForToken = "for" !IdentifierPart -TrueToken = "true" !IdentifierPart -FalseToken = "false" !IdentifierPart -NullToken = "null" !IdentifierPart -NewToken = "new" !IdentifierPart -UseToken = "use" !IdentifierPart -ThisToken = "this" !IdentifierPart -SuperToken = "super" !IdentifierPart -ThrowToken = "throw" !IdentifierPart -BreakToken = "break" !IdentifierPart -ContinueToken = "continue" !IdentifierPart -DebuggerToken = "debugger" !IdentifierPart -WhileToken = "while" !IdentifierPart -UntilToken = "until" !IdentifierPart -TypeofToken = "typeof" !IdentifierPart -InToken = "in" !IdentifierPart -OfToken = "of" !IdentifierPart -TryToken = "try" !IdentifierPart -FinallyToken = "finally" !IdentifierPart -CatchToken = "catch" !IdentifierPart -InstanceofToken = "instanceof" !IdentifierPart -SwitchToken = "switch" !IdentifierPart -CaseToken = "case" !IdentifierPart -DefaultToken = "default" !IdentifierPart -FallthroughToken = "fallthrough" !IdentifierPart -NotToken = "not" !IdentifierPart -ImportToken = "import" !IdentifierPart -FromToken = "from" !IdentifierPart -AsToken = "as" !IdentifierPart -ExportToken = "export" !IdentifierPart -DeleteToken = "delete" !IdentifierPart -DoToken = "do" !IdentifierPart -AsyncToken = "async" !IdentifierPart -AwaitToken = "await" !IdentifierPart -GoToken = "go" !IdentifierPart -UndefinedToken = "undefined" !IdentifierPart - -__ - = (WhiteSpace / LineTerminatorSequence / Comment)* - -_ - = (WhiteSpace / MultiLineCommentNoLineTerminator)* - -EOS - = __ ";" - -EOF - = !. - -Program - = body:StatementList? { - return insertLocationData(new ast.Program(optionalList(body)), text(), line(), column()); - } - -StatementList - = first:Statement rest:(__ Statement)* { - return buildList(first, rest, 1); - } - -Statement - = Block - / VariableStatement - / FunctionDeclaration - / IfStatement - / PushStatement - / ExpressionStatement - / ReturnStatement - / ForStatement - / UseStatement - / ThrowStatement - / TryStatement - / BreakStatement - / ContinueStatement - / DebuggerStatement - / WhileStatement - / UntilStatement - / SwitchStatement - / FallthroughStatement - / ImportDeclarationStatement - / ExportDeclarationStatement - / DoWhileStatement - / GoStatement - -Block - = "{" __ body:(StatementList __)? "}" { - return insertLocationData(new ast.BlockStatement(optionalList(extractOptional(body, 0))), text(), line(), column()); - } - -VariableStatement - = VarToken __ declarations:VariableDeclarationList EOS { - return insertLocationData(new ast.VariableDeclarationStatement(declarations), text(), line(), column()); - } - -VariableDeclarationList - = first:VariableDeclaration rest:(__ "," __ VariableDeclaration)* { - return buildList(first, rest, 3); - } - -VariableDeclaration - = id:Identifier init:(__ Initialiser)? { - return insertLocationData(new ast.VariableDeclarator(id, extractOptional(init, 1)), text(), line(), column()); - } - / id:Pattern init:(__ Initialiser)? { - return insertLocationData(new ast.VariableDeclarator(id, extractOptional(init, 1)), text(), line(), column()); - } - -Initialiser - = "=" !"=" __ expression:AssignmentExpression { return expression; } - -FunctionDeclaration - = AsyncToken __ FnToken __ id:Identifier __ - "(" __ params:(FormalParameterList __)? ")" __ - inheritsFrom:InheritsFrom? - __ body:Block __ - { - return insertLocationData( - new ast.VariableDeclarationStatement( - [new ast.VariableDeclarator(id, - new ast.UnaryExpression("async", - new ast.FunctionExpression( - null, - optionalList(extractOptional(params, 0)), - body, - inheritsFrom - ) - ) - )] - ), - text(), line(), column()); - } - / FnToken __ id:Identifier __ - "(" __ params:(FormalParameterList __)? ")" __ - inheritsFrom:InheritsFrom? - __ body:Block __ - { - return insertLocationData( - new ast.FunctionDeclarationStatement(id, optionalList(extractOptional(params, 0)), body, inheritsFrom), - text(), line(), column()); - } - -InheritsFrom - = "extends" __ call:CallExpression __ { - return call; - } - -FormalParameterList - = first:FormalParameter rest:(__ "," __ FormalParameter)* { - return buildList(first, rest, 3); - } - -FormalParameter - = id:Identifier __ "=" __ defaultValue:Expression { - return insertLocationData(new ast.Parameter(id, defaultValue, false), text(), line(), column()); - } - / id:Identifier __ "..." { - return insertLocationData(new ast.Parameter(id, null, true), text(), line(), column()); - } - / id:Identifier { - return insertLocationData(new ast.Parameter(id, null, false), text(), line(), column()); - } - -IfStatement - = IfToken __ test:Expression __ - consequent:Statement __ - ElseToken __ - alternate:Statement - { - return insertLocationData(new ast.IfStatement(test, consequent, alternate), text(), line(), column()); - } - / IfToken __ test:Expression __ - consequent:Statement { - return insertLocationData(new ast.IfStatement(test, consequent, null), text(), line(), column()); - } - -ReturnStatement - = ReturnToken EOS { - return insertLocationData(new ast.ReturnStatement(null), text(), line(), column()); - } - / ReturnToken _ argument:Expression EOS { - return insertLocationData(new ast.ReturnStatement(argument), text(), line(), column()); - } - -ThrowStatement - = ThrowToken _ argument:Expression EOS { - return insertLocationData(new ast.ThrowStatement(argument), text(), line(), column()); - } - -TryStatement - = TryToken __ block:Block __ handler:Catch __ finalizer:Finally { - return insertLocationData(new ast.TryStatement(block, handler, finalizer), text(), line(), column()); - } - / TryToken __ block:Block __ handler:Catch { - return insertLocationData(new ast.TryStatement(block, handler, null), text(), line(), column()); - } - / TryToken __ block:Block __ finalizer:Finally { - return insertLocationData(new ast.TryStatement(block, null, finalizer), text(), line(), column()); - } - -Catch - = CatchToken __ param:Identifier __ body:Block { - return insertLocationData(new ast.CatchClause(param, body), text(), line(), column()); - } - -Finally - = FinallyToken __ block:Block { return block; } - -BreakStatement - = BreakToken EOS { - return insertLocationData(new ast.BreakStatement(), text(), line(), column()); - } - -ContinueStatement - = ContinueToken EOS { - return insertLocationData(new ast.ContinueStatement(), text(), line(), column()); - } - -FallthroughStatement - = FallthroughToken EOS { - return insertLocationData(new ast.FallthroughStatement(), text(), line(), column()); - } - -ImportDeclarationStatement - = ImportToken __ specifiers:ImportSpecifierList __ FromToken __ source:StringLiteral EOS { - return insertLocationData(new ast.ImportDeclarationStatement(specifiers, source, "named"), text(), line(), column()); - } - / ImportToken __ "*" __ AsToken __ id:Identifier __ FromToken __ source:StringLiteral EOS { - return insertLocationData(new ast.ImportDeclarationStatement([ - new ast.ImportNamespaceSpecifier(id) - ], source, "named"), text(), line(), column()); - } - / ImportToken __ source:StringLiteral __ AsToken __ id:Identifier EOS { - return insertLocationData(new ast.ImportDeclarationStatement([ - new ast.ImportDefaultSpecifier(id) - ], source, "default"), text(), line(), column()); - } - -ImportSpecifierList - = first:ImportSpecifier rest:("," __ ImportSpecifier)* { - return buildList(first, rest, 2); - } - -ImportSpecifier - = id:Identifier __ AsToken __ alias:Identifier { - return insertLocationData(new ast.ImportSpecifier(id, alias), text(), line(), column()); - } - / id:Identifier { - return insertLocationData(new ast.ImportSpecifier(id, null), text(), line(), column()); - } - -ExportDeclarationStatement - = ExportToken __ specifiers:ExportSpecifierList source:(__ FromToken __ StringLiteral)? EOS { - return insertLocationData(new ast.ExportDeclarationStatement(specifiers, extractOptional(source, 3), null, false), text(), line(), column()); - } - / ExportToken __ "*" __ FromToken __ source:StringLiteral EOS { - return insertLocationData(new ast.ExportDeclarationStatement([ - new ast.ExportBatchSpecifier() - ], source, null, false), text(), line(), column()); - } - / ExportToken __ statement:VariableStatement { - return insertLocationData(new ast.ExportDeclarationStatement(null, null, statement, false), text(), line(), column()); - } - / ExportToken __ statement:FunctionDeclaration { - return insertLocationData(new ast.ExportDeclarationStatement(null, null, statement, false), text(), line(), column()); - } - / ExportToken __ DefaultToken __ expression:Expression EOS { - return insertLocationData(new ast.ExportDeclarationStatement(null, null, expression, true), text(), line(), column()); - } - -ExportSpecifierList - = first:ExportSpecifier rest:("," __ ExportSpecifier)* { - return buildList(first, rest, 2); - } - -ExportSpecifier - = id:Identifier __ AsToken __ alias:Identifier { - return insertLocationData(new ast.ExportSpecifier(id, alias), text(), line(), column()); - } - / id:Identifier { - return insertLocationData(new ast.ExportSpecifier(id, null), text(), line(), column()); - } - -DoWhileStatement - = DoToken __ - body:Statement __ - WhileToken __ test:Expression EOS { - return insertLocationData(new ast.DoWhileStatement(test, body), text(), line(), column()); - } - -PushStatement - = left:LeftHandSideExpression __ "<-" __ right:AssignmentExpression EOS { - return insertLocationData(new ast.PushStatement(left, right), text(), line(), column()); - } - -GoStatement - = GoToken __ body:Block EOS { - return insertLocationData(new ast.GoStatement(body), text(), line(), column()); - } - -DebuggerStatement - = DebuggerToken EOS { - return insertLocationData(new ast.DebuggerStatement(), text(), line(), column()); - } - -WhileStatement - = WhileToken __ test:Expression __ - body:Statement { - return insertLocationData(new ast.WhileStatement(test, body), text(), line(), column()); - } - -UntilStatement - = UntilToken __ test:Expression __ - body:Statement { - return insertLocationData(new ast.UntilStatement(test, body), text(), line(), column()); - } - -SwitchStatement - = SwitchToken __ discriminant:Expression __ "{" __ - cases:CaseClauseList __ - "}" { - return insertLocationData(new ast.SwitchStatement(discriminant, cases), text(), line(), column()); - } - -CaseClauseList - = first:CaseClause rest:(__ ","? __ CaseClause)* { - return buildList(first, rest, 3); - } - -CaseClause - = CaseToken __ tests:CaseClauseTestList __ ":" __ body:Statement { - return insertLocationData(new ast.CaseClause(tests, body), text(), line(), column()); - } - / DefaultToken __ ":" __ body:Statement { - return insertLocationData(new ast.CaseClause(null, body), text(), line(), column()); - } - -CaseClauseTestList - = first:CaseClauseTest rest:("," __ CaseClauseTest)* { - return buildList(first, rest, 2); - } - -CaseClauseTest - = OptionalRange - / Expression - -ForStatement - = ForToken __ - item:Identifier __ - index:("," __ Identifier)? __ - InToken __ array:Expression __ - body:Statement { - return insertLocationData(new ast.ForInStatement( - item, - extractOptional(index, 2), - array, - body - ), text(), line(), column()); - } - / ForToken __ - key:Identifier __ - value:("," __ Identifier)? __ - OfToken __ object:Expression __ - body:Statement { - return insertLocationData(new ast.ForOfStatement( - key, - extractOptional(value, 2), - object, - body - ), text(), line(), column()); - } - / ForToken __ - VarToken __ declarations:VariableDeclarationList __ ";" __ - test:(Expression __)? ";" __ - update:(!("{" __ "}") Expression __)? __ - body:Statement { - return insertLocationData(new ast.ForStatement( - new ast.VariableDeclarationStatement(declarations), - extractOptional(test, 0), - extractOptional(update, 1), - body - ), text(), line(), column()); - } - / ForToken __ - init:(Expression __)? ";" __ - test:(Expression __)? ";" __ - update:(!("{" __ "}") Expression __)? __ - body:Statement { - return insertLocationData(new ast.ForStatement( - extractOptional(init, 0), - extractOptional(test, 0), - extractOptional(update, 1), - body - ), text(), line(), column()); - } - -UseStatement - = UseToken __ identifiers:UseIdentifierList EOS - { return new ast.UseStatement(identifiers) } - -UseIdentifierList - = first:UseIdentifier rest:(__ "," __ UseIdentifier)* { - return buildList(first, rest, 3); - } - -UseIdentifier - = Identifier - / ":" id:Identifier { - return id.asPredefinedCollection(); - } - -ExpressionStatement - = !("{" / FnToken) expression:Expression EOS { - return insertLocationData(new ast.ExpressionStatement(expression), text(), line(), column()); - } - -AssignmentExpression - = left:Pattern __ "=" !"=" __ right:AssignmentExpression { - return insertLocationData(new ast.AssignmentExpression( - left, "=", right), text(), line(), column()); - } - / left:ConditionalExpression - assignment:(__ operator:AssignmentOperator __ - right:AssignmentExpression)? { - if (!assignment) { - return left; - } - - return insertLocationData(new ast.AssignmentExpression( - left, - extractOptional(assignment, 1), - extractOptional(assignment, 3)), text(), line(), column()); - } - -AssignmentOperator - = "=" !"=" { return "=" } - / "*=" - / "/=" - / "%=" - / "+=" - / "-=" - / "<<=" - / ">>=" - / ">>>=" - / "&=" - / "^=" - / "|=" - -ConditionalExpression - = consequent:LogicalORExpression __ - condition:(IfToken __ LogicalORExpression __ - ElseToken __ LogicalORExpression)? { - if (condition) { - var test = extractOptional(condition, 2); - var alternate = extractOptional(condition, 6); - - return insertLocationData(new ast.ConditionalExpression(test, consequent, alternate), text(), line(), column()); - } else { - return consequent; - } - } - -LogicalORExpression - = first:LogicalANDExpression - rest:(__ LogicalOROperator __ LogicalANDExpression)* - { return buildLogicalExpression(first, rest); } - -LogicalOROperator - = "||" - / OrToken { return "||"; } - -LogicalANDExpression - = first:BitwiseORExpression - rest:(__ LogicalANDOperator __ BitwiseORExpression)* - { return buildLogicalExpression(first, rest); } - -LogicalANDOperator - = "&&" - / AndToken { return "&&"; } - -BitwiseORExpression - = first:BitwiseXORExpression - rest:(__ BitwiseOROperator __ BitwiseXORExpression)* - { return buildBinaryExpression(first, rest); } - -BitwiseOROperator - = $("|" ![|=]) - -BitwiseXORExpression - = first:BitwiseANDExpression - rest:(__ BitwiseXOROperator __ BitwiseANDExpression)* - { return buildBinaryExpression(first, rest); } - -BitwiseXOROperator - = $("^" !"=") - -BitwiseANDExpression - = first:EqualityExpression - rest:(__ BitwiseANDOperator __ EqualityExpression)* - { return buildBinaryExpression(first, rest); } - -BitwiseANDOperator - = $("&" ![&=]) - -EqualityExpression - = first:RelationalExpression - rest:(__ EqualityOperator __ RelationalExpression)* - { return buildBinaryExpression(first, rest); } - -EqualityOperator - = "==" - / "!=" - -RelationalExpression - = first:InExpression - rest:(__ RelationalOperator __ InExpression)* - { return buildBinaryExpression(first, rest); } - -RelationalOperator - = "<=" - / ">=" - / $("<" !"<") - / $(">" !">") - / $InstanceofToken - -InExpression - = left:NullCoalescingExpression - right:(__ InToken __ NullCoalescingExpression)? { - if (!right) { - return left; - } - return insertLocationData(new ast.InExpression(left, extractOptional(right, 3)), text(), line(), column()); - } - -NullCoalescingExpression - = first:ShiftExpression - rest:(__ "??" __ ShiftExpression)* - { return buildNullCoalescingExpression(first, rest); } - -ShiftExpression - = first:AdditiveExpression - rest:(__ ShiftOperator __ AdditiveExpression)* - { return buildBinaryExpression(first, rest); } - -ShiftOperator - = $("<<" !"=") - / $(">>>" !"=") - / $(">>" !"=") - -AdditiveExpression - = first:MultiplicativeExpression - rest:(__ AdditiveOperator __ MultiplicativeExpression)* - { return buildBinaryExpression(first, rest); } - -AdditiveOperator - = $("+" ![+=]) - / $("-" ![-=]) - -MultiplicativeExpression - = first:ExponentiativeExpression - rest:(__ MultiplicativeOperator __ UnaryExpression)* - { return buildBinaryExpression(first, rest); } - -MultiplicativeOperator - = $("*" ![*=]) - / $("/" !"=") - / $("#" !"=") - / $("%" ![%=]) - / $("%%" !"=") - -ExponentiativeExpression - = first:UnaryExpression - rest:(__ ExponentiativeOperator __ UnaryExpression)* - { return buildBinaryExpression(first, rest); } - -ExponentiativeOperator - = $("**" !"=") - -UnaryExpression - = operator:UnaryOperator __ argument:PostfixExpression { - if (operator === "++" || operator === "--") { - return insertLocationData(new ast.UpdateExpression(argument, operator, true), text(), line(), column()); - } else { - return insertLocationData(new ast.UnaryExpression(operator, argument), text(), line(), column()); - } - } - / PostfixExpression - -UnaryOperator - = $DeleteToken - / $TypeofToken - / $AsyncToken - / $AwaitToken - / $NotToken { return "!" } - / "<-" - / "++" - / "--" - / $("+" !"=") - / $("-" !"=") - / "!" - -PostfixExpression - = argument:ExistentialExpression _ operator:PostfixOperator? { - if (operator) { - return insertLocationData(new ast.UpdateExpression(argument, operator, false), text(), line(), column()); - } else { - return argument; - } - } - -PostfixOperator - = "++" - / "--" - -ExistentialExpression - = argument:LeftHandSideExpression operator:"?"? !"?" { - if (operator) { - return insertLocationData(new ast.ExistentialExpression(argument), text(), line(), column()); - } else { - return argument; - } - } - -LeftHandSideExpression - = CallExpression - -CallExpression - = first:( - callee:MemberExpression call:(__ CallExpressionOperator? __ args:Arguments)? { - if (!call) { - return callee; - } - - var op = extractOptional(call, 1); - if (op === "?") { - return insertLocationData(new ast.NullCheckCallExpression(callee, extractOptional(call, 3)), text(), line(), column()); - } else if (op === "^") { - return insertLocationData(new ast.CurryCallExpression(callee, extractOptional(call, 3)), text(), line(), column()); - } else { - return insertLocationData(new ast.CallExpression(callee, extractOptional(call, 3)), text(), line(), column()); - } - } - ) - rest:( - __ operator:CallExpressionOperator? __ args:Arguments { - var type = "CallExpression"; - if (operator === "?") { - type = "NullCheckCallExpression"; - } else if (operator === "^") { - type = "CurryCallExpression"; - } - - return { - type: type, - arguments: args - }; - } - / __ "[" __ property:Expression __ "]" { - return { - type: "MemberExpression", - property: property, - computed: true - }; - } - / __ "[" __ range:OptionalRange __ "]" { - return { - type: "RangeMemberExpression", - range: range - } - } - / __ nullPropagatingOperator:"?"? __ "." !"." __ property:IdentifierName { - return { - type: nullPropagatingOperator === "?" ? "NullPropagatingExpression" : "MemberExpression", - property: property, - computed: false - }; - } - )* - { - return buildTree(first, rest, function(result, element) { - if (element.type === "MemberExpression") { - return insertLocationData(new ast.MemberExpression(result, element.property, element.computed), text(), line(), column()); - } if (element.type === "NullPropagatingExpression") { - return insertLocationData(new ast.NullPropagatingExpression(result, element.property, element.computed), text(), line(), column()); - } else if (element.type === "CallExpression") { - return insertLocationData(new ast.CallExpression(result, element.arguments), text(), line(), column()); - } else if (element.type === "CurryCallExpression") { - return insertLocationData(new ast.CurryCallExpression(result, element.arguments), text(), line(), column()); - } else if (element.type === "NullCheckCallExpression") { - return insertLocationData(new ast.NullCheckCallExpression(result, element.arguments), text(), line(), column()); - } else if (element.type === "RangeMemberExpression") { - return insertLocationData(new ast.RangeMemberExpression(result, element.range), text(), line(), column()); - } - }); - } - -CallExpressionOperator - = "?" - / "^" - -MemberExpression - = first:( - FunctionExpression - / NewToken __ callee:MemberExpression __ args:Arguments { - return insertLocationData(new ast.NewExpression(callee, args), text(), line(), column()); - } - ) - rest:( - __ "[" __ property:Expression __ "]" { - return { - type: "MemberExpression", - property: property, - computed: true - }; - } - / __ nullPropagatingOperator:"?"? __ "." !"." __ property:IdentifierName { - return { - type: nullPropagatingOperator === "?" ? "NullPropagatingExpression" : "MemberExpression", - property: property, - computed: false - }; - } - / __ "[" __ range:OptionalRange __ "]" { - return { - type: "RangeMemberExpression", - range: range - } - } - )* - { - return buildTree(first, rest, function (result, element) { - if (element.type === "NullPropagatingExpression") { - return insertLocationData(new ast.NullPropagatingExpression(result, element.property, element.computed), text(), line(), column()); - } else if (element.type === "MemberExpression") { - return insertLocationData(new ast.MemberExpression(result, element.property, element.computed), text(), line(), column()); - } else if (element.type === "RangeMemberExpression") { - return insertLocationData(new ast.RangeMemberExpression(result, element.range), text(), line(), column()); - } - }); - } - -Arguments - = "(" __ args:(ArgumentList __)? ")" { - return optionalList(extractOptional(args, 0)); - } - -ArgumentList - = first:Argument rest:(__ "," __ Argument)* { - return buildList(first, rest, 3); - } - -Argument - = expression:AssignmentExpression __ "..." { - return insertLocationData(new ast.SplatExpression(expression), text(), line(), column()); - } - / AssignmentExpression - -FunctionExpression - = FnToken __ id:(Identifier __)? - "(" __ params:(FormalParameterList __)? ")" __ - inheritsFrom:InheritsFrom? - __ body:Block __ - { - return insertLocationData(new ast.FunctionExpression( - extractOptional(id, 0), - optionalList(extractOptional(params, 0)), - body, - inheritsFrom - ), text(), line(), column()); - } - / "(" __ params:(FormalParameterList __)? ")" - __ operator:FunctionExpressionOperator - __ body:Block __ - { - return insertLocationData(new ast.FunctionExpression( - null, - optionalList(extractOptional(params, 0)), - body, - null, - operator - ), text(), line(), column()); - } - / "(" __ params:(FormalParameterList __)? ")" - __ operator:FunctionExpressionOperator - __ body:Expression __ - { - return insertLocationData(new ast.FunctionExpression( - null, - optionalList(extractOptional(params, 0)), - body, - null, - operator - ), text(), line(), column()); - } - / ForInExpression - -FunctionExpressionOperator - = "->" - / "=>" - -ForInExpression - = "[" __ - expression:Expression __ - ForToken __ - item:Identifier __ - index:("," __ Identifier __)? - InToken __ - array:Expression __ - condition:(IfToken __ Expression __)? - "]" { - return insertLocationData(new ast.ForInExpression( - expression, - item, - index ? extractOptional(index, 2) : null, - array, - condition ? extractOptional(condition, 2) : null - ), text(), line(), column()); - } - / GlobalIdentifierExpression - -GlobalIdentifierExpression - = "::" __ id:Identifier - { return id.asGlobal(); } - / PrimaryExpression - -PrimaryExpression - = ThisExpression - / SuperExpression - / RangeExpression - / Identifier - / Literal - / ArrayLiteral - / ObjectLiteral - / "(" __ expression:Expression __ ")" { return expression; } - -ThisExpression - = ThisToken { - return insertLocationData(new ast.ThisExpression(), text(), line(), column()); - } - -SuperExpression - = SuperToken { - return insertLocationData(new ast.SuperExpression(), text(), line(), column()); - } - -RangeExpression - = "[" __ range:Range __ "]" { - return range; - } - -Range - = from:Expression __ operator:RangeOperator __ to:Expression { - return insertLocationData(new ast.Range(from, operator, to), text(), line(), column()); - } - -OptionalRange - = from:Expression? __ operator:RangeOperator __ to:Expression? { - return insertLocationData(new ast.Range(from, operator, to), text(), line(), column()); - } - -RangeOperator - = ".." !"." { return ".."; } - / "..." - -Expression - = expression:AssignmentExpression { - return expression; - } - -ArrayLiteral - = "[" __ elision:(Elision __)? "]" { - return insertLocationData(new ast.ArrayExpression(optionalList(extractOptional(elision, 0))), text(), line(), column()); - } - / "[" __ elements:ElementList __ "]" { - return insertLocationData(new ast.ArrayExpression(elements), text(), line(), column()); - } - / "[" __ elements:ElementList __ "," __ elision:(Elision __)? "]" { - return insertLocationData(new ast.ArrayExpression(elements.concat(optionalList(extractOptional(elision, 0)))), text(), line(), column()); - } - -ElementList - = first:( - elision:(Elision __)? element:AssignmentExpression { - return optionalList(extractOptional(elision, 0)).concat(element); - } - ) - rest:( - __ "," __ elision:(Elision __)? element:AssignmentExpression { - return optionalList(extractOptional(elision, 0)).concat(element); - } - )* - { return Array.prototype.concat.apply(first, rest); } - -ArrayPattern - = "[" __ elision:(Elision __)? "]" { - return insertLocationData(new ast.ArrayPattern(optionalList(extractOptional(elision, 0))), text(), line(), column()); - } - / "[" __ elements:PatternElementList __ "]" { - return insertLocationData(new ast.ArrayPattern(elements), text(), line(), column()); - } - / "[" __ elements:PatternElementList __ "," __ elision:(Elision __)? "]" { - return insertLocationData(new ast.ArrayPattern(elements.concat(optionalList(extractOptional(elision, 0)))), text(), line(), column()); - } - -PatternElementList - = first:( - elision:(Elision __)? element:PatternElement { - return optionalList(extractOptional(elision, 0)).concat(element); - } - ) - rest:( - __ "," __ elision:(Elision __)? element:PatternElement { - return optionalList(extractOptional(elision, 0)).concat(element); - } - )* - { return Array.prototype.concat.apply(first, rest); } - -PatternElement - = Identifier - / ArrayPattern - -Elision - = "," commas:(__ ",")* { return filledArray(commas.length + 1, null); } - -ObjectLiteral - = "{" __ "}" { - return new ast.ObjectExpression([]); - } - / "{" __ properties:PropertyNameAndValueList __ "}" { - return insertLocationData(new ast.ObjectExpression(properties), text(), line(), column()); - } - / "{" __ properties:PropertyNameAndValueList __ "," __ "}" { - return insertLocationData(new ast.ObjectExpression(properties), text(), line(), column()); - } - -PropertyNameAndValueList - = first:PropertyAssignment rest:(__ "," __ PropertyAssignment)* { - return buildList(first, rest, 3); - } - -PropertyAssignment - = key:PropertyName __ ":" __ value:AssignmentExpression { - return insertLocationData(new ast.Property(key, value, false, false), text(), line(), column()); - } - / key:PropertyName __ - "(" __ params:(FormalParameterList __)? ")" - __ body:Block __ - { - return insertLocationData(new ast.Property(key, new ast.FunctionExpression( - null, - optionalList(extractOptional(params, 0)), - body, - null - ), false, true), text(), line(), column()); - } - / key:IdentifierName { - return insertLocationData(new ast.Property(key, key, true, false), text(), line(), column()); - } - -PropertyName - = IdentifierName - / StringLiteral - / NumericLiteral - -ObjectPattern - = "{" __ "}" { - return new ast.ObjectPattern([]); - } - / "{" __ properties:PatternPropertyNameAndValueList __ "}" { - return insertLocationData(new ast.ObjectPattern(properties), text(), line(), column()); - } - / "{" __ properties:PatternPropertyNameAndValueList __ "," __ "}" { - return insertLocationData(new ast.ObjectPattern(properties), text(), line(), column()); - } - -PatternPropertyNameAndValueList - = first:PatternPropertyAssignment rest:(__ "," __ PatternPropertyAssignment)* { - return buildList(first, rest, 3); - } - -PatternPropertyAssignment - = key:IdentifierName __ ":" __ value:IdentifierName { - return insertLocationData(new ast.Property(key, value, false, false), text(), line(), column()); - } - / key:IdentifierName __ ":" __ value:ObjectPattern { - return insertLocationData(new ast.Property(key, value, false, false), text(), line(), column()); - } - / key:IdentifierName { - return insertLocationData(new ast.Property(key, key, true, false), text(), line(), column()); - } - -Pattern - = ObjectPattern - / ArrayPattern \ No newline at end of file diff --git a/src/spider.spider b/src/spider.spider deleted file mode 100644 index 0f3db08..0000000 --- a/src/spider.spider +++ /dev/null @@ -1,279 +0,0 @@ -use :node; - -var parser = module.require('./parser'), - escodegen = require('escodegen'), - ast = module.require('./ast'), - traceur = require("traceur"), - chalk = require("chalk"), - transfer = require("multi-stage-sourcemap").transfer; - -/** - * Compiles Spider code to JavaScript. - * - * @param {string} options.text - * @param {string} options.fileName - * @param {string} options.target - * @param {boolean} [options.verbose] - * @param {boolean} [options.generateSourceMap] - * @param {boolean} [options.iifi] - * @param {boolean} [options.useStrict] - */ -exports.compile = fn (options) { - var result = { - errors: [], - result: null, - sourceMap: null - }; - - options.fileName = options.fileName ?? "tmp"; - - var outFileNameWithoutExtension = options.fileName.substring(0, - options.fileName.lastIndexOf('.')); - - var outFileName = outFileNameWithoutExtension + ".js"; - var mapFileName = outFileNameWithoutExtension + ".map"; - - ::resetVariableNames(); - ast.Node.setErrorManager(new ::ErrorManager(result.errors)); - - var parsed; - - try { - parsed = parser.parse(options.text); - } catch e { - result.errors.push(::getParsingError(e)); - } - - if not parsed { - return result; - } - - var tree = parsed.codegen(); - if options.target != "ES5" { - tree = ::wrapCode(tree, - options.useStrict ?? true, - options.iifi ?? true); - } - - var output = escodegen.generate(tree, { - sourceMap: options.fileName if options.generateSourceMap else null, - sourceMapWithCode: options.generateSourceMap, - format: { - quotes: 'double' - } - }); - - if options.generateSourceMap { - result.result = output.code; - result.sourceMap = output.map.toString(); - } else { - result.result = output; - } - - if options.target == "ES5" { - var traceurCompiler = new traceur.NodeCompiler({ - sourceMaps: options.generateSourceMap, - modules: options.modules, - asyncFunctions: true - }); - - result.result = traceurCompiler.compile(result.result, options.fileName, outFileName); - - if options.generateSourceMap { - result.sourceMap = transfer({ - toSourceMap: result.sourceMap, - fromSourceMap: traceurCompiler.getSourceMap().toString() - }); - } - } else if options.generateSourceMap { - result.result = result.result + "\n\n//# sourceMappingURL=" + mapFileName; - } - - if options.verbose { - console.log(JSON.stringify(parsed, null, 4)); - console.log(result.result); - } - - return result; -}; - -/** - * Format errors array with colors - */ -exports.formatErrors = fn (fileName, content, errors) { - var output = []; - - var maxCol = 0; - var maxLine = 0; - - output.push(chalk.white(fileName), "\n"); - - var lines = content.split("\n"); - var tabCharacter = "__SPIDER_TAB"; - - for error, errorIndex in errors { - var line = error.loc.start.line; - var column = error.loc.start.column + 1; - - var lineCharCount = line.toString().length; - var columnCharCount = column.toString().length; - - maxCol = Math.max(maxCol, columnCharCount); - maxLine = Math.max(maxCol, lineCharCount); - - output.push(tabCharacter); - output.push(chalk.gray("line", line)); - output.push(tabCharacter, lineCharCount); - output.push(chalk.gray("col", column)); - output.push(tabCharacter, columnCharCount); - - output.push(chalk.red(error.message), "\n"); - - if error.loc?.start { - var start = error.loc.start; - var end = error.loc.end; - - if 0 < start.line <= lines.length { - output.push(tabCharacter, tabCharacter, tabCharacter); - - output.push(chalk.green(lines[start.line - 1].replace(/(\r\n|\n|\r)/gm, ""), - "\n", tabCharacter, tabCharacter)); - output.push(chalk.red(::generateErrorColumnString(start.column, end.column - 1 if end else 0))); - } - } - - output.push("\n"); - } - - var str = output.join(""); - var tabLength = Math.max(maxLine, maxCol); - - for var i = 1; i <= tabLength; i++ { - var regex = new RegExp(tabCharacter + i, "g"); - str = str.replace(regex, ::generateSpace(Math.max(2 + tabLength - i, 2))); - } - - return str.replace(new RegExp(tabCharacter, "g"), ::generateSpace(2)); -}; - -fn ErrorManager(errors) { - this.errors = errors; -} - -ErrorManager.prototype.error = (e) -> { - this.errors.push(e); -}; - -fn getParsingError(e) { - var message; - - if e.expected { - if e.found { - message = "unexpected " + e.found; - } else { - message = "unexpected end of input"; - } - } else { - message = e.message; - } - - return { - type: "SyntaxError", - message: message, - loc: { - start: { - line: e.line, - column: e.column - 1 - } - } - }; -} - -fn resetVariableNames() { - ast.NullPropagatingExpression.resetVariableNames(); - ast.NullCoalescingExpression.resetVariableNames(); - ast.NullCheckCallExpression.resetVariableNames(); - ast.ExistentialExpression.resetVariableNames(); - ast.FunctionExpression.resetVariableNames(); - ast.ForOfStatement.resetVariableNames(); - ast.ForInExpression.resetVariableNames(); - ast.FallthroughStatement.resetVariableNames(); - ast.SwitchStatement.resetVariableNames(); -} - -fn wrapCode(tree, useStrict = false, iifi = false) { - if iifi or useStrict { - var body = []; - - if useStrict { - body.push({ - "type": "ExpressionStatement", - "expression": { - "type": "Literal", - "value": "use strict" - } - }); - } - - // Add (function () { ... })() - if iifi { - body.push({ - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "FunctionExpression", - "id": null, - "params": [], - "defaults": [], - "body": { - "type": "BlockStatement", - "body": tree.body - }, - "rest": null, - "generator": false, - "expression": false - }, - "arguments": [] - } - }); - } else { - body = body.concat(tree.body); - } - - tree = { - "type": "Program", - "body": body - }; - } - - return tree; -} - -fn generateSpace(len) { - var chars = []; - for var i = 0; i < len; i++ { - chars.push(' '); - } - - return chars.join(''); -} - -fn generateErrorColumnString(errorStartIndex, errorEndIndex) { - var chars = []; - var i = 0; - - if (!errorEndIndex) { - errorEndIndex = errorStartIndex; - } - - for ; i < errorStartIndex; i++ { - chars.push(' '); - } - - for i = errorStartIndex; i <= errorEndIndex; i++ { - chars.push('^'); - } - - return chars.join(''); -} \ No newline at end of file diff --git a/test/spider_test.js b/test/spider_test.js deleted file mode 100644 index d64a6f6..0000000 --- a/test/spider_test.js +++ /dev/null @@ -1,1787 +0,0 @@ -/*global describe,it*/ -'use strict'; - -require('traceur'); - -var should = require('should'), - spider = require('../lib/spider'); - -function generateTest(code, expectation) { - return function () { - should(spider.compile({ text: code, - generateSourceMap: false, - target: "ES6", - iifi: false, - useStrict: false - }).result).be.exactly(expectation); - }; -} - -function generateErrorTest(code, expectedErrors) { - return function () { - var errors = spider.compile({ - text: code, - generateSourceMap: false, - target: "ES6", - iifi: false, - useStrict: false - }).errors; - - should(errors.map(function (error) { - delete error.message; - delete error.loc; - - return error; - })).eql(expectedErrors); - }; -} - -describe('variable statement:', function () { - it('syntax error', generateErrorTest('var x = y^', [{ type: "SyntaxError" }])); - - it('create variable', - generateTest('var a;', 'let a;')); - - it('create variable with number literal', - generateTest('var a = 5;', 'let a = 5;')); - - it('create variable with string literal', - generateTest('var a = "test";', 'let a = "test";')); - - it('create variable with boolean literal', - generateTest('var a = true;', 'let a = true;')); - - it('create variable with null literal', - generateTest('var a = null;', 'let a = null;')); - - it('create variable with identifier value', - generateTest('var a = b;', 'let a = b;')); - - it('create multiple variables in one statement', - generateTest('var a, b;', 'let a, b;')); - - it('create multiple variables in one statement with values', - generateTest('var a = 5, b = false;', 'let a = 5, b = false;')); - - it('create multiple variables in multiple statements', - generateTest('var a; var b;', 'let a;\nlet b;')); -}); - -describe('member expressions:', function () { - it('member expression with 2 nodes', - generateTest('var a = b.c;', 'let a = b.c;')); - - it('member expression with 3 nodes', - generateTest('var a = b.c.d;', 'let a = b.c.d;')); - - it('member expression with 4 nodes', - generateTest('var a = b.c.d.e;', 'let a = b.c.d.e;')); -}); - -describe('null propagating member expressions:', function () { - it('null propagating member expression with 2 nodes', - generateTest('var a = b?.c;', 'let a = typeof b !== "undefined" && b !== null ? b.c : void 0;')); - - it('null propagating member expression with 3 nodes', - generateTest('var a = b?.c?.d;', 'let a = typeof b !== "undefined" && (b !== null && b.c !== null) ? b.c.d : void 0;')); - - it('null propagating member expression with 4 nodes', - generateTest('var a = b?.c?.d?.e;', 'let a = typeof b !== "undefined" && (b !== null && b.c !== null && b.c.d !== null) ? b.c.d.e : void 0;')); -}); - -describe('member and null propagating member expressions:', function () { - it('1 member expression and 1 null propagating member expression', - generateTest('var a = b.c?.d;', 'let a = typeof b.c !== "undefined" && b.c !== null ? b.c.d : void 0;')); - - it('2 member expressions and 1 null propagating member expression', - generateTest('var a = b.c.d?.e;', 'let a = typeof b.c.d !== "undefined" && b.c.d !== null ? b.c.d.e : void 0;')); - - it('3 member expressions and 1 null propagating member expression', - generateTest('var a = b.c.d.e?.f;', 'let a = typeof b.c.d.e !== "undefined" && b.c.d.e !== null ? b.c.d.e.f : void 0;')); - - it('1 member expression and 2 null propagating member expressions', - generateTest('var a = b.c?.d?.e;', 'let a = typeof b.c !== "undefined" && (b.c !== null && b.c.d !== null) ? b.c.d.e : void 0;')); - - it('1 member expression and 3 null propagating member expressions', - generateTest('var a = b.c?.d?.e?.f;', 'let a = typeof b.c !== "undefined" && (b.c !== null && b.c.d !== null && b.c.d.e !== null) ? b.c.d.e.f : void 0;')); - - it('2 member expressions and 2 null propagating member expressions', - generateTest('var a = b.c.d?.e?.f;', 'let a = typeof b.c.d !== "undefined" && (b.c.d !== null && b.c.d.e !== null) ? b.c.d.e.f : void 0;')); - - it('3 member expressions and 3 null propagating member expressions', - generateTest('var a = b.c.d.e?.f?.g?.h;', 'let a = typeof b.c.d.e !== \"undefined\" && (b.c.d.e !== null && b.c.d.e.f !== null && b.c.d.e.f.g !== null) ? b.c.d.e.f.g.h : void 0;')); - - it('1 null propagating member expression and 1 member expression', - generateTest('var a = b?.c;', 'let a = typeof b !== \"undefined\" && b !== null ? b.c : void 0;')); - - it('2 null propagating member expressions and 1 member expression', - generateTest('var a = b?.c?.d.e;', 'let a = typeof b !== "undefined" && (b !== null && b.c !== null) ? b.c.d.e : void 0;')); - - it('3 null propagating member expressions and 1 member expression', - generateTest('var a = b?.c?.d?.e.f;', 'let a = typeof b !== "undefined" && (b !== null && b.c !== null && b.c.d !== null) ? b.c.d.e.f : void 0;')); - - it('1 null propagating member expression and 2 member expressions', - generateTest('var a = b?.c.d;', 'let a = typeof b !== "undefined" && b !== null ? b.c.d : void 0;')); - - it('1 null propagating member expression and 3 member expressions', - generateTest('var a = b?.c.d.e;', 'let a = typeof b !== "undefined" && b !== null ? b.c.d.e : void 0;')); - - it('2 null propagating member expressions and 2 member expressions', - generateTest('var a = b?.c?.d.e.f;', 'let a = typeof b !== "undefined" && (b !== null && b.c !== null) ? b.c.d.e.f : void 0;')); - - it('3 null propagating member expression and 2 member expressions', - generateTest('var a = b?.c?.d?.e.f.g;', 'let a = typeof b !== "undefined" && (b !== null && b.c !== null && b.c.d !== null) ? b.c.d.e.f.g : void 0;')); - - it('3 null propagating member expression and 3 member expressions', - generateTest('var a = b?.c?.d?.e.f.g.h;', 'let a = typeof b !== "undefined" && (b !== null && b.c !== null && b.c.d !== null) ? b.c.d.e.f.g.h : void 0;')); - - it('1 member expression, 1 null propagating member expression, 1 member expression', - generateTest('var a = b.c?.d.e;', 'let a = typeof b.c !== "undefined" && b.c !== null ? b.c.d.e : void 0;')); - - it('2 member expressions, 1 null propagating member expression, 1 member expression', - generateTest('var a = b.c.d?.e.f;', 'let a = typeof b.c.d !== "undefined" && b.c.d !== null ? b.c.d.e.f : void 0;')); - - it('1 member expression, 2 null propagating member expressions, 1 member expression', - generateTest('var a = b.c?.d?.e.f;', 'let a = typeof b.c !== \"undefined\" && (b.c !== null && b.c.d !== null) ? b.c.d.e.f : void 0;')); - - it('1 member expression, 1 null propagating member expression, 2 member expressions', - generateTest('var a = b.c?.d.e.f;', 'let a = typeof b.c !== "undefined" && b.c !== null ? b.c.d.e.f : void 0;')); - - it('1 null propagating member expression, 1 member expression, 1 null propagating member expression', - generateTest('var a = b?.c.d?.e;', 'let nullPropagating0 = typeof b !== \"undefined\" && b !== null ? b.c.d : void 0;\nlet a = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.e : void 0;')); - - it('2 null propagating member expressions, 1 member expression, 1 null propagating member expression', - generateTest('var a = b?.c?.d.e?.f;', 'let nullPropagating0 = typeof b !== \"undefined\" && (b !== null && b.c !== null) ? b.c.d.e : void 0;\nlet a = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.f : void 0;')); - - it('3 null propagating member expressions, 1 member expression, 1 null propagating member expression', - generateTest('var a = b?.c?.d?.e.f?.h;', 'let nullPropagating0 = typeof b !== \"undefined\" && (b !== null && b.c !== null && b.c.d !== null) ? b.c.d.e.f : void 0;\nlet a = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.h : void 0;')); - - it('1 null propagating member expression, 2 member expressions, 1 null propagating member expression', - generateTest('var a = b?.c.d.e?.f;', 'let nullPropagating0 = typeof b !== \"undefined\" && b !== null ? b.c.d.e : void 0;\nlet a = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.f : void 0;')); - - it('1 null propagating member expression, 3 member expressions, 1 null propagating member expression', - generateTest('var a = b?.c.d.e.f?.h;', 'let nullPropagating0 = typeof b !== \"undefined\" && b !== null ? b.c.d.e.f : void 0;\nlet a = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.h : void 0;')); - - it('1 null propagating member expression, 1 member expression, 2 null propagating member expressions', - generateTest('var a = b?.c.d?.e?.f;', 'let nullPropagating0 = typeof b !== \"undefined\" && b !== null ? b.c.d : void 0;\nlet a = typeof nullPropagating0 !== \"undefined\" && (nullPropagating0 !== null && nullPropagating0.e !== null) ? nullPropagating0.e.f : void 0;')); - - it('1 null propagating member expression, 1 member expression, 3 null propagating member expressions', - generateTest('var a = b?.c.d?.e?.f?.h;', 'let nullPropagating0 = typeof b !== \"undefined\" && b !== null ? b.c.d : void 0;\nlet a = typeof nullPropagating0 !== \"undefined\" && (nullPropagating0 !== null && nullPropagating0.e !== null && nullPropagating0.e.f !== null) ? nullPropagating0.e.f.h : void 0;')); - - it('scramble member and null propagating member expressions (1)', - generateTest('var a = b?.c.d?.e.f;', 'let nullPropagating0 = typeof b !== \"undefined\" && b !== null ? b.c.d : void 0;\nlet a = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.e.f : void 0;')); - - it('scramble member and null propagating member expressions (2)', - generateTest('var a = b?.c?.d.e?.f?.g.h?.i;', 'let nullPropagating0 = typeof b !== \"undefined\" && (b !== null && b.c !== null) ? b.c.d.e : void 0;\nlet nullPropagating1 = typeof nullPropagating0 !== \"undefined\" && (nullPropagating0 !== null && nullPropagating0.f !== null) ? nullPropagating0.f.g.h : void 0;\nlet a = typeof nullPropagating1 !== \"undefined\" && nullPropagating1 !== null ? nullPropagating1.i : void 0;')); -}); - -describe('call expressions and statements:', function () { - it('call statement without arguments', - generateTest('f();', 'f();')); - - it('call statement with 1 argument', - generateTest('f(1);', 'f(1);')); - - it('call statement with 2 arguments', - generateTest('f(1, true);', - 'f(1, true);')); - - it('call statement with 3 arguments', - generateTest('f(1, true, "test");', - 'f(1, true, "test");')); - - it('call statement with 4 arguments', - generateTest('f(1, true, "test", { a: 1 });', - 'f(1, true, "test", { a: 1 });')); - - it('call expression without arguments', - generateTest('var a = f();', 'let a = f();')); - - it('call expression with 1 argument', - generateTest('var a = f(1);', 'let a = f(1);')); - - it('call expression with 2 arguments', - generateTest('var a = f(1, true);', 'let a = f(1, true);')); - - it('call expression with 3 arguments', - generateTest('var a = f(1, true, "test");', 'let a = f(1, true, "test");')); - - it('call expression with 4 arguments', - generateTest('var a = f(1, true, "test", { a: 1 });', 'let a = f(1, true, "test", { a: 1 });')); -}); - -describe('call statements with member expressions:', function () { - it('1 member expression and 1 call statement', - generateTest('a.f();', 'a.f();')); - - it('2 member expressions and 1 call statement', - generateTest('a.b.f();', 'a.b.f();')); - - it('3 member expressions and 1 call statement', - generateTest('a.b.c.f();', 'a.b.c.f();')); - - it('1 member expression and 2 call statements', - generateTest('a.fn1().fn2();', 'a.fn1().fn2();')); - - it('1 member expression and 3 call statements', - generateTest('a.fn1().fn2().fn3();', 'a.fn1().fn2().fn3();')); - - it('1 member expression, 1 call statement, 1 member expression, 1 call statement', - generateTest('a.fn1().b.fn2();', 'a.fn1().b.fn2();')); - - it('2 member expression, 2 call statement, 2 member expression, 2 call statement', - generateTest('a.b.fn1().fn2().c.d.fn3().fn4();', 'a.b.fn1().fn2().c.d.fn3().fn4();')); -}); - -describe('call statements with null propagating member expressions:', function () { - it('1 null propagating member expression and 1 call statement', - generateTest('a?.f();', 'if (typeof a !== \"undefined\" && a !== null) {\n a.f();\n}')); - - it('2 null propagating member expressions and 1 call statement', - generateTest('a?.b?.f();', - 'if (typeof a !== \"undefined\" && (a !== null && a.b !== null)) {\n a.b.f();\n}')); - - it('3 null propagating member expressions and 1 call statement', - generateTest('a?.b?.c?.f();', - 'if (typeof a !== \"undefined\" && (a !== null && a.b !== null && a.b.c !== null)) {\n a.b.c.f();\n}')); - - it('1 null propagating member expression and 2 call statements', - generateTest('a?.fn1()?.fn2();', 'let nullPropagating0 = typeof a !== \"undefined\" && a !== null ? a.fn1() : void 0;\nif (typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null) {\n nullPropagating0.fn2();\n}')); - - it('1 null propagating member expression and 3 call statements', - generateTest('a?.fn1()?.fn2()?.fn3();', 'let nullPropagating0 = typeof a !== \"undefined\" && a !== null ? a.fn1() : void 0;\nlet nullPropagating1 = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.fn2() : void 0;\nif (typeof nullPropagating1 !== \"undefined\" && nullPropagating1 !== null) {\n nullPropagating1.fn3();\n}')); - - it('1 null propagating member expression, 1 call statement, 1 null propagating member expression, 1 call statement', - generateTest('a?.fn1()?.b?.fn2();', 'let nullPropagating0 = typeof a !== \"undefined\" && a !== null ? a.fn1() : void 0;\nif (typeof nullPropagating0 !== \"undefined\" && (nullPropagating0 !== null && nullPropagating0.b !== null)) {\n nullPropagating0.b.fn2();\n}')); - - it('2 null propagating member expression, 2 call statement, 2 null propagating member expression, 2 call statement', - generateTest('a?.b?.fn1()?.fn2()?.c?.d?.fn3()?.fn4();', 'let nullPropagating0 = typeof a !== \"undefined\" && (a !== null && a.b !== null) ? a.b.fn1() : void 0;\nlet nullPropagating1 = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.fn2() : void 0;\nlet nullPropagating2 = typeof nullPropagating1 !== \"undefined\" && (nullPropagating1 !== null && nullPropagating1.c !== null && nullPropagating1.c.d !== null) ? nullPropagating1.c.d.fn3() : void 0;\nif (typeof nullPropagating2 !== \"undefined\" && nullPropagating2 !== null) {\n nullPropagating2.fn4();\n}')); -}); - -describe('call statements with member and null propagating member expressions:', function () { - it('1 member expression, 1 call statement, 1 null propagating member expression, 1 call statement', - generateTest('a.b()?.c();', 'let nullPropagating0 = a.b();\nif (typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null) {\n nullPropagating0.c();\n}')); - - it('2 member expressions, 1 call statement, 1 null propagating member expression, 1 call statement', - generateTest('a.b.c()?.d();', 'let nullPropagating0 = a.b.c();\nif (typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null) {\n nullPropagating0.d();\n}')); - - it('1 member expression, 2 call statements, 1 null propagating member expression, 1 call statement', - generateTest('a.b().c()?.d();', 'let nullPropagating0 = a.b().c();\nif (typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null) {\n nullPropagating0.d();\n}')); - - it('1 member expression, 1 call statement, 2 null propagating member expressions, 1 call statement', - generateTest('a.b()?.c?.d();', 'let nullPropagating0 = a.b();\nif (typeof nullPropagating0 !== \"undefined\" && (nullPropagating0 !== null && nullPropagating0.c !== null)) {\n nullPropagating0.c.d();\n}')); - - it('1 member expression, 1 call statement, 1 null propagating member expression, 2 call statement', - generateTest('a.b()?.c().d();', 'let nullPropagating0 = a.b();\nif (typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null) {\n nullPropagating0.c().d();\n}')); - - it('1 null propagating member expression, 1 call statement, 1 member expression, 1 call statement', - generateTest('a?.b().c();', - 'if (typeof a !== \"undefined\" && a !== null) {\n a.b().c();\n}')); - - it('2 null propagating member expression, 1 call statement, 1 member expression, 1 call statement', - generateTest('a?.b()?.c().d();', 'let nullPropagating0 = typeof a !== \"undefined\" && a !== null ? a.b() : void 0;\nif (typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null) {\n nullPropagating0.c().d();\n}')); - - it('1 null propagating member expression, 2 call statement, 1 member expression, 1 call statement', - generateTest('a?.b()?.c.d();', 'let nullPropagating0 = typeof a !== \"undefined\" && a !== null ? a.b() : void 0;\nif (typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null) {\n nullPropagating0.c.d();\n}')); - - it('scramble call statements with member and null propagating member expressions', - generateTest('a?.b()?.c.d().e.f.g?.h?.i?.j.k();', 'let nullPropagating0 = typeof a !== \"undefined\" && a !== null ? a.b() : void 0;\nlet nullPropagating1 = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.c.d().e.f.g : void 0;\nif (typeof nullPropagating1 !== \"undefined\" && (nullPropagating1 !== null && nullPropagating1.h !== null && nullPropagating1.h.i !== null)) {\n nullPropagating1.h.i.j.k();\n}')); -}); - -describe('call expressions with member expressions:', function () { - it('1 member expression and 1 call expression', - generateTest('var x = a.f();', 'let x = a.f();')); - - it('2 member expressions and 1 call expression', - generateTest('var x = a.b.f();', 'let x = a.b.f();')); - - it('3 member expressions and 1 call expression', - generateTest('var x = a.b.c.f();', 'let x = a.b.c.f();')); - - it('1 member expression and 2 call expressions', - generateTest('var x = a.fn1().fn2();', 'let x = a.fn1().fn2();')); - - it('1 member expression and 3 call expressions', - generateTest('var x = a.fn1().fn2().fn3();', 'let x = a.fn1().fn2().fn3();')); - - it('1 member expression, 1 call expression, 1 member expression, 1 call expression', - generateTest('var x = a.fn1().b.fn2();', 'let x = a.fn1().b.fn2();')); - - it('2 member expression, 2 call expression, 2 member expression, 2 call expression', - generateTest('var x = a.b.fn1().fn2().c.d.fn3().fn4();', 'let x = a.b.fn1().fn2().c.d.fn3().fn4();')); -}); - -describe('call expressions with null propagating member expressions:', function () { - it('1 null propagating member expression and 1 call expression', - generateTest('var x = a?.f();', 'let x = typeof a !== \"undefined\" && a !== null ? a.f() : void 0;')); - - it('2 null propagating member expressions and 1 call expression', - generateTest('var x = a?.b?.f();', 'let x = typeof a !== \"undefined\" && (a !== null && a.b !== null) ? a.b.f() : void 0;')); - - it('3 null propagating member expressions and 1 call expression', - generateTest('var x = a?.b?.c?.f();', 'let x = typeof a !== \"undefined\" && (a !== null && a.b !== null && a.b.c !== null) ? a.b.c.f() : void 0;')); - - it('1 null propagating member expression and 2 call expressions', - generateTest('var x = a?.fn1()?.fn2();', 'let nullPropagating0 = typeof a !== \"undefined\" && a !== null ? a.fn1() : void 0;\nlet x = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.fn2() : void 0;')); - - it('1 null propagating member expression and 3 call expressions', - generateTest('var x = a?.fn1()?.fn2()?.fn3();', 'let nullPropagating0 = typeof a !== \"undefined\" && a !== null ? a.fn1() : void 0;\nlet nullPropagating1 = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.fn2() : void 0;\nlet x = typeof nullPropagating1 !== \"undefined\" && nullPropagating1 !== null ? nullPropagating1.fn3() : void 0;')); - - it('1 null propagating member expression, 1 call expression, 1 null propagating member expression, 1 call expression', - generateTest('var x = a?.fn1()?.b?.fn2();', 'let nullPropagating0 = typeof a !== \"undefined\" && a !== null ? a.fn1() : void 0;\nlet x = typeof nullPropagating0 !== \"undefined\" && (nullPropagating0 !== null && nullPropagating0.b !== null) ? nullPropagating0.b.fn2() : void 0;')); - - it('2 null propagating member expression, 2 call expressions, 2 null propagating member expression, 2 call expressions', - generateTest('var x = a?.b?.fn1()?.fn2()?.c?.d?.fn3()?.fn4();', 'let nullPropagating0 = typeof a !== \"undefined\" && (a !== null && a.b !== null) ? a.b.fn1() : void 0;\nlet nullPropagating1 = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.fn2() : void 0;\nlet nullPropagating2 = typeof nullPropagating1 !== \"undefined\" && (nullPropagating1 !== null && nullPropagating1.c !== null && nullPropagating1.c.d !== null) ? nullPropagating1.c.d.fn3() : void 0;\nlet x = typeof nullPropagating2 !== \"undefined\" && nullPropagating2 !== null ? nullPropagating2.fn4() : void 0;')); -}); - -describe('call expressions with member and null propagating member expressions:', function () { - it('1 member expression, 1 call expression, 1 null propagating member expression, 1 call expression', - generateTest('var x = a.b()?.c();', 'let nullPropagating0 = a.b();\nlet x = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.c() : void 0;')); - - it('2 member expressions, 1 call expression, 1 null propagating member expression, 1 call expression', - generateTest('var x = a.b.c()?.d();', 'let nullPropagating0 = a.b.c();\nlet x = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.d() : void 0;')); - - it('1 member expression, 2 call expressions, 1 null propagating member expression, 1 call expression', - generateTest('var x = a.b().c()?.d();', 'let nullPropagating0 = a.b().c();\nlet x = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.d() : void 0;')); - - it('1 member expression, 1 call expression, 2 null propagating member expressions, 1 call expression', - generateTest('var x = a.b()?.c?.d();', 'let nullPropagating0 = a.b();\nlet x = typeof nullPropagating0 !== \"undefined\" && (nullPropagating0 !== null && nullPropagating0.c !== null) ? nullPropagating0.c.d() : void 0;')); - - it('1 member expression, 1 call expression, 1 null propagating member expression, 2 call expressions', - generateTest('var x = a.b()?.c().d();', 'let nullPropagating0 = a.b();\nlet x = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.c().d() : void 0;')); - - it('1 null propagating member expression, 1 call expression, 1 member expression, 1 call expression', - generateTest('var x = a?.b().c();', 'let x = typeof a !== \"undefined\" && a !== null ? a.b().c() : void 0;')); - - it('2 null propagating member expression, 1 call expression, 1 member expression, 1 call expression', - generateTest('var x = a?.b()?.c().d();', 'let nullPropagating0 = typeof a !== \"undefined\" && a !== null ? a.b() : void 0;\nlet x = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.c().d() : void 0;')); - - it('1 null propagating member expression, 2 call expressions, 1 member expression, 1 call expression', - generateTest('var x = a?.b()?.c.d();', 'let nullPropagating0 = typeof a !== \"undefined\" && a !== null ? a.b() : void 0;\nlet x = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.c.d() : void 0;')); - - it('scramble call expressions with member and null propagating member expressions', - generateTest('var x = a?.b()?.c.d().e.f.g?.h?.i?.j.k();', 'let nullPropagating0 = typeof a !== \"undefined\" && a !== null ? a.b() : void 0;\nlet nullPropagating1 = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.c.d().e.f.g : void 0;\nlet x = typeof nullPropagating1 !== \"undefined\" && (nullPropagating1 !== null && nullPropagating1.h !== null && nullPropagating1.h.i !== null) ? nullPropagating1.h.i.j.k() : void 0;')); -}); - -describe('null coalescing expressions:', function () { - it('null coalescing expression with 2 identifiers', - generateTest('var x = a ?? b;', 'let x = typeof a === \"undefined\" || a == null ? b : a;')); - - it('null coalescing expression with 2 member expressions', - generateTest('var x = a.b ?? c.d;', 'let x = a.b == null ? c.d : a.b;')); - - it('null coalescing expression with 6 member expressions', - generateTest('var x = a.b.c.d ?? e.f.g.h;', 'let x = a.b.c.d == null ? e.f.g.h : a.b.c.d;')); - - it('null coalescing expression with 2 null propagating member expressions', - generateTest('var x = a?.b ?? c?.d;', 'let nullCoalescing0 = typeof a !== \"undefined\" && a !== null ? a.b : void 0;\nlet x = nullCoalescing0 == null ? typeof c !== \"undefined\" && c !== null ? c.d : void 0 : nullCoalescing0;')); - - it('null coalescing expression with 6 null propagating member expressions', - generateTest('var x = a?.b?.c?.d ?? e?.f?.g?.h;', 'let nullCoalescing0 = typeof a !== \"undefined\" && (a !== null && a.b !== null && a.b.c !== null) ? a.b.c.d : void 0;\nlet x = nullCoalescing0 == null ? typeof e !== \"undefined\" && (e !== null && e.f !== null && e.f.g !== null) ? e.f.g.h : void 0 : nullCoalescing0;')); - - it('null coalescing expression with 6 null propagating member expressions combined', - generateTest('var x = a?.b.c?.d ?? e.f?.g?.h;', 'let nullPropagating0 = typeof a !== \"undefined\" && a !== null ? a.b.c : void 0;\nlet nullCoalescing0 = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.d : void 0;\nlet x = nullCoalescing0 == null ? typeof e.f !== \"undefined\" && (e.f !== null && e.f.g !== null) ? e.f.g.h : void 0 : nullCoalescing0;')); - - it('null coalescing expression with 2 call expressions', - generateTest('var x = a() ?? b();', 'let nullCoalescing0 = a();\nlet x = nullCoalescing0 == null ? b() : nullCoalescing0;')); - - it('null coalescing expression with 2 call expressions and null propagating member expressions', - generateTest('var x = a.b()?.c() ?? d?.e().f();', 'let nullPropagating0 = a.b();\nlet nullCoalescing0 = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null ? nullPropagating0.c() : void 0;\nlet x = nullCoalescing0 == null ? typeof d !== \"undefined\" && d !== null ? d.e().f() : void 0 : nullCoalescing0;')); - - it('null coalescing statement', - generateTest('a() ?? b();', 'let nullCoalescing0 = a();\nif (nullCoalescing0 == null) {\n b();\n}')); -}); - -describe('null check call expressions:', function () { - it('null check call expression', - generateTest('var x = a?();', 'let x = typeof a === \"function\" ? a() : void 0;')); - - it('null check call expression with 1 argument', - generateTest('var a = f?(1);', 'let a = typeof f === \"function\" ? f(1) : void 0;')); - - it('null check call expression with 2 arguments', - generateTest('var a = f?(1, true);', 'let a = typeof f === \"function\" ? f(1, true) : void 0;')); - - it('null check call expression with 3 arguments', - generateTest('var a = f?(1, true, "test");', 'let a = typeof f === \"function\" ? f(1, true, \"test\") : void 0;')); - - it('null check call expression with 4 arguments', - generateTest('var a = f?(1, true, "test", { a: 1 });', 'let a = typeof f === \"function\" ? f(1, true, \"test\", { a: 1 }) : void 0;')); - - it('call expression with null check call expression', - generateTest('var x = a?()();', 'let x = (typeof a === \"function\" ? a() : void 0)();')); - - it('null check call expression with null check call expression', - generateTest('var x = a?()?();', 'let nullCheck0 = typeof a === \"function\" ? a() : void 0;\nlet x = typeof nullCheck0 === \"function\" ? nullCheck0() : void 0;')); - - it('null check call expression with member expression', - generateTest('var x = a?().b;', 'let x = typeof a === \"function\" ? a().b : void 0;')); - - it('null check call expression with 2 member expressions', - generateTest('var x = a?().b.c;', 'let x = typeof a === \"function\" ? a().b.c : void 0;')); - - it('null check call expression with call expression', - generateTest('var x = a?().b();', 'let x = typeof a === \"function\" ? a().b() : void 0;')); - - it('null check call expression with 2 call expressions', - generateTest('var x = a?().b().c();', 'let x = typeof a === \"function\" ? a().b().c() : void 0;')); - - it('member expression with null check call expression', - generateTest('var x = a.b?();', 'let x = typeof a.b === \"function\" ? a.b() : void 0;')); - - it('2 member expressions with null check call expression', - generateTest('var x = a.b.c?();', 'let x = typeof a.b.c === \"function\" ? a.b.c() : void 0;')); - - it('call expression with null check call expression', - generateTest('var x = a().b?();', 'let nullCheck0 = a().b;\nlet x = typeof nullCheck0 === \"function\" ? nullCheck0() : void 0;')); - - it('2 call expression with null check call expression', - generateTest('var x = a().b().c?();', 'let nullCheck0 = a().b().c;\nlet x = typeof nullCheck0 === \"function\" ? nullCheck0() : void 0;')); - - it('2 null check call expressions', - generateTest('var x = a?().b?();', 'let nullCheck0 = typeof a === \"function\" ? a().b : void 0;\nlet x = typeof nullCheck0 === \"function\" ? nullCheck0() : void 0;')); - - it('3 null check call expressions', - generateTest('var x = a?().b?().c?();', 'let nullCheck0 = typeof a === \"function\" ? a().b : void 0;\nlet nullCheck1 = typeof nullCheck0 === \"function\" ? nullCheck0().c : void 0;\nlet x = typeof nullCheck1 === \"function\" ? nullCheck1() : void 0;')); - - it('2 null check call expressions with null propagating relationship', - generateTest('var x = a?()?.b?();', 'let nullPropagating0 = typeof a === \"function\" ? a() : void 0;\nlet x = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null && typeof nullPropagating0.b === \"function\" ? nullPropagating0.b() : void 0;')); - - it('3 null check call expressions with null propagating relationship', - generateTest('var x = a?()?.b?()?.c();', 'let nullPropagating0 = typeof a === \"function\" ? a() : void 0;\nlet nullPropagating1 = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null && typeof nullPropagating0.b === \"function\" ? nullPropagating0.b() : void 0;\nlet x = typeof nullPropagating1 !== \"undefined\" && nullPropagating1 !== null ? nullPropagating1.c() : void 0;')); -}); - -describe('null check call statements:', function () { - it('null check call statement', - generateTest('a?();', - 'if (typeof a === \"function\") {\n a();\n}')); - - it('null check call statement with 1 argument', - generateTest('f?(1);', - 'if (typeof f === \"function\") {\n f(1);\n}')); - - it('null check call statement with 2 arguments', - generateTest('f?(1, true);', - 'if (typeof f === \"function\") {\n f(1, true);\n}')); - - it('null check call statement with 3 arguments', - generateTest('f?(1, true, "test");', - 'if (typeof f === \"function\") {\n f(1, true, \"test\");\n}')); - - it('null check call statement with 4 arguments', - generateTest('f?(1, true, "test", { a: 1 });', - 'if (typeof f === \"function\") {\n f(1, true, \"test\", { a: 1 });\n}')); - - it('call statement with null check call expression', - generateTest('a?()();', - '(typeof a === \"function\" ? a() : void 0)();')); - - it('null check call expression with null check call expression', - generateTest('a?()?();', 'let nullCheck0 = typeof a === \"function\" ? a() : void 0;\nif (typeof nullCheck0 === \"function\") {\n nullCheck0();\n}')); - - it('null check call expression with call statement', - generateTest('a?().b();', - 'if (typeof a === \"function\") {\n a().b();\n}')); - - it('null check call expression with 2 call statements', - generateTest('a?().b().c();', - 'if (typeof a === \"function\") {\n a().b().c();\n}')); - - it('member expression with null check call statement', - generateTest('a.b?();', - 'if (typeof a.b === \"function\") {\n a.b();\n}')); - - it('2 member expressions with null check call statement', - generateTest('a.b.c?();', - 'if (typeof a.b.c === \"function\") {\n a.b.c();\n}')); - - it('call expression with null check call statement', - generateTest('a().b?();', 'let nullCheck0 = a().b;\nif (typeof nullCheck0 === \"function\") {\n nullCheck0();\n}')); - - it('2 call expression with null check call statement', - generateTest('a().b().c?();', 'let nullCheck0 = a().b().c;\nif (typeof nullCheck0 === \"function\") {\n nullCheck0();\n}')); - - it('2 null check call statements', - generateTest('a?().b?();', 'let nullCheck0 = typeof a === \"function\" ? a().b : void 0;\nif (typeof nullCheck0 === \"function\") {\n nullCheck0();\n}')); - - it('3 null check call statements', - generateTest('a?().b?().c?();', 'let nullCheck0 = typeof a === \"function\" ? a().b : void 0;\nlet nullCheck1 = typeof nullCheck0 === \"function\" ? nullCheck0().c : void 0;\nif (typeof nullCheck1 === \"function\") {\n nullCheck1();\n}')); - - it('2 null check call statements with null propagating relationship', - generateTest('a?()?.b?();', 'let nullPropagating0 = typeof a === \"function\" ? a() : void 0;\nif (typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null && typeof nullPropagating0.b === \"function\") {\n nullPropagating0.b();\n}')); - - it('3 null check call statements with null propagating relationship', - generateTest('a?()?.b?()?.c();', 'let nullPropagating0 = typeof a === \"function\" ? a() : void 0;\nlet nullPropagating1 = typeof nullPropagating0 !== \"undefined\" && nullPropagating0 !== null && typeof nullPropagating0.b === \"function\" ? nullPropagating0.b() : void 0;\nif (typeof nullPropagating1 !== \"undefined\" && nullPropagating1 !== null) {\n nullPropagating1.c();\n}')); -}); - -describe('existential expressions:', function () { - it('existential opreator on identifier', - generateTest('var x = a?;', 'let x = typeof a !== \"undefined\" && a !== null;')); - - it('existential opreator on call expression', - generateTest('var x = a()?;', 'let existential0 = a();\nlet x = typeof existential0 !== \"undefined\" && existential0 !== null;')); - - it('existential opreator on null check call expression', - generateTest('var x = a?()?;', 'let existential0 = typeof a === \"function\" ? a() : void 0;\nlet x = typeof existential0 !== \"undefined\" && existential0 !== null;')); - - it('existential opreator on member expression', - generateTest('var x = a.b?;', 'let x = typeof a.b !== \"undefined\" && a.b !== null;')); - - it('existential opreator on member expression with call expression', - generateTest('var x = a.b()?;', 'let existential0 = a.b();\nlet x = typeof existential0 !== \"undefined\" && existential0 !== null;')); - - it('existential opreator on member expression with null check call expression', - generateTest('var x = a.b?()?;', 'let existential0 = typeof a.b === \"function\" ? a.b() : void 0;\nlet x = typeof existential0 !== \"undefined\" && existential0 !== null;')); - - it('existential opreator on null propagating member expression', - generateTest('var x = a?.b?;', 'let existential0 = typeof a !== \"undefined\" && a !== null ? a.b : void 0;\nlet x = typeof existential0 !== \"undefined\" && existential0 !== null;')); - - it('existential opreator on propagating member expression with call expression', - generateTest('var x = a?.b()?;', 'let existential0 = typeof a !== \"undefined\" && a !== null ? a.b() : void 0;\nlet x = typeof existential0 !== \"undefined\" && existential0 !== null;')); - - it('existential opreator on propagating member expression with null check call expression', - generateTest('var x = a?.b?()?;', 'let existential0 = typeof a !== \"undefined\" && a !== null && typeof a.b === \"function\" ? a.b() : void 0;\nlet x = typeof existential0 !== \"undefined\" && existential0 !== null;')); -}); - -describe('object expressions:', function () { - it('empty object', - generateTest('var x = {};', 'let x = {};')); - - it('object with number property', - generateTest('var x = { a: 1 };', 'let x = { a: 1 };')); - - it('object with boolean property', - generateTest('var x = { a: true };', 'let x = { a: true };')); - - it('object with identifier property', - generateTest('var x = { a: b };', 'let x = { a: b };')); - - it('object with string property', - generateTest('var x = { a: "test" };', 'let x = { a: "test" };')); - - it('object with object property', - generateTest('var x = { a: { b: 1 } };', 'let x = { a: { b: 1 } };')); - - it('object with array property', - generateTest('var x = { a: [true] };', 'let x = { a: [true] };')); - - it('object with quoted object property name', - generateTest('var x = { "a b": { b: 1 } };', 'let x = { \"a b\": { b: 1 } };')); - - it('object with 2 properties', - generateTest('var x = { a: 1, b: true };', 'let x = {\n a: 1,\n b: true\n};')); - - it('object with 3 properties', - generateTest('var x = { a: 1, b: true, c: b };', 'let x = {\n a: 1,\n b: true,\n c: b\n};')); - - it('object with 4 properties', - generateTest('var x = { a: 1, b: true, c: b, d: "test" };', 'let x = {\n a: 1,\n b: true,\n c: b,\n d: "test"\n};')); -}); - -describe('array expressions:', function () { - it('empty array', - generateTest('var x = [];', 'let x = [];')); - - it('array with 1 number element', - generateTest('var x = [1];', 'let x = [1];')); - - it('array with 2 number elements', - generateTest('var x = [1, 2];', 'let x = [\n 1,\n 2\n];')); - - it('array with 3 number elements', - generateTest('var x = [1, 2, 3];', 'let x = [\n 1,\n 2,\n 3\n];')); - - it('array with 1 boolean element', - generateTest('var x = [true];', 'let x = [true];')); - - it('array with 2 boolean elements', - generateTest('var x = [true, false];', 'let x = [\n true,\n false\n];')); - - it('array with 3 boolean elements', - generateTest('var x = [true, false, true];', 'let x = [\n true,\n false,\n true\n];')); - - it('array with 1 identifier element', - generateTest('var x = [a];', 'let x = [a];')); - - it('array with 2 identifier elements', - generateTest('var x = [a, b];', 'let x = [\n a,\n b\n];')); - - it('array with 3 identifier elements', - generateTest('var x = [a, b, c];', 'let x = [\n a,\n b,\n c\n];')); - - it('array with 1 string element', - generateTest('var x = ["test"];', 'let x = ["test"];')); - - it('array with 2 string elements', - generateTest('var x = ["test", "test2"];', 'let x = [\n "test",\n "test2"\n];')); - - it('array with 3 string elements', - generateTest('var x = ["test", "test2", "test3"];', 'let x = [\n "test",\n "test2",\n "test3"\n];')); - - it('array with 1 array element', - generateTest('var x = [[true]];', 'let x = [[true]];')); - - it('array with 2 array elements', - generateTest('var x = [[true], [false]];', 'let x = [\n [true],\n [false]\n];')); - - it('array with 3 array elements', - generateTest('var x = [[true], [false], [true]];', 'let x = [\n [true],\n [false],\n [true]\n];')); - - it('array with 1 object element', - generateTest('var x = [{ a: 1 }];', 'let x = [{ a: 1 }];')); - - it('array with 2 object elements', - generateTest('var x = [{ a: 1 }, { b: 2 }];', 'let x = [\n { a: 1 },\n { b: 2 }\n];')); - - it('array with 3 object elements', - generateTest('var x = [{ a: 1 }, { b: 2 }, { c: 3 }];', 'let x = [\n { a: 1 },\n { b: 2 },\n { c: 3 }\n];')); -}); - -describe('unary expressions:', function () { - it('unary not', - generateTest('var x = !a;', 'let x = !a;')); - - it('unary plus', - generateTest('var x = +5;', 'let x = +5;')); - - it('unary minus', - generateTest('var x = -5;', 'let x = -5;')); - - it('typeof identifier', - generateTest('var x = typeof a;', 'let x = typeof a === \"undefined\" ? \"undefined\" : {}.toString.call(a).match(/\\s([a-zA-Z]+)/)[1].toLowerCase();')); - - it('typeof call expression', - generateTest('var x = typeof a();', 'let x = {}.toString.call(a()).match(/\\s([a-zA-Z]+)/)[1].toLowerCase();')); -}); - -describe('arithmetic expressions:', function () { - it('plus with 2 elements', - generateTest('var x = a+b;', 'let x = a + b;')); - - it('plus with 3 elements', - generateTest('var x = a+b+c;', 'let x = a + b + c;')); - - it('minus with 2 elements', - generateTest('var x = a-b;', 'let x = a - b;')); - - it('minus with 3 elements', - generateTest('var x = a-b-c;', 'let x = a - b - c;')); - - it('multipication with 2 elements', - generateTest('var x = a*b;', 'let x = a * b;')); - - it('multipication with 3 elements', - generateTest('var x = a*b*c;', 'let x = a * b * c;')); - - it('division with 2 elements', - generateTest('var x = a/b;', 'let x = a / b;')); - - it('division with 3 elements', - generateTest('var x = a/b/c;', 'let x = a / b / c;')); - - it('order of operators', - generateTest('var x = 3+4*5-(3+4)*5/(a+b-c*d);', 'let x = 3 + 4 * 5 - (3 + 4) * 5 / (a + b - c * d);')); - - it('exponentiation with 2 elements', - generateTest('var x = a**b;', 'let x = Math.pow(a, b);')); - - it('exponentiation with 3 elements', - generateTest('var x = a**b**c;', 'let x = Math.pow(Math.pow(a, b), c);')); - - it('integer division with 2 elements', - generateTest('var x = a#b;', 'let x = Math.floor(a / b);')); - - it('integer division with 3 elements', - generateTest('var x = a#b#c;', 'let x = Math.floor(Math.floor(a / b) / c);')); - - it('modulo with 2 elements', - generateTest('var x = a%b;', 'let x = a % b;')); - - it('modulo with 3 elements', - generateTest('var x = a%b%c;', 'let x = a % b % c;')); - - it('math modulo with 2 elements', - generateTest('var x = a%%b;', 'let x = (a % b + b) % b;')); - - it('math modulo with 3 elements', - generateTest('var x = a%%b%%c;', 'let x = ((a % b + b) % b % c + c) % c;')); -}); - -describe('logical expressions:', function () { - it('AND expression', - generateTest('var x = a && b;', 'let x = !!a && !!b;')); - - it('2 AND expressions', - generateTest('var x = a && b && c;', 'let x = !!(!!a && !!b) && !!c;')); - - it('worded AND expression', - generateTest('var x = a and b;', 'let x = !!a && !!b;')); - - it('2 worded AND expressions', - generateTest('var x = a and b and c;', 'let x = !!(!!a && !!b) && !!c;')); - - it('OR expression', - generateTest('var x = a || b;', 'let x = !!a || !!b;')); - - it('2 OR expressions', - generateTest('var x = a || b || c;', 'let x = !!(!!a || !!b) || !!c;')); - - it('worded OR expression', - generateTest('var x = a or b;', 'let x = !!a || !!b;')); - - it('2 worded OR expressions', - generateTest('var x = a or b or c;', 'let x = !!(!!a || !!b) || !!c;')); - - it('order of logical expressions 1', - generateTest('var x = a && b || c;', 'let x = !!(!!a && !!b) || !!c;')); - - it('order of logical expressions 2', - generateTest('var x = a && b || c && d;', 'let x = !!(!!a && !!b) || !!(!!c && !!d);')); - - it('order of logical expressions 3', - generateTest('var x = a && b || c && (d || e || f && g);', 'let x = !!(!!a && !!b) || !!(!!c && !!(!!(!!d || !!e) || !!(!!f && !!g)));')); -}); - -describe('binary expressions:', function () { - it('equals expression', - generateTest('var x = a == b;', 'let x = a === b;')); - - it('not equals expression', - generateTest('var x = a != b;', 'let x = a !== b;')); - - it('larger expression', - generateTest('var x = a > b;', 'let x = a > b;')); - - it('larger or equals expression', - generateTest('var x = a >= b;', 'let x = a >= b;')); - - it('smaller expression', - generateTest('var x = a < b;', 'let x = a < b;')); - - it('smaller or equals expression', - generateTest('var x = a <= b;', 'let x = a <= b;')); - - it('chained comparisons', - generateTest('var x = a > x > c;', 'let x = a > x && x > c;')); - - it('chained comparisons with 2 components', - generateTest('var x = a > x > c > d;', 'let x = a > x && x > c && c > d;')); - - it('chained comparisons with 3 components', - generateTest('var x = a > x > c > d > e;', 'let x = a > x && x > c && c > d && d > e;')); -}); - -describe('update expressions:', function () { - it('increment statement', - generateTest('a++;', 'a++;')); - - it('decrement statement', - generateTest('a--;', 'a--;')); - - it('increment expression', - generateTest('var x = a++;', 'let x = a++;')); - - it('decrement expression', - generateTest('var x = a--;', 'let x = a--;')); - - it('increment prefix statement', - generateTest('++a;', '++a;')); - - it('decrement prefix statement', - generateTest('--a;', '--a;')); - - it('increment prefix expression', - generateTest('var x = ++a;', 'let x = ++a;')); - - it('decrement prefix expression', - generateTest('var x = --a;', 'let x = --a;')); -}); - -describe('assignment expressions:', function () { - it('assignment statement', - generateTest('a = 1;', 'a = 1;')); - - it('assignment statement with 2 variables', - generateTest('a = b = 1;', 'a = b = 1;')); - - it('assignment statement with 3 variables', - generateTest('a = b = c = 1;', 'a = b = c = 1;')); - - it('assignment expression', - generateTest('var x = a = 1;', 'let x = a = 1;')); - - it('assignment expression with 2 variables', - generateTest('var x = a = b = 1;', 'let x = a = b = 1;')); - - it('assignment expression with 3 variables', - generateTest('var x = a = b = c = 1;', 'let x = a = b = c = 1;')); - - it('addition assignment', generateTest('x += a;', 'x += a;')); - it('subtraction assignment', generateTest('x -= a;', 'x -= a;')); - it('multiplication assignment', generateTest('x *= a;', 'x *= a;')); - it('division assignment', generateTest('x /= a;', 'x /= a;')); - it('remainder assignment', generateTest('x %= a;', 'x %= a;')); - it('left shift assignment', generateTest('x <<= a;', 'x <<= a;')); - it('right shift assignment', generateTest('x >>= a;', 'x >>= a;')); - it('logical right shift assignment', generateTest('x >>>= a;', 'x >>>= a;')); - it('bitwise AND assignment', generateTest('x &= a;', 'x &= a;')); - it('bitwise XOR assignment', generateTest('x ^= a;', 'x ^= a;')); - it('bitwise OR assignment', generateTest('x |= a;', 'x |= a;')); -}); - -describe('if statement:', function () { - it('if statement', - generateTest('if true { }', 'if (true) {\n}')); - - it('if statement with else clause', - generateTest('if true { } else { }', 'if (true) {\n} else {\n}')); - - it('if statement without block', - generateTest('if true a();', 'if (true) {\n a();\n}')); - - it('if statement with else without block', - generateTest('if true a(); else b();', 'if (true) {\n a();\n} else {\n b();\n}')); -}); - -describe('for statement:', function () { - it('for loop with empty arguments', - generateTest('for ;; { }', 'for (;;) {\n}')); - - it('for loop with initialiser only', - generateTest('for var i = 0;; { }', 'for (let i = 0;;) {\n}')); - - it('for loop with condition only', - generateTest('for ; i > 0; { }', 'for (; i > 0;) {\n}')); - - it('for loop with update only', - generateTest('for ;; i++ { }', 'for (;; i++) {\n}')); - - it('for loop with initialiser and condition', - generateTest('for var i = 0; i > 0; { }', 'for (let i = 0; i > 0;) {\n}')); - - it('for loop with initialiser and update', - generateTest('for var i = 0;; i++ { }', 'for (let i = 0;; i++) {\n}')); - - it('for loop with condition and update', - generateTest('for ; i > 0; i++ { }', 'for (; i > 0; i++) {\n}')); - - it('for loop with initialiser, condition and update', - generateTest('for var i = 0; i > 0; i++ { }', 'for (let i = 0; i > 0; i++) {\n}')); -}); - -describe('function declarations:', function () { - it('fn decl without arguments', - generateTest('fn f() { }', 'function f() {\n}')); - - it('fn decl with 1 argument', - generateTest('fn f(a) { }', 'function f(a) {\n}')); - - it('fn decl with 2 arguments', - generateTest('fn f(a, b) { }', 'function f(a, b) {\n}')); - - it('fn decl with 3 arguments', - generateTest('fn f(a, b, c) { }', 'function f(a, b, c) {\n}')); -}); - -describe('function expressions:', function () { - it('function expression without arguments', - generateTest('var a = () -> 1;', 'let a = function () {\n return 1;\n};')); - - it('function expression with 1 argument', - generateTest('var a = (a) -> a;', 'let a = function (a) {\n return a;\n};')); - - it('function expression with 2 arguments', - generateTest('var a = (a, b) -> a+b;', 'let a = function (a, b) {\n return a + b;\n};')); - - it('function expression with 3 arguments', - generateTest('var a = (a, b, c) -> a+b-c;', 'let a = function (a, b, c) {\n return a + b - c;\n};')); - - it('block function expression without arguments', - generateTest('var a = () -> { };', 'let a = function () {\n};')); - - it('block function expression with 1 argument', - generateTest('var a = (a) -> { };', 'let a = function (a) {\n};')); - - it('block function expression with 2 arguments', - generateTest('var a = (a, b) -> { };', 'let a = function (a, b) {\n};')); - - it('block function expression with 3 arguments', - generateTest('var a = (a, b, c) -> { };', 'let a = function (a, b, c) {\n};')); - - it('block function expression (fn syntax) without arguments', - generateTest('var a = fn () { };', 'let a = function () {\n};')); - - it('block function expression (fn syntax) with 1 argument', - generateTest('var a = fn (a) { };', 'let a = function (a) {\n};')); - - it('block function expression (fn syntax) with 2 arguments', - generateTest('var a = fn (a, b) { };', 'let a = function (a, b) {\n};')); - - it('block function expression (fn syntax) with 3 arguments', - generateTest('var a = fn (a, b, c) { };', 'let a = function (a, b, c) {\n};')); - - it('block function expression (fn syntax with id) without arguments', - generateTest('var a = fn f() { };', 'let a = function f() {\n};')); - - it('block function expression (fn syntax with id) with 1 argument', - generateTest('var a = fn f(a) { };', 'let a = function f(a) {\n};')); - - it('block function expression (fn syntax with id) with 2 arguments', - generateTest('var a = fn f(a, b) { };', 'let a = function f(a, b) {\n};')); - - it('block function expression (fn syntax with id) with 3 arguments', - generateTest('var a = fn f(a, b, c) { };', 'let a = function f(a, b, c) {\n};')); -}); - -describe('return statement:', function () { - it('function declaration with a return statement', - generateTest('fn x() { return 1; }', - 'function x() {\n return 1;\n}')); - - it('function expression with a return statement', - generateTest('var a = () -> { return 1; };', 'let a = function () {\n return 1;\n};')); - - it('function declaration with empty return statement', - generateTest('fn x() { return; }', - 'function x() {\n return;\n}')); - - it('function expression with empty return statement', - generateTest('var a = () -> { return; };', 'let a = function () {\n return;\n};')); -}); - -describe('global identifiers and use statements:', function () { - it('global function call', - generateErrorTest('x("test");', - [{ type: 'UndefinedIdentifier', 'identifier': 'x' }])); - - it('global function call with :: operator', - generateTest('::x("test");', 'x("test");')); - - it('global function call with use statement', - generateTest('use x; x("test");', 'x("test");')); - - it('global function call with use statement and :: operator', - generateTest('use x; ::x("test");', 'x("test");')); - - it('global function call with use statement after the function call', - generateErrorTest('x("test"); use x;', - [{ type: 'UndefinedIdentifier', 'identifier': 'x' }])); - - it('global member expression', - generateErrorTest('var x = a.b;', - [{ type: 'UndefinedIdentifier', 'identifier': 'a' }])); - - it('global member expression with :: operator', - generateTest('var x = ::a.b;', 'let x = a.b;')); - - it('global member expression with use statement', - generateTest('use a; var x = a.b;', 'let x = a.b;')); - - it('global member expression with use statement and :: operator', - generateTest('use a; var x = ::a.b;', 'let x = a.b;')); - - it('global member expression with use statement after the member expression', - generateErrorTest('var x = a.b; use a;', - [{ type: 'UndefinedIdentifier', 'identifier': 'a' }])); - - it('use statement with 2 identifiers', - generateErrorTest('use a, b; var x = a + b;', [])); - - it('use statement with 3 identifiers', - generateErrorTest('use a, b, c; var x = a + b + c;', [])); - - it(':browser use statement', - generateErrorTest('use :browser; var x = document + console + window;', [])); -}); - -describe('this keyword:', function () { - it('call statement with this', - generateTest('this.x();', 'this.x();')); - it('call expression with this', - generateTest('var a = this.x();', 'let a = this.x();')); - it('member expression with this', - generateTest('var a = this.x;', 'let a = this.x;')); - it('call statement and member expression with this', - generateTest('this.a.b();', 'this.a.b();')); -}); - -describe('fn extends:', function () { - it('extended function with no constructor', - generateTest('fn A() {} fn B() extends A {}', - 'function A() {\n}\nfunction B() {\n A.call(this);\n}\nB.prototype = Object.create(A);')); - - it('extended function with empty constructor', - generateTest('fn A() {} fn B() extends A() {}', - 'function A() {\n}\nfunction B() {\n A.call(this);\n}\nB.prototype = Object.create(A);')); - - it('extended function with 1-param constructor', - generateTest('fn A() {} fn B() extends A(1) {}', - 'function A() {\n}\nfunction B() {\n A.call(this, 1);\n}\nB.prototype = Object.create(A);')); - - it('extended function with 2-params constructor', - generateTest('fn A() {} fn B(a) extends A(1, a) {}', - 'function A() {\n}\nfunction B(a) {\n A.call(this, 1, a);\n}\nB.prototype = Object.create(A);')); - - it('extended function with global identifier', - generateTest('fn B() extends ::A {}', - 'function B() {\n A.call(this);\n}\nB.prototype = Object.create(A);')); - - it('extended function expression with no constructor', - generateTest('var A = fn () {}; var B = fn () extends A {};', 'let A = function () {\n};\nlet functionExpression0 = function () {\n A.call(this);\n};\nfunctionExpression0.prototype = Object.create(A);\nlet B = functionExpression0;')); - - it('extended function expression with empty constructor', - generateTest('var A = fn () {}; var b = fn () extends A() {};', 'let A = function () {\n};\nlet functionExpression0 = function () {\n A.call(this);\n};\nfunctionExpression0.prototype = Object.create(A);\nlet b = functionExpression0;')); - - it('extended function expression with 1-param constructor', - generateTest('var A = fn () {}; var B = fn () extends A(1) {};', 'let A = function () {\n};\nlet functionExpression0 = function () {\n A.call(this, 1);\n};\nfunctionExpression0.prototype = Object.create(A);\nlet B = functionExpression0;')); - - it('extended function expression with 2-params constructor', - generateTest('var A = fn () {}; var B = fn (a) extends A(1, a) {};', 'let A = function () {\n};\nlet functionExpression0 = function (a) {\n A.call(this, 1, a);\n};\nfunctionExpression0.prototype = Object.create(A);\nlet B = functionExpression0;')); - - it('extended function expression with global identifier', - generateTest('var B = fn () extends ::A {};', 'let functionExpression0 = function () {\n A.call(this);\n};\nfunctionExpression0.prototype = Object.create(A);\nlet B = functionExpression0;')); -}); - -describe('super keyword:', function () { - it('super call statement in a method', - generateTest('fn B() extends ::A { this.test = fn () { super.test(); }; }', - 'function B() {\n A.call(this);\n let _self = this;\n let _test = this.test;\n this.test = function () {\n _test.call(_self);\n };\n}\nB.prototype = Object.create(A);')); - - it('super call statement in a method inside an anonymous function', - generateTest('fn B() extends ::A { this.test = fn () { (() -> { return super.test(); })(); }; }', - 'function B() {\n A.call(this);\n let _self = this;\n let _test = this.test;\n this.test = function () {\n (function () {\n return _test.call(_self);\n }());\n };\n}\nB.prototype = Object.create(A);')); - - it('super call statement in a method inside 2 anonymous functions', - generateTest('fn B() extends ::A { this.test = fn () { (() -> () -> { return super.test(); } )()(); }; }', - 'function B() {\n A.call(this);\n let _self = this;\n let _test = this.test;\n this.test = function () {\n (function () {\n return function () {\n return _test.call(_self);\n };\n }()());\n };\n}\nB.prototype = Object.create(A);')); - - it('super member expression in a method', - generateTest('fn B() extends ::A { this.test = fn () { var x = super.x; }; }', - 'function B() {\n A.call(this);\n let _x = this.x;\n this.test = function () {\n let x = _x;\n };\n}\nB.prototype = Object.create(A);')); - - it('super member expression in a method inside an anonymous function', - generateTest('fn B() extends ::A { this.test = fn () { var x = (() -> super.x)(); }; }', - 'function B() {\n A.call(this);\n let _x = this.x;\n this.test = function () {\n let x = function () {\n return _x;\n }();\n };\n}\nB.prototype = Object.create(A);')); - - it('super member expression in a method inside 2 anonymous functions', - generateTest('fn B() extends ::A { this.test = fn () { var x = (() -> () -> super.x)()(); }; }', - 'function B() {\n A.call(this);\n let _x = this.x;\n this.test = function () {\n let x = function () {\n return function () {\n return _x;\n };\n }()();\n };\n}\nB.prototype = Object.create(A);')); - - it('super call statement in a prototype function', - generateTest('fn B() extends ::A {} B.prototype.test = () -> { super.test(); };', - 'function B() {\n A.call(this);\n}\nB.prototype = Object.create(A);\nB.prototype.test = function () {\n A.prototype.test.call(this);\n};')); - - it('super call statement in a prototype function inside an anonymous function', - generateTest('fn B() extends ::A {} B.prototype.test = () -> { (() -> super.test())(); };', - 'function B() {\n A.call(this);\n}\nB.prototype = Object.create(A);\nB.prototype.test = function () {\n let _self = this;\n (function () {\n return A.prototype.test.call(_self);\n }());\n};')); - - it('super member expression in a prototype function', - generateTest('fn B() extends ::A {} B.prototype.test = () -> { var x = super.x; };', - 'function B() {\n A.call(this);\n}\nB.prototype = Object.create(A);\nB.prototype.test = function () {\n let x = this.x;\n};')); - - it('super member expression in a prototype function inside an anonymous function', - generateTest('fn B() extends ::A {} B.prototype.test = () -> { var x = (() -> { return super.x; })(); };', - 'function B() {\n A.call(this);\n}\nB.prototype = Object.create(A);\nB.prototype.test = function () {\n let _self = this;\n let x = function () {\n return _self.x;\n }();\n};')); - - it('super call statement in a prototype object', - generateTest('fn B() extends ::A {} B.prototype = { test: () -> { super.test(); } };', - 'function B() {\n A.call(this);\n}\nB.prototype = Object.create(A);\nB.prototype = {\n test: function () {\n A.prototype.test.call(this);\n }\n};')); - - it('super call statement in a prototype object inside an anonymous function', - generateTest('fn B() extends ::A {} B.prototype = { test: () -> { (() -> super.test())(); } };', - 'function B() {\n A.call(this);\n}\nB.prototype = Object.create(A);\nB.prototype = {\n test: function () {\n let _self = this;\n (function () {\n return A.prototype.test.call(_self);\n }());\n }\n};')); - - it('super member expression in a prototype object', - generateTest('fn B() extends ::A {} B.prototype = { test: () -> { var x = super.x; } };', - 'function B() {\n A.call(this);\n}\nB.prototype = Object.create(A);\nB.prototype = {\n test: function () {\n let x = this.x;\n }\n};')); - - it('super member expression in a prototype object inside an anonymous function', - generateTest('fn B() extends ::A {} B.prototype = { test: () -> { var x = (() -> { return super.x; })(); } };', - 'function B() {\n A.call(this);\n}\nB.prototype = Object.create(A);\nB.prototype = {\n test: function () {\n let _self = this;\n let x = function () {\n return _self.x;\n }();\n }\n};')); -}); - -describe('string interpolation:', function () { - it('string interpolation', - generateTest('var x = "test \\(a) test \\(2+a) \\(Math.pow(2, a)) test test";', 'let x = \"test \" + a + \" test \" + (2 + a) + \" \" + Math.pow(2, a) + \" test test\";')); -}); - -describe('bitwise opreators:', function () { - it('bitwise AND', generateTest('var x = a & b;', 'let x = a & b;')); - it('bitwise OR', generateTest('var x = a | b;', 'let x = a | b;')); - it('bitwise XOR', generateTest('var x = a ^ b;', 'let x = a ^ b;')); - - it('arithmetic shift left', generateTest('var x = a << b;', 'let x = a << b;')); - it('arithmetic shift right', generateTest('var x = a >> b;', 'let x = a >> b;')); - - it('logical shift right', generateTest('var x = a >>> b;', 'let x = a >>> b;')); -}); - -describe('throw statement:', function () { - it('throw number', generateTest('throw 5;', 'throw 5;')); - it('throw object', generateTest('throw { message: "test" };', 'throw { message: "test" };')); -}); - -describe('control flow statements:', function () { - it('break statement', generateTest('break;', 'break;')); - it('continue statement', generateTest('continue;', 'continue;')); -}); - -describe('range expressions:', function () { - it('upward small inclusive numeric range expression', - generateTest('var x = [1..5];', 'let x = [\n 1,\n 2,\n 3,\n 4,\n 5\n];')); - - it('downward small inclusive numeric range expression', - generateTest('var x = [5..1];', 'let x = [\n 5,\n 4,\n 3,\n 2,\n 1\n];')); - - it('upward small exclusive numeric range expression', - generateTest('var x = [1...5];', 'let x = [\n 1,\n 2,\n 3,\n 4\n];')); - - it('downward small exclusive numeric range expression', - generateTest('var x = [5...1];', 'let x = [\n 5,\n 4,\n 3,\n 2\n];')); - - it('upward large inclusive numeric range expression', - generateTest('var x = [1..25];', 'let x = function () {\n let _results = [];\n for (let _i = 1; _i <= 25; _i++) {\n _results.push(_i);\n }\n return _results;\n}.apply(this);')); - - it('downward large inclusive numeric range expression', - generateTest('var x = [25..1];', 'let x = function () {\n let _results = [];\n for (let _i = 25; _i >= 1; _i--) {\n _results.push(_i);\n }\n return _results;\n}.apply(this);')); - - it('upward large exclusive numeric range expression', - generateTest('var x = [1...25];', 'let x = function () {\n let _results = [];\n for (let _i = 1; _i < 25; _i++) {\n _results.push(_i);\n }\n return _results;\n}.apply(this);')); - - it('downward large exclusive numeric range expression', - generateTest('var x = [25...1];', 'let x = function () {\n let _results = [];\n for (let _i = 25; _i > 1; _i--) {\n _results.push(_i);\n }\n return _results;\n}.apply(this);')); - - it('inclusive identifiers range expression', - generateTest('var x = [a..b];', 'let x = function () {\n let _results = [];\n for (let _i = a; a <= b ? _i <= b : _i >= b; a <= b ? _i++ : _i--) {\n _results.push(_i);\n }\n return _results;\n}.apply(this);')); - - it('exclusive identifiers range expression', - generateTest('var x = [a...b];', 'let x = function () {\n let _results = [];\n for (let _i = a; a <= b ? _i < b : _i > b; a <= b ? _i++ : _i--) {\n _results.push(_i);\n }\n return _results;\n}.apply(this);')); - - it('inclusive call range expression', - generateTest('var x = [a()..b()];', 'let x = function () {\n let _results = [], _start = a(), _end = b();\n for (let _i = _start; _start <= _end ? _i <= _end : _i >= _end; _start <= _end ? _i++ : _i--) {\n _results.push(_i);\n }\n return _results;\n}.apply(this);')); - - it('exclusive call range expression', - generateTest('var x = [a()...b()];', 'let x = function () {\n let _results = [], _start = a(), _end = b();\n for (let _i = _start; _start <= _end ? _i < _end : _i > _end; _start <= _end ? _i++ : _i--) {\n _results.push(_i);\n }\n return _results;\n}.apply(this);')); -}); - -describe('debugger statement:', function () { - it('debugger statement', generateTest('debugger;', 'debugger;')); -}); - -describe('while and until statements:', function () { - it('while statement', generateTest('while true {}', 'while (true) {\n}')); - it('while statement without block', generateTest('while true a();', 'while (true) {\n a();\n}')); - - it('until statement', generateTest('until true {}', 'while (!true) {\n}')); - it('until statement without block', generateTest('until true a();', 'while (!true) {\n a();\n}')); -}); - -describe('array slicing:', function () { - it('inclusive array slice with empty from and to', - generateTest('var x = a[..];', 'let x = a.slice(0);')); - - it('inclusive array slice with numeric from and empty to', - generateTest('var x = a[1..];', 'let x = a.slice(1);')); - - it('inclusive array slice with empty from and numeric to', - generateTest('var x = a[..1];', 'let x = a.slice(0, 2);')); - - it('inclusive array slice with numeric from and numeric to', - generateTest('var x = a[1..2];', 'let x = a.slice(1, 3);')); - - it('inclusive array slice with identifier from and empty to', - generateTest('var x = a[c..];', 'let x = a.slice(c);')); - - it('inclusive array slice with empty from and identifier to', - generateTest('var x = a[..c];', 'let x = a.slice(0, c + 1);')); - - it('inclusive array slice with identifier from and identifier to', - generateTest('var x = a[c..d];', 'let x = a.slice(c, d + 1);')); - - it('exclusive array slice with empty from and to', - generateTest('var x = a[...];', 'let x = a.slice(0);')); - - it('exclusive array slice with numeric from and empty to', - generateTest('var x = a[1...];', 'let x = a.slice(1);')); - - it('exclusive array slice with empty from and numeric to', - generateTest('var x = a[...1];', 'let x = a.slice(0, 1);')); - - it('exclusive array slice with numeric from and numeric to', - generateTest('var x = a[1...2];', 'let x = a.slice(1, 2);')); - - it('exclusive array slice with identifier from and empty to', - generateTest('var x = a[c...];', 'let x = a.slice(c);')); - - it('exclusive array slice with empty from and identifier to', - generateTest('var x = a[...c];', 'let x = a.slice(0, c);')); - - it('exclusive array slice with identifier from and identifier to', - generateTest('var x = a[c...d];', 'let x = a.slice(c, d);')); -}); - -describe('array splicing:', function () { - it('inclusive array splicing with empty from and to', - generateTest('a[..] = [x];', '[].splice.apply(a, [\n 0,\n 9000000000\n].concat([x]));')); - - it('inclusive array splicing with numeric from and empty to', - generateTest('a[1..] = [x];', '[].splice.apply(a, [\n 1,\n 9000000000\n].concat([x]));')); - - it('inclusive array splicing with empty from and numeric to', - generateTest('a[..3] = [x];', '[].splice.apply(a, [\n 0,\n 4\n].concat([x]));')); - - it('inclusive array splicing with numeric from and numeric to', - generateTest('a[2..3] = [x];', '[].splice.apply(a, [\n 2,\n 2\n].concat([x]));')); - - it('inclusive array splicing with identifier from and empty to', - generateTest('a[t..] = [x];', '[].splice.apply(a, [\n t,\n 9000000000\n].concat([x]));')); - - it('inclusive array splicing with empty from and numeric to', - generateTest('a[..v] = [x];', '[].splice.apply(a, [\n 0,\n v + 1\n].concat([x]));')); - - it('inclusive array splicing with numeric from and numeric to', - generateTest('a[t..v] = [x];', '[].splice.apply(a, [\n t,\n v - t + 1\n].concat([x]));')); - - it('exclusive array splicing with empty from and to', - generateTest('a[...] = [x];', '[].splice.apply(a, [\n 0,\n 9000000000\n].concat([x]));')); - - it('exclusive array splicing with numeric from and empty to', - generateTest('a[1...] = [x];', '[].splice.apply(a, [\n 1,\n 9000000000\n].concat([x]));')); - - it('exclusive array splicing with empty from and numeric to', - generateTest('a[...3] = [x];', '[].splice.apply(a, [\n 0,\n 3\n].concat([x]));')); - - it('exclusive array splicing with numeric from and numeric to', - generateTest('a[2...3] = [x];', '[].splice.apply(a, [\n 2,\n 1\n].concat([x]));')); - - it('exclusive array splicing with identifier from and empty to', - generateTest('a[t...] = [x];', '[].splice.apply(a, [\n t,\n 9000000000\n].concat([x]));')); - - it('exclusive array splicing with empty from and numeric to', - generateTest('a[...v] = [x];', '[].splice.apply(a, [\n 0,\n v\n].concat([x]));')); - - it('exclusive array splicing with numeric from and numeric to', - generateTest('a[t...v] = [x];', '[].splice.apply(a, [\n t,\n v - t\n].concat([x]));')); -}); - -describe('new expressions:', function () { - it('new expression with 0 arguments', - generateTest('var x = new A();', 'let x = new A();')); - - it('new expression with 1 argument', - generateTest('var x = new A(1);', 'let x = new A(1);')); - - it('new expression with 2 argument', - generateTest('var x = new A(1, b());', 'let x = new A(1, b());')); -}); - -describe('default fn param value:', function () { - it('fn decl with 1 param with default value', - generateTest('fn f(a = 5) {}', - 'function f(a = 5) {\n}')); - - it('fn decl with 2 params with default values', - generateTest('fn f(a = 5, b = 3) {}', - 'function f(a = 5, b = 3) {\n}')); - - it('fn decl with 2 params - first with default value and second without', - generateTest('fn f(a = 5, b) {}', - 'function f(a = 5, b) {\n}')); - - it('fn decl with 2 params - second with default value and first without', - generateTest('fn f(a, b = 3) {}', - 'function f(a, b = 3) {\n}')); - - it('fn decl with 3 params with default values', - generateTest('fn f(a = 5, b = 3, k = { test: 1 }) {}', - 'function f(a = 5, b = 3, k = { test: 1 }) {\n}')); - - it('fn expression with 1 param with default value', - generateTest('var x = (a = 5) -> a;', 'let x = function (a = 5) {\n return a;\n};')); - - it('fn expression with 2 params with default values', - generateTest('var x = fn (a = 5, b = 3) {};', 'let x = function (a = 5, b = 3) {\n};')); - - it('fn expression with 2 params - first with default value and second without', - generateTest('var x = fn (a = 5, b) {};', 'let x = function (a = 5, b) {\n};')); - - it('fn expression with 2 params - second with default value and first without', - generateTest('var x = fn (a, b = 3) {};', 'let x = function (a, b = 3) {\n};')); - - it('fn expression with 3 params with default values', - generateTest('var x = fn (a = 5, b = 3, k = { test: 1 }) {};', 'let x = function (a = 5, b = 3, k = { test: 1 }) {\n};')); -}); - -describe('splat in function declaration:', function () { - it('fn decl with splat', - generateTest('fn f(a...) {}', - 'function f() {\n let __splat, a = 1 <= arguments.length ? [].slice.call(arguments, 0) : [];\n}')); - - it('fn decl with splat, parameter', - generateTest('fn f(a..., b) {}', - 'function f() {\n let __splat, a = 2 <= arguments.length ? [].slice.call(arguments, 0, __splat = arguments.length - 1) : (__splat = 0, []), b = arguments[__splat++];\n}')); - - it('fn decl with parameter, splat', - generateTest('fn f(a, b...) {}', - 'function f() {\n let __splat, a = arguments[0], b = 2 <= arguments.length ? [].slice.call(arguments, 1) : [];\n}')); - - it('fn decl with parameter, splat, parameter', - generateTest('fn f(a, b..., c) {}', - 'function f() {\n let __splat, a = arguments[0], b = 3 <= arguments.length ? [].slice.call(arguments, 1, __splat = arguments.length - 1) : (__splat = 1, []), c = arguments[__splat++];\n}')); - - it('fn decl with parameter, parameter, splat, parameter', - generateTest('fn f(a, b, c..., d) {}', - 'function f() {\n let __splat, a = arguments[0], b = arguments[1], c = 4 <= arguments.length ? [].slice.call(arguments, 2, __splat = arguments.length - 1) : (__splat = 2, []), d = arguments[__splat++];\n}')); - - it('fn decl with parameter, splat, parameter, parameter', - generateTest('fn f(a, b..., c, d) {}', - 'function f() {\n let __splat, a = arguments[0], b = 4 <= arguments.length ? [].slice.call(arguments, 1, __splat = arguments.length - 2) : (__splat = 1, []), c = arguments[__splat++], d = arguments[__splat++];\n}')); - - it('multiple splats in fn decl', - generateErrorTest('fn f(a..., b...) {}', [{ type: "MultipleSplatsDisallowed" }])); -}); - -describe('splat in call expressions:', function () { - it('call expression with a splat', - generateTest('f(a...);', 'f.apply(null, a);')); - - it('call expression with splat, argument', - generateTest('f(a..., b);', 'f.apply(null, [].slice.call(a).concat([b]));')); - - it('call expression with argument, splat', - generateTest('f(a, b...);', 'f.apply(null, [a].concat([].slice.call(b)));')); - - it('call expression with splat, argument, argument', - generateTest('f(a..., b, c);', 'f.apply(null, [].slice.call(a).concat([b], [c]));')); - - it('call expression with argument, splat, argument', - generateTest('f(a, b..., c);', 'f.apply(null, [a].concat([].slice.call(b), [c]));')); - - it('call expression with argument, argument, splat, argument', - generateTest('f(a, b, c..., d);', 'f.apply(null, [\n a,\n b\n].concat([].slice.call(c), [d]));')); - - it('null check call expression with a splat', - generateTest('f?(a...);', 'if (typeof f === \"function\") {\n f.apply(null, a);\n}')); - - it('null check call expression with splat, argument', - generateTest('f?(a..., b);', 'if (typeof f === \"function\") {\n f.apply(null, [].slice.call(a).concat([b]));\n}')); - - it('null check call expression with argument, splat', - generateTest('f?(a, b...);', 'if (typeof f === \"function\") {\n f.apply(null, [a].concat([].slice.call(b)));\n}')); - - it('null check call expression with splat, argument, argument', - generateTest('f?(a..., b, c);', 'if (typeof f === \"function\") {\n f.apply(null, [].slice.call(a).concat([b], [c]));\n}')); - - it('null check call expression with argument, splat, argument', - generateTest('f?(a, b..., c);', 'if (typeof f === \"function\") {\n f.apply(null, [a].concat([].slice.call(b), [c]));\n}')); - - it('null check call expression with argument, argument, splat, argument', - generateTest('f?(a, b, c..., d);', 'if (typeof f === \"function\") {\n f.apply(null, [\n a,\n b\n ].concat([].slice.call(c), [d]));\n}')); -}); - -describe('conditional expressions:', function () { - it('conditional expression', - generateTest('var x = a() if b else c();', 'let x = b ? a() : c();')); -}); - -describe('for in statement:', function () { - it('for in statement without index', - generateTest('for item in array {}', - 'for (let item of array) {\n}')); - - it('for in statement with index', - generateTest('for item, index in array {}', - 'let index = 0;\nfor (let item of array) {\n index++;\n}')); -}); - -describe('for of statement:', function () { - it('for of statement without value', - generateTest('for key of object {}', - 'for (let key of Object.keys(object)) {\n}')); - - it('for of statement with value', - generateTest('for key, value of object {}', - 'for (let key of Object.keys(object)) {\n let value = object[key];\n}')); - - it('for of statement of call expression without value', - generateTest('for key of f() {}', - 'for (let key of Object.keys(f())) {\n}')); - - it('for of statement of call expression with value', - generateTest('for key, value of f() {}', - 'let forOf0 = f();\nfor (let key of Object.keys(forOf0)) {\n let value = forOf0[key];\n}')); -}); - -describe('try statement:', function () { - it('try statement without handler with finalizer', - generateTest('try { a(); } finally { b(); }', - 'try {\n a();\n} finally {\n b();\n}')); - - it('try statement with handler without finalizer', - generateTest('try { a(); } catch error { b(); }', - 'try {\n a();\n} catch (error) {\n b();\n}')); - - it('try statement with handler and finalizer', - generateTest('try { a(); } catch error { b(); } finally { c(); }', - 'try {\n a();\n} catch (error) {\n b();\n} finally {\n c();\n}')); -}); - -describe('in expression:', function () { - it('in expression with identifier', - generateTest('var x = a in b;', 'let x = b instanceof Array ? b.indexOf(a) !== -1 : a in b;')); - - it('in expression with call expression', - generateTest('var x = a in b();', 'let inExpression0 = b();\nlet x = inExpression0 instanceof Array ? inExpression0.indexOf(a) !== -1 : a in inExpression0;')); -}); - -describe('list comprehensions:', function () { - it('list comprehension without condition and without index', - generateTest('var x = [item + 1 for item in array];', - 'let x = function () {\n let forIn0 = [];\n for (let item of array) {\n forIn0.push(item + 1);\n }\n return forIn0;\n}();')); - - it('list comprehension with condition and without index', - generateTest('var x = [item + 1 for item in array if condition];', - 'let x = function () {\n let forIn0 = [];\n for (let item of array) {\n if (condition) {\n forIn0.push(item + 1);\n }\n }\n return forIn0;\n}();')); - - it('list comprehension without condition and with index', - generateTest('var x = [item + index for item, index in array];', - 'let x = function () {\n let forIn0 = [];\n let index = 0;\n for (let item of array) {\n forIn0.push(item + index);\n index++;\n }\n return forIn0;\n}();')); - - it('list comprehension with condition and with index', - generateTest('var x = [item + index for item, index in array if index > 1];', - 'let x = function () {\n let forIn0 = [];\n let index = 0;\n for (let item of array) {\n if (index > 1) {\n forIn0.push(item + index);\n }\n index++;\n }\n return forIn0;\n}();')); -}); - -describe('switch statement:', function () { - it('switch statement with single case', - generateTest('switch n { case 1: { } }', - 'if (n === 1) {\n}')); - - it('switch statement with 2 cases', - generateTest('switch n { case 1: { }, case 2: { } }', - 'if (n === 1) {\n} else if (n === 2) {\n}')); - - it('switch statement with 2 cases with multiple options', - generateTest('switch n { case 1, 2: { }, case 3, 4: { } }', - 'if (n === 1 || n === 2) {\n} else if (n === 3 || n === 4) {\n}')); - - it('switch statement with 2 cases with multiple options and default case', - generateTest('switch n { case 1, 2: { }, case 3, 4: { }, default: { } }', - 'if (n === 1 || n === 2) {\n} else if (n === 3 || n === 4) {\n} else {\n}')); - - it('switch statement with 2 cases with multiple options, inclusive range case and default case', - generateTest('switch n { case 1, 2: { }, case 3, 4: { }, case 5..6: { }, default: { } }', - 'if (n === 1 || n === 2) {\n} else if (n === 3 || n === 4) {\n} else if (n >= 5 && n <= 6) {\n} else {\n}')); - - it('switch statement with 2 cases with multiple options, inclusive range case without from and default case', - generateTest('switch n { case 1, 2: { }, case 3, 4: { }, case ..6: { }, default: { } }', - 'if (n === 1 || n === 2) {\n} else if (n === 3 || n === 4) {\n} else if (n <= 6) {\n} else {\n}')); - - it('switch statement with 2 cases with multiple options, inclusive range case without to and default case', - generateTest('switch n { case 1, 2: { }, case 3, 4: { }, case 5..: { }, default: { } }', - 'if (n === 1 || n === 2) {\n} else if (n === 3 || n === 4) {\n} else if (n >= 5) {\n} else {\n}')); - - it('switch statement with 2 cases with multiple options, exclusive range case and default case', - generateTest('switch n { case 1, 2: { }, case 3, 4: { }, case 5...6: { }, default: { } }', - 'if (n === 1 || n === 2) {\n} else if (n === 3 || n === 4) {\n} else if (n >= 5 && n < 6) {\n} else {\n}')); - - it('switch statement with 2 cases with multiple options, exclusive range case without from and default case', - generateTest('switch n { case 1, 2: { }, case 3, 4: { }, case ...6: { }, default: { } }', - 'if (n === 1 || n === 2) {\n} else if (n === 3 || n === 4) {\n} else if (n < 6) {\n} else {\n}')); - - it('switch statement with 2 cases with multiple options, exclusive range case without to and default case', - generateTest('switch n { case 1, 2: { }, case 3, 4: { }, case 5...: { }, default: { } }', - 'if (n === 1 || n === 2) {\n} else if (n === 3 || n === 4) {\n} else if (n >= 5) {\n} else {\n}')); - - it('switch statement with single default case', - generateErrorTest('switch ::n { default: { } }', - [{ "type": "SingleDefaultClause" }])); - - it('switch statement with range case without from and without to', - generateErrorTest('switch ::n { case ..: { } }', - [{ "type": "EmptyRange" }])); -}); - -describe('fallthrough statement:', function () { - it('switch with 2 fallthrough cases', - generateTest('switch n { case 1..2: { a(); fallthrough; }, case 1..4: { b(); fallthrough; } }', 'let fallthrough0 = 0;\nif (n >= 1 && n <= 2) {\n fallthrough0 = 2;\n a();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2 && (n >= 1 && n <= 4)) {\n fallthrough0 = 2;\n b();\n fallthrough0 = 1;\n}')); - - it('switch with 3 fallthrough cases', - generateTest('switch n { case 1..2: { a(); fallthrough; }, case 1..4: { b(); fallthrough; }, case 1..6: { c(); fallthrough; } }', 'let fallthrough0 = 0;\nif (n >= 1 && n <= 2) {\n fallthrough0 = 2;\n a();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2 && (n >= 1 && n <= 4)) {\n fallthrough0 = 2;\n b();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2 && (n >= 1 && n <= 6)) {\n fallthrough0 = 2;\n c();\n fallthrough0 = 1;\n}')); - - it('switch with fallthrough-normal-fallthrough cases', - generateTest('switch n { case 1..2: { a(); fallthrough; }, case 1..4: { b(); }, case 1..6: { c(); fallthrough; } }', 'let fallthrough0 = 0;\nif (n >= 1 && n <= 2) {\n fallthrough0 = 2;\n a();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2 && (n >= 1 && n <= 4)) {\n fallthrough0 = 2;\n b();\n} else if (fallthrough0 < 2 && (n >= 1 && n <= 6)) {\n fallthrough0 = 2;\n c();\n fallthrough0 = 1;\n}')); - - it('switch with fallthrough-normal-normal-fallthrough cases', - generateTest('switch n { case 1..2: { a(); fallthrough; }, case 1..4: { b(); }, case 1..6: { c(); }, case 1..8: { d(); fallthrough; } }', 'let fallthrough0 = 0;\nif (n >= 1 && n <= 2) {\n fallthrough0 = 2;\n a();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2 && (n >= 1 && n <= 4)) {\n fallthrough0 = 2;\n b();\n} else if (fallthrough0 < 2 && (n >= 1 && n <= 6)) {\n fallthrough0 = 2;\n c();\n} else if (fallthrough0 < 2 && (n >= 1 && n <= 8)) {\n fallthrough0 = 2;\n d();\n fallthrough0 = 1;\n}')); - - it('switch with normal-fallthrough-normal-fallthrough cases', - generateTest('switch n { case 1..2: { a(); }, case 1..4: { b(); fallthrough; }, case 1..6: { c(); }, case 1..8: { d(); fallthrough; } }', 'let fallthrough0 = 0;\nif (n >= 1 && n <= 2) {\n fallthrough0 = 2;\n a();\n} else if (n >= 1 && n <= 4) {\n fallthrough0 = 2;\n b();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2 && (n >= 1 && n <= 6)) {\n fallthrough0 = 2;\n c();\n} else if (fallthrough0 < 2 && (n >= 1 && n <= 8)) {\n fallthrough0 = 2;\n d();\n fallthrough0 = 1;\n}')); - - it('switch with 2 fallthrough cases with default', - generateTest('switch n() { case a(): { a(); fallthrough; }, case 1..4: { b(); fallthrough; }, default: { def(); } }', 'let fallthrough0 = 0;\nlet switchStatement0 = n();\nif (fallthrough0 < 2 && (switchStatement0 >= 1 && switchStatement0 <= 4)) {\n fallthrough0 = 2;\n b();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2) {\n def();\n}\nif (switchStatement0 === a()) {\n fallthrough0 = 2;\n a();\n fallthrough0 = 1;\n}')); - - it('switch with 3 fallthrough cases with default', - generateTest('switch n { case 1..2: { a(); fallthrough; }, case 1..4: { b(); fallthrough; }, case 1..6: { c(); fallthrough; }, default: { def(); } }', 'let fallthrough0 = 0;\nif (n >= 1 && n <= 2) {\n fallthrough0 = 2;\n a();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2 && (n >= 1 && n <= 4)) {\n fallthrough0 = 2;\n b();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2 && (n >= 1 && n <= 6)) {\n fallthrough0 = 2;\n c();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2) {\n def();\n}')); - - it('switch with fallthrough-normal-fallthrough cases with default', - generateTest('switch n { case 1..2: { a(); fallthrough; }, case 1..4: { b(); }, case 1..6: { c(); fallthrough; }, default: { def(); } }', 'let fallthrough0 = 0;\nif (n >= 1 && n <= 2) {\n fallthrough0 = 2;\n a();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2 && (n >= 1 && n <= 4)) {\n fallthrough0 = 2;\n b();\n} else if (fallthrough0 < 2 && (n >= 1 && n <= 6)) {\n fallthrough0 = 2;\n c();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2) {\n def();\n}')); - - it('switch with fallthrough-normal-normal-fallthrough cases with default', - generateTest('switch n { case 1..2: { a(); fallthrough; }, case 1..4: { b(); }, case 1..6: { c(); }, case 1..8: { d(); fallthrough; }, default: { def(); } }', 'let fallthrough0 = 0;\nif (n >= 1 && n <= 2) {\n fallthrough0 = 2;\n a();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2 && (n >= 1 && n <= 4)) {\n fallthrough0 = 2;\n b();\n} else if (fallthrough0 < 2 && (n >= 1 && n <= 6)) {\n fallthrough0 = 2;\n c();\n} else if (fallthrough0 < 2 && (n >= 1 && n <= 8)) {\n fallthrough0 = 2;\n d();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2) {\n def();\n}')); - - it('switch with normal-fallthrough-normal-fallthrough cases with default', - generateTest('switch n { case 1..2: { a(); }, case 1..4: { b(); fallthrough; }, case 1..6: { c(); }, case 1..8: { d(); fallthrough; }, default: { def(); } }', 'let fallthrough0 = 0;\nif (n >= 1 && n <= 2) {\n fallthrough0 = 2;\n a();\n} else if (n >= 1 && n <= 4) {\n fallthrough0 = 2;\n b();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2 && (n >= 1 && n <= 6)) {\n fallthrough0 = 2;\n c();\n} else if (fallthrough0 < 2 && (n >= 1 && n <= 8)) {\n fallthrough0 = 2;\n d();\n fallthrough0 = 1;\n}\nif (fallthrough0 < 2) {\n def();\n}')); -}); - -describe('fat arrow:', function () { - it('fat arrow function expression', - generateTest('var x = () => this.test;', 'let x = () => {\n return this.test;\n};')); - - it('fat arrow function expression inside another', - generateTest('var x = () => () => this.test;', 'let x = () => {\n return () => {\n return this.test;\n };\n};')); -}); - -describe('for-in and for-of with break and return:', function () { - it('for-in with break', - generateTest('for x in array { break; }', - 'for (let x of array) {\n break;\n}')); - - it('for-in with conditional break', - generateTest('for x in array { if x == 5 { break; } }', - 'for (let x of array) {\n if (x === 5) {\n break;\n }\n}')); - - it('for-in with return', - generateTest('for x in array { return 5; }', - 'for (let x of array) {\n return 5;\n}')); - - it('for-in with return w/o argument', - generateTest('for x in array { return; }', - 'for (let x of array) {\n return;\n}')); - - it('for-in with conditional return', - generateTest('for x in array { if x == 5 { return 5; } }', - 'for (let x of array) {\n if (x === 5) {\n return 5;\n }\n}')); - - it('for-of with break', - generateTest('for x of obj { break; }', - 'for (let x of Object.keys(obj)) {\n break;\n}')); - - it('for-of with conditional break', - generateTest('for x of obj { if x == 5 { break; } }', - 'for (let x of Object.keys(obj)) {\n if (x === 5) {\n break;\n }\n}')); - - it('for-of with return', - generateTest('for x of obj { return 5; }', - 'for (let x of Object.keys(obj)) {\n return 5;\n}')); - - it('for-of with conditional return', - generateTest('for x of obj { if x == 5 { return 5; } }', - 'for (let x of Object.keys(obj)) {\n if (x === 5) {\n return 5;\n }\n}')); -}); - -describe('regular expression literals:', function () { - it('regular expression literal', - generateTest('var re = /ab+c/g;', 'let re = /ab+c/g;')); -}); - -describe('import statement:', function () { - it('import with 1 identifier', - generateTest('import foo from "foobar";', - 'import { foo } from \"foobar\";')); - - it('import with 2 identifiers', - generateTest('import foo, bar from "foobar";', - 'import {\n foo,\n bar\n} from \"foobar\";')); - - it('import with 1 identifier with as', - generateTest('import foo as a from "foobar";', - 'import { foo as a } from \"foobar\";')); - - it('import with 2 identifiers with as', - generateTest('import foo as a, bar as b from "foobar";', - 'import {\n foo as a,\n bar as b\n} from \"foobar\";')); - - it('batch import', - generateTest('import * as lib from "lib";', - 'import * as lib from \"lib\";')); - - it('import default', - generateTest('import "jquery" as $;', - 'import $ from "jquery";')); -}); - -describe('export statement:', function () { - it('export with 1 identifier', - generateTest('export foo;', - 'export {\n foo\n};')); - - it('export with 2 identifiers', - generateTest('export foo, bar;', - 'export {\n foo,\n bar\n};')); - - it('export with 1 identifier with as', - generateTest('export foo as f;', - 'export {\n foo as f\n};')); - - it('export with 2 identifiers with as', - generateTest('export foo as f, bar as b;', - 'export {\n foo as f,\n bar as b\n};')); - - it('export with 1 identifier with source', - generateTest('export foo from "foo";', - 'export {\n foo\n} from \"foo\";')); - - it('export with 2 identifiers with source', - generateTest('export foo, bar from "foobar";', - 'export {\n foo,\n bar\n} from \"foobar\";')); - - it('batch export', - generateTest('export * from "foobar";', - 'export * from \"foobar\";')); - - it('export variable statement', - generateTest('export var sqrt = Math.sqrt;', - 'export let sqrt = Math.sqrt;')); - - it('export function statement', - generateTest('export fn x() {}', - 'export function x() {\n}')); - - it('export function statement with extends', - generateTest('export fn x() extends A {}', - 'export function x() {\n A.call(this);\n}\nx.prototype = Object.create(A);')); - - it('export default identifier', - generateTest('export default x;', - 'export default x;')); - - it('export default function expression', - generateTest('export default () -> {};', - 'export default function () {\n};')); -}); - -describe('curried functions:', function () { - it('single function curry', - generateTest('var x = a^(1);', - 'let x = function () {\n return a.apply(this, [1].concat([].slice.apply(arguments)));\n};')); - - it('double function curry', - generateTest('var x = a^(1)^(2, 3);', - 'let x = function () {\n return function () {\n return a.apply(this, [1].concat([].slice.apply(arguments)));\n }.apply(this, [\n 2,\n 3\n ].concat([].slice.apply(arguments)));\n};')); - - it('single function curry with member expression', - generateTest('var x = m.a^(1);', - 'let x = function () {\n return m.a.apply(this, [1].concat([].slice.apply(arguments)));\n};')); - - it('double function curry with member expression', - generateTest('var x = m.a^(1)^(2, 3);', - 'let x = function () {\n return function () {\n return m.a.apply(this, [1].concat([].slice.apply(arguments)));\n }.apply(this, [\n 2,\n 3\n ].concat([].slice.apply(arguments)));\n};')); - - it('curry function with splats', - generateErrorTest('var x = ::a^(::s...);', - [{ type: "InvalidFunctionCurrying" }])); - - it('curry function with null propagating operator', - generateErrorTest('var x = ::m?.a^();', - [{ type: "InvalidFunctionCurrying" }])); -}); - -describe('destructuring assignment:', function () { - it('array pattern destructuring assignment', - generateTest('var [m, d, y] = [3, 14, 1977];', - 'let [\n m,\n d,\n y\n] = [\n 3,\n 14,\n 1977\n];')); - - it('array pattern destructuring assignment with 1 null', - generateTest('var [, d, y] = [3, 14, 1977];', - 'let [\n ,\n d,\n y\n] = [\n 3,\n 14,\n 1977\n];')); - - it('array pattern destructuring assignment with 2 nulls', - generateTest('var [,, y] = [3, 14, 1977];', - 'let [\n ,\n ,\n y\n] = [\n 3,\n 14,\n 1977\n];')); - - it('array pattern destructuring assignment with sub array pattern', - generateTest('var [,, [a,b,c]] = [3, 14, [1,2,3]];', - 'let [\n ,\n ,\n [\n a,\n b,\n c\n ]\n] = [\n 3,\n 14,\n [\n 1,\n 2,\n 3\n ]\n];')); - - it('object pattern destructuring assignment', - generateTest('var { x: x } = f;', - 'let {x: x} = f;')); - - it('object pattern destructuring assignment with 2 properties', - generateTest('var { x: x, y: test } = f;', - 'let {\n x: x,\n y: test\n} = f;')); - - it('object pattern destructuring assignment with sub object pattern', - generateTest('var { x: x, y: { b: b } } = f;', - 'let {\n x: x,\n y: {b: b}\n} = f;')); - - it('swap', - generateTest('[x,y]=[y,x];', - '[\n x,\n y\n] = [\n y,\n x\n];')); -}); - -describe('object initializer shorthand:', function () { - it('object literal initializer shorthand', - generateTest('var a = {x, y};', - 'let a = {\n x,\n y\n};')); - - it('object pattern initializer shorthand', - generateTest('var {x, y} = {x: 1, y: 2};', - 'let {x, y} = {\n x: 1,\n y: 2\n};')); -}); - -describe('property method assignments:', function () { - it('property method assignment', - generateTest('var object = {value: 42, toString() { return this.value; }};', - 'let object = {\n value: 42,\n toString() {\n return this.value;\n }\n};')); -}); - -describe('pattern matching:', function () { - it('pattern match', - generateTest('switch [a,b] { case [,5]: {} case [5,,,6]: {}}', - 'let switchStatement0 = [\n a,\n b\n];\nif (switchStatement0.length >= 2 && switchStatement0[1] === 5) {\n} else if (switchStatement0.length >= 4 && switchStatement0[0] === 5 && switchStatement0[3] === 6) {\n}')); -}); - -describe('delete statement:', function () { - it('delete statement', - generateTest('delete x;', 'delete x;')); -}); - -describe('do-while loop:', function () { - it('do-while loop', - generateTest('do { f(); } while true;', 'do {\n f();\n} while (true);')); -}); - -describe('channels:', function () { - it('get expression', - generateTest('f(<-x);', - 'f(await x.get());')); - - it('push statement', - generateTest('a <- b;', - 'a.push(b);')); - - it('go statement', - generateTest('go { f(); };', - '(async function () {\n f();\n})();')); - - it('get operator in global context', - generateErrorTest('::f(<-::x);', - [{ type: "GetExpressionRequiresAsync" }])); - - it('get operator in a normal function', - generateErrorTest('fn h() { ::f(<-::x); }', - [{ type: "GetExpressionRequiresAsync" }])); - - it('get operator in an async function', - generateErrorTest('async fn h() { ::f(<-::x); }', [])); - - it('get operator in an go statement', - generateErrorTest('go { ::f(<-::x); };', [])); -}); - -describe('undefined literals:', function () { - it('undefined literal', - generateTest('undefined;', 'void 0;')); -}); \ No newline at end of file