in src/main/java/org/apache/sysds/parser/dml/DmlParser.java [1550:1858]
public final FunctionStatementContext functionStatement() throws RecognitionException {
FunctionStatementContext _localctx = new FunctionStatementContext(_ctx, getState());
enterRule(_localctx, 6, RULE_functionStatement);
// This actions occurs regardless of how many alternatives in this rule
((FunctionStatementContext)_localctx).info = new org.apache.sysds.parser.dml.StatementInfo();
int _la;
try {
setState(416);
_errHandler.sync(this);
switch ( getInterpreter().adaptivePredict(_input,57,_ctx) ) {
case 1:
_localctx = new InternalFunctionDefExpressionContext(_localctx);
enterOuterAlt(_localctx, 1);
{
setState(316);
((InternalFunctionDefExpressionContext)_localctx).name = match(ID);
setState(317);
_la = _input.LA(1);
if ( !(_la==T__6 || _la==T__7) ) {
_errHandler.recoverInline(this);
}
else {
if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
_errHandler.reportMatch(this);
consume();
}
setState(318);
match(T__22);
setState(319);
match(T__1);
setState(328);
_errHandler.sync(this);
_la = _input.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__47) | (1L << T__48) | (1L << T__49) | (1L << T__50) | (1L << T__51) | (1L << T__52) | (1L << T__53) | (1L << T__54) | (1L << T__55) | (1L << T__56) | (1L << T__57) | (1L << T__58) | (1L << ID))) != 0)) {
{
setState(320);
((InternalFunctionDefExpressionContext)_localctx).typedArgAssign = typedArgAssign();
((InternalFunctionDefExpressionContext)_localctx).inputParams.add(((InternalFunctionDefExpressionContext)_localctx).typedArgAssign);
setState(325);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==T__8) {
{
{
setState(321);
match(T__8);
setState(322);
((InternalFunctionDefExpressionContext)_localctx).typedArgAssign = typedArgAssign();
((InternalFunctionDefExpressionContext)_localctx).inputParams.add(((InternalFunctionDefExpressionContext)_localctx).typedArgAssign);
}
}
setState(327);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
setState(330);
match(T__2);
setState(344);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==T__23) {
{
setState(331);
match(T__23);
setState(332);
match(T__1);
setState(341);
_errHandler.sync(this);
_la = _input.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__47) | (1L << T__48) | (1L << T__49) | (1L << T__50) | (1L << T__51) | (1L << T__52) | (1L << T__53) | (1L << T__54) | (1L << T__55) | (1L << T__56) | (1L << T__57) | (1L << T__58) | (1L << ID))) != 0)) {
{
setState(333);
((InternalFunctionDefExpressionContext)_localctx).typedArgNoAssign = typedArgNoAssign();
((InternalFunctionDefExpressionContext)_localctx).outputParams.add(((InternalFunctionDefExpressionContext)_localctx).typedArgNoAssign);
setState(338);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==T__8) {
{
{
setState(334);
match(T__8);
setState(335);
((InternalFunctionDefExpressionContext)_localctx).typedArgNoAssign = typedArgNoAssign();
((InternalFunctionDefExpressionContext)_localctx).outputParams.add(((InternalFunctionDefExpressionContext)_localctx).typedArgNoAssign);
}
}
setState(340);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
setState(343);
match(T__2);
}
}
setState(346);
match(T__14);
setState(356);
_errHandler.sync(this);
_la = _input.LA(1);
while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__5) | (1L << T__9) | (1L << T__13) | (1L << T__17) | (1L << T__19) | (1L << T__20) | (1L << ID))) != 0) || _la==COMMANDLINE_NAMED_ID || _la==COMMANDLINE_POSITION_ID) {
{
{
setState(347);
((InternalFunctionDefExpressionContext)_localctx).statement = statement();
((InternalFunctionDefExpressionContext)_localctx).body.add(((InternalFunctionDefExpressionContext)_localctx).statement);
setState(351);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==T__4) {
{
{
setState(348);
match(T__4);
}
}
setState(353);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
setState(358);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(359);
match(T__15);
setState(363);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==T__4) {
{
{
setState(360);
match(T__4);
}
}
setState(365);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
break;
case 2:
_localctx = new ExternalFunctionDefExpressionContext(_localctx);
enterOuterAlt(_localctx, 2);
{
setState(366);
((ExternalFunctionDefExpressionContext)_localctx).name = match(ID);
setState(367);
_la = _input.LA(1);
if ( !(_la==T__6 || _la==T__7) ) {
_errHandler.recoverInline(this);
}
else {
if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
_errHandler.reportMatch(this);
consume();
}
setState(368);
match(T__24);
setState(369);
match(T__1);
setState(378);
_errHandler.sync(this);
_la = _input.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__47) | (1L << T__48) | (1L << T__49) | (1L << T__50) | (1L << T__51) | (1L << T__52) | (1L << T__53) | (1L << T__54) | (1L << T__55) | (1L << T__56) | (1L << T__57) | (1L << T__58) | (1L << ID))) != 0)) {
{
setState(370);
((ExternalFunctionDefExpressionContext)_localctx).typedArgNoAssign = typedArgNoAssign();
((ExternalFunctionDefExpressionContext)_localctx).inputParams.add(((ExternalFunctionDefExpressionContext)_localctx).typedArgNoAssign);
setState(375);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==T__8) {
{
{
setState(371);
match(T__8);
setState(372);
((ExternalFunctionDefExpressionContext)_localctx).typedArgNoAssign = typedArgNoAssign();
((ExternalFunctionDefExpressionContext)_localctx).inputParams.add(((ExternalFunctionDefExpressionContext)_localctx).typedArgNoAssign);
}
}
setState(377);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
setState(380);
match(T__2);
setState(394);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==T__23) {
{
setState(381);
match(T__23);
setState(382);
match(T__1);
setState(391);
_errHandler.sync(this);
_la = _input.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__47) | (1L << T__48) | (1L << T__49) | (1L << T__50) | (1L << T__51) | (1L << T__52) | (1L << T__53) | (1L << T__54) | (1L << T__55) | (1L << T__56) | (1L << T__57) | (1L << T__58) | (1L << ID))) != 0)) {
{
setState(383);
((ExternalFunctionDefExpressionContext)_localctx).typedArgNoAssign = typedArgNoAssign();
((ExternalFunctionDefExpressionContext)_localctx).outputParams.add(((ExternalFunctionDefExpressionContext)_localctx).typedArgNoAssign);
setState(388);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==T__8) {
{
{
setState(384);
match(T__8);
setState(385);
((ExternalFunctionDefExpressionContext)_localctx).typedArgNoAssign = typedArgNoAssign();
((ExternalFunctionDefExpressionContext)_localctx).outputParams.add(((ExternalFunctionDefExpressionContext)_localctx).typedArgNoAssign);
}
}
setState(390);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
setState(393);
match(T__2);
}
}
setState(396);
match(T__25);
setState(397);
match(T__18);
setState(398);
match(T__1);
setState(407);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==ID) {
{
setState(399);
((ExternalFunctionDefExpressionContext)_localctx).strictParameterizedKeyValueString = strictParameterizedKeyValueString();
((ExternalFunctionDefExpressionContext)_localctx).otherParams.add(((ExternalFunctionDefExpressionContext)_localctx).strictParameterizedKeyValueString);
setState(404);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==T__8) {
{
{
setState(400);
match(T__8);
setState(401);
((ExternalFunctionDefExpressionContext)_localctx).strictParameterizedKeyValueString = strictParameterizedKeyValueString();
((ExternalFunctionDefExpressionContext)_localctx).otherParams.add(((ExternalFunctionDefExpressionContext)_localctx).strictParameterizedKeyValueString);
}
}
setState(406);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
setState(409);
match(T__2);
setState(413);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==T__4) {
{
{
setState(410);
match(T__4);
}
}
setState(415);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
break;
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}