webgme-bip
Version:
Design studio for component-based modeling with BIP.
1,287 lines (1,250 loc) • 591 kB
JavaScript
/**
* @author kecso / https://github.com/kecso
*/
/**
* The body of the code is borrowed from https://github.com/mazko/jsjavaparser
* Version used: 0.0.2
*/
define([],function(){
'use strict';
return new function() {
function peg$subclass(child, parent) {
function ctor() {
this.constructor = child;
}
ctor.prototype = parent.prototype;
child.prototype = new ctor();
}
function peg$SyntaxError(message, expected, found, location) {
this.message = message;
this.expected = expected;
this.found = found;
this.location = location;
this.name = "SyntaxError";
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(this, peg$SyntaxError);
}
}
peg$subclass(peg$SyntaxError, Error);
peg$SyntaxError.buildMessage = function (expected, found) {
var DESCRIBE_EXPECTATION_FNS = {
literal: function (expectation) {
return "\"" + literalEscape(expectation.text) + "\"";
},
"class": function (expectation) {
var escapedParts = "",
i;
for (i = 0; i < expectation.parts.length; i++) {
escapedParts += expectation.parts[i] instanceof Array
? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
: classEscape(expectation.parts[i]);
}
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
},
any: function (expectation) {
return "any character";
},
end: function (expectation) {
return "end of input";
},
other: function (expectation) {
return expectation.description;
}
};
function hex(ch) {
return ch.charCodeAt(0).toString(16).toUpperCase();
}
function literalEscape(s) {
return s
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')
.replace(/\0/g, '\\0')
.replace(/\t/g, '\\t')
.replace(/\n/g, '\\n')
.replace(/\r/g, '\\r')
.replace(/[\x00-\x0F]/g, function (ch) {
return '\\x0' + hex(ch);
})
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
return '\\x' + hex(ch);
});
}
function classEscape(s) {
return s
.replace(/\\/g, '\\\\')
.replace(/\]/g, '\\]')
.replace(/\^/g, '\\^')
.replace(/-/g, '\\-')
.replace(/\0/g, '\\0')
.replace(/\t/g, '\\t')
.replace(/\n/g, '\\n')
.replace(/\r/g, '\\r')
.replace(/[\x00-\x0F]/g, function (ch) {
return '\\x0' + hex(ch);
})
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
return '\\x' + hex(ch);
});
}
function describeExpectation(expectation) {
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
}
function describeExpected(expected) {
var descriptions = new Array(expected.length),
i, j;
for (i = 0; i < expected.length; i++) {
descriptions[i] = describeExpectation(expected[i]);
}
descriptions.sort();
if (descriptions.length > 0) {
for (i = 1, j = 1; i < descriptions.length; i++) {
if (descriptions[i - 1] !== descriptions[i]) {
descriptions[j] = descriptions[i];
j++;
}
}
descriptions.length = j;
}
switch (descriptions.length) {
case 1:
return descriptions[0];
case 2:
return descriptions[0] + " or " + descriptions[1];
default:
return descriptions.slice(0, -1).join(", ")
+ ", or "
+ descriptions[descriptions.length - 1];
}
}
function describeFound(found) {
return found ? "\"" + literalEscape(found) + "\"" : "end of input";
}
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
};
function peg$parse(input, options) {
options = options !== void 0 ? options : {};
var peg$FAILED = {},
peg$startRuleFunctions = {CompilationUnit: peg$parseCompilationUnit},
peg$startRuleFunction = peg$parseCompilationUnit,
peg$c0 = function (pack, imports, types) {
return {
node: 'CompilationUnit',
types: skipNulls(types),
package: pack,
imports: skipNulls(imports)
};
},
peg$c1 = function (annot, name) {
return {
node: 'PackageDeclaration',
name: name,
annotations: annot
};
},
peg$c2 = function (stat, name, asterisk) {
return {
node: 'ImportDeclaration',
name: name,
static: !!stat,
onDemand: !!extractOptional(asterisk, 1)
};
},
peg$c3 = function () {
return null;
},
peg$c4 = function (modifiers, type) {
return mergeProps(type, {modifiers: modifiers});
},
peg$c5 = function (id, gen, ext, impl, body) {
return {
node: 'TypeDeclaration',
name: id,
superInterfaceTypes: extractOptionalList(impl, 1),
superclassType: extractOptional(ext, 1),
bodyDeclarations: body,
typeParameters: optionalList(gen),
interface: false
};
},
peg$c6 = function (decls) {
return skipNulls(decls);
},
peg$c7 = function (modifier, body) {
return {
node: 'Initializer',
body: body,
modifiers: modifier === null ? [] : [makeModifier('static')]
};
},
peg$c8 = function (modifiers, member) {
return mergeProps(member, {modifiers: modifiers});
},
peg$c9 = function (params, rest) {
return mergeProps(rest, {
node: 'MethodDeclaration',
typeParameters: params
});
},
peg$c10 = function (type, id, rest) {
return mergeProps(rest, {
node: 'MethodDeclaration',
returnType2: type,
name: id,
typeParameters: []
});
},
peg$c11 = function (type, decls) {
return {
node: 'FieldDeclaration',
fragments: decls,
type: type
};
},
peg$c12 = function (id, rest) {
return mergeProps(rest, {
node: 'MethodDeclaration',
returnType2: makePrimitive('void'),
name: id,
constructor: false
});
},
peg$c13 = function (id, rest) {
return mergeProps(rest, {
node: 'MethodDeclaration',
name: id,
typeParameters: []
});
},
peg$c14 = function () {
return makePrimitive('void');
},
peg$c15 = function (type, id, rest) {
return mergeProps(rest, {
returnType2: type,
name: id
});
},
peg$c16 = function (id, rest) {
return mergeProps(rest, {name: id});
},
peg$c17 = function (params, dims, throws) {
return null;
},
peg$c18 = function (params, dims, throws, body) {
return {
parameters: params,
thrownExceptions: extractThrowsClassType(extractOptionalList(throws, 1)),
extraDimensions: dims.length,
body: body,
constructor: false
};
},
peg$c19 = function (params, throws) {
return null;
},
peg$c20 = function (params, throws, body) {
return {
parameters: params,
thrownExceptions: extractThrowsClassType(extractOptionalList(throws, 1)),
body: body,
extraDimensions: 0,
typeParameters: []
};
},
peg$c21 = function (params, throws, body) {
return {
parameters: params,
thrownExceptions: extractThrowsClassType(extractOptionalList(throws, 1)),
body: body,
returnType2: null,
constructor: true,
extraDimensions: 0
};
},
peg$c22 = function (id, gen, ext, body) {
return {
node: 'TypeDeclaration',
name: id,
superInterfaceTypes: extractOptionalList(ext, 1),
superclassType: null,
bodyDeclarations: body,
typeParameters: optionalList(gen),
interface: true
};
},
peg$c23 = function (type, id, rest) {
if (rest.node === 'FieldDeclaration') {
rest.fragments[0].name = id;
return mergeProps(rest, {type: type});
} else {
return mergeProps(rest, {
returnType2: type,
name: id,
typeParameters: []
});
}
},
peg$c24 = function (rest) {
return {node: 'FieldDeclaration', fragments: rest};
},
peg$c25 = function (params, dims, throws) {
return {
node: 'MethodDeclaration',
parameters: params,
thrownExceptions: extractThrowsClassType(extractOptionalList(throws, 1)),
extraDimensions: dims.length,
body: null,
constructor: false
};
},
peg$c26 = function (params) {
return makePrimitive('void');
},
peg$c27 = function (params, type, id, rest) {
return mergeProps(rest, {
returnType2: type,
name: id,
typeParameters: params
});
},
peg$c28 = function (params, throws) {
return {
node: 'MethodDeclaration',
parameters: params,
thrownExceptions: extractThrowsClassType(extractOptionalList(throws, 1)),
returnType2: makePrimitive('void'),
extraDimensions: 0,
typeParameters: [],
body: null,
constructor: false
};
},
peg$c29 = function (first, rest) {
return buildList(first, rest, 1);
},
peg$c30 = function (dims, init) {
return {
node: 'VariableDeclarationFragment',
extraDimensions: dims.length,
initializer: init
};
},
peg$c31 = function (name, impl, eb) {
return mergeProps(eb, {
node: 'EnumDeclaration',
name: name,
superInterfaceTypes: extractOptionalList(impl, 1)
});
},
peg$c32 = function (consts, body) {
return {
enumConstants: optionalList(consts),
bodyDeclarations: optionalList(body)
};
},
peg$c33 = function (annot, name, args, cls) {
return {
node: 'EnumConstantDeclaration',
anonymousClassDeclaration: cls === null ? null : {
node: 'AnonymousClassDeclaration',
bodyDeclarations: cls
},
arguments: optionalList(args),
modifiers: annot,
name: name
};
},
peg$c34 = function (decl) {
return decl;
},
peg$c35 = function () {
return makeModifier('final');
},
peg$c36 = function (modifiers, type, decls) {
return {
node: 'VariableDeclarationStatement',
fragments: decls,
modifiers: modifiers,
type: type
};
},
peg$c37 = function (name, dims, init) {
return {
node: 'VariableDeclarationFragment',
name: name,
extraDimensions: dims.length,
initializer: extractOptional(init, 1)
};
},
peg$c38 = function (params) {
return optionalList(params);
},
peg$c39 = function (modifiers, type, decl) {
return mergeProps(decl, {
type: type,
modifiers: modifiers,
varargs: false,
initializer: null
});
},
peg$c40 = function (modifiers, type, decl) {
return mergeProps(decl, {
type: type,
modifiers: modifiers,
varargs: true,
initializer: null
});
},
peg$c41 = function (first, rest, last) {
return buildList(first, rest, 1).concat(extractOptionalList(last, 1));
},
peg$c42 = function (last) {
return [last];
},
peg$c43 = function (id, dims) {
return {
node: 'SingleVariableDeclaration',
name: id,
extraDimensions: dims.length
};
},
peg$c44 = function (statements) {
return {
node: 'Block',
statements: statements
}
},
peg$c45 = function (modifiers, decl) {
return {
node: 'TypeDeclarationStatement',
declaration: mergeProps(decl, {modifiers: modifiers})
};
},
peg$c46 = function (expr, message) {
return {
node: 'AssertStatement',
expression: expr,
message: extractOptional(message, 1)
};
},
peg$c47 = function (expr, then, alt) {
return {
node: 'IfStatement',
elseStatement: extractOptional(alt, 1),
thenStatement: then,
expression: expr.expression,
};
},
peg$c48 = function (init, expr, up, body) {
return {
node: 'ForStatement',
initializers: optionalList(init),
expression: expr,
updaters: optionalList(up),
body: body
};
},
peg$c49 = function (param, expr, statement) {
return {
node: 'EnhancedForStatement',
parameter: param,
expression: expr,
body: statement
};
},
peg$c50 = function (expr, body) {
return {
node: 'WhileStatement',
expression: expr.expression,
body: body
};
},
peg$c51 = function (statement, expr) {
return {
node: 'DoStatement',
expression: expr.expression,
body: statement
};
},
peg$c52 = function (first, rest, body, cat, fin) {
return mergeProps(makeCatchFinally(cat, fin), {
node: 'TryStatement',
body: body,
resources: buildList(first, rest, 1)
});
},
peg$c53 = function (body, cat, fin) {
return makeCatchFinally(cat, fin);
},
peg$c54 = function (body, fin) {
return makeCatchFinally([], fin);
},
peg$c55 = function (body, rest) {
return mergeProps(rest, {
node: 'TryStatement',
body: body,
resources: []
});
},
peg$c56 = function (expr, cases) {
return {node: 'SwitchStatement', statements: cases, expression: expr.expression};
},
peg$c57 = function (expr, body) {
return {node: 'SynchronizedStatement', expression: expr.expression, body: body}
},
peg$c58 = function (expr) {
return {node: 'ReturnStatement', expression: expr}
},
peg$c59 = function (expr) {
return {node: 'ThrowStatement', expression: expr};
},
peg$c60 = function (id) {
return {node: 'BreakStatement', label: id};
},
peg$c61 = function (id) {
return {node: 'ContinueStatement', label: id};
},
peg$c62 = function () {
return {node: 'EmptyStatement'};
},
peg$c63 = function (statement) {
return statement;
},
peg$c64 = function (id, statement) {
return {node: 'LabeledStatement', label: id, body: statement};
},
peg$c65 = function (modifiers, type, decl, expr) {
var fragment = mergeProps(decl, {initializer: expr});
fragment.node = 'VariableDeclarationFragment';
return {
node: 'VariableDeclarationExpression',
modifiers: modifiers,
type: type,
fragments: [fragment]
};
},
peg$c66 = function (modifiers, first, rest, decl, body) {
return {
node: 'CatchClause',
body: body,
exception: mergeProps(decl, {
modifiers: modifiers,
initializer: null,
varargs: false,
type: rest.length ? {
node: 'UnionType',
types: buildList(first, rest, 1)
} : first
})
};
},
peg$c67 = function (block) {
return block;
},
peg$c68 = function (blocks) {
return [].concat.apply([], blocks);
},
peg$c69 = function (expr, blocks) {
return [{node: 'SwitchCase', expression: expr}].concat(blocks);
},
peg$c70 = function (expr) {
return expr;
},
peg$c71 = function (modifiers, type, decls) {
return [{
node: 'VariableDeclarationExpression',
modifiers: modifiers,
fragments: decls,
type: type
}];
},
peg$c72 = function (first, rest) {
return extractExpressions(buildList(first, rest, 1));
},
peg$c73 = function (expr) {
switch (expr.node) {
case 'SuperConstructorInvocation':
case 'ConstructorInvocation':
return expr;
default:
return {
node: 'ExpressionStatement',
expression: expr
};
}
},
peg$c74 = function (left, op, right) {
return {
node: 'Assignment',
operator: op[0] /* remove ending spaces */,
leftHandSide: left,
rightHandSide: right
};
},
peg$c75 = function (expr, then, alt) {
return {
node: 'ConditionalExpression',
expression: expr,
thenExpression: then,
elseExpression: alt
};
},
peg$c76 = function (first, rest) {
return buildInfixExpr(first, rest);
},
peg$c77 = function (first, rest) {
return buildTree(first, rest, function (result, element) {
return element[0][0] === 'instanceof' ? {
node: 'InstanceofExpression',
leftOperand: result,
rightOperand: element[1]
} : {
node: 'InfixExpression',
operator: element[0][0], // remove ending Spacing
leftOperand: result,
rightOperand: element[1]
};
});
},
peg$c78 = function (operator, operand) {
return operand.node === 'NumberLiteral' && operator === '-' &&
(operand.token === '9223372036854775808L' ||
operand.token === '9223372036854775808l' ||
operand.token === '2147483648')
? {node: 'NumberLiteral', token: text()}
: {
node: 'PrefixExpression',
operator: operator,
operand: operand
};
},
peg$c79 = function (expr) {
return {
node: 'CastExpression',
type: expr[1],
expression: expr[3]
};
},
peg$c80 = function (arg, sel, sels, operator) {
return operator.length > 1 ? TODO(/* JLS7? */) : {
node: 'PostfixExpression',
operator: operator[0],
operand: buildSelectorTree(arg, sel, sels)
};
},
peg$c81 = function (arg, sel, sels) {
return buildSelectorTree(arg, sel, sels);
},
peg$c82 = function (arg, operator) {
return operator.length > 1 ? TODO(/* JLS7? */) : {
node: 'PostfixExpression',
operator: operator[0],
operand: arg
};
},
peg$c83 = function (args, args_r) {
return {node: 'ConstructorInvocation', arguments: args_r, typeArguments: []};
},
peg$c84 = function (args, ret) {
if (ret.typeArguments.length) return TODO(/* Ugly ! */);
ret.typeArguments = args;
return ret;
},
peg$c85 = function (args) {
return args === null ? {
node: 'ThisExpression',
qualifier: null
} : {
node: 'ConstructorInvocation',
arguments: args,
typeArguments: []
};
},
peg$c86 = function (suffix) {
return suffix.node === 'SuperConstructorInvocation'
? suffix
: mergeProps(suffix, {qualifier: null});
},
peg$c87 = function (creator) {
return creator;
},
peg$c88 = function (type, dims) {
return {
node: 'TypeLiteral',
type: buildArrayTree(type, dims)
};
},
peg$c89 = function () {
return {
node: 'TypeLiteral',
type: makePrimitive('void')
};
},
peg$c90 = function (qual, dims) {
return {
node: 'TypeLiteral',
type: buildArrayTree(buildTypeName(qual, null, []), dims)
};
},
peg$c91 = function (qual, expr) {
return {node: 'ArrayAccess', array: qual, index: expr};
},
peg$c92 = function (qual, args) {
return mergeProps(popQualified(qual), {
node: 'MethodInvocation',
arguments: args,
typeArguments: []
});
},
peg$c93 = function (qual) {
return {node: 'TypeLiteral', type: buildTypeName(qual, null, [])};
},
peg$c94 = function (qual, ret) {
if (ret.expression) return TODO(/* Ugly ! */);
ret.expression = qual;
return ret;
},
peg$c95 = function (qual) {
return {node: 'ThisExpression', qualifier: qual};
},
peg$c96 = function (qual, args) {
return {
node: 'SuperConstructorInvocation',
arguments: args,
expression: qual,
typeArguments: []
};
},
peg$c97 = function (qual, args, rest) {
return mergeProps(rest, {expression: qual, typeArguments: optionalList(args)});
},
peg$c98 = function () {
return [];
},
peg$c99 = function (suffix) {
return suffix;
},
peg$c100 = function (id, args) {
return {node: 'MethodInvocation', arguments: args, name: id, typeArguments: []};
},
peg$c101 = function (op) {
return op[0];
/* remove ending spaces */
},
peg$c102 = function (id) {
return {node: 'FieldAccess', name: id};
},
peg$c103 = function (ret) {
return ret;
},
peg$c104 = function () {
return TODO(/* Any sample ? */);
},
peg$c105 = function (args, ret) {
return mergeProps(ret, {typeArguments: optionalList(args)});
},
peg$c106 = function (expr) {
return {node: 'ArrayAccess', index: expr};
},
peg$c107 = function (args) {
return {
node: 'SuperConstructorInvocation',
arguments: args,
expression: null,
typeArguments: []
};
},
peg$c108 = function (gen, id, args) {
return args === null ? {
node: 'SuperFieldAccess',
name: id
} : {
node: 'SuperMethodInvocation',
typeArguments: optionalList(gen),
name: id,
arguments: args
};
},
peg$c109 = "byte",
peg$c110 = peg$literalExpectation("byte", false),
peg$c111 = "short",
peg$c112 = peg$literalExpectation("short", false),
peg$c113 = "char",
peg$c114 = peg$literalExpectation("char", false),
peg$c115 = "int",
peg$c116 = peg$literalExpectation("int", false),
peg$c117 = "long",
peg$c118 = peg$literalExpectation("long", false),
peg$c119 = "float",
peg$c120 = peg$literalExpectation("float", false),
peg$c121 = "double",
peg$c122 = peg$literalExpectation("double", false),
peg$c123 = "boolean",
peg$c124 = peg$literalExpectation("boolean", false),
peg$c125 = function (type) {
return makePrimitive(type);
},
peg$c126 = function (args) {
return optionalList(args);
},
peg$c127 = function (type, rest) {
return {
node: 'ArrayCreation',
type: buildArrayTree(type, rest.extraDims),
initializer: rest.init,
dimensions: rest.dimms
};
},
peg$c128 = function (args, type, rest) {
return mergeProps(rest, {
node: 'ClassInstanceCreation',
type: type,
typeArguments: optionalList(args),
expression: null
});
},
peg$c129 = function (qual, args, rest) {
return buildTypeName(qual, args, rest);
},
peg$c130 = function (id, args, rest) {
return mergeProps(rest, {
node: 'ClassInstanceCreation',
type: buildTypeName(id, args, [])
});
},
peg$c131 = function (args, body) {
return {
arguments: args,
anonymousClassDeclaration: body === null ? null : {
node: 'AnonymousClassDeclaration',
bodyDeclarations: body
}
};
},
peg$c132 = function (dims, init) {
return {extraDims: dims, init: init, dimms: []};
},
peg$c133 = function (dimexpr, dims) {
return {extraDims: dimexpr.concat(dims), init: null, dimms: dimexpr};
},
peg$c134 = function (dim) {
return {extraDims: [dim], init: null, dimms: []};
},
peg$c135 = function (init) {
return {node: 'ArrayInitializer', expressions: optionalList(init)};
},
peg$c136 = function (expr) {
return {node: 'ParenthesizedExpression', expression: expr};
},
peg$c137 = function (first, rest) {
return buildQualified(first, rest, 1);
},
peg$c138 = function (exp) {
return exp;
},
peg$c139 = function (type, dims) {
return buildArrayTree(type, dims);
},
peg$c140 = function (bas, dims) {
return buildArrayTree(bas, dims);
},
peg$c141 = function (cls, dims) {
return buildArrayTree(cls, dims);
},
peg$c142 = function () {
return true;
},
peg$c143 = function () {
return false;
},
peg$c144 = function (rest) {
return {
node: 'WildcardType',
upperBound: extractOptional(rest, 0, true),
bound: extractOptional(rest, 1)
};
},
peg$c145 = function (id, bounds) {
return {
node: 'TypeParameter',
name: id,
typeBounds: extractOptionalList(bounds, 1)
}
},
peg$c146 = "public",
peg$c147 = peg$literalExpectation("public", false),
peg$c148 = "protected",
peg$c149 = peg$literalExpectation("protected", false),
peg$c150 = "private",
peg$c151 = peg$literalExpectation("private", false),
peg$c152 = "static",
peg$c153 = peg$literalExpectation("static", false),
peg$c154 = "abstract",
peg$c155 = peg$literalExpectation("abstract", false),
peg$c156 = "final",
peg$c157 = peg$literalExpectation("final", false),
peg$c158 = "native",
peg$c159 = peg$literalExpectation("native", false),
peg$c160 = "synchronized",
peg$c161 = peg$literalExpectation("synchronized", false),
peg$c162 = "transient",
peg$c163 = peg$literalExpectation("transient", false),
peg$c164 = "volatile",
peg$c165 = peg$literalExpectation("volatile", false),
peg$c166 = "strictfp",
peg$c167 = peg$literalExpectation("strictfp", false),
peg$c168 = function (keyword) {
return makeModifier(keyword);
},
peg$c169 = function (id, body) {
return {
node: 'AnnotationTypeDeclaration',
name: id,
bodyDeclarations: body
};
},
peg$c170 = function (decl) {
return skipNulls(decl);
},
peg$c171 = function (modifiers, rest) {
return mergeProps(rest, {modifiers: modifiers});
},
peg$c172 = function (type, rest) {
return mergeProps(rest, {type: type});
},
peg$c173 = function (id, def) {
return {
node: 'AnnotationTypeMemberDeclaration',
name: id,
default: def
};
},
peg$c174 = function (fragments) {
return {node: 'FieldDeclaration', fragments: fragments};
},
peg$c175 = function (val) {
return val;
},
peg$c176 = function (id, pairs) {
return {
node: 'NormalAnnotation',
typeName: id,
values: optionalList(pairs)
};
},
peg$c177 = function (id, value) {
return {
node: 'SingleMemberAnnotation',
typeName: id,
value: value
};
},
peg$c178 = function (id) {
return {node: 'MarkerAnnotation', typeName: id};
},
peg$c179 = function (name, value) {
return {
node: 'MemberValuePair',
name: name,
value: value
};
},
peg$c180 = function (values) {
return {node: 'ArrayInitializer', expressions: optionalList(values)};
},
peg$c181 = /^[ \t\r\n\f]/,
peg$c182 = peg$classExpectation([" ", "\t", "\r", "\n", "\f"], false, false),
peg$c183 = "/*",
peg$c184 = peg$literalExpectation("/*", false),
peg$c185 = "*/",
peg$c186 = peg$literalExpectation("*/", false),
peg$c187 = "//",
peg$c188 = peg$literalExpectation("//", false),
peg$c189 = /^[\r\n]/,
peg$c190 = peg$classExpectation(["\r", "\n"], false, false),
peg$c191 = function (first, rest) {
return {identifier: first + rest, node: 'SimpleName'};
},
peg$c192 = /^[a-z]/,
peg$c193 = peg$classExpectation([["a", "z"]], false, false),
peg$c194 = /^[A-Z]/,
peg$c195 = peg$classExpectation([["A", "Z"]], false, false),
peg$c196 = /^[_$]/,
peg$c197 = peg$classExpectation(["_", "$"], false, false),
peg$c198 = /^[0-9]/,
peg$c199 = peg$classExpectation([["0", "9"]], false, false),
peg$c200 = "assert",
peg$c201 = peg$literalExpectation("assert", false),
peg$c202 = "break",
peg$c203 = peg$literalExpectation("break", false),
peg$c204 = "case",
peg$c205 = peg$literalExpectation("case", false),
peg$c206 = "catch",
peg$c207 = peg$literalExpectation("catch", false),
peg$c208 = "class",
peg$c209 = peg$literalExpectation("class", false),
peg$c210 = "const",
peg$c211 = peg$literalExpectation("const", false),
peg$c212 = "continue",
peg$c213 = peg$literalExpectation("continue", false),
peg$c214 = "default",
peg$c215 = peg$literalExpectation("default", false),
peg$c216 = "do",
peg$c217 = peg$literalExpectation("do", false),
peg$c218 = "else",
peg$c219 = peg$literalExpectation("else", false),
peg$c220 = "enum",
peg$c221 = peg$literalExpectation("enum", false),
peg$c222 = "extends",
peg$c223 = peg$literalExpectation("extends", false),
peg$c224 = "false",
peg$c225 = peg$literalExpectation("false", false),
peg$c226 = "finally",
peg$c227 = peg$literalExpectation("finally", false),
peg$c228 = "for",
peg$c229 = peg$literalExpectation("for", false),
peg$c230 = "goto",
peg$c231 = peg$literalExpectation("goto", false),
peg$c232 = "if",
peg$c233 = peg$literalExpectation("if", false),
peg$c234 = "implements",
peg$c235 = peg$literalExpectation("implements", false),
peg$c236 = "import",
peg$c237 = peg$literalExpectation("import", false),
peg$c238 = "interface",
peg$c239 = peg$literalExpectation("interface", false),
peg$c240 = "instanceof",
peg$c241 = peg$literalExpectation("instanceof", false),
peg$c242 = "new",
peg$c243 = peg$literalExpectation("new", false),
peg$c244 = "null",
peg$c245 = peg$literalExpectation("null", false),
peg$c246 = "package",
peg$c247 = peg$literalExpectation("package", false),
peg$c248 = "return",
peg$c249 = peg$literalExpectation("return", false),
peg$c250 = "super",
peg$c251 = peg$literalExpectation("super", false),
peg$c252 = "switch",
peg$c253 = peg$literalExpectation("switch", false),
peg$c254 = "this",
peg$c255 = peg$literalExpectation("this", false),
peg$c256 = "throws",
peg$c257 = peg$literalExpectation("throws", false),
peg$c258 = "throw",
peg$c259 = peg$literalExpectation("throw", false),
peg$c260 = "true",
peg$c261 = peg$literalExpectation("true", false),
peg$c262 = "try",
peg$c263 = peg$literalExpectation("try", false),
peg$c264 = "void",
peg$c265 = peg$literalExpectation("void", false),
peg$c266 = "while",
peg$c267 = peg$literalExpectation("while", false),
peg$c268 = function () {
return {node: 'BooleanLiteral', booleanValue: true};
},
peg$c269 = function () {
return {node: 'BooleanLiteral', booleanValue: false};
},
peg$c270 = function () {
return {node: 'NullLiteral'};
},
peg$c271 = function (literal) {
return literal;
},
peg$c272 = /^[lL]/,
peg$c273 = peg$classExpectation(["l", "L"], false, false),
peg$c274 = function () {
return {node: 'NumberLiteral', token: text()};
},
peg$c275 = "0",
peg$c276 = peg$literalExpectation("0", false),
peg$c277 = /^[1-9]/,
peg$c278 = peg$classExpectation([["1", "9"]], false, false),
peg$c279 = /^[_]/,
peg$c280 = peg$classExpectation(["_"], false, false),
peg$c281 = "0x",
peg$c282 = peg$literalExpectation("0x", false),
peg$c283 = "0X",
peg$c284 = peg$literalExpectation("0X", false),
peg$c285 = "0b",
peg$c286 = peg$literalExpectation("0b", false),
peg$c287 = "0B",
peg$c288 = peg$literalExpectation("0B", false),
peg$c289 = /^[01]/,
peg$c290 = peg$classExpectation(["0", "1"], false, false),
peg$c291 = /^[0-7]/,
peg$c292 = peg$classExpectation([["0", "7"]], false, false),
peg$c293 = ".",
peg$c294 = peg$literalExpectation(".", false),
peg$c295 = /^[fFdD]/,
peg$c296 = peg$classExpectation(["f", "F", "d", "D"], false, false),
peg$c297 = /^[eE]/,
peg$c298 = peg$classExpectation(["e", "E"], false, false),
peg$c299 = /^[+\-]/,
peg$c300 = peg$classExpectation(["+", "-"], false, false),
peg$c301 = /^[pP]/,
peg$c302 = peg$classExpectation(["p", "P"], false, false),
peg$c303 = /^[a-f]/,
peg$c304 = peg$classExpectation([["a", "f"]], false, false),
peg$c305 = /^[A-F]/,
peg$c306 = peg$classExpectation([["A", "F"]], false, false),
peg$c307 = "'",
peg$c308 = peg$literalExpectation("'", false),
peg$c309 = /^['\\\n\r]/,
peg$c310 = peg$classExpectation(["'", "\\", "\n", "\r"], false, false),
peg$c311 = function () {
return {node: 'CharacterLiteral', escapedValue: text()};
},
peg$c312 = "\"",
peg$c313 = peg$literalExpectation("\"", false),
peg$c314 = /^["\\\n\r]/,
peg$c315 = peg$classExpectation(["\"", "\\", "\n", "\r"], false, false),
peg$c316 = function () {
return {node: 'StringLiteral', escapedValue: text()};
},
peg$c317 = "\\",
peg$c318 = peg$literalExpectation("\\", false),
peg$c319 = /^[btnfr"'\\]/,
peg$c320 = peg$classExpectation(["b", "t", "n", "f", "r", "\"", "'", "\\"], false, false),
peg$c321 = /^[0-3]/,
peg$c322 = peg$classExpectation([["0", "3"]], false, false),
peg$c323 = "u",
peg$c324 = peg$literalExpectation("u", false),
peg$c325 = "@",
peg$c326 = peg$literalExpectation("@", false),
peg$c327 = "&",
peg$c328 = peg$literalExpectation("&", false),
peg$c329 = /^[=&]/,
peg$c330 = peg$classExpectation(["=", "&"], false, false),
peg$c331 = "&&",
peg$c332 = peg$literalExpectation("&&", false),
peg$c333 = "&=",
peg$c334 = peg$literalExpectation("&=", false),
peg$c335 = "!",
peg$c336 = peg$literalExpectation("!", false),
peg$c337 = "=",
peg$c338 = peg$literalExpectation("=", false),
peg$c339 = ">>>",
peg$c340 = peg$literalExpectation(">>>", false),
peg$c341 = ">>>=",
peg$c342 = peg$literalExpectation(">>>=", false),
peg$c343 = ":",
peg$c344 = peg$literalExpectation(":", false),
peg$c345 = ",",
peg$c346 = peg$literalExpectation(",", false),
peg$c347 = "--",
peg$c348 = peg$literalExpectation("--", false),
peg$c349 = "/",
peg$c350 = peg$literalExpectation("/", false),
peg$c351 = "/=",
peg$c352 = peg$literalExpectation("/=", false),
peg$c353 = "...",
peg$c354 = peg$literalExpectation("...", false),
peg$c355 = "==",
peg$c356 = peg$literalExpectation("==", false),
peg$c357 = ">=",
peg$c358 = peg$literalExpectation(">=", false),
peg$c359 = ">",
peg$c360 = peg$literalExpectation(">", false),
peg$c361 = /^[=>]/,
peg$c362 = peg$classExpectation(["=", ">"], false, false),
peg$c363 = "^",
peg$c364 = peg$literalExpectation("^", false),
peg$c365 = "^=",
peg$c366 = peg$literalExpectation("^=", false),
peg$c367 = "++",
peg$c368 = peg$literalExpectation("++", false),
peg$c369 = "[",
peg$c370 = peg$literalExpectation("[", false),
peg$c371 = "<=",
peg$c372 = peg$literalExpectation("<=", false),
peg$c373 = "(",
peg$c374 = peg$literalExpectation("(", false),
peg$c375 = "<",
peg$c376 = peg$literalExpectation("<", false),
peg$c377 = /^[=<]/,
peg$c378 = peg$classExpectation(["=", "<"], false, false),
peg$c379 = "{",
peg$c380 = peg$literalExpectation("{", false),
peg$c381 = "-",
peg$c382 = peg$literalExpectation("-", false),
peg$c383 = /^[=\-]/,
peg$c384 = peg$classExpectation(["=", "-"], false, false),
peg$c385 = "-=",
peg$c386 = peg$literalExpectation("-=", false),
peg$c387 = "%",
peg$c388 = peg$literalExpectation("%", false),
peg$c389 = "%=",
peg$c390 = peg$literalExpectation("%=", false),
peg$c391 = "!=",
peg$c392 = peg$literalExpectation("!=", false),
peg$c393 = "|",
peg$c394 = peg$literalExpectation("|", false),
peg$c395 = /^[=|]/,
peg$c396 = peg$classExpectation(["=", "|"], false, false),
peg$c397 = "|=",
peg$c398 = peg$literalExpectation("|=", false),
peg$c399 = "||",
peg$c400 = peg$literalExpectation("||", false),
peg$c401 = "+",
peg$c402 = peg$literalExpectation("+", false),
peg$c403 = /^[=+]/,
peg$c404 = peg$classExpectation(["=", "+"], false, false),
peg$c405 = "+=",
peg$c406 = peg$literalExpectation("+=", false),
peg$c407 = "?",
peg$c408 = peg$literalExpectation("?", false),
peg$c409 = "]",
peg$c410 = peg$literalExpectation("]", false),
peg$c411 = ")",
peg$c412 = peg$literalExpectation(")", false),
peg$c413 = "}",
peg$c414 = peg$literalExpectation("}", false),
peg$c415 = ";",
peg$c416 = peg$literalExpectation(";", false),
peg$c417 = "<<",
peg$c418 = peg$literalExpectation("<<", false),
peg$c419 = "<<=",
peg$c420 = peg$literalExpectation("<<=", false),
peg$c421 = ">>",
peg$c422 = peg$literalExpectation(">>", false),
peg$c423 = ">>=",
peg$c424 = peg$literalExpectation(">>=", false),
peg$c425 = "*",
peg$c426 = peg$literalExpectation("*", false),
peg$c427 = "*=",
peg$c428 = peg$literalExpectation("*=", false),
peg$c429 = "~",
peg$c430 = peg$literalExpectation("~", false),
peg$c431 = peg$anyExpectation(),
peg$currPos = 0,
peg$savedPos = 0,
peg$posDetailsCache = [{line: 1, column: 1}],
peg$maxFailPos = 0,
peg$maxFailExpected = [],
peg$silentFails = 0,
peg$result;
if ("startRule" in options) {
if (!(options.startRule in peg$startRuleFunctions)) {
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
}
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
}
function text() {
return input.substring(peg$savedPos, peg$currPos);
}
function location() {
return peg$computeLocation(peg$savedPos, peg$currPos);
}
function expected(description, location) {
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
throw peg$buildStructuredError(
[peg$otherExpectation(description)],
input.substring(peg$savedPos, peg$currPos),
location
);
}
function error(message, location) {
location = location !== void 0 ? location : peg$computeLocation(peg$