--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/samples/prettyprinter.js Thu Mar 19 16:13:54 2015 -0700
@@ -0,0 +1,642 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Oracle nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * This script is a AST pretty printer for ECMAScript. It uses
+ * Nashorn parser API to parser given script and uses tree visitor
+ * to pretty print the AST to stdout as a script string.
+ */
+
+var File = Java.type("java.io.File");
+var file = arguments.length == 0? new File(__FILE__) : new File(arguments[0]);
+if (! file.isFile()) {
+ print(arguments[0] + " is not a file");
+ exit(1);
+}
+
+// Java classes used
+var ArrayAccess = Java.type("jdk.nashorn.api.tree.ArrayAccessTree");
+var Block = Java.type("jdk.nashorn.api.tree.BlockTree");
+var FunctionDeclaration = Java.type("jdk.nashorn.api.tree.FunctionDeclarationTree");
+var FunctionExpression = Java.type("jdk.nashorn.api.tree.FunctionExpressionTree");
+var Identifier = Java.type("jdk.nashorn.api.tree.IdentifierTree");
+var Kind = Java.type("jdk.nashorn.api.tree.Tree.Kind");
+var MemberSelect = Java.type("jdk.nashorn.api.tree.MemberSelectTree");
+var ObjectLiteral = Java.type("jdk.nashorn.api.tree.ObjectLiteralTree");
+var Parser = Java.type("jdk.nashorn.api.tree.Parser");
+var SimpleTreeVisitor = Java.type("jdk.nashorn.api.tree.SimpleTreeVisitorES5_1");
+var System = Java.type("java.lang.System");
+
+// make a nashorn parser
+var parser = Parser.create("-scripting", "--const-as-var");
+
+// symbols for nashorn operators
+var operatorSymbols = {
+ POSTFIX_INCREMENT: "++",
+ POSTFIX_DECREMENT: "--",
+ PREFIX_INCREMENT: "++",
+ PREFIX_DECREMENT: "--",
+ UNARY_PLUS: "+",
+ UNARY_MINUS: "-",
+ BITWISE_COMPLEMENT: "~",
+ LOGICAL_COMPLEMENT: "!",
+ DELETE: "delete ",
+ TYPEOF: "typeof ",
+ VOID: "void ",
+ COMMA: ",",
+ MULTIPLY: "*",
+ DIVIDE: "/",
+ REMINDER: "%",
+ PLUS: "+",
+ MINUS: "-",
+ LEFT_SHIFT: "<<",
+ RIGHT_SHIFT: ">>",
+ UNSIGNED_RIGHT_SHIFT: ">>>",
+ LESS_THAN: "<",
+ GREATER_THAN: ">",
+ LESS_THAN_EQUAL: "<=",
+ GREATER_THAN_EQUAL: ">=",
+ IN: "in",
+ EQUAL_TO: "==",
+ NOT_EQUAL_TO: "!=",
+ STRICT_EQUAL_TO: "===",
+ STRICT_NOT_EQUAL_TO: "!==",
+ AND: "&",
+ XOR: "^",
+ OR: "|",
+ CONDITIONAL_AND: "&&",
+ CONDITIONAL_OR: "||",
+ MULTIPLY_ASSIGNMENT: "*=",
+ DIVIDE_ASSIGNMENT: "/=",
+ REMINDER_ASSIGNMENT: "%=",
+ PLUS_ASSIGNMENT: "+=",
+ MINUS_ASSIGNMENT: "-=",
+ LEFT_SHIFT_ASSIGNMENT: "<<=",
+ RIGHT_SHIFT_ASSIGNMENT: ">>=",
+ UNSIGNED_RIGHT_SHIFT_ASSIGNMENT: ">>>=",
+ AND_ASSIGNMENT: "&=",
+ XOR_ASSIGNMENT: "^=",
+ OR_ASSIGNMENT: "|="
+};
+
+function operatorOf(kind) {
+ var name = kind.name();
+ if (name in operatorSymbols) {
+ return operatorSymbols[name];
+ }
+ throw "invalid operator: " + name;
+}
+
+var gprint = print;
+
+function prettyPrint(file) {
+ var ast = parser.parse(file, gprint);
+ if (!ast) {
+ // failed to parse. don't print anything!
+ return;
+ }
+
+ // AST visitor
+ var visitor;
+ // current indent level
+ var indentLevel = 0;
+ var out = System.out;
+
+ function print(obj) {
+ out.print(String(obj));
+ }
+
+ function println(obj) {
+ obj? out.println(String(obj)) : out.println();
+ }
+
+ // semicolon and end-of-line
+ function eol() {
+ println(";");
+ }
+
+ // print indentation - 4 spaces per level
+ function indent() {
+ for (var i = 0; i < indentLevel; i++) {
+ // 4 spaces per indent level
+ print(" ");
+ }
+ }
+
+ // escape string literals
+ function escapeString(str) {
+ // FIXME: incomplete, revisit again!
+ return str.replace(/[\\"']/g, '\\$&')
+ }
+
+ // print a single statement (could be a block too)
+ function printStatement(stat, extra, end) {
+ if (stat instanceof Block) {
+ println(" {");
+ printStatements(stat.statements, extra);
+ indent();
+ print('}');
+ typeof end != "undefined"? print(end) : println();
+ } else {
+ println();
+ indentLevel++;
+ try {
+ stat.accept(visitor, extra);
+ } finally {
+ indentLevel--;
+ }
+ }
+ }
+
+ // print a statement list
+ function printStatements(stats, extra) {
+ indentLevel++;
+ try {
+ for each (var stat in stats) {
+ stat.accept(visitor, extra);
+ }
+ } finally {
+ indentLevel--;
+ }
+ }
+
+ // function arguments, array literal elements.
+ function printCommaList(args, extra) {
+ var len = args.length;
+ for (var i = 0; i < len; i++) {
+ args[i].accept(visitor, extra);
+ if (i != len - 1) {
+ print(", ");
+ }
+ }
+ }
+
+ // print function declarations and expressions
+ function printFunction(func, extra, end) {
+ // extra lines around function declarations for clarity
+ var funcDecl = (func instanceof FunctionDeclaration);
+ if (funcDecl) {
+ println();
+ indent();
+ }
+ print("function ");
+ if (func.name) {
+ print(func.name);
+ }
+ printFunctionBody(func, extra, end);
+ if (funcDecl) {
+ println();
+ }
+ }
+
+ // print function declaration/expression body
+ function printFunctionBody(func, extra, end) {
+ print('(');
+ var params = func.parameters;
+ if (params) {
+ printCommaList(params);
+ }
+ print(')');
+ printStatement(func.body, extra, end);
+ }
+
+ // print object literal property
+ function printProperty(node, extra, comma) {
+ var key = node.key;
+ var val = node.value;
+ var getter = node.getter;
+ var setter = node.setter;
+
+ if (getter) {
+ print("get ");
+ } else if (setter) {
+ print("set ");
+ }
+
+ if (typeof key == "string") {
+ print(key);
+ } else {
+ key.accept(visitor, extra);
+ }
+
+ if (val) {
+ print(": ");
+ if (val instanceof FunctionExpression) {
+ printFunction(val, extra, comma? ',' : undefined);
+ } else {
+ val.accept(visitor, extra);
+ if (comma) print(',');
+ }
+ } else if (getter) {
+ printFunctionBody(getter, extra, comma? ',' : undefined);
+ } else if (setter) {
+ printFunctionBody(setter, extra, comma? ',' : undefined);
+ }
+ }
+
+
+ ast.accept(visitor = new (Java.extend(SimpleTreeVisitor)) {
+ visitAssignment: function(node, extra) {
+ node.variable.accept(visitor, extra);
+ print(" = ");
+ node.expression.accept(visitor, extra);
+ },
+
+ visitCompoundAssignment: function(node, extra) {
+ node.variable.accept(visitor, extra);
+ print(' ' + operatorOf(node.kind) + ' ');
+ node.expression.accept(visitor, extra);
+ },
+
+ visitBinary: function(node, extra) {
+ node.leftOperand.accept(visitor, extra);
+ print(' ' + operatorOf(node.kind) + ' ');
+ node.rightOperand.accept(visitor, extra);
+ },
+
+ visitBlock: function(node, extra) {
+ indent();
+ println('{');
+ printStatements(node.statements, extra);
+ indent();
+ println('}');
+ },
+
+ visitBreak: function(node, extra) {
+ indent();
+ print("break");
+ if (node.label) {
+ print(' ' + node.label);
+ }
+ eol();
+ },
+
+ visitCase: function(node, extra) {
+ var expr = node.expression;
+ indent();
+ if (expr) {
+ print("case ");
+ expr.accept(visitor, extra);
+ println(':');
+ } else {
+ println("default:");
+ }
+
+ printStatements(node.statements, extra);
+ },
+
+ visitCatch: function(node, extra) {
+ indent();
+ print("catch (" + node.parameter.name);
+ var cond = node.condition;
+ if (cond) {
+ print(" if ");
+ cond.accept(visitor, extra);
+ }
+ print(')');
+ printStatement(node.block);
+ },
+
+ visitConditionalExpression: function(node, extra) {
+ print('(');
+ node.condition.accept(visitor, extra);
+ print(" ? ");
+ node.trueExpression.accept(visitor, extra);
+ print(" : ");
+ node.falseExpression.accept(visitor, extra);
+ print(')');
+ },
+
+ visitContinue: function(node, extra) {
+ indent();
+ print("continue");
+ if (node.label) {
+ print(' ' + node.label);
+ }
+ eol();
+ },
+
+ visitDebugger: function(node, extra) {
+ indent();
+ print("debugger");
+ eol();
+ },
+
+ visitDoWhileLoop: function(node, extra) {
+ indent();
+ print("do");
+ printStatement(node.statement, extra);
+ indent();
+ print("while (");
+ node.condition.accept(visitor, extra);
+ print(')');
+ eol();
+ },
+
+ visitExpressionStatement: function(node, extra) {
+ indent();
+ var expr = node.expression;
+ var objLiteral = expr instanceof ObjectLiteral;
+ if (objLiteral) {
+ print('(');
+ }
+
+ expr.accept(visitor, extra);
+ if (objLiteral) {
+ print(')');
+ }
+ eol();
+ },
+
+ visitForLoop: function(node, extra) {
+ indent();
+ print("for (");
+ if (node.initializer) {
+ node.initializer.accept(visitor, extra);
+ }
+
+ print(';');
+ if (node.condition) {
+ node.condition.accept(visitor, extra);
+ }
+ print(';');
+ if (node.update) {
+ node.update.accept(visitor, extra);
+ }
+ print(')');
+ printStatement(node.statement);
+ },
+
+ visitForInLoop: function(node, extra) {
+ indent();
+ print("for ");
+ if (node.forEach) {
+ print("each ");
+ }
+ print('(');
+ node.variable.accept(visitor, extra);
+ print(" in ");
+ node.expression.accept(visitor, extra);
+ print(')');
+ printStatement(node.statement);
+ },
+
+ visitFunctionCall: function(node, extra) {
+ var func = node.functionSelect;
+ // We need parens around function selected
+ // in many non-simple cases. Eg. function
+ // expression created and called immediately.
+ // Such parens are not preserved in AST and so
+ // introduce here.
+ var simpleFunc =
+ (func instanceof ArrayAccess) ||
+ (func instanceof Identifier) ||
+ (func instanceof MemberSelect);
+ if (! simpleFunc) {
+ print('(');
+ }
+ func.accept(visitor, extra);
+ if (! simpleFunc) {
+ print(')');
+ }
+ print('(');
+ printCommaList(node.arguments, extra);
+ print(')');
+ },
+
+ visitFunctionDeclaration: function(node, extra) {
+ printFunction(node, extra);
+ },
+
+ visitFunctionExpression: function(node, extra) {
+ printFunction(node, extra);
+ },
+
+ visitIdentifier: function(node, extra) {
+ print(node.name);
+ },
+
+ visitIf: function(node, extra) {
+ indent();
+ print("if (");
+ node.condition.accept(visitor, extra);
+ print(')');
+ printStatement(node.thenStatement);
+ var el = node.elseStatement;
+ if (el) {
+ indent();
+ print("else");
+ printStatement(el);
+ }
+ },
+
+ visitArrayAccess: function(node, extra) {
+ node.expression.accept(visitor, extra);
+ print('[');
+ node.index.accept(visitor, extra);
+ print(']');
+ },
+
+ visitArrayLiteral: function(node, extra) {
+ print('[');
+ printCommaList(node.elements);
+ print(']');
+ },
+
+ visitLabeledStatement: function(node, extra) {
+ indent();
+ print(node.label);
+ print(':');
+ printStatement(node.statement);
+ },
+
+ visitLiteral: function(node, extra) {
+ var val = node.value;
+ if (typeof val == "string") {
+ print("'" + escapeString(val) + "'");
+ } else {
+ print(val);
+ }
+ },
+
+ visitParenthesized: function(node, extra) {
+ print('(');
+ node.expression.accept(visitor, extra);
+ print(')');
+ },
+
+ visitReturn: function(node, extra) {
+ indent();
+ print("return");
+ if (node.expression) {
+ print(' ');
+ node.expression.accept(visitor, extra);
+ }
+ eol();
+ },
+
+ visitMemberSelect: function(node, extra) {
+ node.expression.accept(visitor, extra);
+ print('.' + node.identifier);
+ },
+
+ visitNew: function(node, extra) {
+ print("new ");
+ node.constructorExpression.accept(visitor, extra);
+ },
+
+ visitObjectLiteral: function(node, extra) {
+ println('{');
+ indentLevel++;
+ try {
+ var props = node.properties;
+ var len = props.length;
+ for (var p = 0; p < len; p++) {
+ var last = (p == len - 1);
+ indent();
+ printProperty(props[p], extra, !last);
+ println();
+ }
+ } finally {
+ indentLevel--;
+ }
+ indent();
+ print('}');
+ },
+
+ visitRegExpLiteral: function(node, extra) {
+ print('/' + node.pattern + '/');
+ print(node.options);
+ },
+
+ visitEmptyStatement: function(node, extra) {
+ indent();
+ eol();
+ },
+
+ visitSwitch: function(node, extra) {
+ indent();
+ print("switch (");
+ node.expression.accept(visitor, extra);
+ println(") {");
+ indentLevel++;
+ try {
+ for each (var c in node.cases) {
+ c.accept(visitor, extra);
+ }
+ } finally {
+ indentLevel--;
+ }
+ indent();
+ println('}');
+ },
+
+ visitThrow: function(node, extra) {
+ indent();
+ print("throw ");
+ node.expression.accept(visitor, extra);
+ eol();
+ },
+
+ visitCompilationUnit: function(node, extra) {
+ for each (var stat in node.sourceElements) {
+ stat.accept(visitor, extra);
+ }
+ },
+
+ visitTry: function(node, extra) {
+ indent();
+ print("try");
+ printStatement(node.block);
+ var catches = node.catches;
+ for each (var c in catches) {
+ c.accept(visitor, extra);
+ }
+ var finallyBlock = node.finallyBlock;
+ if (finallyBlock) {
+ indent();
+ print("finally");
+ printStatement(finallyBlock);
+ }
+ },
+
+ visitInstanceOf: function(node, extra) {
+ node.expression.accept(visitor, extra);
+ print(" instanceof ");
+ node.type.accept(visitor, extra);
+ },
+
+ visitUnary: function(node, extra) {
+ var kind = node.kind;
+ var prefix = kind != Kind.POSTFIX_INCREMENT && kind != Kind.POSTFIX_DECREMENT;
+ if (prefix) {
+ print(operatorOf(kind));
+ }
+ node.expression.accept(visitor, extra);
+ if (!prefix) {
+ print(operatorOf(kind));
+ }
+ },
+
+ visitVariable: function(node, extra) {
+ indent();
+ print("var " + node.name);
+ var init = node.initializer;
+ if (init) {
+ print(" = ");
+ if (init instanceof FunctionExpression) {
+ printFunction(init, extra, "");
+ } else {
+ init.accept(visitor, extra);
+ }
+ }
+ eol();
+ },
+
+ visitWhileLoop: function(node, extra) {
+ indent();
+ print("while (");
+ node.condition.accept(visitor, extra);
+ print(')');
+ printStatement(node.statement);
+ },
+
+ visitWith: function(node, extra) {
+ indent();
+ print("with (");
+ node.scope.accept(visitor, extra);
+ print(')');
+ printStatement(node.statement);
+ }
+ }, null);
+}
+
+prettyPrint(file);
--- a/nashorn/test/script/nosecurity/parserapi.js.EXPECTED Thu Mar 19 12:59:27 2015 -0700
+++ b/nashorn/test/script/nosecurity/parserapi.js.EXPECTED Thu Mar 19 16:13:54 2015 -0700
@@ -1364,32 +1364,6 @@
]
},
{
- "endPosition": "1380",
- "kind": "FUNCTION",
- "name": "test",
- "body": {
- "endPosition": "1377",
- "kind": "BLOCK",
- "statements": [
- {
- "expression": {
- "endPosition": "1377",
- "kind": "STRING_LITERAL",
- "value": "use strict",
- "startPosition": "1367"
- },
- "endPosition": "1377",
- "kind": "EXPRESSION_STATEMENT",
- "startPosition": "1367"
- }
- ],
- "startPosition": "1364"
- },
- "strict": "true",
- "startPosition": "1348",
- "parameters": []
- },
- {
"endPosition": "1282",
"kind": "VARIABLE",
"name": "hello",
@@ -1495,6 +1469,32 @@
"endPosition": "1347",
"kind": "EXPRESSION_STATEMENT",
"startPosition": "1333"
+ },
+ {
+ "endPosition": "1380",
+ "kind": "FUNCTION",
+ "name": "test",
+ "body": {
+ "endPosition": "1377",
+ "kind": "BLOCK",
+ "statements": [
+ {
+ "expression": {
+ "endPosition": "1377",
+ "kind": "STRING_LITERAL",
+ "value": "use strict",
+ "startPosition": "1367"
+ },
+ "endPosition": "1377",
+ "kind": "EXPRESSION_STATEMENT",
+ "startPosition": "1367"
+ }
+ ],
+ "startPosition": "1364"
+ },
+ "strict": "true",
+ "startPosition": "1348",
+ "parameters": []
}
],
"sourceName": "parsertests/functions.js",
@@ -3976,6 +3976,17 @@
"kind": "COMPILATION_UNIT",
"sourceElements": [
{
+ "expression": {
+ "endPosition": "1133",
+ "kind": "STRING_LITERAL",
+ "value": "use strict",
+ "startPosition": "1123"
+ },
+ "endPosition": "1133",
+ "kind": "EXPRESSION_STATEMENT",
+ "startPosition": "1123"
+ },
+ {
"endPosition": "1165",
"kind": "FUNCTION",
"name": "f",
@@ -4000,17 +4011,6 @@
"strict": "true",
"startPosition": "1136",
"parameters": []
- },
- {
- "expression": {
- "endPosition": "1133",
- "kind": "STRING_LITERAL",
- "value": "use strict",
- "startPosition": "1123"
- },
- "endPosition": "1133",
- "kind": "EXPRESSION_STATEMENT",
- "startPosition": "1123"
}
],
"sourceName": "parsertests/useStrict.js",
@@ -4919,808 +4919,6 @@
"parameters": []
},
{
- "endPosition": "3598",
- "kind": "FUNCTION",
- "name": "processFiles",
- "body": {
- "endPosition": "3555",
- "kind": "BLOCK",
- "statements": [
- {
- "endPosition": "2938",
- "kind": "VARIABLE",
- "name": "File",
- "startPosition": "2906",
- "initializer": {
- "endPosition": "2938",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "identifier": "type",
- "expression": {
- "endPosition": "2917",
- "kind": "IDENTIFIER",
- "name": "Java",
- "startPosition": "2913"
- },
- "endPosition": "2922",
- "kind": "MEMBER_SELECT",
- "startPosition": "2913"
- },
- "arguments": [
- {
- "endPosition": "2936",
- "kind": "STRING_LITERAL",
- "value": "java.io.File",
- "startPosition": "2924"
- }
- ],
- "startPosition": "2913"
- }
- },
- {
- "endPosition": "2993",
- "kind": "VARIABLE",
- "name": "files",
- "startPosition": "2947",
- "initializer": {
- "endPosition": "2993",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "identifier": "listFiles",
- "expression": {
- "constructorExpression": {
- "endPosition": "2981",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "2963",
- "kind": "IDENTIFIER",
- "name": "File",
- "startPosition": "2959"
- },
- "arguments": [
- {
- "leftOperand": {
- "endPosition": "2971",
- "kind": "IDENTIFIER",
- "name": "__DIR__",
- "startPosition": "2964"
- },
- "endPosition": "2980",
- "kind": "PLUS",
- "rightOperand": {
- "endPosition": "2980",
- "kind": "IDENTIFIER",
- "name": "subdir",
- "startPosition": "2974"
- },
- "startPosition": "2964"
- }
- ],
- "startPosition": "2959"
- },
- "endPosition": "2981",
- "kind": "NEW",
- "startPosition": "2955"
- },
- "endPosition": "2991",
- "kind": "MEMBER_SELECT",
- "startPosition": "2955"
- },
- "arguments": [],
- "startPosition": "2955"
- }
- },
- {
- "expression": {
- "endPosition": "3026",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "identifier": "sort",
- "expression": {
- "identifier": "Arrays",
- "expression": {
- "identifier": "util",
- "expression": {
- "endPosition": "3002",
- "kind": "IDENTIFIER",
- "name": "java",
- "startPosition": "2998"
- },
- "endPosition": "3007",
- "kind": "MEMBER_SELECT",
- "startPosition": "2998"
- },
- "endPosition": "3014",
- "kind": "MEMBER_SELECT",
- "startPosition": "2998"
- },
- "endPosition": "3019",
- "kind": "MEMBER_SELECT",
- "startPosition": "2998"
- },
- "arguments": [
- {
- "endPosition": "3025",
- "kind": "IDENTIFIER",
- "name": "files",
- "startPosition": "3020"
- }
- ],
- "startPosition": "2998"
- },
- "endPosition": "3026",
- "kind": "EXPRESSION_STATEMENT",
- "startPosition": "2998"
- },
- {
- "endPosition": "3049",
- "kind": "VARIABLE",
- "name": "file",
- "startPosition": "3045"
- },
- {
- "expression": {
- "endPosition": "3058",
- "kind": "IDENTIFIER",
- "name": "files",
- "startPosition": "3053"
- },
- "endPosition": "3555",
- "kind": "FOR_IN_LOOP",
- "forEach": "true",
- "variable": {
- "endPosition": "3049",
- "kind": "IDENTIFIER",
- "name": "file",
- "startPosition": "3045"
- },
- "statement": {
- "endPosition": "3555",
- "kind": "BLOCK",
- "statements": [
- {
- "condition": {
- "endPosition": "3098",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "identifier": "endsWith",
- "expression": {
- "identifier": "name",
- "expression": {
- "endPosition": "3077",
- "kind": "IDENTIFIER",
- "name": "file",
- "startPosition": "3073"
- },
- "endPosition": "3082",
- "kind": "MEMBER_SELECT",
- "startPosition": "3073"
- },
- "endPosition": "3091",
- "kind": "MEMBER_SELECT",
- "startPosition": "3073"
- },
- "arguments": [
- {
- "endPosition": "3096",
- "kind": "STRING_LITERAL",
- "value": ".js",
- "startPosition": "3093"
- }
- ],
- "startPosition": "3073"
- },
- "endPosition": "3550",
- "kind": "IF",
- "startPosition": "3069",
- "thenStatement": {
- "endPosition": "3550",
- "kind": "BLOCK",
- "statements": [
- {
- "endPosition": "3141",
- "kind": "VARIABLE",
- "name": "script",
- "startPosition": "3117",
- "initializer": {
- "endPosition": "3141",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "3135",
- "kind": "IDENTIFIER",
- "name": "readFully",
- "startPosition": "3126"
- },
- "arguments": [
- {
- "endPosition": "3140",
- "kind": "IDENTIFIER",
- "name": "file",
- "startPosition": "3136"
- }
- ],
- "startPosition": "3126"
- }
- },
- {
- "endPosition": "3179",
- "kind": "VARIABLE",
- "name": "parser",
- "startPosition": "3158",
- "initializer": {
- "constructorExpression": {
- "endPosition": "3179",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "3177",
- "kind": "IDENTIFIER",
- "name": "Parser",
- "startPosition": "3171"
- },
- "arguments": [],
- "startPosition": "3171"
- },
- "endPosition": "3179",
- "kind": "NEW",
- "startPosition": "3167"
- }
- },
- {
- "endPosition": "3415",
- "kind": "VARIABLE",
- "name": "tree",
- "startPosition": "3196",
- "initializer": {
- "endPosition": "3415",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "identifier": "parse",
- "expression": {
- "endPosition": "3209",
- "kind": "IDENTIFIER",
- "name": "parser",
- "startPosition": "3203"
- },
- "endPosition": "3215",
- "kind": "MEMBER_SELECT",
- "startPosition": "3203"
- },
- "arguments": [
- {
- "leftOperand": {
- "leftOperand": {
- "endPosition": "3222",
- "kind": "IDENTIFIER",
- "name": "subdir",
- "startPosition": "3216"
- },
- "endPosition": "3227",
- "kind": "PLUS",
- "rightOperand": {
- "endPosition": "3227",
- "kind": "STRING_LITERAL",
- "value": "/",
- "startPosition": "3226"
- },
- "startPosition": "3216"
- },
- "endPosition": "3240",
- "kind": "PLUS",
- "rightOperand": {
- "identifier": "name",
- "expression": {
- "endPosition": "3235",
- "kind": "IDENTIFIER",
- "name": "file",
- "startPosition": "3231"
- },
- "endPosition": "3240",
- "kind": "MEMBER_SELECT",
- "startPosition": "3231"
- },
- "startPosition": "3216"
- },
- {
- "endPosition": "3248",
- "kind": "IDENTIFIER",
- "name": "script",
- "startPosition": "3242"
- },
- {
- "endPosition": "3286",
- "kind": "FUNCTION_EXPRESSION",
- "body": {
- "endPosition": "3397",
- "kind": "BLOCK",
- "statements": [
- {
- "expression": {
- "endPosition": "3365",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "3312",
- "kind": "IDENTIFIER",
- "name": "print",
- "startPosition": "3307"
- },
- "arguments": [
- {
- "endPosition": "3364",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "identifier": "stringify",
- "expression": {
- "endPosition": "3317",
- "kind": "IDENTIFIER",
- "name": "JSON",
- "startPosition": "3313"
- },
- "endPosition": "3327",
- "kind": "MEMBER_SELECT",
- "startPosition": "3313"
- },
- "arguments": [
- {
- "endPosition": "3354",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "identifier": "convert",
- "expression": {
- "endPosition": "3334",
- "kind": "IDENTIFIER",
- "name": "parser",
- "startPosition": "3328"
- },
- "endPosition": "3342",
- "kind": "MEMBER_SELECT",
- "startPosition": "3328"
- },
- "arguments": [
- {
- "endPosition": "3353",
- "kind": "IDENTIFIER",
- "name": "diagnostic",
- "startPosition": "3343"
- }
- ],
- "startPosition": "3328"
- },
- {
- "endPosition": "3360",
- "kind": "NULL_LITERAL",
- "startPosition": "3356"
- },
- {
- "endPosition": "3363",
- "kind": "NUMBER_LITERAL",
- "value": "2",
- "startPosition": "3362"
- }
- ],
- "startPosition": "3313"
- }
- ],
- "startPosition": "3307"
- },
- "endPosition": "3365",
- "kind": "EXPRESSION_STATEMENT",
- "startPosition": "3307"
- },
- {
- "expression": {
- "endPosition": "3396",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "3391",
- "kind": "IDENTIFIER",
- "name": "print",
- "startPosition": "3386"
- },
- "arguments": [
- {
- "endPosition": "3394",
- "kind": "STRING_LITERAL",
- "value": ",",
- "startPosition": "3393"
- }
- ],
- "startPosition": "3386"
- },
- "endPosition": "3396",
- "kind": "EXPRESSION_STATEMENT",
- "startPosition": "3386"
- }
- ],
- "startPosition": "3286"
- },
- "strict": "false",
- "startPosition": "3286",
- "parameters": [
- {
- "endPosition": "3284",
- "kind": "IDENTIFIER",
- "name": "diagnostic",
- "startPosition": "3274"
- }
- ]
- }
- ],
- "startPosition": "3203"
- }
- },
- {
- "condition": {
- "leftOperand": {
- "endPosition": "3437",
- "kind": "IDENTIFIER",
- "name": "tree",
- "startPosition": "3433"
- },
- "endPosition": "3445",
- "kind": "NOT_EQUAL_TO",
- "rightOperand": {
- "endPosition": "3445",
- "kind": "NULL_LITERAL",
- "startPosition": "3441"
- },
- "startPosition": "3433"
- },
- "endPosition": "3541",
- "kind": "IF",
- "startPosition": "3429",
- "thenStatement": {
- "endPosition": "3541",
- "kind": "BLOCK",
- "statements": [
- {
- "expression": {
- "endPosition": "3500",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "3469",
- "kind": "IDENTIFIER",
- "name": "print",
- "startPosition": "3464"
- },
- "arguments": [
- {
- "endPosition": "3499",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "identifier": "stringify",
- "expression": {
- "endPosition": "3474",
- "kind": "IDENTIFIER",
- "name": "JSON",
- "startPosition": "3470"
- },
- "endPosition": "3484",
- "kind": "MEMBER_SELECT",
- "startPosition": "3470"
- },
- "arguments": [
- {
- "endPosition": "3489",
- "kind": "IDENTIFIER",
- "name": "tree",
- "startPosition": "3485"
- },
- {
- "endPosition": "3495",
- "kind": "NULL_LITERAL",
- "startPosition": "3491"
- },
- {
- "endPosition": "3498",
- "kind": "NUMBER_LITERAL",
- "value": "2",
- "startPosition": "3497"
- }
- ],
- "startPosition": "3470"
- }
- ],
- "startPosition": "3464"
- },
- "endPosition": "3500",
- "kind": "EXPRESSION_STATEMENT",
- "startPosition": "3464"
- },
- {
- "expression": {
- "endPosition": "3527",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "3522",
- "kind": "IDENTIFIER",
- "name": "print",
- "startPosition": "3517"
- },
- "arguments": [
- {
- "endPosition": "3525",
- "kind": "STRING_LITERAL",
- "value": ",",
- "startPosition": "3524"
- }
- ],
- "startPosition": "3517"
- },
- "endPosition": "3527",
- "kind": "EXPRESSION_STATEMENT",
- "startPosition": "3517"
- }
- ],
- "startPosition": "3447"
- }
- }
- ],
- "startPosition": "3100"
- }
- }
- ],
- "startPosition": "3060"
- },
- "startPosition": "3031"
- }
- ],
- "startPosition": "2897"
- },
- "strict": "false",
- "startPosition": "2867",
- "parameters": [
- {
- "endPosition": "2895",
- "kind": "IDENTIFIER",
- "name": "subdir",
- "startPosition": "2889"
- }
- ]
- },
- {
- "endPosition": "3901",
- "kind": "FUNCTION",
- "name": "main",
- "body": {
- "endPosition": "3899",
- "kind": "BLOCK",
- "statements": [
- {
- "expression": {
- "endPosition": "3631",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "3626",
- "kind": "IDENTIFIER",
- "name": "print",
- "startPosition": "3621"
- },
- "arguments": [
- {
- "endPosition": "3629",
- "kind": "STRING_LITERAL",
- "value": "[",
- "startPosition": "3628"
- }
- ],
- "startPosition": "3621"
- },
- "endPosition": "3631",
- "kind": "EXPRESSION_STATEMENT",
- "startPosition": "3621"
- },
- {
- "expression": {
- "endPosition": "3665",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "3650",
- "kind": "IDENTIFIER",
- "name": "processFiles",
- "startPosition": "3638"
- },
- "arguments": [
- {
- "endPosition": "3663",
- "kind": "STRING_LITERAL",
- "value": "parsertests",
- "startPosition": "3652"
- }
- ],
- "startPosition": "3638"
- },
- "endPosition": "3665",
- "kind": "EXPRESSION_STATEMENT",
- "startPosition": "3638"
- },
- {
- "expression": {
- "endPosition": "3706",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "3683",
- "kind": "IDENTIFIER",
- "name": "processFiles",
- "startPosition": "3671"
- },
- "arguments": [
- {
- "endPosition": "3704",
- "kind": "STRING_LITERAL",
- "value": "parsernegativetests",
- "startPosition": "3685"
- }
- ],
- "startPosition": "3671"
- },
- "endPosition": "3706",
- "kind": "EXPRESSION_STATEMENT",
- "startPosition": "3671"
- },
- {
- "endPosition": "3775",
- "kind": "VARIABLE",
- "name": "script",
- "startPosition": "3747",
- "initializer": {
- "endPosition": "3775",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "3765",
- "kind": "IDENTIFIER",
- "name": "readFully",
- "startPosition": "3756"
- },
- "arguments": [
- {
- "endPosition": "3774",
- "kind": "IDENTIFIER",
- "name": "__FILE__",
- "startPosition": "3766"
- }
- ],
- "startPosition": "3756"
- }
- },
- {
- "endPosition": "3840",
- "kind": "VARIABLE",
- "name": "tree",
- "startPosition": "3785",
- "initializer": {
- "endPosition": "3840",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "identifier": "parse",
- "expression": {
- "constructorExpression": {
- "endPosition": "3804",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "3802",
- "kind": "IDENTIFIER",
- "name": "Parser",
- "startPosition": "3796"
- },
- "arguments": [],
- "startPosition": "3796"
- },
- "endPosition": "3804",
- "kind": "NEW",
- "startPosition": "3792"
- },
- "endPosition": "3810",
- "kind": "MEMBER_SELECT",
- "startPosition": "3792"
- },
- "arguments": [
- {
- "endPosition": "3824",
- "kind": "STRING_LITERAL",
- "value": "parserapi.js",
- "startPosition": "3812"
- },
- {
- "endPosition": "3833",
- "kind": "IDENTIFIER",
- "name": "script",
- "startPosition": "3827"
- },
- {
- "endPosition": "3839",
- "kind": "NULL_LITERAL",
- "startPosition": "3835"
- }
- ],
- "startPosition": "3792"
- }
- },
- {
- "expression": {
- "endPosition": "3882",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "3851",
- "kind": "IDENTIFIER",
- "name": "print",
- "startPosition": "3846"
- },
- "arguments": [
- {
- "endPosition": "3881",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "identifier": "stringify",
- "expression": {
- "endPosition": "3856",
- "kind": "IDENTIFIER",
- "name": "JSON",
- "startPosition": "3852"
- },
- "endPosition": "3866",
- "kind": "MEMBER_SELECT",
- "startPosition": "3852"
- },
- "arguments": [
- {
- "endPosition": "3871",
- "kind": "IDENTIFIER",
- "name": "tree",
- "startPosition": "3867"
- },
- {
- "endPosition": "3877",
- "kind": "NULL_LITERAL",
- "startPosition": "3873"
- },
- {
- "endPosition": "3880",
- "kind": "NUMBER_LITERAL",
- "value": "2",
- "startPosition": "3879"
- }
- ],
- "startPosition": "3852"
- }
- ],
- "startPosition": "3846"
- },
- "endPosition": "3882",
- "kind": "EXPRESSION_STATEMENT",
- "startPosition": "3846"
- },
- {
- "expression": {
- "endPosition": "3898",
- "kind": "FUNCTION_INVOCATION",
- "functionSelect": {
- "endPosition": "3893",
- "kind": "IDENTIFIER",
- "name": "print",
- "startPosition": "3888"
- },
- "arguments": [
- {
- "endPosition": "3896",
- "kind": "STRING_LITERAL",
- "value": "]",
- "startPosition": "3895"
- }
- ],
- "startPosition": "3888"
- },
- "endPosition": "3898",
- "kind": "EXPRESSION_STATEMENT",
- "startPosition": "3888"
- }
- ],
- "startPosition": "3615"
- },
- "strict": "false",
- "startPosition": "3599",
- "parameters": []
- },
- {
"expression": {
"expression": {
"endPosition": "1305",
@@ -6991,6 +6189,808 @@
"startPosition": "1972"
},
{
+ "endPosition": "3598",
+ "kind": "FUNCTION",
+ "name": "processFiles",
+ "body": {
+ "endPosition": "3555",
+ "kind": "BLOCK",
+ "statements": [
+ {
+ "endPosition": "2938",
+ "kind": "VARIABLE",
+ "name": "File",
+ "startPosition": "2906",
+ "initializer": {
+ "endPosition": "2938",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "identifier": "type",
+ "expression": {
+ "endPosition": "2917",
+ "kind": "IDENTIFIER",
+ "name": "Java",
+ "startPosition": "2913"
+ },
+ "endPosition": "2922",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "2913"
+ },
+ "arguments": [
+ {
+ "endPosition": "2936",
+ "kind": "STRING_LITERAL",
+ "value": "java.io.File",
+ "startPosition": "2924"
+ }
+ ],
+ "startPosition": "2913"
+ }
+ },
+ {
+ "endPosition": "2993",
+ "kind": "VARIABLE",
+ "name": "files",
+ "startPosition": "2947",
+ "initializer": {
+ "endPosition": "2993",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "identifier": "listFiles",
+ "expression": {
+ "constructorExpression": {
+ "endPosition": "2981",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "2963",
+ "kind": "IDENTIFIER",
+ "name": "File",
+ "startPosition": "2959"
+ },
+ "arguments": [
+ {
+ "leftOperand": {
+ "endPosition": "2971",
+ "kind": "IDENTIFIER",
+ "name": "__DIR__",
+ "startPosition": "2964"
+ },
+ "endPosition": "2980",
+ "kind": "PLUS",
+ "rightOperand": {
+ "endPosition": "2980",
+ "kind": "IDENTIFIER",
+ "name": "subdir",
+ "startPosition": "2974"
+ },
+ "startPosition": "2964"
+ }
+ ],
+ "startPosition": "2959"
+ },
+ "endPosition": "2981",
+ "kind": "NEW",
+ "startPosition": "2955"
+ },
+ "endPosition": "2991",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "2955"
+ },
+ "arguments": [],
+ "startPosition": "2955"
+ }
+ },
+ {
+ "expression": {
+ "endPosition": "3026",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "identifier": "sort",
+ "expression": {
+ "identifier": "Arrays",
+ "expression": {
+ "identifier": "util",
+ "expression": {
+ "endPosition": "3002",
+ "kind": "IDENTIFIER",
+ "name": "java",
+ "startPosition": "2998"
+ },
+ "endPosition": "3007",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "2998"
+ },
+ "endPosition": "3014",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "2998"
+ },
+ "endPosition": "3019",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "2998"
+ },
+ "arguments": [
+ {
+ "endPosition": "3025",
+ "kind": "IDENTIFIER",
+ "name": "files",
+ "startPosition": "3020"
+ }
+ ],
+ "startPosition": "2998"
+ },
+ "endPosition": "3026",
+ "kind": "EXPRESSION_STATEMENT",
+ "startPosition": "2998"
+ },
+ {
+ "endPosition": "3049",
+ "kind": "VARIABLE",
+ "name": "file",
+ "startPosition": "3045"
+ },
+ {
+ "expression": {
+ "endPosition": "3058",
+ "kind": "IDENTIFIER",
+ "name": "files",
+ "startPosition": "3053"
+ },
+ "endPosition": "3555",
+ "kind": "FOR_IN_LOOP",
+ "forEach": "true",
+ "variable": {
+ "endPosition": "3049",
+ "kind": "IDENTIFIER",
+ "name": "file",
+ "startPosition": "3045"
+ },
+ "statement": {
+ "endPosition": "3555",
+ "kind": "BLOCK",
+ "statements": [
+ {
+ "condition": {
+ "endPosition": "3098",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "identifier": "endsWith",
+ "expression": {
+ "identifier": "name",
+ "expression": {
+ "endPosition": "3077",
+ "kind": "IDENTIFIER",
+ "name": "file",
+ "startPosition": "3073"
+ },
+ "endPosition": "3082",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "3073"
+ },
+ "endPosition": "3091",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "3073"
+ },
+ "arguments": [
+ {
+ "endPosition": "3096",
+ "kind": "STRING_LITERAL",
+ "value": ".js",
+ "startPosition": "3093"
+ }
+ ],
+ "startPosition": "3073"
+ },
+ "endPosition": "3550",
+ "kind": "IF",
+ "startPosition": "3069",
+ "thenStatement": {
+ "endPosition": "3550",
+ "kind": "BLOCK",
+ "statements": [
+ {
+ "endPosition": "3141",
+ "kind": "VARIABLE",
+ "name": "script",
+ "startPosition": "3117",
+ "initializer": {
+ "endPosition": "3141",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "3135",
+ "kind": "IDENTIFIER",
+ "name": "readFully",
+ "startPosition": "3126"
+ },
+ "arguments": [
+ {
+ "endPosition": "3140",
+ "kind": "IDENTIFIER",
+ "name": "file",
+ "startPosition": "3136"
+ }
+ ],
+ "startPosition": "3126"
+ }
+ },
+ {
+ "endPosition": "3179",
+ "kind": "VARIABLE",
+ "name": "parser",
+ "startPosition": "3158",
+ "initializer": {
+ "constructorExpression": {
+ "endPosition": "3179",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "3177",
+ "kind": "IDENTIFIER",
+ "name": "Parser",
+ "startPosition": "3171"
+ },
+ "arguments": [],
+ "startPosition": "3171"
+ },
+ "endPosition": "3179",
+ "kind": "NEW",
+ "startPosition": "3167"
+ }
+ },
+ {
+ "endPosition": "3415",
+ "kind": "VARIABLE",
+ "name": "tree",
+ "startPosition": "3196",
+ "initializer": {
+ "endPosition": "3415",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "identifier": "parse",
+ "expression": {
+ "endPosition": "3209",
+ "kind": "IDENTIFIER",
+ "name": "parser",
+ "startPosition": "3203"
+ },
+ "endPosition": "3215",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "3203"
+ },
+ "arguments": [
+ {
+ "leftOperand": {
+ "leftOperand": {
+ "endPosition": "3222",
+ "kind": "IDENTIFIER",
+ "name": "subdir",
+ "startPosition": "3216"
+ },
+ "endPosition": "3227",
+ "kind": "PLUS",
+ "rightOperand": {
+ "endPosition": "3227",
+ "kind": "STRING_LITERAL",
+ "value": "/",
+ "startPosition": "3226"
+ },
+ "startPosition": "3216"
+ },
+ "endPosition": "3240",
+ "kind": "PLUS",
+ "rightOperand": {
+ "identifier": "name",
+ "expression": {
+ "endPosition": "3235",
+ "kind": "IDENTIFIER",
+ "name": "file",
+ "startPosition": "3231"
+ },
+ "endPosition": "3240",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "3231"
+ },
+ "startPosition": "3216"
+ },
+ {
+ "endPosition": "3248",
+ "kind": "IDENTIFIER",
+ "name": "script",
+ "startPosition": "3242"
+ },
+ {
+ "endPosition": "3286",
+ "kind": "FUNCTION_EXPRESSION",
+ "body": {
+ "endPosition": "3397",
+ "kind": "BLOCK",
+ "statements": [
+ {
+ "expression": {
+ "endPosition": "3365",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "3312",
+ "kind": "IDENTIFIER",
+ "name": "print",
+ "startPosition": "3307"
+ },
+ "arguments": [
+ {
+ "endPosition": "3364",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "identifier": "stringify",
+ "expression": {
+ "endPosition": "3317",
+ "kind": "IDENTIFIER",
+ "name": "JSON",
+ "startPosition": "3313"
+ },
+ "endPosition": "3327",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "3313"
+ },
+ "arguments": [
+ {
+ "endPosition": "3354",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "identifier": "convert",
+ "expression": {
+ "endPosition": "3334",
+ "kind": "IDENTIFIER",
+ "name": "parser",
+ "startPosition": "3328"
+ },
+ "endPosition": "3342",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "3328"
+ },
+ "arguments": [
+ {
+ "endPosition": "3353",
+ "kind": "IDENTIFIER",
+ "name": "diagnostic",
+ "startPosition": "3343"
+ }
+ ],
+ "startPosition": "3328"
+ },
+ {
+ "endPosition": "3360",
+ "kind": "NULL_LITERAL",
+ "startPosition": "3356"
+ },
+ {
+ "endPosition": "3363",
+ "kind": "NUMBER_LITERAL",
+ "value": "2",
+ "startPosition": "3362"
+ }
+ ],
+ "startPosition": "3313"
+ }
+ ],
+ "startPosition": "3307"
+ },
+ "endPosition": "3365",
+ "kind": "EXPRESSION_STATEMENT",
+ "startPosition": "3307"
+ },
+ {
+ "expression": {
+ "endPosition": "3396",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "3391",
+ "kind": "IDENTIFIER",
+ "name": "print",
+ "startPosition": "3386"
+ },
+ "arguments": [
+ {
+ "endPosition": "3394",
+ "kind": "STRING_LITERAL",
+ "value": ",",
+ "startPosition": "3393"
+ }
+ ],
+ "startPosition": "3386"
+ },
+ "endPosition": "3396",
+ "kind": "EXPRESSION_STATEMENT",
+ "startPosition": "3386"
+ }
+ ],
+ "startPosition": "3286"
+ },
+ "strict": "false",
+ "startPosition": "3286",
+ "parameters": [
+ {
+ "endPosition": "3284",
+ "kind": "IDENTIFIER",
+ "name": "diagnostic",
+ "startPosition": "3274"
+ }
+ ]
+ }
+ ],
+ "startPosition": "3203"
+ }
+ },
+ {
+ "condition": {
+ "leftOperand": {
+ "endPosition": "3437",
+ "kind": "IDENTIFIER",
+ "name": "tree",
+ "startPosition": "3433"
+ },
+ "endPosition": "3445",
+ "kind": "NOT_EQUAL_TO",
+ "rightOperand": {
+ "endPosition": "3445",
+ "kind": "NULL_LITERAL",
+ "startPosition": "3441"
+ },
+ "startPosition": "3433"
+ },
+ "endPosition": "3541",
+ "kind": "IF",
+ "startPosition": "3429",
+ "thenStatement": {
+ "endPosition": "3541",
+ "kind": "BLOCK",
+ "statements": [
+ {
+ "expression": {
+ "endPosition": "3500",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "3469",
+ "kind": "IDENTIFIER",
+ "name": "print",
+ "startPosition": "3464"
+ },
+ "arguments": [
+ {
+ "endPosition": "3499",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "identifier": "stringify",
+ "expression": {
+ "endPosition": "3474",
+ "kind": "IDENTIFIER",
+ "name": "JSON",
+ "startPosition": "3470"
+ },
+ "endPosition": "3484",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "3470"
+ },
+ "arguments": [
+ {
+ "endPosition": "3489",
+ "kind": "IDENTIFIER",
+ "name": "tree",
+ "startPosition": "3485"
+ },
+ {
+ "endPosition": "3495",
+ "kind": "NULL_LITERAL",
+ "startPosition": "3491"
+ },
+ {
+ "endPosition": "3498",
+ "kind": "NUMBER_LITERAL",
+ "value": "2",
+ "startPosition": "3497"
+ }
+ ],
+ "startPosition": "3470"
+ }
+ ],
+ "startPosition": "3464"
+ },
+ "endPosition": "3500",
+ "kind": "EXPRESSION_STATEMENT",
+ "startPosition": "3464"
+ },
+ {
+ "expression": {
+ "endPosition": "3527",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "3522",
+ "kind": "IDENTIFIER",
+ "name": "print",
+ "startPosition": "3517"
+ },
+ "arguments": [
+ {
+ "endPosition": "3525",
+ "kind": "STRING_LITERAL",
+ "value": ",",
+ "startPosition": "3524"
+ }
+ ],
+ "startPosition": "3517"
+ },
+ "endPosition": "3527",
+ "kind": "EXPRESSION_STATEMENT",
+ "startPosition": "3517"
+ }
+ ],
+ "startPosition": "3447"
+ }
+ }
+ ],
+ "startPosition": "3100"
+ }
+ }
+ ],
+ "startPosition": "3060"
+ },
+ "startPosition": "3031"
+ }
+ ],
+ "startPosition": "2897"
+ },
+ "strict": "false",
+ "startPosition": "2867",
+ "parameters": [
+ {
+ "endPosition": "2895",
+ "kind": "IDENTIFIER",
+ "name": "subdir",
+ "startPosition": "2889"
+ }
+ ]
+ },
+ {
+ "endPosition": "3901",
+ "kind": "FUNCTION",
+ "name": "main",
+ "body": {
+ "endPosition": "3899",
+ "kind": "BLOCK",
+ "statements": [
+ {
+ "expression": {
+ "endPosition": "3631",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "3626",
+ "kind": "IDENTIFIER",
+ "name": "print",
+ "startPosition": "3621"
+ },
+ "arguments": [
+ {
+ "endPosition": "3629",
+ "kind": "STRING_LITERAL",
+ "value": "[",
+ "startPosition": "3628"
+ }
+ ],
+ "startPosition": "3621"
+ },
+ "endPosition": "3631",
+ "kind": "EXPRESSION_STATEMENT",
+ "startPosition": "3621"
+ },
+ {
+ "expression": {
+ "endPosition": "3665",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "3650",
+ "kind": "IDENTIFIER",
+ "name": "processFiles",
+ "startPosition": "3638"
+ },
+ "arguments": [
+ {
+ "endPosition": "3663",
+ "kind": "STRING_LITERAL",
+ "value": "parsertests",
+ "startPosition": "3652"
+ }
+ ],
+ "startPosition": "3638"
+ },
+ "endPosition": "3665",
+ "kind": "EXPRESSION_STATEMENT",
+ "startPosition": "3638"
+ },
+ {
+ "expression": {
+ "endPosition": "3706",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "3683",
+ "kind": "IDENTIFIER",
+ "name": "processFiles",
+ "startPosition": "3671"
+ },
+ "arguments": [
+ {
+ "endPosition": "3704",
+ "kind": "STRING_LITERAL",
+ "value": "parsernegativetests",
+ "startPosition": "3685"
+ }
+ ],
+ "startPosition": "3671"
+ },
+ "endPosition": "3706",
+ "kind": "EXPRESSION_STATEMENT",
+ "startPosition": "3671"
+ },
+ {
+ "endPosition": "3775",
+ "kind": "VARIABLE",
+ "name": "script",
+ "startPosition": "3747",
+ "initializer": {
+ "endPosition": "3775",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "3765",
+ "kind": "IDENTIFIER",
+ "name": "readFully",
+ "startPosition": "3756"
+ },
+ "arguments": [
+ {
+ "endPosition": "3774",
+ "kind": "IDENTIFIER",
+ "name": "__FILE__",
+ "startPosition": "3766"
+ }
+ ],
+ "startPosition": "3756"
+ }
+ },
+ {
+ "endPosition": "3840",
+ "kind": "VARIABLE",
+ "name": "tree",
+ "startPosition": "3785",
+ "initializer": {
+ "endPosition": "3840",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "identifier": "parse",
+ "expression": {
+ "constructorExpression": {
+ "endPosition": "3804",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "3802",
+ "kind": "IDENTIFIER",
+ "name": "Parser",
+ "startPosition": "3796"
+ },
+ "arguments": [],
+ "startPosition": "3796"
+ },
+ "endPosition": "3804",
+ "kind": "NEW",
+ "startPosition": "3792"
+ },
+ "endPosition": "3810",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "3792"
+ },
+ "arguments": [
+ {
+ "endPosition": "3824",
+ "kind": "STRING_LITERAL",
+ "value": "parserapi.js",
+ "startPosition": "3812"
+ },
+ {
+ "endPosition": "3833",
+ "kind": "IDENTIFIER",
+ "name": "script",
+ "startPosition": "3827"
+ },
+ {
+ "endPosition": "3839",
+ "kind": "NULL_LITERAL",
+ "startPosition": "3835"
+ }
+ ],
+ "startPosition": "3792"
+ }
+ },
+ {
+ "expression": {
+ "endPosition": "3882",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "3851",
+ "kind": "IDENTIFIER",
+ "name": "print",
+ "startPosition": "3846"
+ },
+ "arguments": [
+ {
+ "endPosition": "3881",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "identifier": "stringify",
+ "expression": {
+ "endPosition": "3856",
+ "kind": "IDENTIFIER",
+ "name": "JSON",
+ "startPosition": "3852"
+ },
+ "endPosition": "3866",
+ "kind": "MEMBER_SELECT",
+ "startPosition": "3852"
+ },
+ "arguments": [
+ {
+ "endPosition": "3871",
+ "kind": "IDENTIFIER",
+ "name": "tree",
+ "startPosition": "3867"
+ },
+ {
+ "endPosition": "3877",
+ "kind": "NULL_LITERAL",
+ "startPosition": "3873"
+ },
+ {
+ "endPosition": "3880",
+ "kind": "NUMBER_LITERAL",
+ "value": "2",
+ "startPosition": "3879"
+ }
+ ],
+ "startPosition": "3852"
+ }
+ ],
+ "startPosition": "3846"
+ },
+ "endPosition": "3882",
+ "kind": "EXPRESSION_STATEMENT",
+ "startPosition": "3846"
+ },
+ {
+ "expression": {
+ "endPosition": "3898",
+ "kind": "FUNCTION_INVOCATION",
+ "functionSelect": {
+ "endPosition": "3893",
+ "kind": "IDENTIFIER",
+ "name": "print",
+ "startPosition": "3888"
+ },
+ "arguments": [
+ {
+ "endPosition": "3896",
+ "kind": "STRING_LITERAL",
+ "value": "]",
+ "startPosition": "3895"
+ }
+ ],
+ "startPosition": "3888"
+ },
+ "endPosition": "3898",
+ "kind": "EXPRESSION_STATEMENT",
+ "startPosition": "3888"
+ }
+ ],
+ "startPosition": "3615"
+ },
+ "strict": "false",
+ "startPosition": "3599",
+ "parameters": []
+ },
+ {
"expression": {
"endPosition": "3909",
"kind": "FUNCTION_INVOCATION",