diff --git a/localstack-core/localstack/services/stepfunctions/asl/antlr/LSLLexer.g4 b/localstack-core/localstack/services/stepfunctions/asl/antlr/LSLLexer.g4 new file mode 100644 index 0000000000000..2cfb37094b6cb --- /dev/null +++ b/localstack-core/localstack/services/stepfunctions/asl/antlr/LSLLexer.g4 @@ -0,0 +1,86 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + +lexer grammar LSLLexer; + +// Comments: +LINECOMMENT: '#' ~[\r\n\f]* -> skip; + +JSONATA: 'jsonata(' ~[)]* ')'; + +// ErrorNames +ERRORNAMEStatesALL: 'States.ALL'; +ERRORNAMEStatesDataLimitExceeded: 'States.DataLimitExceeded'; +ERRORNAMEStatesHeartbeatTimeout: 'States.HeartbeatTimeout'; +ERRORNAMEStatesTimeout: 'States.Timeout'; +ERRORNAMEStatesTaskFailed: 'States.TaskFailed'; +ERRORNAMEStatesPermissions: 'States.Permissions'; +ERRORNAMEStatesResultPathMatchFailure: 'States.ResultPathMatchFailure'; +ERRORNAMEStatesParameterPathFailure: 'States.ParameterPathFailure'; +ERRORNAMEStatesBranchFailed: 'States.BranchFailed'; +ERRORNAMEStatesNoChoiceMatched: 'States.NoChoiceMatched'; +ERRORNAMEStatesIntrinsicFailure: 'States.IntrinsicFailure'; +ERRORNAMEStatesExceedToleratedFailureThreshold: 'States.ExceedToleratedFailureThreshold'; +ERRORNAMEStatesItemReaderFailed: 'States.ItemReaderFailed'; +ERRORNAMEStatesResultWriterFailed: 'States.ResultWriterFailed'; +ERRORNAMEStatesQueryEvaluationError: 'States.QueryEvaluationError'; + +// Symbols. +ARROW: '->'; +EQUALS: '='; +COMMA: ','; +COLON: ':'; +LPAREN: '('; +RPAREN: ')'; +LBRACK: '['; +RBRACK: ']'; +LBRACE: '{'; +RBRACE: '}'; + +// Literals. +TRUE: 'true'; +FALSE: 'false'; +NULL: 'null'; + +// Keywords. +WHERE: 'where'; +AS: 'as'; +FAIL: 'fail'; +OUTPUT: 'output'; +RETURN: 'return'; +ERROR: 'error'; +CAUSE: 'cause'; +LAMBDA: 'lambda'; +ARGUMENTS: 'arguments'; +CATCH: 'catch'; +FOR: 'for'; +IN: 'in'; +PROCESS: 'process'; +PARALLEL: 'parallel'; + +STRINGPATH: '"$"' | '"$' ('.' | '[') (ESC | SAFECODEPOINT)* '"'; + +STRING: '"' (ESC | SAFECODEPOINT)* '"'; + +fragment ESC: '\\' (["\\/bfnrt] | UNICODE); + +fragment UNICODE: 'u' HEX HEX HEX HEX; + +fragment HEX: [0-9a-fA-F]; + +fragment SAFECODEPOINT: ~ ["\\\u0000-\u001F]; + +// Numbers. +INT: '0' | [1-9] [0-9]*; + +NUMBER: '-'? INT ('.' [0-9]+)? EXP?; + +fragment EXP: [Ee] [+\-]? INT; + +IDEN: [a-zA-Z_0-9-]+; + +// Whitespace. +WS: [ \t\n\r]+ -> skip; + +TOK: .; diff --git a/localstack-core/localstack/services/stepfunctions/asl/antlr/LSLParser.g4 b/localstack-core/localstack/services/stepfunctions/asl/antlr/LSLParser.g4 new file mode 100644 index 0000000000000..3f49bb15a003b --- /dev/null +++ b/localstack-core/localstack/services/stepfunctions/asl/antlr/LSLParser.g4 @@ -0,0 +1,94 @@ +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + +parser grammar LSLParser; + +options { + tokenVocab = LSLLexer; +} + +state_machine: (state_declaration | var_assign | state_call)+ EOF; + +state_declaration: + IDEN parameter_list EQUALS state +; + +state_call: + IDEN args_assign_list # state_call_template + | IDEN AS state # state_call_named + | state # state_call_anonymous + ; + +state: + service_name COLON IDEN task_where # state_task + | FAIL fail_where # state_fail + | RETURN json_value # state_return + | FOR IDEN IN json_value WHERE process # state_map + | PARALLEL WHERE process+ # state_parallel +; + +service_name: LAMBDA; + +task_where: WHERE arguments? catch_block?; +fail_where: WHERE error cause?; + +arguments: ARGUMENTS json_value; +catch_block: CATCH LBRACE catch_case (catch_case)* RBRACE; +catch_case: error_name ARROW state_call; + +parameter_list: + LPAREN IDEN? (COMMA IDEN)* RPAREN +; + +args_assign_list: + LPAREN args_assign (COMMA args_assign)* RPAREN +; +args_assign: IDEN EQUALS json_value; + +error: ERROR string_or_jsonata; +cause: CAUSE string_or_jsonata; + +process: PROCESS LBRACE (state_declaration | var_assign | state_call)+ RBRACE; + +var_assign: + IDEN EQUALS state_call # var_assign_state_call + | IDEN EQUALS json_value # var_assign_json_value +; + +json_value: json_object | json_arr | json_value_lit; +json_object: LBRACE json_binding (COMMA json_binding)* RBRACE | LBRACE RBRACE; +json_binding: (STRING | IDEN) COLON json_value; +json_arr: LBRACK json_value (COMMA json_value)* RBRACK | LBRACK RBRACK; +json_value_lit: + NUMBER # json_value_float + | INT # json_value_int + | (TRUE | FALSE) # json_value_bool + | NULL # json_value_null + | STRING # json_value_str + | JSONATA # json_value_jsonata +; + +string_or_jsonata: + STRING # string_or_jsonata_string + | JSONATA # string_or_jsonata_jsonata +; + +error_name: + ERRORNAMEStatesALL + | ERRORNAMEStatesDataLimitExceeded + | ERRORNAMEStatesHeartbeatTimeout + | ERRORNAMEStatesTimeout + | ERRORNAMEStatesTaskFailed + | ERRORNAMEStatesPermissions + | ERRORNAMEStatesResultPathMatchFailure + | ERRORNAMEStatesParameterPathFailure + | ERRORNAMEStatesBranchFailed + | ERRORNAMEStatesNoChoiceMatched + | ERRORNAMEStatesIntrinsicFailure + | ERRORNAMEStatesExceedToleratedFailureThreshold + | ERRORNAMEStatesItemReaderFailed + | ERRORNAMEStatesResultWriterFailed + | ERRORNAMEStatesQueryEvaluationError + | STRING +; diff --git a/localstack-core/localstack/services/stepfunctions/asl/antlr/runtime/LSLLexer.py b/localstack-core/localstack/services/stepfunctions/asl/antlr/runtime/LSLLexer.py new file mode 100644 index 0000000000000..30760540eb7df --- /dev/null +++ b/localstack-core/localstack/services/stepfunctions/asl/antlr/runtime/LSLLexer.py @@ -0,0 +1,382 @@ +# Generated from LSLLexer.g4 by ANTLR 4.13.2 +from antlr4 import * +from io import StringIO +import sys +if sys.version_info[1] > 5: + from typing import TextIO +else: + from typing.io import TextIO + + +def serializedATN(): + return [ + 4,0,52,715,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5, + 2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2, + 13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7, + 19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2, + 26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7, + 32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2, + 39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7, + 45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2, + 52,7,52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,1,0,1,0,5,0,118, + 8,0,10,0,12,0,121,9,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,5,1,135,8,1,10,1,12,1,138,9,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2, + 1,2,1,2,1,2,1,2,1,2,1,2,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, + 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,4, + 1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4, + 1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5, + 1,5,1,5,1,5,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6, + 1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7, + 1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,8,1,8,1,8,1,8,1,8, + 1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8, + 1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,9,1,9,1,9,1,9,1,9,1,9,1,9, + 1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9, + 1,9,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10, + 1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,11,1,11, + 1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11, + 1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,12, + 1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12, + 1,12,1,12,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,13,1,13, + 1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13, + 1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13, + 1,13,1,13,1,13,1,13,1,13,1,13,1,14,1,14,1,14,1,14,1,14,1,14,1,14, + 1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14, + 1,14,1,14,1,14,1,14,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15, + 1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15, + 1,15,1,15,1,15,1,15,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16, + 1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16, + 1,16,1,16,1,16,1,16,1,16,1,16,1,17,1,17,1,17,1,18,1,18,1,19,1,19, + 1,20,1,20,1,21,1,21,1,22,1,22,1,23,1,23,1,24,1,24,1,25,1,25,1,26, + 1,26,1,27,1,27,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,28,1,29, + 1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,30,1,30,1,30,1,31,1,31,1,31, + 1,32,1,32,1,32,1,32,1,32,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,34, + 1,34,1,34,1,34,1,34,1,34,1,34,1,35,1,35,1,35,1,35,1,35,1,35,1,36, + 1,36,1,36,1,36,1,36,1,36,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,38, + 1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,39,1,39,1,39,1,39, + 1,39,1,39,1,40,1,40,1,40,1,40,1,41,1,41,1,41,1,42,1,42,1,42,1,42, + 1,42,1,42,1,42,1,42,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43, + 1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,5,44,629,8,44,10,44, + 12,44,632,9,44,1,44,3,44,635,8,44,1,45,1,45,1,45,1,45,5,45,641,8, + 45,10,45,12,45,644,9,45,1,46,1,46,1,46,5,46,649,8,46,10,46,12,46, + 652,9,46,1,46,1,46,1,47,1,47,1,47,3,47,659,8,47,1,48,1,48,1,48,1, + 48,1,48,1,48,1,49,1,49,1,50,1,50,1,51,1,51,1,51,5,51,674,8,51,10, + 51,12,51,677,9,51,3,51,679,8,51,1,52,3,52,682,8,52,1,52,1,52,1,52, + 4,52,687,8,52,11,52,12,52,688,3,52,691,8,52,1,52,3,52,694,8,52,1, + 53,1,53,3,53,698,8,53,1,53,1,53,1,54,4,54,703,8,54,11,54,12,54,704, + 1,55,4,55,708,8,55,11,55,12,55,709,1,55,1,55,1,56,1,56,0,0,57,1, + 1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27, + 14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,49, + 25,51,26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,35,71, + 36,73,37,75,38,77,39,79,40,81,41,83,42,85,43,87,44,89,45,91,46,93, + 47,95,0,97,0,99,0,101,0,103,48,105,49,107,0,109,50,111,51,113,52, + 1,0,13,2,0,10,10,12,13,1,0,41,41,2,0,46,46,91,91,3,0,65,90,95,95, + 97,122,8,0,34,34,47,47,92,92,98,98,102,102,110,110,114,114,116,116, + 3,0,48,57,65,70,97,102,3,0,0,31,34,34,92,92,1,0,49,57,1,0,48,57, + 2,0,69,69,101,101,2,0,43,43,45,45,5,0,45,45,48,57,65,90,95,95,97, + 122,3,0,9,10,13,13,32,32,728,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0, + 0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0, + 17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0, + 27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0, + 37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0, + 47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0, + 57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0, + 67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0, + 77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,0, + 87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,0,0,0,93,1,0,0,0,0,103,1,0,0,0, + 0,105,1,0,0,0,0,109,1,0,0,0,0,111,1,0,0,0,0,113,1,0,0,0,1,115,1, + 0,0,0,3,124,1,0,0,0,5,141,1,0,0,0,7,152,1,0,0,0,9,177,1,0,0,0,11, + 201,1,0,0,0,13,216,1,0,0,0,15,234,1,0,0,0,17,253,1,0,0,0,19,283, + 1,0,0,0,21,311,1,0,0,0,23,331,1,0,0,0,25,354,1,0,0,0,27,378,1,0, + 0,0,29,417,1,0,0,0,31,441,1,0,0,0,33,467,1,0,0,0,35,495,1,0,0,0, + 37,498,1,0,0,0,39,500,1,0,0,0,41,502,1,0,0,0,43,504,1,0,0,0,45,506, + 1,0,0,0,47,508,1,0,0,0,49,510,1,0,0,0,51,512,1,0,0,0,53,514,1,0, + 0,0,55,516,1,0,0,0,57,521,1,0,0,0,59,527,1,0,0,0,61,532,1,0,0,0, + 63,538,1,0,0,0,65,541,1,0,0,0,67,546,1,0,0,0,69,553,1,0,0,0,71,560, + 1,0,0,0,73,566,1,0,0,0,75,572,1,0,0,0,77,579,1,0,0,0,79,589,1,0, + 0,0,81,595,1,0,0,0,83,599,1,0,0,0,85,602,1,0,0,0,87,610,1,0,0,0, + 89,634,1,0,0,0,91,636,1,0,0,0,93,645,1,0,0,0,95,655,1,0,0,0,97,660, + 1,0,0,0,99,666,1,0,0,0,101,668,1,0,0,0,103,678,1,0,0,0,105,681,1, + 0,0,0,107,695,1,0,0,0,109,702,1,0,0,0,111,707,1,0,0,0,113,713,1, + 0,0,0,115,119,5,35,0,0,116,118,8,0,0,0,117,116,1,0,0,0,118,121,1, + 0,0,0,119,117,1,0,0,0,119,120,1,0,0,0,120,122,1,0,0,0,121,119,1, + 0,0,0,122,123,6,0,0,0,123,2,1,0,0,0,124,125,5,106,0,0,125,126,5, + 115,0,0,126,127,5,111,0,0,127,128,5,110,0,0,128,129,5,97,0,0,129, + 130,5,116,0,0,130,131,5,97,0,0,131,132,5,40,0,0,132,136,1,0,0,0, + 133,135,8,1,0,0,134,133,1,0,0,0,135,138,1,0,0,0,136,134,1,0,0,0, + 136,137,1,0,0,0,137,139,1,0,0,0,138,136,1,0,0,0,139,140,5,41,0,0, + 140,4,1,0,0,0,141,142,5,83,0,0,142,143,5,116,0,0,143,144,5,97,0, + 0,144,145,5,116,0,0,145,146,5,101,0,0,146,147,5,115,0,0,147,148, + 5,46,0,0,148,149,5,65,0,0,149,150,5,76,0,0,150,151,5,76,0,0,151, + 6,1,0,0,0,152,153,5,83,0,0,153,154,5,116,0,0,154,155,5,97,0,0,155, + 156,5,116,0,0,156,157,5,101,0,0,157,158,5,115,0,0,158,159,5,46,0, + 0,159,160,5,68,0,0,160,161,5,97,0,0,161,162,5,116,0,0,162,163,5, + 97,0,0,163,164,5,76,0,0,164,165,5,105,0,0,165,166,5,109,0,0,166, + 167,5,105,0,0,167,168,5,116,0,0,168,169,5,69,0,0,169,170,5,120,0, + 0,170,171,5,99,0,0,171,172,5,101,0,0,172,173,5,101,0,0,173,174,5, + 100,0,0,174,175,5,101,0,0,175,176,5,100,0,0,176,8,1,0,0,0,177,178, + 5,83,0,0,178,179,5,116,0,0,179,180,5,97,0,0,180,181,5,116,0,0,181, + 182,5,101,0,0,182,183,5,115,0,0,183,184,5,46,0,0,184,185,5,72,0, + 0,185,186,5,101,0,0,186,187,5,97,0,0,187,188,5,114,0,0,188,189,5, + 116,0,0,189,190,5,98,0,0,190,191,5,101,0,0,191,192,5,97,0,0,192, + 193,5,116,0,0,193,194,5,84,0,0,194,195,5,105,0,0,195,196,5,109,0, + 0,196,197,5,101,0,0,197,198,5,111,0,0,198,199,5,117,0,0,199,200, + 5,116,0,0,200,10,1,0,0,0,201,202,5,83,0,0,202,203,5,116,0,0,203, + 204,5,97,0,0,204,205,5,116,0,0,205,206,5,101,0,0,206,207,5,115,0, + 0,207,208,5,46,0,0,208,209,5,84,0,0,209,210,5,105,0,0,210,211,5, + 109,0,0,211,212,5,101,0,0,212,213,5,111,0,0,213,214,5,117,0,0,214, + 215,5,116,0,0,215,12,1,0,0,0,216,217,5,83,0,0,217,218,5,116,0,0, + 218,219,5,97,0,0,219,220,5,116,0,0,220,221,5,101,0,0,221,222,5,115, + 0,0,222,223,5,46,0,0,223,224,5,84,0,0,224,225,5,97,0,0,225,226,5, + 115,0,0,226,227,5,107,0,0,227,228,5,70,0,0,228,229,5,97,0,0,229, + 230,5,105,0,0,230,231,5,108,0,0,231,232,5,101,0,0,232,233,5,100, + 0,0,233,14,1,0,0,0,234,235,5,83,0,0,235,236,5,116,0,0,236,237,5, + 97,0,0,237,238,5,116,0,0,238,239,5,101,0,0,239,240,5,115,0,0,240, + 241,5,46,0,0,241,242,5,80,0,0,242,243,5,101,0,0,243,244,5,114,0, + 0,244,245,5,109,0,0,245,246,5,105,0,0,246,247,5,115,0,0,247,248, + 5,115,0,0,248,249,5,105,0,0,249,250,5,111,0,0,250,251,5,110,0,0, + 251,252,5,115,0,0,252,16,1,0,0,0,253,254,5,83,0,0,254,255,5,116, + 0,0,255,256,5,97,0,0,256,257,5,116,0,0,257,258,5,101,0,0,258,259, + 5,115,0,0,259,260,5,46,0,0,260,261,5,82,0,0,261,262,5,101,0,0,262, + 263,5,115,0,0,263,264,5,117,0,0,264,265,5,108,0,0,265,266,5,116, + 0,0,266,267,5,80,0,0,267,268,5,97,0,0,268,269,5,116,0,0,269,270, + 5,104,0,0,270,271,5,77,0,0,271,272,5,97,0,0,272,273,5,116,0,0,273, + 274,5,99,0,0,274,275,5,104,0,0,275,276,5,70,0,0,276,277,5,97,0,0, + 277,278,5,105,0,0,278,279,5,108,0,0,279,280,5,117,0,0,280,281,5, + 114,0,0,281,282,5,101,0,0,282,18,1,0,0,0,283,284,5,83,0,0,284,285, + 5,116,0,0,285,286,5,97,0,0,286,287,5,116,0,0,287,288,5,101,0,0,288, + 289,5,115,0,0,289,290,5,46,0,0,290,291,5,80,0,0,291,292,5,97,0,0, + 292,293,5,114,0,0,293,294,5,97,0,0,294,295,5,109,0,0,295,296,5,101, + 0,0,296,297,5,116,0,0,297,298,5,101,0,0,298,299,5,114,0,0,299,300, + 5,80,0,0,300,301,5,97,0,0,301,302,5,116,0,0,302,303,5,104,0,0,303, + 304,5,70,0,0,304,305,5,97,0,0,305,306,5,105,0,0,306,307,5,108,0, + 0,307,308,5,117,0,0,308,309,5,114,0,0,309,310,5,101,0,0,310,20,1, + 0,0,0,311,312,5,83,0,0,312,313,5,116,0,0,313,314,5,97,0,0,314,315, + 5,116,0,0,315,316,5,101,0,0,316,317,5,115,0,0,317,318,5,46,0,0,318, + 319,5,66,0,0,319,320,5,114,0,0,320,321,5,97,0,0,321,322,5,110,0, + 0,322,323,5,99,0,0,323,324,5,104,0,0,324,325,5,70,0,0,325,326,5, + 97,0,0,326,327,5,105,0,0,327,328,5,108,0,0,328,329,5,101,0,0,329, + 330,5,100,0,0,330,22,1,0,0,0,331,332,5,83,0,0,332,333,5,116,0,0, + 333,334,5,97,0,0,334,335,5,116,0,0,335,336,5,101,0,0,336,337,5,115, + 0,0,337,338,5,46,0,0,338,339,5,78,0,0,339,340,5,111,0,0,340,341, + 5,67,0,0,341,342,5,104,0,0,342,343,5,111,0,0,343,344,5,105,0,0,344, + 345,5,99,0,0,345,346,5,101,0,0,346,347,5,77,0,0,347,348,5,97,0,0, + 348,349,5,116,0,0,349,350,5,99,0,0,350,351,5,104,0,0,351,352,5,101, + 0,0,352,353,5,100,0,0,353,24,1,0,0,0,354,355,5,83,0,0,355,356,5, + 116,0,0,356,357,5,97,0,0,357,358,5,116,0,0,358,359,5,101,0,0,359, + 360,5,115,0,0,360,361,5,46,0,0,361,362,5,73,0,0,362,363,5,110,0, + 0,363,364,5,116,0,0,364,365,5,114,0,0,365,366,5,105,0,0,366,367, + 5,110,0,0,367,368,5,115,0,0,368,369,5,105,0,0,369,370,5,99,0,0,370, + 371,5,70,0,0,371,372,5,97,0,0,372,373,5,105,0,0,373,374,5,108,0, + 0,374,375,5,117,0,0,375,376,5,114,0,0,376,377,5,101,0,0,377,26,1, + 0,0,0,378,379,5,83,0,0,379,380,5,116,0,0,380,381,5,97,0,0,381,382, + 5,116,0,0,382,383,5,101,0,0,383,384,5,115,0,0,384,385,5,46,0,0,385, + 386,5,69,0,0,386,387,5,120,0,0,387,388,5,99,0,0,388,389,5,101,0, + 0,389,390,5,101,0,0,390,391,5,100,0,0,391,392,5,84,0,0,392,393,5, + 111,0,0,393,394,5,108,0,0,394,395,5,101,0,0,395,396,5,114,0,0,396, + 397,5,97,0,0,397,398,5,116,0,0,398,399,5,101,0,0,399,400,5,100,0, + 0,400,401,5,70,0,0,401,402,5,97,0,0,402,403,5,105,0,0,403,404,5, + 108,0,0,404,405,5,117,0,0,405,406,5,114,0,0,406,407,5,101,0,0,407, + 408,5,84,0,0,408,409,5,104,0,0,409,410,5,114,0,0,410,411,5,101,0, + 0,411,412,5,115,0,0,412,413,5,104,0,0,413,414,5,111,0,0,414,415, + 5,108,0,0,415,416,5,100,0,0,416,28,1,0,0,0,417,418,5,83,0,0,418, + 419,5,116,0,0,419,420,5,97,0,0,420,421,5,116,0,0,421,422,5,101,0, + 0,422,423,5,115,0,0,423,424,5,46,0,0,424,425,5,73,0,0,425,426,5, + 116,0,0,426,427,5,101,0,0,427,428,5,109,0,0,428,429,5,82,0,0,429, + 430,5,101,0,0,430,431,5,97,0,0,431,432,5,100,0,0,432,433,5,101,0, + 0,433,434,5,114,0,0,434,435,5,70,0,0,435,436,5,97,0,0,436,437,5, + 105,0,0,437,438,5,108,0,0,438,439,5,101,0,0,439,440,5,100,0,0,440, + 30,1,0,0,0,441,442,5,83,0,0,442,443,5,116,0,0,443,444,5,97,0,0,444, + 445,5,116,0,0,445,446,5,101,0,0,446,447,5,115,0,0,447,448,5,46,0, + 0,448,449,5,82,0,0,449,450,5,101,0,0,450,451,5,115,0,0,451,452,5, + 117,0,0,452,453,5,108,0,0,453,454,5,116,0,0,454,455,5,87,0,0,455, + 456,5,114,0,0,456,457,5,105,0,0,457,458,5,116,0,0,458,459,5,101, + 0,0,459,460,5,114,0,0,460,461,5,70,0,0,461,462,5,97,0,0,462,463, + 5,105,0,0,463,464,5,108,0,0,464,465,5,101,0,0,465,466,5,100,0,0, + 466,32,1,0,0,0,467,468,5,83,0,0,468,469,5,116,0,0,469,470,5,97,0, + 0,470,471,5,116,0,0,471,472,5,101,0,0,472,473,5,115,0,0,473,474, + 5,46,0,0,474,475,5,81,0,0,475,476,5,117,0,0,476,477,5,101,0,0,477, + 478,5,114,0,0,478,479,5,121,0,0,479,480,5,69,0,0,480,481,5,118,0, + 0,481,482,5,97,0,0,482,483,5,108,0,0,483,484,5,117,0,0,484,485,5, + 97,0,0,485,486,5,116,0,0,486,487,5,105,0,0,487,488,5,111,0,0,488, + 489,5,110,0,0,489,490,5,69,0,0,490,491,5,114,0,0,491,492,5,114,0, + 0,492,493,5,111,0,0,493,494,5,114,0,0,494,34,1,0,0,0,495,496,5,45, + 0,0,496,497,5,62,0,0,497,36,1,0,0,0,498,499,5,61,0,0,499,38,1,0, + 0,0,500,501,5,44,0,0,501,40,1,0,0,0,502,503,5,58,0,0,503,42,1,0, + 0,0,504,505,5,40,0,0,505,44,1,0,0,0,506,507,5,41,0,0,507,46,1,0, + 0,0,508,509,5,91,0,0,509,48,1,0,0,0,510,511,5,93,0,0,511,50,1,0, + 0,0,512,513,5,123,0,0,513,52,1,0,0,0,514,515,5,125,0,0,515,54,1, + 0,0,0,516,517,5,116,0,0,517,518,5,114,0,0,518,519,5,117,0,0,519, + 520,5,101,0,0,520,56,1,0,0,0,521,522,5,102,0,0,522,523,5,97,0,0, + 523,524,5,108,0,0,524,525,5,115,0,0,525,526,5,101,0,0,526,58,1,0, + 0,0,527,528,5,110,0,0,528,529,5,117,0,0,529,530,5,108,0,0,530,531, + 5,108,0,0,531,60,1,0,0,0,532,533,5,119,0,0,533,534,5,104,0,0,534, + 535,5,101,0,0,535,536,5,114,0,0,536,537,5,101,0,0,537,62,1,0,0,0, + 538,539,5,97,0,0,539,540,5,115,0,0,540,64,1,0,0,0,541,542,5,102, + 0,0,542,543,5,97,0,0,543,544,5,105,0,0,544,545,5,108,0,0,545,66, + 1,0,0,0,546,547,5,111,0,0,547,548,5,117,0,0,548,549,5,116,0,0,549, + 550,5,112,0,0,550,551,5,117,0,0,551,552,5,116,0,0,552,68,1,0,0,0, + 553,554,5,114,0,0,554,555,5,101,0,0,555,556,5,116,0,0,556,557,5, + 117,0,0,557,558,5,114,0,0,558,559,5,110,0,0,559,70,1,0,0,0,560,561, + 5,101,0,0,561,562,5,114,0,0,562,563,5,114,0,0,563,564,5,111,0,0, + 564,565,5,114,0,0,565,72,1,0,0,0,566,567,5,99,0,0,567,568,5,97,0, + 0,568,569,5,117,0,0,569,570,5,115,0,0,570,571,5,101,0,0,571,74,1, + 0,0,0,572,573,5,108,0,0,573,574,5,97,0,0,574,575,5,109,0,0,575,576, + 5,98,0,0,576,577,5,100,0,0,577,578,5,97,0,0,578,76,1,0,0,0,579,580, + 5,97,0,0,580,581,5,114,0,0,581,582,5,103,0,0,582,583,5,117,0,0,583, + 584,5,109,0,0,584,585,5,101,0,0,585,586,5,110,0,0,586,587,5,116, + 0,0,587,588,5,115,0,0,588,78,1,0,0,0,589,590,5,99,0,0,590,591,5, + 97,0,0,591,592,5,116,0,0,592,593,5,99,0,0,593,594,5,104,0,0,594, + 80,1,0,0,0,595,596,5,102,0,0,596,597,5,111,0,0,597,598,5,114,0,0, + 598,82,1,0,0,0,599,600,5,105,0,0,600,601,5,110,0,0,601,84,1,0,0, + 0,602,603,5,112,0,0,603,604,5,114,0,0,604,605,5,111,0,0,605,606, + 5,99,0,0,606,607,5,101,0,0,607,608,5,115,0,0,608,609,5,115,0,0,609, + 86,1,0,0,0,610,611,5,112,0,0,611,612,5,97,0,0,612,613,5,114,0,0, + 613,614,5,97,0,0,614,615,5,108,0,0,615,616,5,108,0,0,616,617,5,101, + 0,0,617,618,5,108,0,0,618,88,1,0,0,0,619,620,5,34,0,0,620,621,5, + 36,0,0,621,635,5,34,0,0,622,623,5,34,0,0,623,624,5,36,0,0,624,625, + 1,0,0,0,625,630,7,2,0,0,626,629,3,95,47,0,627,629,3,101,50,0,628, + 626,1,0,0,0,628,627,1,0,0,0,629,632,1,0,0,0,630,628,1,0,0,0,630, + 631,1,0,0,0,631,633,1,0,0,0,632,630,1,0,0,0,633,635,5,34,0,0,634, + 619,1,0,0,0,634,622,1,0,0,0,635,90,1,0,0,0,636,637,5,36,0,0,637, + 642,7,3,0,0,638,641,3,95,47,0,639,641,3,101,50,0,640,638,1,0,0,0, + 640,639,1,0,0,0,641,644,1,0,0,0,642,640,1,0,0,0,642,643,1,0,0,0, + 643,92,1,0,0,0,644,642,1,0,0,0,645,650,5,34,0,0,646,649,3,95,47, + 0,647,649,3,101,50,0,648,646,1,0,0,0,648,647,1,0,0,0,649,652,1,0, + 0,0,650,648,1,0,0,0,650,651,1,0,0,0,651,653,1,0,0,0,652,650,1,0, + 0,0,653,654,5,34,0,0,654,94,1,0,0,0,655,658,5,92,0,0,656,659,7,4, + 0,0,657,659,3,97,48,0,658,656,1,0,0,0,658,657,1,0,0,0,659,96,1,0, + 0,0,660,661,5,117,0,0,661,662,3,99,49,0,662,663,3,99,49,0,663,664, + 3,99,49,0,664,665,3,99,49,0,665,98,1,0,0,0,666,667,7,5,0,0,667,100, + 1,0,0,0,668,669,8,6,0,0,669,102,1,0,0,0,670,679,5,48,0,0,671,675, + 7,7,0,0,672,674,7,8,0,0,673,672,1,0,0,0,674,677,1,0,0,0,675,673, + 1,0,0,0,675,676,1,0,0,0,676,679,1,0,0,0,677,675,1,0,0,0,678,670, + 1,0,0,0,678,671,1,0,0,0,679,104,1,0,0,0,680,682,5,45,0,0,681,680, + 1,0,0,0,681,682,1,0,0,0,682,683,1,0,0,0,683,690,3,103,51,0,684,686, + 5,46,0,0,685,687,7,8,0,0,686,685,1,0,0,0,687,688,1,0,0,0,688,686, + 1,0,0,0,688,689,1,0,0,0,689,691,1,0,0,0,690,684,1,0,0,0,690,691, + 1,0,0,0,691,693,1,0,0,0,692,694,3,107,53,0,693,692,1,0,0,0,693,694, + 1,0,0,0,694,106,1,0,0,0,695,697,7,9,0,0,696,698,7,10,0,0,697,696, + 1,0,0,0,697,698,1,0,0,0,698,699,1,0,0,0,699,700,3,103,51,0,700,108, + 1,0,0,0,701,703,7,11,0,0,702,701,1,0,0,0,703,704,1,0,0,0,704,702, + 1,0,0,0,704,705,1,0,0,0,705,110,1,0,0,0,706,708,7,12,0,0,707,706, + 1,0,0,0,708,709,1,0,0,0,709,707,1,0,0,0,709,710,1,0,0,0,710,711, + 1,0,0,0,711,712,6,55,0,0,712,112,1,0,0,0,713,714,9,0,0,0,714,114, + 1,0,0,0,20,0,119,136,628,630,634,640,642,648,650,658,675,678,681, + 688,690,693,697,704,709,1,6,0,0 + ] + +class LSLLexer(Lexer): + + atn = ATNDeserializer().deserialize(serializedATN()) + + decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ] + + LINECOMMENT = 1 + JSONATA = 2 + ERRORNAMEStatesALL = 3 + ERRORNAMEStatesDataLimitExceeded = 4 + ERRORNAMEStatesHeartbeatTimeout = 5 + ERRORNAMEStatesTimeout = 6 + ERRORNAMEStatesTaskFailed = 7 + ERRORNAMEStatesPermissions = 8 + ERRORNAMEStatesResultPathMatchFailure = 9 + ERRORNAMEStatesParameterPathFailure = 10 + ERRORNAMEStatesBranchFailed = 11 + ERRORNAMEStatesNoChoiceMatched = 12 + ERRORNAMEStatesIntrinsicFailure = 13 + ERRORNAMEStatesExceedToleratedFailureThreshold = 14 + ERRORNAMEStatesItemReaderFailed = 15 + ERRORNAMEStatesResultWriterFailed = 16 + ERRORNAMEStatesQueryEvaluationError = 17 + ARROW = 18 + EQUALS = 19 + COMMA = 20 + COLON = 21 + LPAREN = 22 + RPAREN = 23 + LBRACK = 24 + RBRACK = 25 + LBRACE = 26 + RBRACE = 27 + TRUE = 28 + FALSE = 29 + NULL = 30 + WHERE = 31 + AS = 32 + FAIL = 33 + OUTPUT = 34 + RETURN = 35 + ERROR = 36 + CAUSE = 37 + LAMBDA = 38 + ARGUMENTS = 39 + CATCH = 40 + FOR = 41 + IN = 42 + PROCESS = 43 + PARALLEL = 44 + STRINGPATH = 45 + VAR = 46 + STRING = 47 + INT = 48 + NUMBER = 49 + IDEN = 50 + WS = 51 + TOK = 52 + + channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ] + + modeNames = [ "DEFAULT_MODE" ] + + literalNames = [ "", + "'States.ALL'", "'States.DataLimitExceeded'", "'States.HeartbeatTimeout'", + "'States.Timeout'", "'States.TaskFailed'", "'States.Permissions'", + "'States.ResultPathMatchFailure'", "'States.ParameterPathFailure'", + "'States.BranchFailed'", "'States.NoChoiceMatched'", "'States.IntrinsicFailure'", + "'States.ExceedToleratedFailureThreshold'", "'States.ItemReaderFailed'", + "'States.ResultWriterFailed'", "'States.QueryEvaluationError'", + "'->'", "'='", "','", "':'", "'('", "')'", "'['", "']'", "'{'", + "'}'", "'true'", "'false'", "'null'", "'where'", "'as'", "'fail'", + "'output'", "'return'", "'error'", "'cause'", "'lambda'", "'arguments'", + "'catch'", "'for'", "'in'", "'process'", "'parallel'" ] + + symbolicNames = [ "", + "LINECOMMENT", "JSONATA", "ERRORNAMEStatesALL", "ERRORNAMEStatesDataLimitExceeded", + "ERRORNAMEStatesHeartbeatTimeout", "ERRORNAMEStatesTimeout", + "ERRORNAMEStatesTaskFailed", "ERRORNAMEStatesPermissions", "ERRORNAMEStatesResultPathMatchFailure", + "ERRORNAMEStatesParameterPathFailure", "ERRORNAMEStatesBranchFailed", + "ERRORNAMEStatesNoChoiceMatched", "ERRORNAMEStatesIntrinsicFailure", + "ERRORNAMEStatesExceedToleratedFailureThreshold", "ERRORNAMEStatesItemReaderFailed", + "ERRORNAMEStatesResultWriterFailed", "ERRORNAMEStatesQueryEvaluationError", + "ARROW", "EQUALS", "COMMA", "COLON", "LPAREN", "RPAREN", "LBRACK", + "RBRACK", "LBRACE", "RBRACE", "TRUE", "FALSE", "NULL", "WHERE", + "AS", "FAIL", "OUTPUT", "RETURN", "ERROR", "CAUSE", "LAMBDA", + "ARGUMENTS", "CATCH", "FOR", "IN", "PROCESS", "PARALLEL", "STRINGPATH", + "VAR", "STRING", "INT", "NUMBER", "IDEN", "WS", "TOK" ] + + ruleNames = [ "LINECOMMENT", "JSONATA", "ERRORNAMEStatesALL", "ERRORNAMEStatesDataLimitExceeded", + "ERRORNAMEStatesHeartbeatTimeout", "ERRORNAMEStatesTimeout", + "ERRORNAMEStatesTaskFailed", "ERRORNAMEStatesPermissions", + "ERRORNAMEStatesResultPathMatchFailure", "ERRORNAMEStatesParameterPathFailure", + "ERRORNAMEStatesBranchFailed", "ERRORNAMEStatesNoChoiceMatched", + "ERRORNAMEStatesIntrinsicFailure", "ERRORNAMEStatesExceedToleratedFailureThreshold", + "ERRORNAMEStatesItemReaderFailed", "ERRORNAMEStatesResultWriterFailed", + "ERRORNAMEStatesQueryEvaluationError", "ARROW", "EQUALS", + "COMMA", "COLON", "LPAREN", "RPAREN", "LBRACK", "RBRACK", + "LBRACE", "RBRACE", "TRUE", "FALSE", "NULL", "WHERE", + "AS", "FAIL", "OUTPUT", "RETURN", "ERROR", "CAUSE", "LAMBDA", + "ARGUMENTS", "CATCH", "FOR", "IN", "PROCESS", "PARALLEL", + "STRINGPATH", "VAR", "STRING", "ESC", "UNICODE", "HEX", + "SAFECODEPOINT", "INT", "NUMBER", "EXP", "IDEN", "WS", + "TOK" ] + + grammarFileName = "LSLLexer.g4" + + def __init__(self, input=None, output:TextIO = sys.stdout): + super().__init__(input, output) + self.checkVersion("4.13.2") + self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache()) + self._actions = None + self._predicates = None + + diff --git a/localstack-core/localstack/services/stepfunctions/asl/antlr/runtime/LSLParser.py b/localstack-core/localstack/services/stepfunctions/asl/antlr/runtime/LSLParser.py new file mode 100644 index 0000000000000..47fb97ccb3e3a --- /dev/null +++ b/localstack-core/localstack/services/stepfunctions/asl/antlr/runtime/LSLParser.py @@ -0,0 +1,2475 @@ +# Generated from LSLParser.g4 by ANTLR 4.13.2 +# encoding: utf-8 +from antlr4 import * +from io import StringIO +import sys +if sys.version_info[1] > 5: + from typing import TextIO +else: + from typing.io import TextIO + +def serializedATN(): + return [ + 4,1,52,234,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7, + 6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13, + 2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20, + 7,20,2,21,7,21,2,22,7,22,2,23,7,23,1,0,1,0,1,0,4,0,52,8,0,11,0,12, + 0,53,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,2,3,2,69, + 8,2,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, + 1,3,1,3,1,3,1,3,4,3,90,8,3,11,3,12,3,91,3,3,94,8,3,1,4,1,4,1,5,1, + 5,3,5,100,8,5,1,5,3,5,103,8,5,1,6,1,6,1,6,3,6,108,8,6,1,7,1,7,1, + 7,1,8,1,8,1,8,1,8,5,8,117,8,8,10,8,12,8,120,9,8,1,8,1,8,1,9,1,9, + 1,9,1,9,1,10,1,10,3,10,130,8,10,1,10,1,10,5,10,134,8,10,10,10,12, + 10,137,9,10,1,10,1,10,1,11,1,11,1,11,1,11,5,11,145,8,11,10,11,12, + 11,148,9,11,1,11,1,11,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,14,1, + 14,1,14,1,15,1,15,1,15,1,15,1,15,4,15,167,8,15,11,15,12,15,168,1, + 15,1,15,1,16,1,16,1,16,1,16,1,16,1,16,3,16,179,8,16,1,17,1,17,1, + 17,3,17,184,8,17,1,18,1,18,1,18,1,18,5,18,190,8,18,10,18,12,18,193, + 9,18,1,18,1,18,1,18,1,18,3,18,199,8,18,1,19,1,19,1,19,1,19,1,20, + 1,20,1,20,1,20,5,20,209,8,20,10,20,12,20,212,9,20,1,20,1,20,1,20, + 1,20,3,20,218,8,20,1,21,1,21,1,21,1,21,1,21,1,21,3,21,226,8,21,1, + 22,1,22,3,22,230,8,22,1,23,1,23,1,23,0,0,24,0,2,4,6,8,10,12,14,16, + 18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,0,3,2,0,47,47,50,50, + 1,0,28,29,2,0,3,17,47,47,242,0,51,1,0,0,0,2,57,1,0,0,0,4,68,1,0, + 0,0,6,93,1,0,0,0,8,95,1,0,0,0,10,97,1,0,0,0,12,104,1,0,0,0,14,109, + 1,0,0,0,16,112,1,0,0,0,18,123,1,0,0,0,20,127,1,0,0,0,22,140,1,0, + 0,0,24,151,1,0,0,0,26,155,1,0,0,0,28,158,1,0,0,0,30,161,1,0,0,0, + 32,178,1,0,0,0,34,183,1,0,0,0,36,198,1,0,0,0,38,200,1,0,0,0,40,217, + 1,0,0,0,42,225,1,0,0,0,44,229,1,0,0,0,46,231,1,0,0,0,48,52,3,2,1, + 0,49,52,3,32,16,0,50,52,3,4,2,0,51,48,1,0,0,0,51,49,1,0,0,0,51,50, + 1,0,0,0,52,53,1,0,0,0,53,51,1,0,0,0,53,54,1,0,0,0,54,55,1,0,0,0, + 55,56,5,0,0,1,56,1,1,0,0,0,57,58,5,50,0,0,58,59,3,20,10,0,59,60, + 5,19,0,0,60,61,3,6,3,0,61,3,1,0,0,0,62,63,5,50,0,0,63,69,3,22,11, + 0,64,65,5,50,0,0,65,66,5,32,0,0,66,69,3,6,3,0,67,69,3,6,3,0,68,62, + 1,0,0,0,68,64,1,0,0,0,68,67,1,0,0,0,69,5,1,0,0,0,70,71,3,8,4,0,71, + 72,5,21,0,0,72,73,5,50,0,0,73,74,3,10,5,0,74,94,1,0,0,0,75,76,5, + 33,0,0,76,94,3,12,6,0,77,78,5,35,0,0,78,94,3,34,17,0,79,80,5,41, + 0,0,80,81,5,50,0,0,81,82,5,42,0,0,82,83,3,34,17,0,83,84,5,31,0,0, + 84,85,3,30,15,0,85,94,1,0,0,0,86,87,5,44,0,0,87,89,5,31,0,0,88,90, + 3,30,15,0,89,88,1,0,0,0,90,91,1,0,0,0,91,89,1,0,0,0,91,92,1,0,0, + 0,92,94,1,0,0,0,93,70,1,0,0,0,93,75,1,0,0,0,93,77,1,0,0,0,93,79, + 1,0,0,0,93,86,1,0,0,0,94,7,1,0,0,0,95,96,5,38,0,0,96,9,1,0,0,0,97, + 99,5,31,0,0,98,100,3,14,7,0,99,98,1,0,0,0,99,100,1,0,0,0,100,102, + 1,0,0,0,101,103,3,16,8,0,102,101,1,0,0,0,102,103,1,0,0,0,103,11, + 1,0,0,0,104,105,5,31,0,0,105,107,3,26,13,0,106,108,3,28,14,0,107, + 106,1,0,0,0,107,108,1,0,0,0,108,13,1,0,0,0,109,110,5,39,0,0,110, + 111,3,34,17,0,111,15,1,0,0,0,112,113,5,40,0,0,113,114,5,26,0,0,114, + 118,3,18,9,0,115,117,3,18,9,0,116,115,1,0,0,0,117,120,1,0,0,0,118, + 116,1,0,0,0,118,119,1,0,0,0,119,121,1,0,0,0,120,118,1,0,0,0,121, + 122,5,27,0,0,122,17,1,0,0,0,123,124,3,46,23,0,124,125,5,18,0,0,125, + 126,3,4,2,0,126,19,1,0,0,0,127,129,5,22,0,0,128,130,5,50,0,0,129, + 128,1,0,0,0,129,130,1,0,0,0,130,135,1,0,0,0,131,132,5,20,0,0,132, + 134,5,50,0,0,133,131,1,0,0,0,134,137,1,0,0,0,135,133,1,0,0,0,135, + 136,1,0,0,0,136,138,1,0,0,0,137,135,1,0,0,0,138,139,5,23,0,0,139, + 21,1,0,0,0,140,141,5,22,0,0,141,146,3,24,12,0,142,143,5,20,0,0,143, + 145,3,24,12,0,144,142,1,0,0,0,145,148,1,0,0,0,146,144,1,0,0,0,146, + 147,1,0,0,0,147,149,1,0,0,0,148,146,1,0,0,0,149,150,5,23,0,0,150, + 23,1,0,0,0,151,152,5,50,0,0,152,153,5,19,0,0,153,154,3,34,17,0,154, + 25,1,0,0,0,155,156,5,36,0,0,156,157,3,44,22,0,157,27,1,0,0,0,158, + 159,5,37,0,0,159,160,3,44,22,0,160,29,1,0,0,0,161,162,5,43,0,0,162, + 166,5,26,0,0,163,167,3,2,1,0,164,167,3,32,16,0,165,167,3,4,2,0,166, + 163,1,0,0,0,166,164,1,0,0,0,166,165,1,0,0,0,167,168,1,0,0,0,168, + 166,1,0,0,0,168,169,1,0,0,0,169,170,1,0,0,0,170,171,5,27,0,0,171, + 31,1,0,0,0,172,173,5,50,0,0,173,174,5,19,0,0,174,179,3,4,2,0,175, + 176,5,50,0,0,176,177,5,19,0,0,177,179,3,34,17,0,178,172,1,0,0,0, + 178,175,1,0,0,0,179,33,1,0,0,0,180,184,3,36,18,0,181,184,3,40,20, + 0,182,184,3,42,21,0,183,180,1,0,0,0,183,181,1,0,0,0,183,182,1,0, + 0,0,184,35,1,0,0,0,185,186,5,26,0,0,186,191,3,38,19,0,187,188,5, + 20,0,0,188,190,3,38,19,0,189,187,1,0,0,0,190,193,1,0,0,0,191,189, + 1,0,0,0,191,192,1,0,0,0,192,194,1,0,0,0,193,191,1,0,0,0,194,195, + 5,27,0,0,195,199,1,0,0,0,196,197,5,26,0,0,197,199,5,27,0,0,198,185, + 1,0,0,0,198,196,1,0,0,0,199,37,1,0,0,0,200,201,7,0,0,0,201,202,5, + 21,0,0,202,203,3,34,17,0,203,39,1,0,0,0,204,205,5,24,0,0,205,210, + 3,34,17,0,206,207,5,20,0,0,207,209,3,34,17,0,208,206,1,0,0,0,209, + 212,1,0,0,0,210,208,1,0,0,0,210,211,1,0,0,0,211,213,1,0,0,0,212, + 210,1,0,0,0,213,214,5,25,0,0,214,218,1,0,0,0,215,216,5,24,0,0,216, + 218,5,25,0,0,217,204,1,0,0,0,217,215,1,0,0,0,218,41,1,0,0,0,219, + 226,5,49,0,0,220,226,5,48,0,0,221,226,7,1,0,0,222,226,5,30,0,0,223, + 226,5,47,0,0,224,226,5,2,0,0,225,219,1,0,0,0,225,220,1,0,0,0,225, + 221,1,0,0,0,225,222,1,0,0,0,225,223,1,0,0,0,225,224,1,0,0,0,226, + 43,1,0,0,0,227,230,5,47,0,0,228,230,5,2,0,0,229,227,1,0,0,0,229, + 228,1,0,0,0,230,45,1,0,0,0,231,232,7,2,0,0,232,47,1,0,0,0,22,51, + 53,68,91,93,99,102,107,118,129,135,146,166,168,178,183,191,198,210, + 217,225,229 + ] + +class LSLParser ( Parser ): + + grammarFileName = "LSLParser.g4" + + atn = ATNDeserializer().deserialize(serializedATN()) + + decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ] + + sharedContextCache = PredictionContextCache() + + literalNames = [ "", "", "", "'States.ALL'", + "'States.DataLimitExceeded'", "'States.HeartbeatTimeout'", + "'States.Timeout'", "'States.TaskFailed'", "'States.Permissions'", + "'States.ResultPathMatchFailure'", "'States.ParameterPathFailure'", + "'States.BranchFailed'", "'States.NoChoiceMatched'", + "'States.IntrinsicFailure'", "'States.ExceedToleratedFailureThreshold'", + "'States.ItemReaderFailed'", "'States.ResultWriterFailed'", + "'States.QueryEvaluationError'", "'->'", "'='", "','", + "':'", "'('", "')'", "'['", "']'", "'{'", "'}'", "'true'", + "'false'", "'null'", "'where'", "'as'", "'fail'", "'output'", + "'return'", "'error'", "'cause'", "'lambda'", "'arguments'", + "'catch'", "'for'", "'in'", "'process'", "'parallel'" ] + + symbolicNames = [ "", "LINECOMMENT", "JSONATA", "ERRORNAMEStatesALL", + "ERRORNAMEStatesDataLimitExceeded", "ERRORNAMEStatesHeartbeatTimeout", + "ERRORNAMEStatesTimeout", "ERRORNAMEStatesTaskFailed", + "ERRORNAMEStatesPermissions", "ERRORNAMEStatesResultPathMatchFailure", + "ERRORNAMEStatesParameterPathFailure", "ERRORNAMEStatesBranchFailed", + "ERRORNAMEStatesNoChoiceMatched", "ERRORNAMEStatesIntrinsicFailure", + "ERRORNAMEStatesExceedToleratedFailureThreshold", + "ERRORNAMEStatesItemReaderFailed", "ERRORNAMEStatesResultWriterFailed", + "ERRORNAMEStatesQueryEvaluationError", "ARROW", "EQUALS", + "COMMA", "COLON", "LPAREN", "RPAREN", "LBRACK", "RBRACK", + "LBRACE", "RBRACE", "TRUE", "FALSE", "NULL", "WHERE", + "AS", "FAIL", "OUTPUT", "RETURN", "ERROR", "CAUSE", + "LAMBDA", "ARGUMENTS", "CATCH", "FOR", "IN", "PROCESS", + "PARALLEL", "STRINGPATH", "VAR", "STRING", "INT", + "NUMBER", "IDEN", "WS", "TOK" ] + + RULE_state_machine = 0 + RULE_state_declaration = 1 + RULE_state_call = 2 + RULE_state = 3 + RULE_service_name = 4 + RULE_task_where = 5 + RULE_fail_where = 6 + RULE_arguments = 7 + RULE_catch_block = 8 + RULE_catch_case = 9 + RULE_parameter_list = 10 + RULE_args_assign_list = 11 + RULE_args_assign = 12 + RULE_error = 13 + RULE_cause = 14 + RULE_process = 15 + RULE_var_assign = 16 + RULE_json_value = 17 + RULE_json_object = 18 + RULE_json_binding = 19 + RULE_json_arr = 20 + RULE_json_value_lit = 21 + RULE_string_or_jsonata = 22 + RULE_error_name = 23 + + ruleNames = [ "state_machine", "state_declaration", "state_call", "state", + "service_name", "task_where", "fail_where", "arguments", + "catch_block", "catch_case", "parameter_list", "args_assign_list", + "args_assign", "error", "cause", "process", "var_assign", + "json_value", "json_object", "json_binding", "json_arr", + "json_value_lit", "string_or_jsonata", "error_name" ] + + EOF = Token.EOF + LINECOMMENT=1 + JSONATA=2 + ERRORNAMEStatesALL=3 + ERRORNAMEStatesDataLimitExceeded=4 + ERRORNAMEStatesHeartbeatTimeout=5 + ERRORNAMEStatesTimeout=6 + ERRORNAMEStatesTaskFailed=7 + ERRORNAMEStatesPermissions=8 + ERRORNAMEStatesResultPathMatchFailure=9 + ERRORNAMEStatesParameterPathFailure=10 + ERRORNAMEStatesBranchFailed=11 + ERRORNAMEStatesNoChoiceMatched=12 + ERRORNAMEStatesIntrinsicFailure=13 + ERRORNAMEStatesExceedToleratedFailureThreshold=14 + ERRORNAMEStatesItemReaderFailed=15 + ERRORNAMEStatesResultWriterFailed=16 + ERRORNAMEStatesQueryEvaluationError=17 + ARROW=18 + EQUALS=19 + COMMA=20 + COLON=21 + LPAREN=22 + RPAREN=23 + LBRACK=24 + RBRACK=25 + LBRACE=26 + RBRACE=27 + TRUE=28 + FALSE=29 + NULL=30 + WHERE=31 + AS=32 + FAIL=33 + OUTPUT=34 + RETURN=35 + ERROR=36 + CAUSE=37 + LAMBDA=38 + ARGUMENTS=39 + CATCH=40 + FOR=41 + IN=42 + PROCESS=43 + PARALLEL=44 + STRINGPATH=45 + VAR=46 + STRING=47 + INT=48 + NUMBER=49 + IDEN=50 + WS=51 + TOK=52 + + def __init__(self, input:TokenStream, output:TextIO = sys.stdout): + super().__init__(input, output) + self.checkVersion("4.13.2") + self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache) + self._predicates = None + + + + + class State_machineContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def EOF(self): + return self.getToken(LSLParser.EOF, 0) + + def state_declaration(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(LSLParser.State_declarationContext) + else: + return self.getTypedRuleContext(LSLParser.State_declarationContext,i) + + + def var_assign(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(LSLParser.Var_assignContext) + else: + return self.getTypedRuleContext(LSLParser.Var_assignContext,i) + + + def state_call(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(LSLParser.State_callContext) + else: + return self.getTypedRuleContext(LSLParser.State_callContext,i) + + + def getRuleIndex(self): + return LSLParser.RULE_state_machine + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterState_machine" ): + listener.enterState_machine(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitState_machine" ): + listener.exitState_machine(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitState_machine" ): + return visitor.visitState_machine(self) + else: + return visitor.visitChildren(self) + + + + + def state_machine(self): + + localctx = LSLParser.State_machineContext(self, self._ctx, self.state) + self.enterRule(localctx, 0, self.RULE_state_machine) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 51 + self._errHandler.sync(self) + _la = self._input.LA(1) + while True: + self.state = 51 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,0,self._ctx) + if la_ == 1: + self.state = 48 + self.state_declaration() + pass + + elif la_ == 2: + self.state = 49 + self.var_assign() + pass + + elif la_ == 3: + self.state = 50 + self.state_call() + pass + + + self.state = 53 + self._errHandler.sync(self) + _la = self._input.LA(1) + if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & 1146008943722496) != 0)): + break + + self.state = 55 + self.match(LSLParser.EOF) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class State_declarationContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def IDEN(self): + return self.getToken(LSLParser.IDEN, 0) + + def parameter_list(self): + return self.getTypedRuleContext(LSLParser.Parameter_listContext,0) + + + def EQUALS(self): + return self.getToken(LSLParser.EQUALS, 0) + + def state_(self): + return self.getTypedRuleContext(LSLParser.StateContext,0) + + + def getRuleIndex(self): + return LSLParser.RULE_state_declaration + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterState_declaration" ): + listener.enterState_declaration(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitState_declaration" ): + listener.exitState_declaration(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitState_declaration" ): + return visitor.visitState_declaration(self) + else: + return visitor.visitChildren(self) + + + + + def state_declaration(self): + + localctx = LSLParser.State_declarationContext(self, self._ctx, self.state) + self.enterRule(localctx, 2, self.RULE_state_declaration) + try: + self.enterOuterAlt(localctx, 1) + self.state = 57 + self.match(LSLParser.IDEN) + self.state = 58 + self.parameter_list() + self.state = 59 + self.match(LSLParser.EQUALS) + self.state = 60 + self.state_() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class State_callContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + + def getRuleIndex(self): + return LSLParser.RULE_state_call + + + def copyFrom(self, ctx:ParserRuleContext): + super().copyFrom(ctx) + + + + class State_call_templateContext(State_callContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.State_callContext + super().__init__(parser) + self.copyFrom(ctx) + + def IDEN(self): + return self.getToken(LSLParser.IDEN, 0) + def args_assign_list(self): + return self.getTypedRuleContext(LSLParser.Args_assign_listContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterState_call_template" ): + listener.enterState_call_template(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitState_call_template" ): + listener.exitState_call_template(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitState_call_template" ): + return visitor.visitState_call_template(self) + else: + return visitor.visitChildren(self) + + + class State_call_anonymousContext(State_callContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.State_callContext + super().__init__(parser) + self.copyFrom(ctx) + + def state_(self): + return self.getTypedRuleContext(LSLParser.StateContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterState_call_anonymous" ): + listener.enterState_call_anonymous(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitState_call_anonymous" ): + listener.exitState_call_anonymous(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitState_call_anonymous" ): + return visitor.visitState_call_anonymous(self) + else: + return visitor.visitChildren(self) + + + class State_call_namedContext(State_callContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.State_callContext + super().__init__(parser) + self.copyFrom(ctx) + + def IDEN(self): + return self.getToken(LSLParser.IDEN, 0) + def AS(self): + return self.getToken(LSLParser.AS, 0) + def state_(self): + return self.getTypedRuleContext(LSLParser.StateContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterState_call_named" ): + listener.enterState_call_named(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitState_call_named" ): + listener.exitState_call_named(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitState_call_named" ): + return visitor.visitState_call_named(self) + else: + return visitor.visitChildren(self) + + + + def state_call(self): + + localctx = LSLParser.State_callContext(self, self._ctx, self.state) + self.enterRule(localctx, 4, self.RULE_state_call) + try: + self.state = 68 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,2,self._ctx) + if la_ == 1: + localctx = LSLParser.State_call_templateContext(self, localctx) + self.enterOuterAlt(localctx, 1) + self.state = 62 + self.match(LSLParser.IDEN) + self.state = 63 + self.args_assign_list() + pass + + elif la_ == 2: + localctx = LSLParser.State_call_namedContext(self, localctx) + self.enterOuterAlt(localctx, 2) + self.state = 64 + self.match(LSLParser.IDEN) + self.state = 65 + self.match(LSLParser.AS) + self.state = 66 + self.state_() + pass + + elif la_ == 3: + localctx = LSLParser.State_call_anonymousContext(self, localctx) + self.enterOuterAlt(localctx, 3) + self.state = 67 + self.state_() + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class StateContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + + def getRuleIndex(self): + return LSLParser.RULE_state + + + def copyFrom(self, ctx:ParserRuleContext): + super().copyFrom(ctx) + + + + class State_failContext(StateContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.StateContext + super().__init__(parser) + self.copyFrom(ctx) + + def FAIL(self): + return self.getToken(LSLParser.FAIL, 0) + def fail_where(self): + return self.getTypedRuleContext(LSLParser.Fail_whereContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterState_fail" ): + listener.enterState_fail(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitState_fail" ): + listener.exitState_fail(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitState_fail" ): + return visitor.visitState_fail(self) + else: + return visitor.visitChildren(self) + + + class State_returnContext(StateContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.StateContext + super().__init__(parser) + self.copyFrom(ctx) + + def RETURN(self): + return self.getToken(LSLParser.RETURN, 0) + def json_value(self): + return self.getTypedRuleContext(LSLParser.Json_valueContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterState_return" ): + listener.enterState_return(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitState_return" ): + listener.exitState_return(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitState_return" ): + return visitor.visitState_return(self) + else: + return visitor.visitChildren(self) + + + class State_parallelContext(StateContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.StateContext + super().__init__(parser) + self.copyFrom(ctx) + + def PARALLEL(self): + return self.getToken(LSLParser.PARALLEL, 0) + def WHERE(self): + return self.getToken(LSLParser.WHERE, 0) + def process(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(LSLParser.ProcessContext) + else: + return self.getTypedRuleContext(LSLParser.ProcessContext,i) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterState_parallel" ): + listener.enterState_parallel(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitState_parallel" ): + listener.exitState_parallel(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitState_parallel" ): + return visitor.visitState_parallel(self) + else: + return visitor.visitChildren(self) + + + class State_taskContext(StateContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.StateContext + super().__init__(parser) + self.copyFrom(ctx) + + def service_name(self): + return self.getTypedRuleContext(LSLParser.Service_nameContext,0) + + def COLON(self): + return self.getToken(LSLParser.COLON, 0) + def IDEN(self): + return self.getToken(LSLParser.IDEN, 0) + def task_where(self): + return self.getTypedRuleContext(LSLParser.Task_whereContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterState_task" ): + listener.enterState_task(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitState_task" ): + listener.exitState_task(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitState_task" ): + return visitor.visitState_task(self) + else: + return visitor.visitChildren(self) + + + class State_mapContext(StateContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.StateContext + super().__init__(parser) + self.copyFrom(ctx) + + def FOR(self): + return self.getToken(LSLParser.FOR, 0) + def IDEN(self): + return self.getToken(LSLParser.IDEN, 0) + def IN(self): + return self.getToken(LSLParser.IN, 0) + def json_value(self): + return self.getTypedRuleContext(LSLParser.Json_valueContext,0) + + def WHERE(self): + return self.getToken(LSLParser.WHERE, 0) + def process(self): + return self.getTypedRuleContext(LSLParser.ProcessContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterState_map" ): + listener.enterState_map(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitState_map" ): + listener.exitState_map(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitState_map" ): + return visitor.visitState_map(self) + else: + return visitor.visitChildren(self) + + + + def state_(self): + + localctx = LSLParser.StateContext(self, self._ctx, self.state) + self.enterRule(localctx, 6, self.RULE_state) + self._la = 0 # Token type + try: + self.state = 93 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [38]: + localctx = LSLParser.State_taskContext(self, localctx) + self.enterOuterAlt(localctx, 1) + self.state = 70 + self.service_name() + self.state = 71 + self.match(LSLParser.COLON) + self.state = 72 + self.match(LSLParser.IDEN) + self.state = 73 + self.task_where() + pass + elif token in [33]: + localctx = LSLParser.State_failContext(self, localctx) + self.enterOuterAlt(localctx, 2) + self.state = 75 + self.match(LSLParser.FAIL) + self.state = 76 + self.fail_where() + pass + elif token in [35]: + localctx = LSLParser.State_returnContext(self, localctx) + self.enterOuterAlt(localctx, 3) + self.state = 77 + self.match(LSLParser.RETURN) + self.state = 78 + self.json_value() + pass + elif token in [41]: + localctx = LSLParser.State_mapContext(self, localctx) + self.enterOuterAlt(localctx, 4) + self.state = 79 + self.match(LSLParser.FOR) + self.state = 80 + self.match(LSLParser.IDEN) + self.state = 81 + self.match(LSLParser.IN) + self.state = 82 + self.json_value() + self.state = 83 + self.match(LSLParser.WHERE) + self.state = 84 + self.process() + pass + elif token in [44]: + localctx = LSLParser.State_parallelContext(self, localctx) + self.enterOuterAlt(localctx, 5) + self.state = 86 + self.match(LSLParser.PARALLEL) + self.state = 87 + self.match(LSLParser.WHERE) + self.state = 89 + self._errHandler.sync(self) + _la = self._input.LA(1) + while True: + self.state = 88 + self.process() + self.state = 91 + self._errHandler.sync(self) + _la = self._input.LA(1) + if not (_la==43): + break + + pass + else: + raise NoViableAltException(self) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Service_nameContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def LAMBDA(self): + return self.getToken(LSLParser.LAMBDA, 0) + + def getRuleIndex(self): + return LSLParser.RULE_service_name + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterService_name" ): + listener.enterService_name(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitService_name" ): + listener.exitService_name(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitService_name" ): + return visitor.visitService_name(self) + else: + return visitor.visitChildren(self) + + + + + def service_name(self): + + localctx = LSLParser.Service_nameContext(self, self._ctx, self.state) + self.enterRule(localctx, 8, self.RULE_service_name) + try: + self.enterOuterAlt(localctx, 1) + self.state = 95 + self.match(LSLParser.LAMBDA) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Task_whereContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def WHERE(self): + return self.getToken(LSLParser.WHERE, 0) + + def arguments(self): + return self.getTypedRuleContext(LSLParser.ArgumentsContext,0) + + + def catch_block(self): + return self.getTypedRuleContext(LSLParser.Catch_blockContext,0) + + + def getRuleIndex(self): + return LSLParser.RULE_task_where + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterTask_where" ): + listener.enterTask_where(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitTask_where" ): + listener.exitTask_where(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitTask_where" ): + return visitor.visitTask_where(self) + else: + return visitor.visitChildren(self) + + + + + def task_where(self): + + localctx = LSLParser.Task_whereContext(self, self._ctx, self.state) + self.enterRule(localctx, 10, self.RULE_task_where) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 97 + self.match(LSLParser.WHERE) + self.state = 99 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==39: + self.state = 98 + self.arguments() + + + self.state = 102 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==40: + self.state = 101 + self.catch_block() + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Fail_whereContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def WHERE(self): + return self.getToken(LSLParser.WHERE, 0) + + def error(self): + return self.getTypedRuleContext(LSLParser.ErrorContext,0) + + + def cause(self): + return self.getTypedRuleContext(LSLParser.CauseContext,0) + + + def getRuleIndex(self): + return LSLParser.RULE_fail_where + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterFail_where" ): + listener.enterFail_where(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitFail_where" ): + listener.exitFail_where(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitFail_where" ): + return visitor.visitFail_where(self) + else: + return visitor.visitChildren(self) + + + + + def fail_where(self): + + localctx = LSLParser.Fail_whereContext(self, self._ctx, self.state) + self.enterRule(localctx, 12, self.RULE_fail_where) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 104 + self.match(LSLParser.WHERE) + self.state = 105 + self.error() + self.state = 107 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==37: + self.state = 106 + self.cause() + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class ArgumentsContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def ARGUMENTS(self): + return self.getToken(LSLParser.ARGUMENTS, 0) + + def json_value(self): + return self.getTypedRuleContext(LSLParser.Json_valueContext,0) + + + def getRuleIndex(self): + return LSLParser.RULE_arguments + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterArguments" ): + listener.enterArguments(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitArguments" ): + listener.exitArguments(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitArguments" ): + return visitor.visitArguments(self) + else: + return visitor.visitChildren(self) + + + + + def arguments(self): + + localctx = LSLParser.ArgumentsContext(self, self._ctx, self.state) + self.enterRule(localctx, 14, self.RULE_arguments) + try: + self.enterOuterAlt(localctx, 1) + self.state = 109 + self.match(LSLParser.ARGUMENTS) + self.state = 110 + self.json_value() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Catch_blockContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def CATCH(self): + return self.getToken(LSLParser.CATCH, 0) + + def LBRACE(self): + return self.getToken(LSLParser.LBRACE, 0) + + def catch_case(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(LSLParser.Catch_caseContext) + else: + return self.getTypedRuleContext(LSLParser.Catch_caseContext,i) + + + def RBRACE(self): + return self.getToken(LSLParser.RBRACE, 0) + + def getRuleIndex(self): + return LSLParser.RULE_catch_block + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterCatch_block" ): + listener.enterCatch_block(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitCatch_block" ): + listener.exitCatch_block(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitCatch_block" ): + return visitor.visitCatch_block(self) + else: + return visitor.visitChildren(self) + + + + + def catch_block(self): + + localctx = LSLParser.Catch_blockContext(self, self._ctx, self.state) + self.enterRule(localctx, 16, self.RULE_catch_block) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 112 + self.match(LSLParser.CATCH) + self.state = 113 + self.match(LSLParser.LBRACE) + self.state = 114 + self.catch_case() + self.state = 118 + self._errHandler.sync(self) + _la = self._input.LA(1) + while (((_la) & ~0x3f) == 0 and ((1 << _la) & 140737488617464) != 0): + self.state = 115 + self.catch_case() + self.state = 120 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 121 + self.match(LSLParser.RBRACE) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Catch_caseContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def error_name(self): + return self.getTypedRuleContext(LSLParser.Error_nameContext,0) + + + def ARROW(self): + return self.getToken(LSLParser.ARROW, 0) + + def state_call(self): + return self.getTypedRuleContext(LSLParser.State_callContext,0) + + + def getRuleIndex(self): + return LSLParser.RULE_catch_case + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterCatch_case" ): + listener.enterCatch_case(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitCatch_case" ): + listener.exitCatch_case(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitCatch_case" ): + return visitor.visitCatch_case(self) + else: + return visitor.visitChildren(self) + + + + + def catch_case(self): + + localctx = LSLParser.Catch_caseContext(self, self._ctx, self.state) + self.enterRule(localctx, 18, self.RULE_catch_case) + try: + self.enterOuterAlt(localctx, 1) + self.state = 123 + self.error_name() + self.state = 124 + self.match(LSLParser.ARROW) + self.state = 125 + self.state_call() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Parameter_listContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def LPAREN(self): + return self.getToken(LSLParser.LPAREN, 0) + + def RPAREN(self): + return self.getToken(LSLParser.RPAREN, 0) + + def IDEN(self, i:int=None): + if i is None: + return self.getTokens(LSLParser.IDEN) + else: + return self.getToken(LSLParser.IDEN, i) + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(LSLParser.COMMA) + else: + return self.getToken(LSLParser.COMMA, i) + + def getRuleIndex(self): + return LSLParser.RULE_parameter_list + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterParameter_list" ): + listener.enterParameter_list(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitParameter_list" ): + listener.exitParameter_list(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitParameter_list" ): + return visitor.visitParameter_list(self) + else: + return visitor.visitChildren(self) + + + + + def parameter_list(self): + + localctx = LSLParser.Parameter_listContext(self, self._ctx, self.state) + self.enterRule(localctx, 20, self.RULE_parameter_list) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 127 + self.match(LSLParser.LPAREN) + self.state = 129 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==50: + self.state = 128 + self.match(LSLParser.IDEN) + + + self.state = 135 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==20: + self.state = 131 + self.match(LSLParser.COMMA) + self.state = 132 + self.match(LSLParser.IDEN) + self.state = 137 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 138 + self.match(LSLParser.RPAREN) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Args_assign_listContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def LPAREN(self): + return self.getToken(LSLParser.LPAREN, 0) + + def args_assign(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(LSLParser.Args_assignContext) + else: + return self.getTypedRuleContext(LSLParser.Args_assignContext,i) + + + def RPAREN(self): + return self.getToken(LSLParser.RPAREN, 0) + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(LSLParser.COMMA) + else: + return self.getToken(LSLParser.COMMA, i) + + def getRuleIndex(self): + return LSLParser.RULE_args_assign_list + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterArgs_assign_list" ): + listener.enterArgs_assign_list(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitArgs_assign_list" ): + listener.exitArgs_assign_list(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitArgs_assign_list" ): + return visitor.visitArgs_assign_list(self) + else: + return visitor.visitChildren(self) + + + + + def args_assign_list(self): + + localctx = LSLParser.Args_assign_listContext(self, self._ctx, self.state) + self.enterRule(localctx, 22, self.RULE_args_assign_list) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 140 + self.match(LSLParser.LPAREN) + self.state = 141 + self.args_assign() + self.state = 146 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==20: + self.state = 142 + self.match(LSLParser.COMMA) + self.state = 143 + self.args_assign() + self.state = 148 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 149 + self.match(LSLParser.RPAREN) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Args_assignContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def IDEN(self): + return self.getToken(LSLParser.IDEN, 0) + + def EQUALS(self): + return self.getToken(LSLParser.EQUALS, 0) + + def json_value(self): + return self.getTypedRuleContext(LSLParser.Json_valueContext,0) + + + def getRuleIndex(self): + return LSLParser.RULE_args_assign + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterArgs_assign" ): + listener.enterArgs_assign(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitArgs_assign" ): + listener.exitArgs_assign(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitArgs_assign" ): + return visitor.visitArgs_assign(self) + else: + return visitor.visitChildren(self) + + + + + def args_assign(self): + + localctx = LSLParser.Args_assignContext(self, self._ctx, self.state) + self.enterRule(localctx, 24, self.RULE_args_assign) + try: + self.enterOuterAlt(localctx, 1) + self.state = 151 + self.match(LSLParser.IDEN) + self.state = 152 + self.match(LSLParser.EQUALS) + self.state = 153 + self.json_value() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class ErrorContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def ERROR(self): + return self.getToken(LSLParser.ERROR, 0) + + def string_or_jsonata(self): + return self.getTypedRuleContext(LSLParser.String_or_jsonataContext,0) + + + def getRuleIndex(self): + return LSLParser.RULE_error + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterError" ): + listener.enterError(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitError" ): + listener.exitError(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitError" ): + return visitor.visitError(self) + else: + return visitor.visitChildren(self) + + + + + def error(self): + + localctx = LSLParser.ErrorContext(self, self._ctx, self.state) + self.enterRule(localctx, 26, self.RULE_error) + try: + self.enterOuterAlt(localctx, 1) + self.state = 155 + self.match(LSLParser.ERROR) + self.state = 156 + self.string_or_jsonata() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class CauseContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def CAUSE(self): + return self.getToken(LSLParser.CAUSE, 0) + + def string_or_jsonata(self): + return self.getTypedRuleContext(LSLParser.String_or_jsonataContext,0) + + + def getRuleIndex(self): + return LSLParser.RULE_cause + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterCause" ): + listener.enterCause(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitCause" ): + listener.exitCause(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitCause" ): + return visitor.visitCause(self) + else: + return visitor.visitChildren(self) + + + + + def cause(self): + + localctx = LSLParser.CauseContext(self, self._ctx, self.state) + self.enterRule(localctx, 28, self.RULE_cause) + try: + self.enterOuterAlt(localctx, 1) + self.state = 158 + self.match(LSLParser.CAUSE) + self.state = 159 + self.string_or_jsonata() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class ProcessContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def PROCESS(self): + return self.getToken(LSLParser.PROCESS, 0) + + def LBRACE(self): + return self.getToken(LSLParser.LBRACE, 0) + + def RBRACE(self): + return self.getToken(LSLParser.RBRACE, 0) + + def state_declaration(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(LSLParser.State_declarationContext) + else: + return self.getTypedRuleContext(LSLParser.State_declarationContext,i) + + + def var_assign(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(LSLParser.Var_assignContext) + else: + return self.getTypedRuleContext(LSLParser.Var_assignContext,i) + + + def state_call(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(LSLParser.State_callContext) + else: + return self.getTypedRuleContext(LSLParser.State_callContext,i) + + + def getRuleIndex(self): + return LSLParser.RULE_process + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterProcess" ): + listener.enterProcess(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitProcess" ): + listener.exitProcess(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitProcess" ): + return visitor.visitProcess(self) + else: + return visitor.visitChildren(self) + + + + + def process(self): + + localctx = LSLParser.ProcessContext(self, self._ctx, self.state) + self.enterRule(localctx, 30, self.RULE_process) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 161 + self.match(LSLParser.PROCESS) + self.state = 162 + self.match(LSLParser.LBRACE) + self.state = 166 + self._errHandler.sync(self) + _la = self._input.LA(1) + while True: + self.state = 166 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,12,self._ctx) + if la_ == 1: + self.state = 163 + self.state_declaration() + pass + + elif la_ == 2: + self.state = 164 + self.var_assign() + pass + + elif la_ == 3: + self.state = 165 + self.state_call() + pass + + + self.state = 168 + self._errHandler.sync(self) + _la = self._input.LA(1) + if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & 1146008943722496) != 0)): + break + + self.state = 170 + self.match(LSLParser.RBRACE) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Var_assignContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + + def getRuleIndex(self): + return LSLParser.RULE_var_assign + + + def copyFrom(self, ctx:ParserRuleContext): + super().copyFrom(ctx) + + + + class Var_assign_state_callContext(Var_assignContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.Var_assignContext + super().__init__(parser) + self.copyFrom(ctx) + + def IDEN(self): + return self.getToken(LSLParser.IDEN, 0) + def EQUALS(self): + return self.getToken(LSLParser.EQUALS, 0) + def state_call(self): + return self.getTypedRuleContext(LSLParser.State_callContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterVar_assign_state_call" ): + listener.enterVar_assign_state_call(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitVar_assign_state_call" ): + listener.exitVar_assign_state_call(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitVar_assign_state_call" ): + return visitor.visitVar_assign_state_call(self) + else: + return visitor.visitChildren(self) + + + class Var_assign_json_valueContext(Var_assignContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.Var_assignContext + super().__init__(parser) + self.copyFrom(ctx) + + def IDEN(self): + return self.getToken(LSLParser.IDEN, 0) + def EQUALS(self): + return self.getToken(LSLParser.EQUALS, 0) + def json_value(self): + return self.getTypedRuleContext(LSLParser.Json_valueContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterVar_assign_json_value" ): + listener.enterVar_assign_json_value(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitVar_assign_json_value" ): + listener.exitVar_assign_json_value(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitVar_assign_json_value" ): + return visitor.visitVar_assign_json_value(self) + else: + return visitor.visitChildren(self) + + + + def var_assign(self): + + localctx = LSLParser.Var_assignContext(self, self._ctx, self.state) + self.enterRule(localctx, 32, self.RULE_var_assign) + try: + self.state = 178 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,14,self._ctx) + if la_ == 1: + localctx = LSLParser.Var_assign_state_callContext(self, localctx) + self.enterOuterAlt(localctx, 1) + self.state = 172 + self.match(LSLParser.IDEN) + self.state = 173 + self.match(LSLParser.EQUALS) + self.state = 174 + self.state_call() + pass + + elif la_ == 2: + localctx = LSLParser.Var_assign_json_valueContext(self, localctx) + self.enterOuterAlt(localctx, 2) + self.state = 175 + self.match(LSLParser.IDEN) + self.state = 176 + self.match(LSLParser.EQUALS) + self.state = 177 + self.json_value() + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Json_valueContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def json_object(self): + return self.getTypedRuleContext(LSLParser.Json_objectContext,0) + + + def json_arr(self): + return self.getTypedRuleContext(LSLParser.Json_arrContext,0) + + + def json_value_lit(self): + return self.getTypedRuleContext(LSLParser.Json_value_litContext,0) + + + def getRuleIndex(self): + return LSLParser.RULE_json_value + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterJson_value" ): + listener.enterJson_value(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitJson_value" ): + listener.exitJson_value(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitJson_value" ): + return visitor.visitJson_value(self) + else: + return visitor.visitChildren(self) + + + + + def json_value(self): + + localctx = LSLParser.Json_valueContext(self, self._ctx, self.state) + self.enterRule(localctx, 34, self.RULE_json_value) + try: + self.state = 183 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [26]: + self.enterOuterAlt(localctx, 1) + self.state = 180 + self.json_object() + pass + elif token in [24]: + self.enterOuterAlt(localctx, 2) + self.state = 181 + self.json_arr() + pass + elif token in [2, 28, 29, 30, 47, 48, 49]: + self.enterOuterAlt(localctx, 3) + self.state = 182 + self.json_value_lit() + pass + else: + raise NoViableAltException(self) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Json_objectContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def LBRACE(self): + return self.getToken(LSLParser.LBRACE, 0) + + def json_binding(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(LSLParser.Json_bindingContext) + else: + return self.getTypedRuleContext(LSLParser.Json_bindingContext,i) + + + def RBRACE(self): + return self.getToken(LSLParser.RBRACE, 0) + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(LSLParser.COMMA) + else: + return self.getToken(LSLParser.COMMA, i) + + def getRuleIndex(self): + return LSLParser.RULE_json_object + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterJson_object" ): + listener.enterJson_object(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitJson_object" ): + listener.exitJson_object(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitJson_object" ): + return visitor.visitJson_object(self) + else: + return visitor.visitChildren(self) + + + + + def json_object(self): + + localctx = LSLParser.Json_objectContext(self, self._ctx, self.state) + self.enterRule(localctx, 36, self.RULE_json_object) + self._la = 0 # Token type + try: + self.state = 198 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,17,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 185 + self.match(LSLParser.LBRACE) + self.state = 186 + self.json_binding() + self.state = 191 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==20: + self.state = 187 + self.match(LSLParser.COMMA) + self.state = 188 + self.json_binding() + self.state = 193 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 194 + self.match(LSLParser.RBRACE) + pass + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 196 + self.match(LSLParser.LBRACE) + self.state = 197 + self.match(LSLParser.RBRACE) + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Json_bindingContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def COLON(self): + return self.getToken(LSLParser.COLON, 0) + + def json_value(self): + return self.getTypedRuleContext(LSLParser.Json_valueContext,0) + + + def STRING(self): + return self.getToken(LSLParser.STRING, 0) + + def IDEN(self): + return self.getToken(LSLParser.IDEN, 0) + + def getRuleIndex(self): + return LSLParser.RULE_json_binding + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterJson_binding" ): + listener.enterJson_binding(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitJson_binding" ): + listener.exitJson_binding(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitJson_binding" ): + return visitor.visitJson_binding(self) + else: + return visitor.visitChildren(self) + + + + + def json_binding(self): + + localctx = LSLParser.Json_bindingContext(self, self._ctx, self.state) + self.enterRule(localctx, 38, self.RULE_json_binding) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 200 + _la = self._input.LA(1) + if not(_la==47 or _la==50): + self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + self.state = 201 + self.match(LSLParser.COLON) + self.state = 202 + self.json_value() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Json_arrContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def LBRACK(self): + return self.getToken(LSLParser.LBRACK, 0) + + def json_value(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(LSLParser.Json_valueContext) + else: + return self.getTypedRuleContext(LSLParser.Json_valueContext,i) + + + def RBRACK(self): + return self.getToken(LSLParser.RBRACK, 0) + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(LSLParser.COMMA) + else: + return self.getToken(LSLParser.COMMA, i) + + def getRuleIndex(self): + return LSLParser.RULE_json_arr + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterJson_arr" ): + listener.enterJson_arr(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitJson_arr" ): + listener.exitJson_arr(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitJson_arr" ): + return visitor.visitJson_arr(self) + else: + return visitor.visitChildren(self) + + + + + def json_arr(self): + + localctx = LSLParser.Json_arrContext(self, self._ctx, self.state) + self.enterRule(localctx, 40, self.RULE_json_arr) + self._la = 0 # Token type + try: + self.state = 217 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,19,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 204 + self.match(LSLParser.LBRACK) + self.state = 205 + self.json_value() + self.state = 210 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==20: + self.state = 206 + self.match(LSLParser.COMMA) + self.state = 207 + self.json_value() + self.state = 212 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 213 + self.match(LSLParser.RBRACK) + pass + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 215 + self.match(LSLParser.LBRACK) + self.state = 216 + self.match(LSLParser.RBRACK) + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Json_value_litContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + + def getRuleIndex(self): + return LSLParser.RULE_json_value_lit + + + def copyFrom(self, ctx:ParserRuleContext): + super().copyFrom(ctx) + + + + class Json_value_strContext(Json_value_litContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.Json_value_litContext + super().__init__(parser) + self.copyFrom(ctx) + + def STRING(self): + return self.getToken(LSLParser.STRING, 0) + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterJson_value_str" ): + listener.enterJson_value_str(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitJson_value_str" ): + listener.exitJson_value_str(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitJson_value_str" ): + return visitor.visitJson_value_str(self) + else: + return visitor.visitChildren(self) + + + class Json_value_floatContext(Json_value_litContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.Json_value_litContext + super().__init__(parser) + self.copyFrom(ctx) + + def NUMBER(self): + return self.getToken(LSLParser.NUMBER, 0) + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterJson_value_float" ): + listener.enterJson_value_float(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitJson_value_float" ): + listener.exitJson_value_float(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitJson_value_float" ): + return visitor.visitJson_value_float(self) + else: + return visitor.visitChildren(self) + + + class Json_value_intContext(Json_value_litContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.Json_value_litContext + super().__init__(parser) + self.copyFrom(ctx) + + def INT(self): + return self.getToken(LSLParser.INT, 0) + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterJson_value_int" ): + listener.enterJson_value_int(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitJson_value_int" ): + listener.exitJson_value_int(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitJson_value_int" ): + return visitor.visitJson_value_int(self) + else: + return visitor.visitChildren(self) + + + class Json_value_nullContext(Json_value_litContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.Json_value_litContext + super().__init__(parser) + self.copyFrom(ctx) + + def NULL(self): + return self.getToken(LSLParser.NULL, 0) + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterJson_value_null" ): + listener.enterJson_value_null(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitJson_value_null" ): + listener.exitJson_value_null(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitJson_value_null" ): + return visitor.visitJson_value_null(self) + else: + return visitor.visitChildren(self) + + + class Json_value_jsonataContext(Json_value_litContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.Json_value_litContext + super().__init__(parser) + self.copyFrom(ctx) + + def JSONATA(self): + return self.getToken(LSLParser.JSONATA, 0) + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterJson_value_jsonata" ): + listener.enterJson_value_jsonata(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitJson_value_jsonata" ): + listener.exitJson_value_jsonata(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitJson_value_jsonata" ): + return visitor.visitJson_value_jsonata(self) + else: + return visitor.visitChildren(self) + + + class Json_value_boolContext(Json_value_litContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.Json_value_litContext + super().__init__(parser) + self.copyFrom(ctx) + + def TRUE(self): + return self.getToken(LSLParser.TRUE, 0) + def FALSE(self): + return self.getToken(LSLParser.FALSE, 0) + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterJson_value_bool" ): + listener.enterJson_value_bool(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitJson_value_bool" ): + listener.exitJson_value_bool(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitJson_value_bool" ): + return visitor.visitJson_value_bool(self) + else: + return visitor.visitChildren(self) + + + + def json_value_lit(self): + + localctx = LSLParser.Json_value_litContext(self, self._ctx, self.state) + self.enterRule(localctx, 42, self.RULE_json_value_lit) + self._la = 0 # Token type + try: + self.state = 225 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [49]: + localctx = LSLParser.Json_value_floatContext(self, localctx) + self.enterOuterAlt(localctx, 1) + self.state = 219 + self.match(LSLParser.NUMBER) + pass + elif token in [48]: + localctx = LSLParser.Json_value_intContext(self, localctx) + self.enterOuterAlt(localctx, 2) + self.state = 220 + self.match(LSLParser.INT) + pass + elif token in [28, 29]: + localctx = LSLParser.Json_value_boolContext(self, localctx) + self.enterOuterAlt(localctx, 3) + self.state = 221 + _la = self._input.LA(1) + if not(_la==28 or _la==29): + self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + pass + elif token in [30]: + localctx = LSLParser.Json_value_nullContext(self, localctx) + self.enterOuterAlt(localctx, 4) + self.state = 222 + self.match(LSLParser.NULL) + pass + elif token in [47]: + localctx = LSLParser.Json_value_strContext(self, localctx) + self.enterOuterAlt(localctx, 5) + self.state = 223 + self.match(LSLParser.STRING) + pass + elif token in [2]: + localctx = LSLParser.Json_value_jsonataContext(self, localctx) + self.enterOuterAlt(localctx, 6) + self.state = 224 + self.match(LSLParser.JSONATA) + pass + else: + raise NoViableAltException(self) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class String_or_jsonataContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + + def getRuleIndex(self): + return LSLParser.RULE_string_or_jsonata + + + def copyFrom(self, ctx:ParserRuleContext): + super().copyFrom(ctx) + + + + class String_or_jsonata_jsonataContext(String_or_jsonataContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.String_or_jsonataContext + super().__init__(parser) + self.copyFrom(ctx) + + def JSONATA(self): + return self.getToken(LSLParser.JSONATA, 0) + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterString_or_jsonata_jsonata" ): + listener.enterString_or_jsonata_jsonata(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitString_or_jsonata_jsonata" ): + listener.exitString_or_jsonata_jsonata(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitString_or_jsonata_jsonata" ): + return visitor.visitString_or_jsonata_jsonata(self) + else: + return visitor.visitChildren(self) + + + class String_or_jsonata_stringContext(String_or_jsonataContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a LSLParser.String_or_jsonataContext + super().__init__(parser) + self.copyFrom(ctx) + + def STRING(self): + return self.getToken(LSLParser.STRING, 0) + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterString_or_jsonata_string" ): + listener.enterString_or_jsonata_string(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitString_or_jsonata_string" ): + listener.exitString_or_jsonata_string(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitString_or_jsonata_string" ): + return visitor.visitString_or_jsonata_string(self) + else: + return visitor.visitChildren(self) + + + + def string_or_jsonata(self): + + localctx = LSLParser.String_or_jsonataContext(self, self._ctx, self.state) + self.enterRule(localctx, 44, self.RULE_string_or_jsonata) + try: + self.state = 229 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [47]: + localctx = LSLParser.String_or_jsonata_stringContext(self, localctx) + self.enterOuterAlt(localctx, 1) + self.state = 227 + self.match(LSLParser.STRING) + pass + elif token in [2]: + localctx = LSLParser.String_or_jsonata_jsonataContext(self, localctx) + self.enterOuterAlt(localctx, 2) + self.state = 228 + self.match(LSLParser.JSONATA) + pass + else: + raise NoViableAltException(self) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + class Error_nameContext(ParserRuleContext): + __slots__ = 'parser' + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def ERRORNAMEStatesALL(self): + return self.getToken(LSLParser.ERRORNAMEStatesALL, 0) + + def ERRORNAMEStatesDataLimitExceeded(self): + return self.getToken(LSLParser.ERRORNAMEStatesDataLimitExceeded, 0) + + def ERRORNAMEStatesHeartbeatTimeout(self): + return self.getToken(LSLParser.ERRORNAMEStatesHeartbeatTimeout, 0) + + def ERRORNAMEStatesTimeout(self): + return self.getToken(LSLParser.ERRORNAMEStatesTimeout, 0) + + def ERRORNAMEStatesTaskFailed(self): + return self.getToken(LSLParser.ERRORNAMEStatesTaskFailed, 0) + + def ERRORNAMEStatesPermissions(self): + return self.getToken(LSLParser.ERRORNAMEStatesPermissions, 0) + + def ERRORNAMEStatesResultPathMatchFailure(self): + return self.getToken(LSLParser.ERRORNAMEStatesResultPathMatchFailure, 0) + + def ERRORNAMEStatesParameterPathFailure(self): + return self.getToken(LSLParser.ERRORNAMEStatesParameterPathFailure, 0) + + def ERRORNAMEStatesBranchFailed(self): + return self.getToken(LSLParser.ERRORNAMEStatesBranchFailed, 0) + + def ERRORNAMEStatesNoChoiceMatched(self): + return self.getToken(LSLParser.ERRORNAMEStatesNoChoiceMatched, 0) + + def ERRORNAMEStatesIntrinsicFailure(self): + return self.getToken(LSLParser.ERRORNAMEStatesIntrinsicFailure, 0) + + def ERRORNAMEStatesExceedToleratedFailureThreshold(self): + return self.getToken(LSLParser.ERRORNAMEStatesExceedToleratedFailureThreshold, 0) + + def ERRORNAMEStatesItemReaderFailed(self): + return self.getToken(LSLParser.ERRORNAMEStatesItemReaderFailed, 0) + + def ERRORNAMEStatesResultWriterFailed(self): + return self.getToken(LSLParser.ERRORNAMEStatesResultWriterFailed, 0) + + def ERRORNAMEStatesQueryEvaluationError(self): + return self.getToken(LSLParser.ERRORNAMEStatesQueryEvaluationError, 0) + + def STRING(self): + return self.getToken(LSLParser.STRING, 0) + + def getRuleIndex(self): + return LSLParser.RULE_error_name + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterError_name" ): + listener.enterError_name(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitError_name" ): + listener.exitError_name(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitError_name" ): + return visitor.visitError_name(self) + else: + return visitor.visitChildren(self) + + + + + def error_name(self): + + localctx = LSLParser.Error_nameContext(self, self._ctx, self.state) + self.enterRule(localctx, 46, self.RULE_error_name) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 231 + _la = self._input.LA(1) + if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 140737488617464) != 0)): + self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + + + diff --git a/localstack-core/localstack/services/stepfunctions/asl/antlr/runtime/LSLParserListener.py b/localstack-core/localstack/services/stepfunctions/asl/antlr/runtime/LSLParserListener.py new file mode 100644 index 0000000000000..aed092e7d465f --- /dev/null +++ b/localstack-core/localstack/services/stepfunctions/asl/antlr/runtime/LSLParserListener.py @@ -0,0 +1,345 @@ +# Generated from LSLParser.g4 by ANTLR 4.13.2 +from antlr4 import * +if "." in __name__: + from .LSLParser import LSLParser +else: + from LSLParser import LSLParser + +# This class defines a complete listener for a parse tree produced by LSLParser. +class LSLParserListener(ParseTreeListener): + + # Enter a parse tree produced by LSLParser#state_machine. + def enterState_machine(self, ctx:LSLParser.State_machineContext): + pass + + # Exit a parse tree produced by LSLParser#state_machine. + def exitState_machine(self, ctx:LSLParser.State_machineContext): + pass + + + # Enter a parse tree produced by LSLParser#state_declaration. + def enterState_declaration(self, ctx:LSLParser.State_declarationContext): + pass + + # Exit a parse tree produced by LSLParser#state_declaration. + def exitState_declaration(self, ctx:LSLParser.State_declarationContext): + pass + + + # Enter a parse tree produced by LSLParser#state_call_template. + def enterState_call_template(self, ctx:LSLParser.State_call_templateContext): + pass + + # Exit a parse tree produced by LSLParser#state_call_template. + def exitState_call_template(self, ctx:LSLParser.State_call_templateContext): + pass + + + # Enter a parse tree produced by LSLParser#state_call_named. + def enterState_call_named(self, ctx:LSLParser.State_call_namedContext): + pass + + # Exit a parse tree produced by LSLParser#state_call_named. + def exitState_call_named(self, ctx:LSLParser.State_call_namedContext): + pass + + + # Enter a parse tree produced by LSLParser#state_call_anonymous. + def enterState_call_anonymous(self, ctx:LSLParser.State_call_anonymousContext): + pass + + # Exit a parse tree produced by LSLParser#state_call_anonymous. + def exitState_call_anonymous(self, ctx:LSLParser.State_call_anonymousContext): + pass + + + # Enter a parse tree produced by LSLParser#state_task. + def enterState_task(self, ctx:LSLParser.State_taskContext): + pass + + # Exit a parse tree produced by LSLParser#state_task. + def exitState_task(self, ctx:LSLParser.State_taskContext): + pass + + + # Enter a parse tree produced by LSLParser#state_fail. + def enterState_fail(self, ctx:LSLParser.State_failContext): + pass + + # Exit a parse tree produced by LSLParser#state_fail. + def exitState_fail(self, ctx:LSLParser.State_failContext): + pass + + + # Enter a parse tree produced by LSLParser#state_return. + def enterState_return(self, ctx:LSLParser.State_returnContext): + pass + + # Exit a parse tree produced by LSLParser#state_return. + def exitState_return(self, ctx:LSLParser.State_returnContext): + pass + + + # Enter a parse tree produced by LSLParser#state_map. + def enterState_map(self, ctx:LSLParser.State_mapContext): + pass + + # Exit a parse tree produced by LSLParser#state_map. + def exitState_map(self, ctx:LSLParser.State_mapContext): + pass + + + # Enter a parse tree produced by LSLParser#state_parallel. + def enterState_parallel(self, ctx:LSLParser.State_parallelContext): + pass + + # Exit a parse tree produced by LSLParser#state_parallel. + def exitState_parallel(self, ctx:LSLParser.State_parallelContext): + pass + + + # Enter a parse tree produced by LSLParser#service_name. + def enterService_name(self, ctx:LSLParser.Service_nameContext): + pass + + # Exit a parse tree produced by LSLParser#service_name. + def exitService_name(self, ctx:LSLParser.Service_nameContext): + pass + + + # Enter a parse tree produced by LSLParser#task_where. + def enterTask_where(self, ctx:LSLParser.Task_whereContext): + pass + + # Exit a parse tree produced by LSLParser#task_where. + def exitTask_where(self, ctx:LSLParser.Task_whereContext): + pass + + + # Enter a parse tree produced by LSLParser#fail_where. + def enterFail_where(self, ctx:LSLParser.Fail_whereContext): + pass + + # Exit a parse tree produced by LSLParser#fail_where. + def exitFail_where(self, ctx:LSLParser.Fail_whereContext): + pass + + + # Enter a parse tree produced by LSLParser#arguments. + def enterArguments(self, ctx:LSLParser.ArgumentsContext): + pass + + # Exit a parse tree produced by LSLParser#arguments. + def exitArguments(self, ctx:LSLParser.ArgumentsContext): + pass + + + # Enter a parse tree produced by LSLParser#catch_block. + def enterCatch_block(self, ctx:LSLParser.Catch_blockContext): + pass + + # Exit a parse tree produced by LSLParser#catch_block. + def exitCatch_block(self, ctx:LSLParser.Catch_blockContext): + pass + + + # Enter a parse tree produced by LSLParser#catch_case. + def enterCatch_case(self, ctx:LSLParser.Catch_caseContext): + pass + + # Exit a parse tree produced by LSLParser#catch_case. + def exitCatch_case(self, ctx:LSLParser.Catch_caseContext): + pass + + + # Enter a parse tree produced by LSLParser#parameter_list. + def enterParameter_list(self, ctx:LSLParser.Parameter_listContext): + pass + + # Exit a parse tree produced by LSLParser#parameter_list. + def exitParameter_list(self, ctx:LSLParser.Parameter_listContext): + pass + + + # Enter a parse tree produced by LSLParser#args_assign_list. + def enterArgs_assign_list(self, ctx:LSLParser.Args_assign_listContext): + pass + + # Exit a parse tree produced by LSLParser#args_assign_list. + def exitArgs_assign_list(self, ctx:LSLParser.Args_assign_listContext): + pass + + + # Enter a parse tree produced by LSLParser#args_assign. + def enterArgs_assign(self, ctx:LSLParser.Args_assignContext): + pass + + # Exit a parse tree produced by LSLParser#args_assign. + def exitArgs_assign(self, ctx:LSLParser.Args_assignContext): + pass + + + # Enter a parse tree produced by LSLParser#error. + def enterError(self, ctx:LSLParser.ErrorContext): + pass + + # Exit a parse tree produced by LSLParser#error. + def exitError(self, ctx:LSLParser.ErrorContext): + pass + + + # Enter a parse tree produced by LSLParser#cause. + def enterCause(self, ctx:LSLParser.CauseContext): + pass + + # Exit a parse tree produced by LSLParser#cause. + def exitCause(self, ctx:LSLParser.CauseContext): + pass + + + # Enter a parse tree produced by LSLParser#process. + def enterProcess(self, ctx:LSLParser.ProcessContext): + pass + + # Exit a parse tree produced by LSLParser#process. + def exitProcess(self, ctx:LSLParser.ProcessContext): + pass + + + # Enter a parse tree produced by LSLParser#var_assign_state_call. + def enterVar_assign_state_call(self, ctx:LSLParser.Var_assign_state_callContext): + pass + + # Exit a parse tree produced by LSLParser#var_assign_state_call. + def exitVar_assign_state_call(self, ctx:LSLParser.Var_assign_state_callContext): + pass + + + # Enter a parse tree produced by LSLParser#var_assign_json_value. + def enterVar_assign_json_value(self, ctx:LSLParser.Var_assign_json_valueContext): + pass + + # Exit a parse tree produced by LSLParser#var_assign_json_value. + def exitVar_assign_json_value(self, ctx:LSLParser.Var_assign_json_valueContext): + pass + + + # Enter a parse tree produced by LSLParser#json_value. + def enterJson_value(self, ctx:LSLParser.Json_valueContext): + pass + + # Exit a parse tree produced by LSLParser#json_value. + def exitJson_value(self, ctx:LSLParser.Json_valueContext): + pass + + + # Enter a parse tree produced by LSLParser#json_object. + def enterJson_object(self, ctx:LSLParser.Json_objectContext): + pass + + # Exit a parse tree produced by LSLParser#json_object. + def exitJson_object(self, ctx:LSLParser.Json_objectContext): + pass + + + # Enter a parse tree produced by LSLParser#json_binding. + def enterJson_binding(self, ctx:LSLParser.Json_bindingContext): + pass + + # Exit a parse tree produced by LSLParser#json_binding. + def exitJson_binding(self, ctx:LSLParser.Json_bindingContext): + pass + + + # Enter a parse tree produced by LSLParser#json_arr. + def enterJson_arr(self, ctx:LSLParser.Json_arrContext): + pass + + # Exit a parse tree produced by LSLParser#json_arr. + def exitJson_arr(self, ctx:LSLParser.Json_arrContext): + pass + + + # Enter a parse tree produced by LSLParser#json_value_float. + def enterJson_value_float(self, ctx:LSLParser.Json_value_floatContext): + pass + + # Exit a parse tree produced by LSLParser#json_value_float. + def exitJson_value_float(self, ctx:LSLParser.Json_value_floatContext): + pass + + + # Enter a parse tree produced by LSLParser#json_value_int. + def enterJson_value_int(self, ctx:LSLParser.Json_value_intContext): + pass + + # Exit a parse tree produced by LSLParser#json_value_int. + def exitJson_value_int(self, ctx:LSLParser.Json_value_intContext): + pass + + + # Enter a parse tree produced by LSLParser#json_value_bool. + def enterJson_value_bool(self, ctx:LSLParser.Json_value_boolContext): + pass + + # Exit a parse tree produced by LSLParser#json_value_bool. + def exitJson_value_bool(self, ctx:LSLParser.Json_value_boolContext): + pass + + + # Enter a parse tree produced by LSLParser#json_value_null. + def enterJson_value_null(self, ctx:LSLParser.Json_value_nullContext): + pass + + # Exit a parse tree produced by LSLParser#json_value_null. + def exitJson_value_null(self, ctx:LSLParser.Json_value_nullContext): + pass + + + # Enter a parse tree produced by LSLParser#json_value_str. + def enterJson_value_str(self, ctx:LSLParser.Json_value_strContext): + pass + + # Exit a parse tree produced by LSLParser#json_value_str. + def exitJson_value_str(self, ctx:LSLParser.Json_value_strContext): + pass + + + # Enter a parse tree produced by LSLParser#json_value_jsonata. + def enterJson_value_jsonata(self, ctx:LSLParser.Json_value_jsonataContext): + pass + + # Exit a parse tree produced by LSLParser#json_value_jsonata. + def exitJson_value_jsonata(self, ctx:LSLParser.Json_value_jsonataContext): + pass + + + # Enter a parse tree produced by LSLParser#string_or_jsonata_string. + def enterString_or_jsonata_string(self, ctx:LSLParser.String_or_jsonata_stringContext): + pass + + # Exit a parse tree produced by LSLParser#string_or_jsonata_string. + def exitString_or_jsonata_string(self, ctx:LSLParser.String_or_jsonata_stringContext): + pass + + + # Enter a parse tree produced by LSLParser#string_or_jsonata_jsonata. + def enterString_or_jsonata_jsonata(self, ctx:LSLParser.String_or_jsonata_jsonataContext): + pass + + # Exit a parse tree produced by LSLParser#string_or_jsonata_jsonata. + def exitString_or_jsonata_jsonata(self, ctx:LSLParser.String_or_jsonata_jsonataContext): + pass + + + # Enter a parse tree produced by LSLParser#error_name. + def enterError_name(self, ctx:LSLParser.Error_nameContext): + pass + + # Exit a parse tree produced by LSLParser#error_name. + def exitError_name(self, ctx:LSLParser.Error_nameContext): + pass + + + +del LSLParser \ No newline at end of file diff --git a/localstack-core/localstack/services/stepfunctions/asl/antlr/runtime/LSLParserVisitor.py b/localstack-core/localstack/services/stepfunctions/asl/antlr/runtime/LSLParserVisitor.py new file mode 100644 index 0000000000000..7184533fb4e6c --- /dev/null +++ b/localstack-core/localstack/services/stepfunctions/asl/antlr/runtime/LSLParserVisitor.py @@ -0,0 +1,198 @@ +# Generated from LSLParser.g4 by ANTLR 4.13.2 +from antlr4 import * +if "." in __name__: + from .LSLParser import LSLParser +else: + from LSLParser import LSLParser + +# This class defines a complete generic visitor for a parse tree produced by LSLParser. + +class LSLParserVisitor(ParseTreeVisitor): + + # Visit a parse tree produced by LSLParser#state_machine. + def visitState_machine(self, ctx:LSLParser.State_machineContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#state_declaration. + def visitState_declaration(self, ctx:LSLParser.State_declarationContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#state_call_template. + def visitState_call_template(self, ctx:LSLParser.State_call_templateContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#state_call_named. + def visitState_call_named(self, ctx:LSLParser.State_call_namedContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#state_call_anonymous. + def visitState_call_anonymous(self, ctx:LSLParser.State_call_anonymousContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#state_task. + def visitState_task(self, ctx:LSLParser.State_taskContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#state_fail. + def visitState_fail(self, ctx:LSLParser.State_failContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#state_return. + def visitState_return(self, ctx:LSLParser.State_returnContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#state_map. + def visitState_map(self, ctx:LSLParser.State_mapContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#state_parallel. + def visitState_parallel(self, ctx:LSLParser.State_parallelContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#service_name. + def visitService_name(self, ctx:LSLParser.Service_nameContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#task_where. + def visitTask_where(self, ctx:LSLParser.Task_whereContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#fail_where. + def visitFail_where(self, ctx:LSLParser.Fail_whereContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#arguments. + def visitArguments(self, ctx:LSLParser.ArgumentsContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#catch_block. + def visitCatch_block(self, ctx:LSLParser.Catch_blockContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#catch_case. + def visitCatch_case(self, ctx:LSLParser.Catch_caseContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#parameter_list. + def visitParameter_list(self, ctx:LSLParser.Parameter_listContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#args_assign_list. + def visitArgs_assign_list(self, ctx:LSLParser.Args_assign_listContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#args_assign. + def visitArgs_assign(self, ctx:LSLParser.Args_assignContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#error. + def visitError(self, ctx:LSLParser.ErrorContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#cause. + def visitCause(self, ctx:LSLParser.CauseContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#process. + def visitProcess(self, ctx:LSLParser.ProcessContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#var_assign_state_call. + def visitVar_assign_state_call(self, ctx:LSLParser.Var_assign_state_callContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#var_assign_json_value. + def visitVar_assign_json_value(self, ctx:LSLParser.Var_assign_json_valueContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#json_value. + def visitJson_value(self, ctx:LSLParser.Json_valueContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#json_object. + def visitJson_object(self, ctx:LSLParser.Json_objectContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#json_binding. + def visitJson_binding(self, ctx:LSLParser.Json_bindingContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#json_arr. + def visitJson_arr(self, ctx:LSLParser.Json_arrContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#json_value_float. + def visitJson_value_float(self, ctx:LSLParser.Json_value_floatContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#json_value_int. + def visitJson_value_int(self, ctx:LSLParser.Json_value_intContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#json_value_bool. + def visitJson_value_bool(self, ctx:LSLParser.Json_value_boolContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#json_value_null. + def visitJson_value_null(self, ctx:LSLParser.Json_value_nullContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#json_value_str. + def visitJson_value_str(self, ctx:LSLParser.Json_value_strContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#json_value_jsonata. + def visitJson_value_jsonata(self, ctx:LSLParser.Json_value_jsonataContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#string_or_jsonata_string. + def visitString_or_jsonata_string(self, ctx:LSLParser.String_or_jsonata_stringContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#string_or_jsonata_jsonata. + def visitString_or_jsonata_jsonata(self, ctx:LSLParser.String_or_jsonata_jsonataContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by LSLParser#error_name. + def visitError_name(self, ctx:LSLParser.Error_nameContext): + return self.visitChildren(ctx) + + + +del LSLParser \ No newline at end of file diff --git a/localstack-core/localstack/services/stepfunctions/asl/lsl/__init__.py b/localstack-core/localstack/services/stepfunctions/asl/lsl/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/localstack-core/localstack/services/stepfunctions/asl/lsl/lsl_cli.py b/localstack-core/localstack/services/stepfunctions/asl/lsl/lsl_cli.py new file mode 100644 index 0000000000000..bb94ce7e6a10c --- /dev/null +++ b/localstack-core/localstack/services/stepfunctions/asl/lsl/lsl_cli.py @@ -0,0 +1,34 @@ +import json +import os + +import click + +from localstack.services.stepfunctions.asl.lsl.transpiler import transpile + + +@click.command() +@click.argument( + "input_file", type=click.Path(exists=True, dir_okay=False, readable=True, path_type=str) +) +@click.option( + "--output", + "-o", + type=click.Path(dir_okay=False, writable=True, path_type=str), + help="Path to output JSON file.", +) +def cli(input_file: str, output: str): + """Transpile an LSL derivation file to JSON.""" + with open(input_file, "r") as f: + content = f.read() + + result = transpile(content) + + output_file = output or os.path.splitext(input_file)[0] + ".asl.json" + with open(output_file, "w") as f: + json.dump(result, f, indent=2) + + click.echo(f"Transpiled successfully to {output_file}") + + +if __name__ == "__main__": + cli() diff --git a/localstack-core/localstack/services/stepfunctions/asl/lsl/transpiler.py b/localstack-core/localstack/services/stepfunctions/asl/lsl/transpiler.py new file mode 100644 index 0000000000000..8c4058178f98c --- /dev/null +++ b/localstack-core/localstack/services/stepfunctions/asl/lsl/transpiler.py @@ -0,0 +1,356 @@ +from __future__ import annotations + +import copy +from typing import Optional, OrderedDict + +from antlr4 import CommonTokenStream, InputStream +from antlr4.ParserRuleContext import ParserRuleContext +from antlr4.tree.Tree import TerminalNodeImpl + +from localstack.services.stepfunctions.asl.antlr.runtime.LSLLexer import LSLLexer +from localstack.services.stepfunctions.asl.antlr.runtime.LSLParser import LSLParser +from localstack.services.stepfunctions.asl.antlr.runtime.LSLParserVisitor import LSLParserVisitor +from localstack.services.stepfunctions.asl.antlt4utils.antlr4utils import from_string_literal + + +def transpile(lsl_derivation: str) -> dict: + input_stream = InputStream(lsl_derivation) + lexer = LSLLexer(input_stream) + stream = CommonTokenStream(lexer) + parser = LSLParser(stream) + tree = parser.state_machine() + transpiler = _Transpiler() + transpiler.visit(tree) + workflow = transpiler.get_workflow() + return workflow + + +class _Scope: + _last_called: Optional[str] + _state_templates: dict[str, dict] + _start_at: Optional[str] + _states: OrderedDict[str, dict] + + def __init__(self, upper_scope: Optional[_Scope] = None): + self._last_called = None + self._start_at = None + if upper_scope is not None: + self._state_templates = copy.deepcopy(upper_scope._state_templates) + else: + self._state_templates = dict() + self._states = OrderedDict() + + def new_template(self, state_name: str, state: dict): + self._state_templates[state_name] = state + + def get_template(self, state_name): + template = self._state_templates[state_name] + return copy.deepcopy(template) + + def set_next(self, state_name: str, state: dict): + if self._start_at is None: + self._start_at = state_name + else: + last_state = self._states[self._last_called] + last_state.pop("End", None) + last_state["Next"] = state_name + self._last_called = state_name + self._states[state_name] = state + + def to_scope_workflow(self) -> dict: + return {"StartAt": self._start_at, "States": {**self._states}} + + +class _Transpiler(LSLParserVisitor): + _scopes: list[_Scope] + + def __init__(self): + self._scopes = list() + self._scopes.append(_Scope()) + + def get_workflow(self) -> dict: + scope = self._this_scope() + scope_workflow = scope.to_scope_workflow() + workflow = {"Comment": "Auto-generated", "QueryLanguage": "JSONata", **scope_workflow} + return workflow + + def _this_scope(self) -> _Scope: + return self._scopes[-1] + + def visitState_declaration(self, ctx: LSLParser.State_declarationContext): + state_name = from_string_literal(ctx.IDEN()) + state = self.visit(ctx.state_()) + state_type = state["Type"] + if state_type not in {"Fail", "Pass"}: + parameters = self.visitParameter_list(ctx.parameter_list()) + cleanup_assign = dict.fromkeys(parameters) + state["Assign"] = cleanup_assign + state["Output"] = "{% $states.result %}" + + scope = self._this_scope() + scope.new_template(state_name=state_name, state=state) + + return state_name, state + + def transpile_inner_state_call(self, state_name: str, state: dict): + scope = self._this_scope() + scope.set_next(state_name=state_name, state=state) + + def visitState_call_named(self, ctx: LSLParser.State_call_namedContext): + inner_name = from_string_literal(ctx.IDEN()) + state = self.visit(ctx.state_()) + self.transpile_inner_state_call(state_name=inner_name, state=state) + + def visitState_call_anonymous(self, ctx: LSLParser.State_call_anonymousContext): + anonymous_inner_name = f"call:{ctx.start.line}:{ctx.start.column}" + state = self.visit(ctx.state_()) + self.transpile_inner_state_call(state_name=anonymous_inner_name, state=state) + + def visitState_call_template(self, ctx: LSLParser.State_call_templateContext): + scope = self._this_scope() + call_marker = f"call:{ctx.start.line}:{ctx.start.column}" + + template_state_name = from_string_literal(ctx.IDEN()) + target_state_name = f"{call_marker}:{template_state_name}" + target_state = scope.get_template(state_name=template_state_name) + + input_state_name = f"{target_state_name}:input" + input_state = self.create_state_for_arg_assign_list( + target_state_name=target_state_name, ctx=ctx.args_assign_list() + ) + + scope.set_next(state_name=input_state_name, state=input_state) + scope.set_next(state_name=target_state_name, state=target_state) + + return target_state_name, input_state + + def create_state_for_arg_assign_list( + self, target_state_name: str, ctx: LSLParser.Args_assign_listContext + ): + assign_body = self.visitArgs_assign_list(ctx=ctx) + state = {"Type": "Pass", "Assign": assign_body, "Next": target_state_name} + return state + + def visitArgs_assign_list(self, ctx: LSLParser.Args_assign_listContext): + assign_body = dict() + for child in ctx.children: + if ( + isinstance(child, ParserRuleContext) + and child.getRuleIndex() == LSLParser.RULE_args_assign + ): + variable_name, value = self.visitArgs_assign(child) # noqa + assign_body[variable_name] = value + return assign_body + + def visitArgs_assign(self, ctx: LSLParser.Args_assignContext): + variable_name = from_string_literal(ctx.IDEN()) + value = self.visit(ctx.json_value()) + return variable_name, value + + def visitParameter_list(self, ctx: LSLParser.Parameter_listContext): + parameters = list() + for child in ctx.children: + if isinstance(child, TerminalNodeImpl) and child.symbol.type == LSLLexer.IDEN: + parameter_identifier = from_string_literal(child) # noqa + parameters.append(parameter_identifier) + return parameters + + def visitState_return(self, ctx: LSLParser.State_returnContext): + output_expression = self.visit(ctx.json_value()) + output_prepare_state = {"Type": "Pass", "End": True, "Output": output_expression} + return output_prepare_state + + def visitState_fail(self, ctx: LSLParser.State_failContext): + where = self.visit(ctx.fail_where()) + state = {"Type": "Fail", **where} + return state + + def visitFail_where(self, ctx: LSLParser.Fail_whereContext): + where = dict() + for child in ctx.children: + if isinstance(child, ParserRuleContext) and child.getRuleIndex() in { + LSLParser.RULE_error, + LSLParser.RULE_cause, + }: + key, value = self.visit(child) + where[key] = value + return where + + def visitError(self, ctx: LSLParser.ErrorContext): + error_expr = self.visit(ctx.string_or_jsonata()) + return "Error", error_expr + + def visitCause(self, ctx: LSLParser.CauseContext): + cause_expr = self.visit(ctx.string_or_jsonata()) + return "Cause", cause_expr + + def visitState_task(self, ctx: LSLParser.State_taskContext): + service_name = self.visitService_name(ctx.service_name()) + action_name = from_string_literal(ctx.IDEN()) + where = self.visitTask_where(ctx.task_where()) + state = { + "Type": "Task", + # TODO: add support for aws-sdk, and callbacks + "Resource": f"arn:aws:states:::{service_name}:{action_name}", + "End": True, + **where, + } + return state + + def visitService_name(self, ctx: LSLParser.Service_nameContext): + service_name = from_string_literal(ctx.children[0]) + return service_name + + def visitTask_where(self, ctx: LSLParser.Task_whereContext): + where = dict() + for child in ctx.children: + if isinstance(child, ParserRuleContext) and child.getRuleIndex() in { + LSLParser.RULE_arguments, + LSLParser.RULE_catch_block, + }: + key, value = self.visit(child) + where[key] = value + return where + + def new_inner_scope(self): + scope = _Scope(self._this_scope()) + self._scopes.append(scope) + return scope + + def close_scope(self): + self._scopes.pop() + + def visitState_parallel(self, ctx: LSLParser.State_parallelContext): + branches = list() + for child in ctx.children: + if ( + isinstance(child, ParserRuleContext) + and child.getRuleIndex() == LSLParser.RULE_process + ): + scope = self.new_inner_scope() + self.visit(child) + self.close_scope() + workflow = scope.to_scope_workflow() + branches.append(workflow) + state = {"Type": "Parallel", "End": True, "Branches": [*branches]} + return state + + def visitState_map(self, ctx: LSLParser.State_mapContext): + scope = self.new_inner_scope() + items_var_name = from_string_literal(ctx.IDEN()) + input_state_name = f"map:process:{ctx.start.line}:{ctx.start.column}:input" + input_state = { + "Type": "Pass", + "Assign": {items_var_name: "{% $states.input %}"}, + "End": True, + } + scope.set_next(state_name=input_state_name, state=input_state) + self.visit(ctx.process()) + self.close_scope() + inner_workflow = scope.to_scope_workflow() + + items_expression = self.visit(ctx.json_value()) + state = { + "Type": "Map", + "End": True, + "Items": items_expression, + "MaxConcurrency": 1, + "ItemProcessor": {"ProcessorConfig": {"Mode": "INLINE"}, **inner_workflow}, + } + return state + + def visitProcess(self, ctx: LSLParser.ProcessContext): + expressions = list() + for child in ctx.children: + if isinstance(child, ParserRuleContext) and child.getRuleIndex() in { + LSLParser.RULE_state_call, + LSLParser.RULE_state_declaration, + LSLParser.RULE_var_assign, + }: + expression = self.visit(child) + expressions.append(expression) + return expressions + + def visitArguments(self, ctx: LSLParser.ArgumentsContext): + value = self.visit(ctx.json_value()) + return "Arguments", value + + def visitVar_assign_json_value(self, ctx: LSLParser.Var_assign_json_valueContext): + variable_name = from_string_literal(ctx.IDEN()) + value_expression = self.visit(ctx.json_value()) + + state_name = f"assign:{ctx.start.line}:{ctx.start.column}" + state = {"Type": "Pass", "Assign": {variable_name: value_expression}, "End": True} + + scope = self._this_scope() + scope.set_next(state_name=state_name, state=state) + + return state + + def visitVar_assign_state_call(self, ctx: LSLParser.Var_assign_state_callContext): + super().visit(ctx.state_call()) + + variable_name = from_string_literal(ctx.IDEN()) + + state_name = f"assign:{ctx.start.line}:{ctx.start.column}" + state = {"Type": "Pass", "Assign": {variable_name: "{% $states.input %}"}, "End": True} + + scope = self._this_scope() + scope.set_next(state_name=state_name, state=state) + + return state + + def visitJson_value_int(self, ctx: LSLParser.Json_value_intContext): + return int(ctx.INT().getText()) + + def visitJson_value_float(self, ctx: LSLParser.Json_value_floatContext): + return float(ctx.NUMBER().getText()) + + def visitJson_value_bool(self, ctx: LSLParser.Json_value_boolContext): + bool_child = ctx.children[0] + bool_term_rule: int = bool_child.getSymbol().type + bool_val: bool = bool_term_rule == LSLLexer.TRUE + return bool_val + + def visitJson_value_null(self, ctx: LSLParser.Json_value_nullContext): + return None + + def visitJson_binding(self, ctx: LSLParser.Json_bindingContext): + key = from_string_literal(ctx.children[0]) + value = self.visit(ctx.json_value()) + return key, value + + def visitJson_value_str(self, ctx: LSLParser.Json_value_strContext): + string = from_string_literal(ctx.STRING()) + return string + + def visitJson_value_jsonata(self, ctx: LSLParser.Json_value_jsonataContext): + jsonata_expression = ctx.JSONATA().getText()[len("jsonata(") : -1] + return "{% " + jsonata_expression + " %}" + + def visitJson_object(self, ctx: LSLParser.Json_objectContext): + o = dict() + for child in ctx.children: + if ( + isinstance(child, ParserRuleContext) + and child.getRuleIndex() == LSLParser.RULE_json_binding + ): + key, value = self.visitJson_binding(ctx=child) # noqa + o[key] = value + return o + + def visitJson_arr(self, ctx: LSLParser.Json_arrContext): + arr = list() + for child in ctx.children: + if isinstance(child, ParserRuleContext): + value = self.visit(child) + arr.append(value) + return arr + + def visitString_or_jsonata_string(self, ctx: LSLParser.String_or_jsonata_stringContext): + string = from_string_literal(ctx.STRING()) + return string + + def visitString_or_jsonata_jsonata(self, ctx: LSLParser.String_or_jsonata_jsonataContext): + jsonata_expression = ctx.JSONATA().getText()[len("jsonata(") : -1] + return "{% " + jsonata_expression + " %}" diff --git a/tests/aws/services/stepfunctions/v2/localstack_states_language.py b/tests/aws/services/stepfunctions/v2/localstack_states_language.py new file mode 100644 index 0000000000000..84ce5291e4220 --- /dev/null +++ b/tests/aws/services/stepfunctions/v2/localstack_states_language.py @@ -0,0 +1,535 @@ +import json + +from aws.services.stepfunctions.templates.services.services_templates import ServicesTemplates +from localstack.aws.api.lambda_ import Runtime +from localstack.services.stepfunctions.asl.lsl.transpiler import transpile +from localstack.testing.pytest import markers +from localstack.testing.pytest.stepfunctions.utils import await_execution_terminated +from localstack.utils.strings import short_uid + + +class TestLocalStackStatesLanguage: + @markers.aws.only_localstack + def test_parallel_anonymous( + self, + aws_client, + create_lambda_function, + ): + state_machine = transpile(""" + # Uses lambda to gree the user. + GreetUser(user_name) = lambda:invoke where + arguments { + FunctionName: "GreetingFunction", + Payload: { + full_name: jsonata("Hello " & $user_name) + } + } + # Users lambda to email the user. + EmailUser(user_name) = lambda:invoke where + arguments { + FunctionName: "GreetingFunction", + Payload: { + full_name: jsonata("an email to " & $user_name) + } + } + # Runs all of the tasks for a new user. + NewUserTasks(user) = parallel where + process { + greet = GreetUser(user_name = jsonata($user)) + return jsonata($greet) + } + process { + email = EmailUser(user_name = jsonata($user)) + return jsonata($email.Payload) + } + # Run all the new user tasks for all the users. + user_names = ["Lewis", "George", "James"] + tasks_outcomes = for next_user_name in jsonata($user_names) where + process { + NewUserTasks(user = jsonata($next_user_name)) + } + return jsonata($tasks_outcomes) + """) + definition = json.dumps(state_machine) + + sfn = aws_client.stepfunctions + + create_state_machine_response = sfn.create_state_machine( + name=f"autogen-{short_uid()}", + definition=definition, + roleArn="arn:aws:iam::000000000000:role/dummy", + ) + state_machine_arn = create_state_machine_response["stateMachineArn"] + + function_name = "GreetingFunction" + create_lambda_function( + func_name=function_name, + handler_file=ServicesTemplates.LAMBDA_ID_FUNCTION, + runtime=Runtime.python3_12, + ) + + execute_state_machine_response = sfn.start_execution(stateMachineArn=state_machine_arn) + execution_arn = execute_state_machine_response["executionArn"] + + await_execution_terminated( + stepfunctions_client=aws_client.stepfunctions, execution_arn=execution_arn + ) + execution_history_response = sfn.get_execution_history(executionArn=execution_arn) + assert "executionSucceededEventDetails" in execution_history_response["events"][-1] + details = execution_history_response["events"][-1]["executionSucceededEventDetails"] + assert "Hello George" in details["output"] + assert "Hello Lewis" in details["output"] + assert "Hello James" in details["output"] + assert "an email to George" in details["output"] + assert "an email to Lewis" in details["output"] + assert "an email to James" in details["output"] + + @markers.aws.only_localstack + def test_map_template_anonymous_inner_task( + self, + aws_client, + create_lambda_function, + ): + state_machine = transpile(""" + MapState(names) = for name in jsonata($names) where + process { + greet_result = lambda:invoke where + arguments { + FunctionName: "GreetingFunction", + Payload: { + full_name: jsonata("Hello " & $name) + } + } + greet_value = jsonata($greet_result.Payload) + return jsonata($greet_value) + } + user_names = ["John", "Lewis"] + all_greetings = MapState(names = jsonata($user_names)) + return jsonata($all_greetings) + """) + definition = json.dumps(state_machine) + + sfn = aws_client.stepfunctions + + create_state_machine_response = sfn.create_state_machine( + name=f"autogen-{short_uid()}", + definition=definition, + roleArn="arn:aws:iam::000000000000:role/dummy", + ) + state_machine_arn = create_state_machine_response["stateMachineArn"] + + function_name = "GreetingFunction" + create_lambda_function( + func_name=function_name, + handler_file=ServicesTemplates.LAMBDA_ID_FUNCTION, + runtime=Runtime.python3_12, + ) + + execute_state_machine_response = sfn.start_execution(stateMachineArn=state_machine_arn) + execution_arn = execute_state_machine_response["executionArn"] + + await_execution_terminated( + stepfunctions_client=aws_client.stepfunctions, execution_arn=execution_arn + ) + execution_history_response = sfn.get_execution_history(executionArn=execution_arn) + assert "executionSucceededEventDetails" in execution_history_response["events"][-1] + details = execution_history_response["events"][-1]["executionSucceededEventDetails"] + assert "Hello John" in details["output"] + assert "Hello Lewis" in details["output"] + + @markers.aws.only_localstack + def test_map_anonymous_inner( + self, + aws_client, + create_lambda_function, + ): + state_machine = transpile(""" + LambdaGreet(first_name, last_name) = lambda:invoke where + arguments { + FunctionName: "GreetingFunction", + Payload: { + full_name: jsonata($first_name & " " & $last_name) + } + } + + user_names = ["John", "Lewis"] + all_greetings = for name in jsonata($user_names) where + process { + greet_result = LambdaGreet(first_name=jsonata($name), last_name="value") + greet_value = jsonata($greet_result.Payload) + return jsonata($greet_value) + } + return jsonata($all_greetings) + """) + definition = json.dumps(state_machine) + + sfn = aws_client.stepfunctions + + create_state_machine_response = sfn.create_state_machine( + name=f"autogen-{short_uid()}", + definition=definition, + roleArn="arn:aws:iam::000000000000:role/dummy", + ) + state_machine_arn = create_state_machine_response["stateMachineArn"] + + function_name = "GreetingFunction" + create_lambda_function( + func_name=function_name, + handler_file=ServicesTemplates.LAMBDA_ID_FUNCTION, + runtime=Runtime.python3_12, + ) + + execute_state_machine_response = sfn.start_execution(stateMachineArn=state_machine_arn) + execution_arn = execute_state_machine_response["executionArn"] + + await_execution_terminated( + stepfunctions_client=aws_client.stepfunctions, execution_arn=execution_arn + ) + execution_history_response = sfn.get_execution_history(executionArn=execution_arn) + assert "executionSucceededEventDetails" in execution_history_response["events"][-1] + details = execution_history_response["events"][-1]["executionSucceededEventDetails"] + assert "John" in details["output"] + assert "Lewis" in details["output"] + + @markers.aws.only_localstack + def test_assign_invoke_succeed( + self, + aws_client, + create_lambda_function, + ): + state_machine = transpile(""" + LambdaGreet(first_name, last_name) = lambda:invoke where + arguments { + FunctionName: "GreetingFunction", + Payload: { + full_name: jsonata($first_name & " " & $last_name) + } + } + + user_name = "John" + user_surname = "Smith" + greeting_output = LambdaGreet( + first_name=jsonata($user_name), + last_name=jsonata($user_surname) + ) + payload_value = jsonata($greeting_output.Payload) + return jsonata($payload_value) + """) + definition = json.dumps(state_machine) + + sfn = aws_client.stepfunctions + + create_state_machine_response = sfn.create_state_machine( + name=f"autogen-{short_uid()}", + definition=definition, + roleArn="arn:aws:iam::000000000000:role/dummy", + ) + state_machine_arn = create_state_machine_response["stateMachineArn"] + + function_name = "GreetingFunction" + create_lambda_function( + func_name=function_name, + handler_file=ServicesTemplates.LAMBDA_ID_FUNCTION, + runtime=Runtime.python3_12, + ) + + execute_state_machine_response = sfn.start_execution(stateMachineArn=state_machine_arn) + execution_arn = execute_state_machine_response["executionArn"] + + await_execution_terminated( + stepfunctions_client=aws_client.stepfunctions, execution_arn=execution_arn + ) + execution_history_response = sfn.get_execution_history(executionArn=execution_arn) + assert "executionSucceededEventDetails" in execution_history_response["events"][-1] + details = execution_history_response["events"][-1]["executionSucceededEventDetails"] + assert "John Smith" in details["output"] + + @markers.aws.only_localstack + def test_assign_and_invoke( + self, + aws_client, + create_lambda_function, + ): + state_machine = transpile(""" + LambdaGreet(first_name, last_name) = lambda:invoke where + arguments { + FunctionName: "GreetingFunction", + Payload: { + full_name: jsonata($first_name & " " & $last_name) + } + } + user_name = "John" + user_surname = "Smith" + LambdaGreet( + first_name=jsonata($user_name), + last_name=jsonata($user_surname) + ) + """) + definition = json.dumps(state_machine) + + sfn = aws_client.stepfunctions + + create_state_machine_response = sfn.create_state_machine( + name=f"autogen-{short_uid()}", + definition=definition, + roleArn="arn:aws:iam::000000000000:role/dummy", + ) + state_machine_arn = create_state_machine_response["stateMachineArn"] + + function_name = "GreetingFunction" + create_lambda_function( + func_name=function_name, + handler_file=ServicesTemplates.LAMBDA_RETURN_DECORATED_INPUT, + runtime=Runtime.python3_12, + ) + + execute_state_machine_response = sfn.start_execution(stateMachineArn=state_machine_arn) + execution_arn = execute_state_machine_response["executionArn"] + + await_execution_terminated( + stepfunctions_client=aws_client.stepfunctions, execution_arn=execution_arn + ) + execution_history_response = sfn.get_execution_history(executionArn=execution_arn) + assert "executionSucceededEventDetails" in execution_history_response["events"][-1] + details = execution_history_response["events"][-1]["executionSucceededEventDetails"] + assert "John Smith" in details["output"] + + @markers.aws.only_localstack + def test_assign_and_succeed(self, aws_client): + state_machine = transpile(""" + WorkflowSucceeded(value) = return jsonata($value) + output_message = jsonata("Hello" & " " & "World!") + WorkflowSucceeded(value = jsonata($output_message)) + """) + definition = json.dumps(state_machine) + + sfn = aws_client.stepfunctions + + create_state_machine_response = sfn.create_state_machine( + name=f"autogen-{short_uid()}", + definition=definition, + roleArn="arn:aws:iam::000000000000:role/dummy", + ) + state_machine_arn = create_state_machine_response["stateMachineArn"] + + execute_state_machine_response = sfn.start_execution(stateMachineArn=state_machine_arn) + execution_arn = execute_state_machine_response["executionArn"] + + await_execution_terminated( + stepfunctions_client=aws_client.stepfunctions, execution_arn=execution_arn + ) + execution_history_response = sfn.get_execution_history(executionArn=execution_arn) + assert "executionSucceededEventDetails" in execution_history_response["events"][-1] + details = execution_history_response["events"][-1]["executionSucceededEventDetails"] + assert "Hello World" in details["output"] + + @markers.aws.only_localstack + def test_succeed_template(self, aws_client): + state_machine = transpile(""" + WorkflowSucceeded(value) = return jsonata($value) + WorkflowSucceeded(value = {"message": "string-literal"}) + """) + definition = json.dumps(state_machine) + + sfn = aws_client.stepfunctions + + create_state_machine_response = sfn.create_state_machine( + name=f"autogen-{short_uid()}", + definition=definition, + roleArn="arn:aws:iam::000000000000:role/dummy", + ) + state_machine_arn = create_state_machine_response["stateMachineArn"] + + execute_state_machine_response = sfn.start_execution(stateMachineArn=state_machine_arn) + execution_arn = execute_state_machine_response["executionArn"] + + await_execution_terminated( + stepfunctions_client=aws_client.stepfunctions, execution_arn=execution_arn + ) + execution_history_response = sfn.get_execution_history(executionArn=execution_arn) + assert "executionSucceededEventDetails" in execution_history_response["events"][-1] + details = execution_history_response["events"][-1]["executionSucceededEventDetails"] + assert details["output"] == '{"message":"string-literal"}' + + @markers.aws.only_localstack + def test_succeed_inplace(self, aws_client): + state_machine = transpile(""" + WorkflowSucceeded as return jsonata('string' & ' ' & 'literal') + """) + definition = json.dumps(state_machine) + + sfn = aws_client.stepfunctions + + create_state_machine_response = sfn.create_state_machine( + name=f"autogen-{short_uid()}", + definition=definition, + roleArn="arn:aws:iam::000000000000:role/dummy", + ) + state_machine_arn = create_state_machine_response["stateMachineArn"] + + execute_state_machine_response = sfn.start_execution(stateMachineArn=state_machine_arn) + execution_arn = execute_state_machine_response["executionArn"] + + await_execution_terminated( + stepfunctions_client=aws_client.stepfunctions, execution_arn=execution_arn + ) + execution_history_response = sfn.get_execution_history(executionArn=execution_arn) + assert "executionSucceededEventDetails" in execution_history_response["events"][-1] + details = execution_history_response["events"][-1]["executionSucceededEventDetails"] + assert details["output"] == '"string literal"' + + @markers.aws.only_localstack + def test_succeed_anonymous_inplace(self, aws_client): + state_machine = transpile(""" + return jsonata('string' & ' ' & 'literal') + """) + definition = json.dumps(state_machine) + + sfn = aws_client.stepfunctions + + create_state_machine_response = sfn.create_state_machine( + name=f"autogen-{short_uid()}", + definition=definition, + roleArn="arn:aws:iam::000000000000:role/dummy", + ) + state_machine_arn = create_state_machine_response["stateMachineArn"] + + execute_state_machine_response = sfn.start_execution(stateMachineArn=state_machine_arn) + execution_arn = execute_state_machine_response["executionArn"] + + await_execution_terminated( + stepfunctions_client=aws_client.stepfunctions, execution_arn=execution_arn + ) + execution_history_response = sfn.get_execution_history(executionArn=execution_arn) + assert "executionSucceededEventDetails" in execution_history_response["events"][-1] + details = execution_history_response["events"][-1]["executionSucceededEventDetails"] + assert details["output"] == '"string literal"' + + @markers.aws.only_localstack + def test_lambda_invoke_anonymous_inplace( + self, + aws_client, + create_lambda_function, + ): + state_machine = transpile(""" + lambda:invoke where + arguments { + FunctionName: "GreetingFunction", + Payload: { + full_name: jsonata('John' & " " & 'Smith') + } + } + """) + definition = json.dumps(state_machine) + + sfn = aws_client.stepfunctions + + create_state_machine_response = sfn.create_state_machine( + name=f"autogen-{short_uid()}", + definition=definition, + roleArn="arn:aws:iam::000000000000:role/dummy", + ) + state_machine_arn = create_state_machine_response["stateMachineArn"] + + function_name = "GreetingFunction" + create_lambda_function( + func_name=function_name, + handler_file=ServicesTemplates.LAMBDA_RETURN_DECORATED_INPUT, + runtime=Runtime.python3_12, + ) + + execute_state_machine_response = sfn.start_execution(stateMachineArn=state_machine_arn) + execution_arn = execute_state_machine_response["executionArn"] + + await_execution_terminated( + stepfunctions_client=aws_client.stepfunctions, execution_arn=execution_arn + ) + execution_history_response = sfn.get_execution_history(executionArn=execution_arn) + assert "executionSucceededEventDetails" in execution_history_response["events"][-1] + + @markers.aws.only_localstack + def test_lambda_invoke_named_inplace( + self, + aws_client, + create_lambda_function, + ): + state_machine = transpile(""" + LambdaGreet as lambda:invoke where + arguments { + FunctionName: "GreetingFunction", + Payload: { + full_name: jsonata('John' & " " & 'Smith') + } + } + """) + definition = json.dumps(state_machine) + + sfn = aws_client.stepfunctions + + create_state_machine_response = sfn.create_state_machine( + name=f"autogen-{short_uid()}", + definition=definition, + roleArn="arn:aws:iam::000000000000:role/dummy", + ) + state_machine_arn = create_state_machine_response["stateMachineArn"] + + function_name = "GreetingFunction" + create_lambda_function( + func_name=function_name, + handler_file=ServicesTemplates.LAMBDA_RETURN_DECORATED_INPUT, + runtime=Runtime.python3_12, + ) + + execute_state_machine_response = sfn.start_execution(stateMachineArn=state_machine_arn) + execution_arn = execute_state_machine_response["executionArn"] + + await_execution_terminated( + stepfunctions_client=aws_client.stepfunctions, execution_arn=execution_arn + ) + execution_history_response = sfn.get_execution_history(executionArn=execution_arn) + assert "executionSucceededEventDetails" in execution_history_response["events"][-1] + + @markers.aws.only_localstack + def test_lambda_invoke( + self, + aws_client, + create_lambda_function, + ): + state_machine = transpile(""" + LambdaGreet(first_name, last_name) = lambda:invoke where + arguments { + FunctionName: "GreetingFunction", + Payload: { + full_name: jsonata($first_name & " " & $last_name) + } + } + + LambdaGreet(first_name="John", last_name="Smith") + LambdaGreet(first_name="second", last_name="s") # create a copy of the target on demand! + """) + definition = json.dumps(state_machine) + + sfn = aws_client.stepfunctions + + create_state_machine_response = sfn.create_state_machine( + name=f"autogen-{short_uid()}", + definition=definition, + roleArn="arn:aws:iam::000000000000:role/dummy", + ) + state_machine_arn = create_state_machine_response["stateMachineArn"] + + function_name = "GreetingFunction" + create_lambda_function( + func_name=function_name, + handler_file=ServicesTemplates.LAMBDA_RETURN_DECORATED_INPUT, + runtime=Runtime.python3_12, + ) + + execute_state_machine_response = sfn.start_execution(stateMachineArn=state_machine_arn) + execution_arn = execute_state_machine_response["executionArn"] + + await_execution_terminated( + stepfunctions_client=aws_client.stepfunctions, execution_arn=execution_arn + ) + execution_history_response = sfn.get_execution_history(executionArn=execution_arn) + assert "executionSucceededEventDetails" in execution_history_response["events"][-1]