ralph-parser-ts
Version:
A Ralph language parser
1,249 lines (1,248 loc) • 182 kB
JavaScript
"use strict";
// Generated from ./src/RalphParser.g4 by ANTLR 4.9.0-SNAPSHOT
Object.defineProperty(exports, "__esModule", { value: true });
exports.EosContext = exports.ForStmtContext = exports.WhileStmtContext = exports.ElseStmtContext = exports.IfStmtContext = exports.ReturnStmtContext = exports.EmptyStmtContext = exports.SimpleStmtContext = exports.StatementContext = exports.BlockContext = exports.AnnotationContext = exports.EmitContext = exports.EventContext = exports.InterfaceContext = exports.ImplementsContext = exports.ContractExtendsContext = exports.ExtendsContext = exports.ContractContext = exports.AssetScriptContext = exports.TxScriptContext = exports.TypeStructBodyContext = exports.EnumContext = exports.VarNameAssignContext = exports.String_Context = exports.IntegerContext = exports.BasicLitContext = exports.MethodDeclContext = exports.ParamListContext = exports.ParamContext = exports.ResultContext = exports.TypeNameContext = exports.ArrayExprContext = exports.ArrayTypeContext = exports.PrimitiveTypeContext = exports.PrimaryExprContext = exports.ApsContext = exports.ApsBothContext = exports.ApsTokenContext = exports.ApsAlphContext = exports.MethodCallContext = exports.CallChainContext = exports.ExpressionListContext = exports.ExpressionContext = exports.VarNameContext = exports.VarDeclContext = exports.VarDeclMultiContext = exports.VarDeclSingleContext = exports.IdentifierListContext = exports.SourceFileContext = exports.RalphParser = void 0;
const ATN_1 = require("antlr4ts/atn/ATN");
const ATNDeserializer_1 = require("antlr4ts/atn/ATNDeserializer");
const FailedPredicateException_1 = require("antlr4ts/FailedPredicateException");
const NoViableAltException_1 = require("antlr4ts/NoViableAltException");
const Parser_1 = require("antlr4ts/Parser");
const ParserRuleContext_1 = require("antlr4ts/ParserRuleContext");
const ParserATNSimulator_1 = require("antlr4ts/atn/ParserATNSimulator");
const RecognitionException_1 = require("antlr4ts/RecognitionException");
const Token_1 = require("antlr4ts/Token");
const VocabularyImpl_1 = require("antlr4ts/VocabularyImpl");
const Utils = require("antlr4ts/misc/Utils");
class RalphParser extends Parser_1.Parser {
constructor(input) {
super(input);
this._interp = new ParserATNSimulator_1.ParserATNSimulator(RalphParser._ATN, this);
}
// @Override
// @NotNull
get vocabulary() {
return RalphParser.VOCABULARY;
}
// tslint:enable:no-trailing-whitespace
// @Override
get grammarFileName() { return "RalphParser.g4"; }
// @Override
get ruleNames() { return RalphParser.ruleNames; }
// @Override
get serializedATN() { return RalphParser._serializedATN; }
createFailedPredicateException(predicate, message) {
return new FailedPredicateException_1.FailedPredicateException(this, predicate, message);
}
// @RuleVersion(0)
sourceFile() {
let _localctx = new SourceFileContext(this._ctx, this.state);
this.enterRule(_localctx, 0, RalphParser.RULE_sourceFile);
let _la;
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 104;
this._errHandler.sync(this);
_la = this._input.LA(1);
while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << RalphParser.INTERFACE) | (1 << RalphParser.TXSCRIPT) | (1 << RalphParser.CONTRACT) | (1 << RalphParser.ASSETSCRIPT) | (1 << RalphParser.ABSTRACT))) !== 0)) {
{
this.state = 102;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case RalphParser.TXSCRIPT:
{
this.state = 98;
this.txScript();
}
break;
case RalphParser.CONTRACT:
case RalphParser.ABSTRACT:
{
this.state = 99;
this.contract();
}
break;
case RalphParser.INTERFACE:
{
this.state = 100;
this.interface();
}
break;
case RalphParser.ASSETSCRIPT:
{
this.state = 101;
this.assetScript();
}
break;
default:
throw new NoViableAltException_1.NoViableAltException(this);
}
}
this.state = 106;
this._errHandler.sync(this);
_la = this._input.LA(1);
}
this.state = 107;
this.match(RalphParser.EOF);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
identifierList() {
let _localctx = new IdentifierListContext(this._ctx, this.state);
this.enterRule(_localctx, 2, RalphParser.RULE_identifierList);
let _la;
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 109;
this.varName();
this.state = 114;
this._errHandler.sync(this);
_la = this._input.LA(1);
while (_la === RalphParser.COMMA) {
{
{
this.state = 110;
this.match(RalphParser.COMMA);
this.state = 111;
this.varName();
}
}
this.state = 116;
this._errHandler.sync(this);
_la = this._input.LA(1);
}
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
varDeclSingle() {
let _localctx = new VarDeclSingleContext(this._ctx, this.state);
this.enterRule(_localctx, 4, RalphParser.RULE_varDeclSingle);
let _la;
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 122;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case RalphParser.CONST:
{
this.state = 117;
this.match(RalphParser.CONST);
}
break;
case RalphParser.LET:
{
{
this.state = 118;
this.match(RalphParser.LET);
this.state = 120;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === RalphParser.MUT) {
{
this.state = 119;
this.match(RalphParser.MUT);
}
}
}
}
break;
default:
throw new NoViableAltException_1.NoViableAltException(this);
}
this.state = 124;
this.varName();
this.state = 125;
this.match(RalphParser.ASSIGN);
this.state = 126;
this.expression(0);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
varDeclMulti() {
let _localctx = new VarDeclMultiContext(this._ctx, this.state);
this.enterRule(_localctx, 6, RalphParser.RULE_varDeclMulti);
let _la;
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 133;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case RalphParser.CONST:
{
this.state = 128;
this.match(RalphParser.CONST);
}
break;
case RalphParser.LET:
{
{
this.state = 129;
this.match(RalphParser.LET);
this.state = 131;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === RalphParser.MUT) {
{
this.state = 130;
this.match(RalphParser.MUT);
}
}
}
}
break;
default:
throw new NoViableAltException_1.NoViableAltException(this);
}
this.state = 135;
this.match(RalphParser.L_PAREN);
this.state = 136;
this.identifierList();
this.state = 137;
this.match(RalphParser.R_PAREN);
this.state = 138;
this.match(RalphParser.ASSIGN);
this.state = 139;
this.expression(0);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
varDecl() {
let _localctx = new VarDeclContext(this._ctx, this.state);
this.enterRule(_localctx, 8, RalphParser.RULE_varDecl);
try {
this.state = 143;
this._errHandler.sync(this);
switch (this.interpreter.adaptivePredict(this._input, 7, this._ctx)) {
case 1:
this.enterOuterAlt(_localctx, 1);
{
this.state = 141;
this.varDeclSingle();
}
break;
case 2:
this.enterOuterAlt(_localctx, 2);
{
this.state = 142;
this.varDeclMulti();
}
break;
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
varName() {
let _localctx = new VarNameContext(this._ctx, this.state);
this.enterRule(_localctx, 10, RalphParser.RULE_varName);
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 145;
this.match(RalphParser.IDENTIFIER);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
expression(_p) {
if (_p === undefined) {
_p = 0;
}
let _parentctx = this._ctx;
let _parentState = this.state;
let _localctx = new ExpressionContext(this._ctx, _parentState);
let _prevctx = _localctx;
let _startState = 12;
this.enterRecursionRule(_localctx, 12, RalphParser.RULE_expression, _p);
let _la;
try {
let _alt;
this.enterOuterAlt(_localctx, 1);
{
this.state = 157;
this._errHandler.sync(this);
switch (this.interpreter.adaptivePredict(this._input, 8, this._ctx)) {
case 1:
{
this.state = 148;
this.primaryExpr();
}
break;
case 2:
{
this.state = 149;
this.callChain();
}
break;
case 3:
{
this.state = 150;
this.ifStmt();
}
break;
case 4:
{
this.state = 151;
this.match(RalphParser.L_PAREN);
this.state = 152;
this.expression(0);
this.state = 153;
this.match(RalphParser.R_PAREN);
}
break;
case 5:
{
this.state = 155;
_la = this._input.LA(1);
if (!(_la === RalphParser.SUB || _la === RalphParser.NOT)) {
this._errHandler.recoverInline(this);
}
else {
if (this._input.LA(1) === Token_1.Token.EOF) {
this.matchedEOF = true;
}
this._errHandler.reportMatch(this);
this.consume();
}
this.state = 156;
this.expression(5);
}
break;
}
this._ctx._stop = this._input.tryLT(-1);
this.state = 173;
this._errHandler.sync(this);
_alt = this.interpreter.adaptivePredict(this._input, 10, this._ctx);
while (_alt !== 2 && _alt !== ATN_1.ATN.INVALID_ALT_NUMBER) {
if (_alt === 1) {
if (this._parseListeners != null) {
this.triggerExitRuleEvent();
}
_prevctx = _localctx;
{
this.state = 171;
this._errHandler.sync(this);
switch (this.interpreter.adaptivePredict(this._input, 9, this._ctx)) {
case 1:
{
_localctx = new ExpressionContext(_parentctx, _parentState);
this.pushNewRecursionContext(_localctx, _startState, RalphParser.RULE_expression);
this.state = 159;
if (!(this.precpred(this._ctx, 4))) {
throw this.createFailedPredicateException("this.precpred(this._ctx, 4)");
}
this.state = 160;
_la = this._input.LA(1);
if (!(((((_la - 47)) & ~0x1F) === 0 && ((1 << (_la - 47)) & ((1 << (RalphParser.CONCAT - 47)) | (1 << (RalphParser.ADD - 47)) | (1 << (RalphParser.SUB - 47)) | (1 << (RalphParser.MUL - 47)) | (1 << (RalphParser.DIV - 47)) | (1 << (RalphParser.MOD - 47)) | (1 << (RalphParser.MODADD - 47)) | (1 << (RalphParser.MODSUB - 47)) | (1 << (RalphParser.MODMUL - 47)) | (1 << (RalphParser.SHL - 47)) | (1 << (RalphParser.SHR - 47)) | (1 << (RalphParser.BITAND - 47)) | (1 << (RalphParser.XOR - 47)) | (1 << (RalphParser.BITOR - 47)))) !== 0))) {
this._errHandler.recoverInline(this);
}
else {
if (this._input.LA(1) === Token_1.Token.EOF) {
this.matchedEOF = true;
}
this._errHandler.reportMatch(this);
this.consume();
}
this.state = 161;
this.expression(5);
}
break;
case 2:
{
_localctx = new ExpressionContext(_parentctx, _parentState);
this.pushNewRecursionContext(_localctx, _startState, RalphParser.RULE_expression);
this.state = 162;
if (!(this.precpred(this._ctx, 3))) {
throw this.createFailedPredicateException("this.precpred(this._ctx, 3)");
}
this.state = 163;
_la = this._input.LA(1);
if (!(((((_la - 61)) & ~0x1F) === 0 && ((1 << (_la - 61)) & ((1 << (RalphParser.EQ - 61)) | (1 << (RalphParser.NQ - 61)) | (1 << (RalphParser.LT - 61)) | (1 << (RalphParser.LE - 61)) | (1 << (RalphParser.GT - 61)) | (1 << (RalphParser.GE - 61)))) !== 0))) {
this._errHandler.recoverInline(this);
}
else {
if (this._input.LA(1) === Token_1.Token.EOF) {
this.matchedEOF = true;
}
this._errHandler.reportMatch(this);
this.consume();
}
this.state = 164;
this.expression(4);
}
break;
case 3:
{
_localctx = new ExpressionContext(_parentctx, _parentState);
this.pushNewRecursionContext(_localctx, _startState, RalphParser.RULE_expression);
this.state = 165;
if (!(this.precpred(this._ctx, 2))) {
throw this.createFailedPredicateException("this.precpred(this._ctx, 2)");
}
this.state = 166;
_la = this._input.LA(1);
if (!(_la === RalphParser.AND || _la === RalphParser.OR)) {
this._errHandler.recoverInline(this);
}
else {
if (this._input.LA(1) === Token_1.Token.EOF) {
this.matchedEOF = true;
}
this._errHandler.reportMatch(this);
this.consume();
}
this.state = 167;
this.expression(3);
}
break;
case 4:
{
_localctx = new ExpressionContext(_parentctx, _parentState);
this.pushNewRecursionContext(_localctx, _startState, RalphParser.RULE_expression);
this.state = 168;
if (!(this.precpred(this._ctx, 1))) {
throw this.createFailedPredicateException("this.precpred(this._ctx, 1)");
}
this.state = 169;
this.match(RalphParser.ASSIGN);
this.state = 170;
this.expression(2);
}
break;
}
}
}
this.state = 175;
this._errHandler.sync(this);
_alt = this.interpreter.adaptivePredict(this._input, 10, this._ctx);
}
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.unrollRecursionContexts(_parentctx);
}
return _localctx;
}
// @RuleVersion(0)
expressionList() {
let _localctx = new ExpressionListContext(this._ctx, this.state);
this.enterRule(_localctx, 14, RalphParser.RULE_expressionList);
try {
let _alt;
this.enterOuterAlt(_localctx, 1);
{
this.state = 182;
this._errHandler.sync(this);
_alt = this.interpreter.adaptivePredict(this._input, 12, this._ctx);
while (_alt !== 2 && _alt !== ATN_1.ATN.INVALID_ALT_NUMBER) {
if (_alt === 1) {
{
{
this.state = 176;
this.expression(0);
this.state = 178;
this._errHandler.sync(this);
switch (this.interpreter.adaptivePredict(this._input, 11, this._ctx)) {
case 1:
{
this.state = 177;
this.match(RalphParser.COMMA);
}
break;
}
}
}
}
this.state = 184;
this._errHandler.sync(this);
_alt = this.interpreter.adaptivePredict(this._input, 12, this._ctx);
}
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
callChain() {
let _localctx = new CallChainContext(this._ctx, this.state);
this.enterRule(_localctx, 16, RalphParser.RULE_callChain);
try {
let _alt;
this.enterOuterAlt(_localctx, 1);
{
this.state = 187;
this._errHandler.sync(this);
switch (this.interpreter.adaptivePredict(this._input, 13, this._ctx)) {
case 1:
{
this.state = 185;
this.varName();
}
break;
case 2:
{
this.state = 186;
this.methodCall();
}
break;
}
this.state = 193;
this._errHandler.sync(this);
_alt = this.interpreter.adaptivePredict(this._input, 14, this._ctx);
while (_alt !== 2 && _alt !== ATN_1.ATN.INVALID_ALT_NUMBER) {
if (_alt === 1) {
{
{
this.state = 189;
this.match(RalphParser.DOT);
this.state = 190;
this.callChain();
}
}
}
this.state = 195;
this._errHandler.sync(this);
_alt = this.interpreter.adaptivePredict(this._input, 14, this._ctx);
}
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
methodCall() {
let _localctx = new MethodCallContext(this._ctx, this.state);
this.enterRule(_localctx, 18, RalphParser.RULE_methodCall);
let _la;
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 196;
this.match(RalphParser.IDENTIFIER);
this.state = 198;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === RalphParser.L_CURLY) {
{
this.state = 197;
this.aps();
}
}
this.state = 200;
this.match(RalphParser.L_PAREN);
this.state = 201;
this.expressionList();
this.state = 202;
this.match(RalphParser.R_PAREN);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
apsAlph() {
let _localctx = new ApsAlphContext(this._ctx, this.state);
this.enterRule(_localctx, 20, RalphParser.RULE_apsAlph);
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 204;
this.expression(0);
this.state = 205;
this.match(RalphParser.R_ARROW);
this.state = 206;
this.expression(0);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
apsToken() {
let _localctx = new ApsTokenContext(this._ctx, this.state);
this.enterRule(_localctx, 22, RalphParser.RULE_apsToken);
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 208;
this.apsAlph();
this.state = 209;
this.match(RalphParser.COLON);
this.state = 210;
this.expression(0);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
apsBoth() {
let _localctx = new ApsBothContext(this._ctx, this.state);
this.enterRule(_localctx, 24, RalphParser.RULE_apsBoth);
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 212;
this.apsAlph();
this.state = 213;
this.match(RalphParser.COMMA);
this.state = 214;
this.expression(0);
this.state = 215;
this.match(RalphParser.COLON);
this.state = 216;
this.expression(0);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
aps() {
let _localctx = new ApsContext(this._ctx, this.state);
this.enterRule(_localctx, 26, RalphParser.RULE_aps);
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 218;
this.match(RalphParser.L_CURLY);
this.state = 222;
this._errHandler.sync(this);
switch (this.interpreter.adaptivePredict(this._input, 16, this._ctx)) {
case 1:
{
this.state = 219;
this.apsAlph();
}
break;
case 2:
{
this.state = 220;
this.apsToken();
}
break;
case 3:
{
this.state = 221;
this.apsBoth();
}
break;
}
this.state = 224;
this.match(RalphParser.R_CURLY);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
primaryExpr() {
let _localctx = new PrimaryExprContext(this._ctx, this.state);
this.enterRule(_localctx, 28, RalphParser.RULE_primaryExpr);
try {
this.state = 228;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case RalphParser.ADDRESS_LIT:
case RalphParser.ALPH_LIT:
case RalphParser.BOOL_LIT:
case RalphParser.DECIMAL_LIT:
case RalphParser.BINARY_LIT:
case RalphParser.OCTAL_LIT:
case RalphParser.HEX_LIT:
case RalphParser.IMAGINARY_LIT:
case RalphParser.RUNE_LIT:
case RalphParser.RAW_STRING_LIT:
case RalphParser.INTERPRETED_STRING_LIT:
this.enterOuterAlt(_localctx, 1);
{
this.state = 226;
this.basicLit();
}
break;
case RalphParser.IDENTIFIER:
case RalphParser.L_BRACKET:
this.enterOuterAlt(_localctx, 2);
{
this.state = 227;
this.arrayExpr();
}
break;
default:
throw new NoViableAltException_1.NoViableAltException(this);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
primitiveType() {
let _localctx = new PrimitiveTypeContext(this._ctx, this.state);
this.enterRule(_localctx, 30, RalphParser.RULE_primitiveType);
try {
this.state = 237;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case RalphParser.BOOL:
this.enterOuterAlt(_localctx, 1);
{
this.state = 230;
this.match(RalphParser.BOOL);
}
break;
case RalphParser.I256:
this.enterOuterAlt(_localctx, 2);
{
this.state = 231;
this.match(RalphParser.I256);
}
break;
case RalphParser.BYTE:
this.enterOuterAlt(_localctx, 3);
{
this.state = 232;
this.match(RalphParser.BYTE);
}
break;
case RalphParser.U256:
this.enterOuterAlt(_localctx, 4);
{
this.state = 233;
this.match(RalphParser.U256);
}
break;
case RalphParser.BYTEVEC:
this.enterOuterAlt(_localctx, 5);
{
this.state = 234;
this.match(RalphParser.BYTEVEC);
}
break;
case RalphParser.ADDRESS:
this.enterOuterAlt(_localctx, 6);
{
this.state = 235;
this.match(RalphParser.ADDRESS);
}
break;
case RalphParser.L_BRACKET:
this.enterOuterAlt(_localctx, 7);
{
this.state = 236;
this.arrayType();
}
break;
default:
throw new NoViableAltException_1.NoViableAltException(this);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
arrayType() {
let _localctx = new ArrayTypeContext(this._ctx, this.state);
this.enterRule(_localctx, 32, RalphParser.RULE_arrayType);
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 239;
this.match(RalphParser.L_BRACKET);
this.state = 240;
this.typeName();
this.state = 241;
this.match(RalphParser.SEMI);
this.state = 242;
this.expression(0);
this.state = 243;
this.match(RalphParser.R_BRACKET);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
arrayExpr() {
let _localctx = new ArrayExprContext(this._ctx, this.state);
this.enterRule(_localctx, 34, RalphParser.RULE_arrayExpr);
let _la;
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 246;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === RalphParser.IDENTIFIER) {
{
this.state = 245;
this.match(RalphParser.IDENTIFIER);
}
}
this.state = 248;
this.match(RalphParser.L_BRACKET);
this.state = 249;
this.expression(0);
this.state = 254;
this._errHandler.sync(this);
_la = this._input.LA(1);
while (_la === RalphParser.COMMA) {
{
{
this.state = 250;
this.match(RalphParser.COMMA);
this.state = 251;
this.expression(0);
}
}
this.state = 256;
this._errHandler.sync(this);
_la = this._input.LA(1);
}
this.state = 257;
this.match(RalphParser.R_BRACKET);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
typeName() {
let _localctx = new TypeNameContext(this._ctx, this.state);
this.enterRule(_localctx, 36, RalphParser.RULE_typeName);
try {
this.state = 261;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case RalphParser.BOOL:
case RalphParser.I256:
case RalphParser.U256:
case RalphParser.BYTE:
case RalphParser.BYTEVEC:
case RalphParser.ADDRESS:
case RalphParser.L_BRACKET:
this.enterOuterAlt(_localctx, 1);
{
this.state = 259;
this.primitiveType();
}
break;
case RalphParser.IDENTIFIER:
this.enterOuterAlt(_localctx, 2);
{
this.state = 260;
this.match(RalphParser.IDENTIFIER);
}
break;
default:
throw new NoViableAltException_1.NoViableAltException(this);
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
result() {
let _localctx = new ResultContext(this._ctx, this.state);
this.enterRule(_localctx, 38, RalphParser.RULE_result);
let _la;
try {
let _alt;
this.state = 281;
this._errHandler.sync(this);
switch (this.interpreter.adaptivePredict(this._input, 25, this._ctx)) {
case 1:
this.enterOuterAlt(_localctx, 1);
{
this.state = 263;
this.match(RalphParser.L_PAREN);
this.state = 264;
this.match(RalphParser.R_PAREN);
}
break;
case 2:
this.enterOuterAlt(_localctx, 2);
{
this.state = 265;
this.typeName();
}
break;
case 3:
this.enterOuterAlt(_localctx, 3);
{
this.state = 266;
this.match(RalphParser.L_PAREN);
this.state = 278;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (((((_la - 24)) & ~0x1F) === 0 && ((1 << (_la - 24)) & ((1 << (RalphParser.BOOL - 24)) | (1 << (RalphParser.I256 - 24)) | (1 << (RalphParser.U256 - 24)) | (1 << (RalphParser.BYTE - 24)) | (1 << (RalphParser.BYTEVEC - 24)) | (1 << (RalphParser.ADDRESS - 24)) | (1 << (RalphParser.IDENTIFIER - 24)) | (1 << (RalphParser.L_BRACKET - 24)))) !== 0)) {
{
this.state = 267;
this.typeName();
this.state = 272;
this._errHandler.sync(this);
_alt = this.interpreter.adaptivePredict(this._input, 22, this._ctx);
while (_alt !== 2 && _alt !== ATN_1.ATN.INVALID_ALT_NUMBER) {
if (_alt === 1) {
{
{
this.state = 268;
this.match(RalphParser.COMMA);
this.state = 269;
this.typeName();
}
}
}
this.state = 274;
this._errHandler.sync(this);
_alt = this.interpreter.adaptivePredict(this._input, 22, this._ctx);
}
this.state = 276;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === RalphParser.COMMA) {
{
this.state = 275;
this.match(RalphParser.COMMA);
}
}
}
}
this.state = 280;
this.match(RalphParser.R_PAREN);
}
break;
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
param() {
let _localctx = new ParamContext(this._ctx, this.state);
this.enterRule(_localctx, 40, RalphParser.RULE_param);
let _la;
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 284;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === RalphParser.ATUNUSED) {
{
this.state = 283;
this.match(RalphParser.ATUNUSED);
}
}
this.state = 287;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === RalphParser.MUT) {
{
this.state = 286;
this.match(RalphParser.MUT);
}
}
this.state = 289;
this.match(RalphParser.IDENTIFIER);
this.state = 290;
this.match(RalphParser.COLON);
this.state = 291;
this.typeName();
}
}
catch (re) {
if (re instanceof RecognitionException_1.RecognitionException) {
_localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return _localctx;
}
// @RuleVersion(0)
paramList() {
let _localctx = new ParamListContext(this._ctx, this.state);
this.enterRule(_localctx, 42, RalphParser.RULE_paramList);
let _la;
try {
this.enterOuterAlt(_localctx, 1);
{
this.state = 299;
this._errHandler.sync(this);
_la = this._input.LA(1);
while (((((_la - 15)) & ~0x1F) === 0 && ((1 << (_la - 15)) & ((1 << (RalphParser.MUT - 15)) | (1 << (RalphParser.ATUNUSED - 15)) | (1 << (RalphParser.IDENTIFIER - 15)))) !== 0)) {
{
{
this.state = 293;
this.param();
this.state = 295;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === RalphParser.COMMA) {
{
this.state = 294;
this.match(RalphParser.COMMA);
}
}