solidity-antlr4
Version:
Solidity Lang Lexer and Parser by official ANTLR4 grammar
1,316 lines (1,314 loc) • 383 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.UsingDirectiveContext = exports.UsingAliasesContext = exports.UserDefinedValueTypeDefinitionContext = exports.UserDefinableOperatorContext = exports.UnicodeStringLiteralContext = exports.UncheckedBlockContext = exports.UnarySuffixOperationContext = exports.UnaryPrefixOperationContext = exports.TypeNameContext = exports.TupleExpressionContext = exports.TupleContext = exports.TryStatementContext = exports.SymbolAliasesContext = exports.StructMemberContext = exports.StructDefinitionContext = exports.StringLiteralContext = exports.StatementContext = exports.StateVariableDeclarationContext = exports.StateMutabilityContext = exports.SourceUnitContext = exports.SolidityParser = exports.SimpleStatementContext = exports.ShiftOperationContext = exports.RevertStatementContext = exports.ReturnStatementContext = exports.ReceiveFunctionDefinitionContext = exports.PrimaryExpressionContext = exports.PragmaDirectiveContext = exports.PayableConversionContext = exports.PathContext = exports.ParameterListContext = exports.ParameterDeclarationContext = exports.OverrideSpecifierContext = exports.OrderComparisonContext = exports.OrOperationContext = exports.NumberLiteralContext = exports.NewExprContext = exports.NamedArgumentContext = exports.MulDivModOperationContext = exports.ModifierInvocationContext = exports.ModifierDefinitionContext = exports.MetaTypeContext = exports.MemberAccessContext = exports.MappingTypeContext = exports.MappingKeyTypeContext = exports.LiteralWithSubDenominationContext = exports.LiteralContext = exports.LibraryDefinitionContext = exports.InterfaceDefinitionContext = exports.InlineArrayExpressionContext = exports.InlineArrayContext = exports.InheritanceSpecifierListContext = exports.InheritanceSpecifierContext = exports.IndexRangeAccessContext = exports.IndexAccessContext = exports.ImportDirectiveContext = exports.ImportAliasesContext = exports.IfStatementContext = exports.IdentifierPathContext = exports.IdentifierContext = exports.HexStringLiteralContext = exports.FunctionTypeNameContext = exports.FunctionDefinitionContext = exports.FunctionCallOptionsContext = exports.FunctionCallContext = exports.ForStatementContext = exports.FallbackFunctionDefinitionContext = exports.ExpressionStatementContext = exports.ExpressionContext = exports.ExpOperationContext = exports.EventParameterContext = exports.EventDefinitionContext = exports.ErrorParameterContext = exports.ErrorDefinitionContext = exports.EqualityComparisonContext = exports.EnumDefinitionContext = exports.EmitStatementContext = exports.ElementaryTypeNameContext = exports.DoWhileStatementContext = exports.DataLocationContext = exports.ContractDefinitionContext = exports.ContractBodyElementContext = exports.ContinueStatementContext = exports.ConstructorDefinitionContext = exports.ConstantVariableDeclarationContext = exports.ConditionalContext = exports.CatchClauseContext = exports.CallArgumentListContext = exports.BreakStatementContext = exports.BooleanLiteralContext = exports.BlockContext = exports.BitXorOperationContext = exports.BitOrOperationContext = exports.BitAndOperationContext = exports.AssignmentContext = exports.AssignOpContext = exports.AssemblyStatementContext = exports.AssemblyFlagsContext = exports.AndOperationContext = exports.AddSubOperationContext = void 0;
exports.YulVariableDeclarationContext = exports.YulSwitchStatementContext = exports.YulSwitchCaseContext = exports.YulStatementContext = exports.YulPathContext = exports.YulLiteralContext = exports.YulIfStatementContext = exports.YulFunctionDefinitionContext = exports.YulFunctionCallContext = exports.YulForStatementContext = exports.YulExpressionContext = exports.YulBooleanContext = exports.YulBlockContext = exports.YulAssignmentContext = exports.WhileStatementContext = exports.VisibilityContext = exports.VariableDeclarationTupleContext = exports.VariableDeclarationStatementContext = exports.VariableDeclarationListContext = exports.VariableDeclarationContext = void 0;
var antlr = _interopRequireWildcard(require("antlr4ng"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
class SolidityParser extends antlr.Parser {
static ReservedKeywords = 1;
static Abstract = 2;
static Address = 3;
static Anonymous = 4;
static As = 5;
static Assembly = 6;
static Bool = 7;
static Break = 8;
static Bytes = 9;
static Calldata = 10;
static Catch = 11;
static Constant = 12;
static Constructor = 13;
static Continue = 14;
static Contract = 15;
static Delete = 16;
static Do = 17;
static Else = 18;
static Emit = 19;
static Enum = 20;
static Error = 21;
static Event = 22;
static External = 23;
static Fallback = 24;
static False = 25;
static Fixed = 26;
static FixedBytes = 27;
static For = 28;
static From = 29;
static Function = 30;
static Global = 31;
static Hex = 32;
static If = 33;
static Immutable = 34;
static Import = 35;
static Indexed = 36;
static Interface = 37;
static Internal = 38;
static Is = 39;
static Library = 40;
static Mapping = 41;
static Memory = 42;
static Modifier = 43;
static New = 44;
static SubDenomination = 45;
static Override = 46;
static Payable = 47;
static Pragma = 48;
static Private = 49;
static Public = 50;
static Pure = 51;
static Receive = 52;
static Return = 53;
static Returns = 54;
static Revert = 55;
static SignedIntegerType = 56;
static Storage = 57;
static String = 58;
static Struct = 59;
static True = 60;
static Try = 61;
static Type = 62;
static Ufixed = 63;
static Unchecked = 64;
static Unicode = 65;
static UnsignedIntegerType = 66;
static Using = 67;
static View = 68;
static Virtual = 69;
static While = 70;
static LParen = 71;
static RParen = 72;
static LBrack = 73;
static RBrack = 74;
static LBrace = 75;
static RBrace = 76;
static Colon = 77;
static Semicolon = 78;
static Period = 79;
static Conditional = 80;
static DoubleArrow = 81;
static RightArrow = 82;
static Assign = 83;
static AssignBitOr = 84;
static AssignBitXor = 85;
static AssignBitAnd = 86;
static AssignShl = 87;
static AssignSar = 88;
static AssignShr = 89;
static AssignAdd = 90;
static AssignSub = 91;
static AssignMul = 92;
static AssignDiv = 93;
static AssignMod = 94;
static Comma = 95;
static Or = 96;
static And = 97;
static BitOr = 98;
static BitXor = 99;
static BitAnd = 100;
static Shl = 101;
static Sar = 102;
static Shr = 103;
static Add = 104;
static Sub = 105;
static Mul = 106;
static Div = 107;
static Mod = 108;
static Exp = 109;
static Equal = 110;
static NotEqual = 111;
static LessThan = 112;
static GreaterThan = 113;
static LessThanOrEqual = 114;
static GreaterThanOrEqual = 115;
static Not = 116;
static BitNot = 117;
static Inc = 118;
static Dec = 119;
static DoubleQuote = 120;
static SingleQuote = 121;
static NonEmptyStringLiteral = 122;
static EmptyStringLiteral = 123;
static UnicodeStringLiteral = 124;
static HexString = 125;
static HexNumber = 126;
static OctalNumber = 127;
static DecimalNumber = 128;
static DecimalNumberFollowedByIdentifier = 129;
static Identifier = 130;
static WS = 131;
static COMMENT = 132;
static LINE_COMMENT = 133;
static AssemblyDialect = 134;
static AssemblyLBrace = 135;
static AssemblyFlagString = 136;
static AssemblyBlockLParen = 137;
static AssemblyBlockRParen = 138;
static AssemblyBlockComma = 139;
static AssemblyBlockWS = 140;
static AssemblyBlockCOMMENT = 141;
static AssemblyBlockLINE_COMMENT = 142;
static YulBreak = 143;
static YulCase = 144;
static YulContinue = 145;
static YulDefault = 146;
static YulFalse = 147;
static YulFor = 148;
static YulFunction = 149;
static YulIf = 150;
static YulLeave = 151;
static YulLet = 152;
static YulSwitch = 153;
static YulTrue = 154;
static YulHex = 155;
static YulEVMBuiltin = 156;
static YulLBrace = 157;
static YulRBrace = 158;
static YulLParen = 159;
static YulRParen = 160;
static YulAssign = 161;
static YulPeriod = 162;
static YulComma = 163;
static YulArrow = 164;
static YulIdentifier = 165;
static YulHexNumber = 166;
static YulDecimalNumber = 167;
static YulStringLiteral = 168;
static YulHexStringLiteral = 169;
static YulWS = 170;
static YulCOMMENT = 171;
static YulLINE_COMMENT = 172;
static PragmaToken = 173;
static PragmaSemicolon = 174;
static PragmaWS = 175;
static PragmaCOMMENT = 176;
static PragmaLINE_COMMENT = 177;
static RULE_sourceUnit = 0;
static RULE_pragmaDirective = 1;
static RULE_importDirective = 2;
static RULE_importAliases = 3;
static RULE_path = 4;
static RULE_symbolAliases = 5;
static RULE_contractDefinition = 6;
static RULE_interfaceDefinition = 7;
static RULE_libraryDefinition = 8;
static RULE_inheritanceSpecifierList = 9;
static RULE_inheritanceSpecifier = 10;
static RULE_contractBodyElement = 11;
static RULE_namedArgument = 12;
static RULE_callArgumentList = 13;
static RULE_identifierPath = 14;
static RULE_modifierInvocation = 15;
static RULE_visibility = 16;
static RULE_parameterList = 17;
static RULE_parameterDeclaration = 18;
static RULE_constructorDefinition = 19;
static RULE_stateMutability = 20;
static RULE_overrideSpecifier = 21;
static RULE_functionDefinition = 22;
static RULE_modifierDefinition = 23;
static RULE_fallbackFunctionDefinition = 24;
static RULE_receiveFunctionDefinition = 25;
static RULE_structDefinition = 26;
static RULE_structMember = 27;
static RULE_enumDefinition = 28;
static RULE_userDefinedValueTypeDefinition = 29;
static RULE_stateVariableDeclaration = 30;
static RULE_constantVariableDeclaration = 31;
static RULE_eventParameter = 32;
static RULE_eventDefinition = 33;
static RULE_errorParameter = 34;
static RULE_errorDefinition = 35;
static RULE_userDefinableOperator = 36;
static RULE_usingDirective = 37;
static RULE_usingAliases = 38;
static RULE_typeName = 39;
static RULE_elementaryTypeName = 40;
static RULE_functionTypeName = 41;
static RULE_variableDeclaration = 42;
static RULE_dataLocation = 43;
static RULE_expression = 44;
static RULE_assignOp = 45;
static RULE_tupleExpression = 46;
static RULE_inlineArrayExpression = 47;
static RULE_identifier = 48;
static RULE_literal = 49;
static RULE_literalWithSubDenomination = 50;
static RULE_booleanLiteral = 51;
static RULE_stringLiteral = 52;
static RULE_hexStringLiteral = 53;
static RULE_unicodeStringLiteral = 54;
static RULE_numberLiteral = 55;
static RULE_block = 56;
static RULE_uncheckedBlock = 57;
static RULE_statement = 58;
static RULE_simpleStatement = 59;
static RULE_ifStatement = 60;
static RULE_forStatement = 61;
static RULE_whileStatement = 62;
static RULE_doWhileStatement = 63;
static RULE_continueStatement = 64;
static RULE_breakStatement = 65;
static RULE_tryStatement = 66;
static RULE_catchClause = 67;
static RULE_returnStatement = 68;
static RULE_emitStatement = 69;
static RULE_revertStatement = 70;
static RULE_assemblyStatement = 71;
static RULE_assemblyFlags = 72;
static RULE_variableDeclarationList = 73;
static RULE_variableDeclarationTuple = 74;
static RULE_variableDeclarationStatement = 75;
static RULE_expressionStatement = 76;
static RULE_mappingType = 77;
static RULE_mappingKeyType = 78;
static RULE_yulStatement = 79;
static RULE_yulBlock = 80;
static RULE_yulVariableDeclaration = 81;
static RULE_yulAssignment = 82;
static RULE_yulIfStatement = 83;
static RULE_yulForStatement = 84;
static RULE_yulSwitchCase = 85;
static RULE_yulSwitchStatement = 86;
static RULE_yulFunctionDefinition = 87;
static RULE_yulPath = 88;
static RULE_yulFunctionCall = 89;
static RULE_yulBoolean = 90;
static RULE_yulLiteral = 91;
static RULE_yulExpression = 92;
static literalNames = [null, null, "'abstract'", "'address'", "'anonymous'", "'as'", "'assembly'", "'bool'", null, "'bytes'", "'calldata'", "'catch'", "'constant'", "'constructor'", null, "'contract'", "'delete'", "'do'", "'else'", "'emit'", "'enum'", "'error'", "'event'", "'external'", "'fallback'", null, null, null, null, "'from'", null, "'global'", null, null, "'immutable'", "'import'", "'indexed'", "'interface'", "'internal'", "'is'", "'library'", "'mapping'", "'memory'", "'modifier'", "'new'", null, "'override'", "'payable'", "'pragma'", "'private'", "'public'", "'pure'", "'receive'", "'return'", "'returns'", "'revert'", null, "'storage'", "'string'", "'struct'", null, "'try'", "'type'", null, "'unchecked'", "'unicode'", null, "'using'", "'view'", "'virtual'", "'while'", null, null, "'['", "']'", null, null, "':'", null, null, "'?'", "'=>'", null, "'='", "'|='", "'^='", "'&='", "'<<='", "'>>='", "'>>>='", "'+='", "'-='", "'*='", "'/='", "'%='", null, "'||'", "'&&'", "'|'", "'^'", "'&'", "'<<'", "'>>'", "'>>>'", "'+'", "'-'", "'*'", "'/'", "'%'", "'**'", "'=='", "'!='", "'<'", "'>'", "'<='", "'>='", "'!'", "'~'", "'++'", "'--'", `'"'`, "'''", null, null, null, null, null, null, null, null, null, null, null, null, `'"evmasm"'`, null, null, null, null, null, null, null, null, null, "'case'", null, "'default'", null, null, null, null, "'leave'", "'let'", "'switch'", null, null, null, null, null, null, null, "':='"];
static symbolicNames = [null, "ReservedKeywords", "Abstract", "Address", "Anonymous", "As", "Assembly", "Bool", "Break", "Bytes", "Calldata", "Catch", "Constant", "Constructor", "Continue", "Contract", "Delete", "Do", "Else", "Emit", "Enum", "Error", "Event", "External", "Fallback", "False", "Fixed", "FixedBytes", "For", "From", "Function", "Global", "Hex", "If", "Immutable", "Import", "Indexed", "Interface", "Internal", "Is", "Library", "Mapping", "Memory", "Modifier", "New", "SubDenomination", "Override", "Payable", "Pragma", "Private", "Public", "Pure", "Receive", "Return", "Returns", "Revert", "SignedIntegerType", "Storage", "String", "Struct", "True", "Try", "Type", "Ufixed", "Unchecked", "Unicode", "UnsignedIntegerType", "Using", "View", "Virtual", "While", "LParen", "RParen", "LBrack", "RBrack", "LBrace", "RBrace", "Colon", "Semicolon", "Period", "Conditional", "DoubleArrow", "RightArrow", "Assign", "AssignBitOr", "AssignBitXor", "AssignBitAnd", "AssignShl", "AssignSar", "AssignShr", "AssignAdd", "AssignSub", "AssignMul", "AssignDiv", "AssignMod", "Comma", "Or", "And", "BitOr", "BitXor", "BitAnd", "Shl", "Sar", "Shr", "Add", "Sub", "Mul", "Div", "Mod", "Exp", "Equal", "NotEqual", "LessThan", "GreaterThan", "LessThanOrEqual", "GreaterThanOrEqual", "Not", "BitNot", "Inc", "Dec", "DoubleQuote", "SingleQuote", "NonEmptyStringLiteral", "EmptyStringLiteral", "UnicodeStringLiteral", "HexString", "HexNumber", "OctalNumber", "DecimalNumber", "DecimalNumberFollowedByIdentifier", "Identifier", "WS", "COMMENT", "LINE_COMMENT", "AssemblyDialect", "AssemblyLBrace", "AssemblyFlagString", "AssemblyBlockLParen", "AssemblyBlockRParen", "AssemblyBlockComma", "AssemblyBlockWS", "AssemblyBlockCOMMENT", "AssemblyBlockLINE_COMMENT", "YulBreak", "YulCase", "YulContinue", "YulDefault", "YulFalse", "YulFor", "YulFunction", "YulIf", "YulLeave", "YulLet", "YulSwitch", "YulTrue", "YulHex", "YulEVMBuiltin", "YulLBrace", "YulRBrace", "YulLParen", "YulRParen", "YulAssign", "YulPeriod", "YulComma", "YulArrow", "YulIdentifier", "YulHexNumber", "YulDecimalNumber", "YulStringLiteral", "YulHexStringLiteral", "YulWS", "YulCOMMENT", "YulLINE_COMMENT", "PragmaToken", "PragmaSemicolon", "PragmaWS", "PragmaCOMMENT", "PragmaLINE_COMMENT"];
static ruleNames = ["sourceUnit", "pragmaDirective", "importDirective", "importAliases", "path", "symbolAliases", "contractDefinition", "interfaceDefinition", "libraryDefinition", "inheritanceSpecifierList", "inheritanceSpecifier", "contractBodyElement", "namedArgument", "callArgumentList", "identifierPath", "modifierInvocation", "visibility", "parameterList", "parameterDeclaration", "constructorDefinition", "stateMutability", "overrideSpecifier", "functionDefinition", "modifierDefinition", "fallbackFunctionDefinition", "receiveFunctionDefinition", "structDefinition", "structMember", "enumDefinition", "userDefinedValueTypeDefinition", "stateVariableDeclaration", "constantVariableDeclaration", "eventParameter", "eventDefinition", "errorParameter", "errorDefinition", "userDefinableOperator", "usingDirective", "usingAliases", "typeName", "elementaryTypeName", "functionTypeName", "variableDeclaration", "dataLocation", "expression", "assignOp", "tupleExpression", "inlineArrayExpression", "identifier", "literal", "literalWithSubDenomination", "booleanLiteral", "stringLiteral", "hexStringLiteral", "unicodeStringLiteral", "numberLiteral", "block", "uncheckedBlock", "statement", "simpleStatement", "ifStatement", "forStatement", "whileStatement", "doWhileStatement", "continueStatement", "breakStatement", "tryStatement", "catchClause", "returnStatement", "emitStatement", "revertStatement", "assemblyStatement", "assemblyFlags", "variableDeclarationList", "variableDeclarationTuple", "variableDeclarationStatement", "expressionStatement", "mappingType", "mappingKeyType", "yulStatement", "yulBlock", "yulVariableDeclaration", "yulAssignment", "yulIfStatement", "yulForStatement", "yulSwitchCase", "yulSwitchStatement", "yulFunctionDefinition", "yulPath", "yulFunctionCall", "yulBoolean", "yulLiteral", "yulExpression"];
get grammarFileName() {
return "SolidityParser.g4";
}
get literalNames() {
return SolidityParser.literalNames;
}
get symbolicNames() {
return SolidityParser.symbolicNames;
}
get ruleNames() {
return SolidityParser.ruleNames;
}
get serializedATN() {
return SolidityParser._serializedATN;
}
createFailedPredicateException(predicate, message) {
return new antlr.FailedPredicateException(this, predicate, message);
}
constructor(input) {
super(input);
this.interpreter = new antlr.ParserATNSimulator(this, SolidityParser._ATN, SolidityParser.decisionsToDFA, new antlr.PredictionContextCache());
}
sourceUnit() {
let localContext = new SourceUnitContext(this.context, this.state);
this.enterRule(localContext, 0, SolidityParser.RULE_sourceUnit);
try {
let alternative;
this.enterOuterAlt(localContext, 1);
{
this.state = 201;
this.errorHandler.sync(this);
alternative = this.interpreter.adaptivePredict(this.tokenStream, 1, this.context);
while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) {
if (alternative === 1) {
{
this.state = 199;
this.errorHandler.sync(this);
switch (this.interpreter.adaptivePredict(this.tokenStream, 0, this.context)) {
case 1:
{
this.state = 186;
this.pragmaDirective();
}
break;
case 2:
{
this.state = 187;
this.importDirective();
}
break;
case 3:
{
this.state = 188;
this.usingDirective();
}
break;
case 4:
{
this.state = 189;
this.contractDefinition();
}
break;
case 5:
{
this.state = 190;
this.interfaceDefinition();
}
break;
case 6:
{
this.state = 191;
this.libraryDefinition();
}
break;
case 7:
{
this.state = 192;
this.functionDefinition();
}
break;
case 8:
{
this.state = 193;
this.constantVariableDeclaration();
}
break;
case 9:
{
this.state = 194;
this.structDefinition();
}
break;
case 10:
{
this.state = 195;
this.enumDefinition();
}
break;
case 11:
{
this.state = 196;
this.userDefinedValueTypeDefinition();
}
break;
case 12:
{
this.state = 197;
this.errorDefinition();
}
break;
case 13:
{
this.state = 198;
this.eventDefinition();
}
break;
}
}
}
this.state = 203;
this.errorHandler.sync(this);
alternative = this.interpreter.adaptivePredict(this.tokenStream, 1, this.context);
}
this.state = 204;
this.match(SolidityParser.EOF);
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
pragmaDirective() {
let localContext = new PragmaDirectiveContext(this.context, this.state);
this.enterRule(localContext, 2, SolidityParser.RULE_pragmaDirective);
let _la;
try {
this.enterOuterAlt(localContext, 1);
{
this.state = 206;
this.match(SolidityParser.Pragma);
this.state = 208;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
do {
{
{
this.state = 207;
this.match(SolidityParser.PragmaToken);
}
}
this.state = 210;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
} while (_la === 173);
this.state = 212;
this.match(SolidityParser.PragmaSemicolon);
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
importDirective() {
let localContext = new ImportDirectiveContext(this.context, this.state);
this.enterRule(localContext, 4, SolidityParser.RULE_importDirective);
let _la;
try {
this.enterOuterAlt(localContext, 1);
{
this.state = 214;
this.match(SolidityParser.Import);
this.state = 230;
this.errorHandler.sync(this);
switch (this.tokenStream.LA(1)) {
case SolidityParser.NonEmptyStringLiteral:
{
{
this.state = 215;
this.path();
this.state = 218;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
if (_la === 5) {
{
this.state = 216;
this.match(SolidityParser.As);
this.state = 217;
localContext._unitAlias = this.identifier();
}
}
}
}
break;
case SolidityParser.LBrace:
{
{
this.state = 220;
this.symbolAliases();
this.state = 221;
this.match(SolidityParser.From);
this.state = 222;
this.path();
}
}
break;
case SolidityParser.Mul:
{
{
this.state = 224;
this.match(SolidityParser.Mul);
this.state = 225;
this.match(SolidityParser.As);
this.state = 226;
localContext._unitAlias = this.identifier();
this.state = 227;
this.match(SolidityParser.From);
this.state = 228;
this.path();
}
}
break;
default:
throw new antlr.NoViableAltException(this);
}
this.state = 232;
this.match(SolidityParser.Semicolon);
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
importAliases() {
let localContext = new ImportAliasesContext(this.context, this.state);
this.enterRule(localContext, 6, SolidityParser.RULE_importAliases);
let _la;
try {
this.enterOuterAlt(localContext, 1);
{
this.state = 234;
localContext._symbol_ = this.identifier();
this.state = 237;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
if (_la === 5) {
{
this.state = 235;
this.match(SolidityParser.As);
this.state = 236;
localContext._alias = this.identifier();
}
}
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
path() {
let localContext = new PathContext(this.context, this.state);
this.enterRule(localContext, 8, SolidityParser.RULE_path);
try {
this.enterOuterAlt(localContext, 1);
{
this.state = 239;
this.match(SolidityParser.NonEmptyStringLiteral);
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
symbolAliases() {
let localContext = new SymbolAliasesContext(this.context, this.state);
this.enterRule(localContext, 10, SolidityParser.RULE_symbolAliases);
let _la;
try {
this.enterOuterAlt(localContext, 1);
{
this.state = 241;
this.match(SolidityParser.LBrace);
this.state = 242;
localContext._importAliases = this.importAliases();
localContext._aliases.push(localContext._importAliases);
this.state = 247;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
while (_la === 95) {
{
{
this.state = 243;
this.match(SolidityParser.Comma);
this.state = 244;
localContext._importAliases = this.importAliases();
localContext._aliases.push(localContext._importAliases);
}
}
this.state = 249;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
}
this.state = 250;
this.match(SolidityParser.RBrace);
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
contractDefinition() {
let localContext = new ContractDefinitionContext(this.context, this.state);
this.enterRule(localContext, 12, SolidityParser.RULE_contractDefinition);
let _la;
try {
let alternative;
this.enterOuterAlt(localContext, 1);
{
this.state = 253;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
if (_la === 2) {
{
this.state = 252;
this.match(SolidityParser.Abstract);
}
}
this.state = 255;
this.match(SolidityParser.Contract);
this.state = 256;
localContext._name = this.identifier();
this.state = 258;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
if (_la === 39) {
{
this.state = 257;
this.inheritanceSpecifierList();
}
}
this.state = 260;
this.match(SolidityParser.LBrace);
this.state = 264;
this.errorHandler.sync(this);
alternative = this.interpreter.adaptivePredict(this.tokenStream, 9, this.context);
while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) {
if (alternative === 1) {
{
{
this.state = 261;
this.contractBodyElement();
}
}
}
this.state = 266;
this.errorHandler.sync(this);
alternative = this.interpreter.adaptivePredict(this.tokenStream, 9, this.context);
}
this.state = 267;
this.match(SolidityParser.RBrace);
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
interfaceDefinition() {
let localContext = new InterfaceDefinitionContext(this.context, this.state);
this.enterRule(localContext, 14, SolidityParser.RULE_interfaceDefinition);
let _la;
try {
let alternative;
this.enterOuterAlt(localContext, 1);
{
this.state = 269;
this.match(SolidityParser.Interface);
this.state = 270;
localContext._name = this.identifier();
this.state = 272;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
if (_la === 39) {
{
this.state = 271;
this.inheritanceSpecifierList();
}
}
this.state = 274;
this.match(SolidityParser.LBrace);
this.state = 278;
this.errorHandler.sync(this);
alternative = this.interpreter.adaptivePredict(this.tokenStream, 11, this.context);
while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) {
if (alternative === 1) {
{
{
this.state = 275;
this.contractBodyElement();
}
}
}
this.state = 280;
this.errorHandler.sync(this);
alternative = this.interpreter.adaptivePredict(this.tokenStream, 11, this.context);
}
this.state = 281;
this.match(SolidityParser.RBrace);
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
libraryDefinition() {
let localContext = new LibraryDefinitionContext(this.context, this.state);
this.enterRule(localContext, 16, SolidityParser.RULE_libraryDefinition);
try {
let alternative;
this.enterOuterAlt(localContext, 1);
{
this.state = 283;
this.match(SolidityParser.Library);
this.state = 284;
localContext._name = this.identifier();
this.state = 285;
this.match(SolidityParser.LBrace);
this.state = 289;
this.errorHandler.sync(this);
alternative = this.interpreter.adaptivePredict(this.tokenStream, 12, this.context);
while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) {
if (alternative === 1) {
{
{
this.state = 286;
this.contractBodyElement();
}
}
}
this.state = 291;
this.errorHandler.sync(this);
alternative = this.interpreter.adaptivePredict(this.tokenStream, 12, this.context);
}
this.state = 292;
this.match(SolidityParser.RBrace);
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
inheritanceSpecifierList() {
let localContext = new InheritanceSpecifierListContext(this.context, this.state);
this.enterRule(localContext, 18, SolidityParser.RULE_inheritanceSpecifierList);
try {
let alternative;
this.enterOuterAlt(localContext, 1);
{
this.state = 294;
this.match(SolidityParser.Is);
this.state = 295;
localContext._inheritanceSpecifier = this.inheritanceSpecifier();
localContext._inheritanceSpecifiers.push(localContext._inheritanceSpecifier);
this.state = 300;
this.errorHandler.sync(this);
alternative = this.interpreter.adaptivePredict(this.tokenStream, 13, this.context);
while (alternative !== 1 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) {
if (alternative === 1 + 1) {
{
{
this.state = 296;
this.match(SolidityParser.Comma);
this.state = 297;
localContext._inheritanceSpecifier = this.inheritanceSpecifier();
localContext._inheritanceSpecifiers.push(localContext._inheritanceSpecifier);
}
}
}
this.state = 302;
this.errorHandler.sync(this);
alternative = this.interpreter.adaptivePredict(this.tokenStream, 13, this.context);
}
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
inheritanceSpecifier() {
let localContext = new InheritanceSpecifierContext(this.context, this.state);
this.enterRule(localContext, 20, SolidityParser.RULE_inheritanceSpecifier);
let _la;
try {
this.enterOuterAlt(localContext, 1);
{
this.state = 303;
localContext._name = this.identifierPath();
this.state = 305;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
if (_la === 71) {
{
this.state = 304;
localContext._arguments = this.callArgumentList();
}
}
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
contractBodyElement() {
let localContext = new ContractBodyElementContext(this.context, this.state);
this.enterRule(localContext, 22, SolidityParser.RULE_contractBodyElement);
try {
this.state = 319;
this.errorHandler.sync(this);
switch (this.interpreter.adaptivePredict(this.tokenStream, 15, this.context)) {
case 1:
this.enterOuterAlt(localContext, 1);
{
this.state = 307;
this.constructorDefinition();
}
break;
case 2:
this.enterOuterAlt(localContext, 2);
{
this.state = 308;
this.functionDefinition();
}
break;
case 3:
this.enterOuterAlt(localContext, 3);
{
this.state = 309;
this.modifierDefinition();
}
break;
case 4:
this.enterOuterAlt(localContext, 4);
{
this.state = 310;
this.fallbackFunctionDefinition();
}
break;
case 5:
this.enterOuterAlt(localContext, 5);
{
this.state = 311;
this.receiveFunctionDefinition();
}
break;
case 6:
this.enterOuterAlt(localContext, 6);
{
this.state = 312;
this.structDefinition();
}
break;
case 7:
this.enterOuterAlt(localContext, 7);
{
this.state = 313;
this.enumDefinition();
}
break;
case 8:
this.enterOuterAlt(localContext, 8);
{
this.state = 314;
this.userDefinedValueTypeDefinition();
}
break;
case 9:
this.enterOuterAlt(localContext, 9);
{
this.state = 315;
this.stateVariableDeclaration();
}
break;
case 10:
this.enterOuterAlt(localContext, 10);
{
this.state = 316;
this.eventDefinition();
}
break;
case 11:
this.enterOuterAlt(localContext, 11);
{
this.state = 317;
this.errorDefinition();
}
break;
case 12:
this.enterOuterAlt(localContext, 12);
{
this.state = 318;
this.usingDirective();
}
break;
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
namedArgument() {
let localContext = new NamedArgumentContext(this.context, this.state);
this.enterRule(localContext, 24, SolidityParser.RULE_namedArgument);
try {
this.enterOuterAlt(localContext, 1);
{
this.state = 321;
localContext._name = this.identifier();
this.state = 322;
this.match(SolidityParser.Colon);
this.state = 323;
localContext._value = this.expression(0);
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
callArgumentList() {
let localContext = new CallArgumentListContext(this.context, this.state);
this.enterRule(localContext, 26, SolidityParser.RULE_callArgumentList);
let _la;
try {
this.enterOuterAlt(localContext, 1);
{
this.state = 325;
this.match(SolidityParser.LParen);
this.state = 348;
this.errorHandler.sync(this);
switch (this.interpreter.adaptivePredict(this.tokenStream, 20, this.context)) {
case 1:
{
this.state = 334;
this.errorHandler.sync(this);
switch (this.interpreter.adaptivePredict(this.tokenStream, 17, this.context)) {
case 1:
{
this.state = 326;
this.expression(0);
this.state = 331;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
while (_la === 95) {
{
{
this.state = 327;
this.match(SolidityParser.Comma);
this.state = 328;
this.expression(0);
}
}
this.state = 333;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
}
}
break;
}
}
break;
case 2:
{
this.state = 336;
this.match(SolidityParser.LBrace);
this.state = 345;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
if ((_la & ~31) === 0 && (1 << _la & 2686451712) !== 0 || _la === 55 || _la === 130) {
{
this.state = 337;
this.namedArgument();
this.state = 342;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
while (_la === 95) {
{
{
this.state = 338;
this.match(SolidityParser.Comma);
this.state = 339;
this.namedArgument();
}
}
this.state = 344;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
}
}
}
this.state = 347;
this.match(SolidityParser.RBrace);
}
break;
}
this.state = 350;
this.match(SolidityParser.RParen);
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
identifierPath() {
let localContext = new IdentifierPathContext(this.context, this.state);
this.enterRule(localContext, 28, SolidityParser.RULE_identifierPath);
try {
let alternative;
this.enterOuterAlt(localContext, 1);
{
this.state = 352;
this.identifier();
this.state = 357;
this.errorHandler.sync(this);
alternative = this.interpreter.adaptivePredict(this.tokenStream, 21, this.context);
while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) {
if (alternative === 1) {
{
{
this.state = 353;
this.match(SolidityParser.Period);
this.state = 354;
this.identifier();
}
}
}
this.state = 359;
this.errorHandler.sync(this);
alternative = this.interpreter.adaptivePredict(this.tokenStream, 21, this.context);
}
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
modifierInvocation() {
let localContext = new ModifierInvocationContext(this.context, this.state);
this.enterRule(localContext, 30, SolidityParser.RULE_modifierInvocation);
try {
this.enterOuterAlt(localContext, 1);
{
this.state = 360;
this.identifierPath();
this.state = 362;
this.errorHandler.sync(this);
switch (this.interpreter.adaptivePredict(this.tokenStream, 22, this.context)) {
case 1:
{
this.state = 361;
this.callArgumentList();
}
break;
}
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
visibility() {
let localContext = new VisibilityContext(this.context, this.state);
this.enterRule(localContext, 32, SolidityParser.RULE_visibility);
let _la;
try {
this.enterOuterAlt(localContext, 1);
{
this.state = 364;
_la = this.tokenStream.LA(1);
if (!((_la - 23 & ~31) === 0 && (1 << _la - 23 & 201359361) !== 0)) {
this.errorHandler.recoverInline(this);
} else {
this.errorHandler.reportMatch(this);
this.consume();
}
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
parameterList() {
let localContext = new ParameterListContext(this.context, this.state);
this.enterRule(localContext, 34, SolidityParser.RULE_parameterList);
let _la;
try {
this.enterOuterAlt(localContext, 1);
{
this.state = 366;
localContext._parameterDeclaration = this.parameterDeclaration();
localContext._parameters.push(localContext._parameterDeclaration);
this.state = 371;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
while (_la === 95) {
{
{
this.state = 367;
this.match(SolidityParser.Comma);
this.state = 368;
localContext._parameterDeclaration = this.parameterDeclaration();
localContext._parameters.push(localContext._parameterDeclaration);
}
}
this.state = 373;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
}
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
parameterDeclaration() {
let localContext = new ParameterDeclarationContext(this.context, this.state);
this.enterRule(localContext, 36, SolidityParser.RULE_parameterDeclaration);
let _la;
try {
this.enterOuterAlt(localContext, 1);
{
this.state = 374;
localContext._type_ = this.typeName(0);
this.state = 376;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
if (_la === 10 || _la === 42 || _la === 57) {
{
this.state = 375;
localContext._location = this.dataLocation();
}
}
this.state = 379;
this.errorHandler.sync(this);
_la = this.tokenStream.LA(1);
if ((_la & ~31) === 0 && (1 << _la & 2686451712) !== 0 || _la === 55 || _la === 130) {
{
this.state = 378;
localContext._name = this.identifier();
}
}
}
} catch (re) {
if (re instanceof antlr.RecognitionException) {
localContext.exception = re;
this.errorHandler.reportError(this, re);
this.errorHandler.recover(this, re);
} else {
throw re;
}
} finally {
this.exitRule();
}
return localContext;
}
constructorDefinition() {
let localContext = new ConstructorDefinitionContext(this.context, this.state);
this.enterRule(localContext, 38, SolidityParser.RULE_constructorDefinition);
try {
let alternative;
this.enterOuterAlt(localContext, 1);
{
this.state = 381;
this.match(SolidityParser.Constructor);
this.state = 382;
this.match(SolidityParser.LParen);
this.state = 384;
this.errorHandler.sync(this);
switch (this.interpreter.adaptivePredict(this.tokenStream, 26, this.context)) {
case 1:
{
this.state = 383;
localContext._arguments = this.parameterList();
}
break;
}
this.state = 386;
this.match(SolidityParser.RParen);
this.state = 399;
this.errorHandler.sync(this);
alternative = this.interpreter.adaptivePredict(this.tokenStream, 28, this.context);