From 8191cd5615c8c22db748214f34fa7b967deb0a7f Mon Sep 17 00:00:00 2001 From: ascandone Date: Tue, 4 Feb 2025 19:33:12 +0100 Subject: [PATCH] Implemented account interpolation fix, finally renamed antlr module quick and dirty, but wrong maybe we're almost there impl account interpolation run diagnostic on interp str fix stupid pointers error --- Lexer.g4 | 57 ++ Numscript.g4 | 71 +- generate-parser.sh | 3 +- internal/analysis/check.go | 17 +- internal/analysis/check_test.go | 50 + internal/analysis/hover.go | 11 + internal/analysis/hover_test.go | 27 + internal/interpreter/evaluate_expr.go | 40 +- internal/interpreter/interpreter_error.go | 9 + internal/interpreter/interpreter_test.go | 30 + .../parser_fault_tolerance_test.snap | 38 +- .../parser/__snapshots__/parser_test.snap | 401 ++++++-- internal/parser/antlr/Numscript.interp | 104 -- internal/parser/antlr/Numscript.tokens | 62 -- internal/parser/antlr/NumscriptLexer.interp | 128 --- internal/parser/antlr/NumscriptLexer.tokens | 62 -- internal/parser/antlr/numscript_lexer.go | 300 ------ internal/parser/antlrParser/Lexer.interp | 139 +++ internal/parser/antlrParser/Lexer.tokens | 67 ++ internal/parser/antlrParser/Numscript.interp | 111 +++ internal/parser/antlrParser/Numscript.tokens | 67 ++ internal/parser/antlrParser/lexer.go | 314 ++++++ .../numscript_base_listener.go | 15 +- .../numscript_listener.go | 15 +- .../numscript_parser.go | 929 ++++++++++++------ internal/parser/ast.go | 54 +- internal/parser/parser.go | 161 +-- internal/parser/parser_test.go | 18 + 28 files changed, 2053 insertions(+), 1247 deletions(-) create mode 100644 Lexer.g4 delete mode 100644 internal/parser/antlr/Numscript.interp delete mode 100644 internal/parser/antlr/Numscript.tokens delete mode 100644 internal/parser/antlr/NumscriptLexer.interp delete mode 100644 internal/parser/antlr/NumscriptLexer.tokens delete mode 100644 internal/parser/antlr/numscript_lexer.go create mode 100644 internal/parser/antlrParser/Lexer.interp create mode 100644 internal/parser/antlrParser/Lexer.tokens create mode 100644 internal/parser/antlrParser/Numscript.interp create mode 100644 internal/parser/antlrParser/Numscript.tokens create mode 100644 internal/parser/antlrParser/lexer.go rename internal/parser/{antlr => antlrParser}/numscript_base_listener.go (95%) rename internal/parser/{antlr => antlrParser}/numscript_listener.go (94%) rename internal/parser/{antlr => antlrParser}/numscript_parser.go (83%) diff --git a/Lexer.g4 b/Lexer.g4 new file mode 100644 index 00000000..73f68102 --- /dev/null +++ b/Lexer.g4 @@ -0,0 +1,57 @@ +lexer grammar Lexer; +WS: [ \t\r\n]+ -> skip; +NEWLINE: [\r\n]+; +MULTILINE_COMMENT: '/*' (MULTILINE_COMMENT | .)*? '*/' -> skip; +LINE_COMMENT: '//' .*? NEWLINE -> skip; + +VARS: 'vars'; +MAX: 'max'; +SOURCE: 'source'; +DESTINATION: 'destination'; +SEND: 'send'; +FROM: 'from'; +UP: 'up'; +TO: 'to'; +REMAINING: 'remaining'; +ALLOWING: 'allowing'; +UNBOUNDED: 'unbounded'; +OVERDRAFT: 'overdraft'; +KEPT: 'kept'; +SAVE: 'save'; +LPARENS: '('; +RPARENS: ')'; +LBRACKET: '['; +RBRACKET: ']'; +LBRACE: '{'; +RBRACE: '}'; +COMMA: ','; +EQ: '='; +STAR: '*'; +PLUS: '+'; +MINUS: '-'; + +RATIO_PORTION_LITERAL: [0-9]+ [ ]? '/' [ ]? [0-9]+; +PERCENTAGE_PORTION_LITERAL: [0-9]+ ('.' [0-9]+)? '%'; + +STRING: '"' ('\\"' | ~[\r\n"])* '"'; + +IDENTIFIER: [a-z]+ [a-z_]*; +NUMBER: MINUS? [0-9]+ ('_' [0-9]+)*; +// VARIABLE_NAME: '$' [a-z_]+ [a-z0-9_]*; + +ASSET: [A-Z/0-9]+; + +ACCOUNT_START: '@' -> pushMode(ACCOUNT_MODE); +COLON: ':' -> pushMode(ACCOUNT_MODE); +// fragment ACCOUNT_FRAGMENT_PART: [a-zA-Z0-9_-]+ | VARIABLE_NAME; ACCOUNT: '@' [a-zA-Z0-9_-]+ (':' +// ACCOUNT_FRAGMENT_PART)*; + +fragment VARIABLE_NAME_FRAMGMENT: '$' [a-z_]+ [a-z0-9_]*; + +mode ACCOUNT_MODE; + +ACCOUNT_TEXT: [a-zA-Z0-9_-]+ -> popMode; +VARIABLE_NAME_ACC: VARIABLE_NAME_FRAMGMENT -> popMode; + +mode DEFAULT_MODE; +VARIABLE_NAME_DEFAULT: VARIABLE_NAME_FRAMGMENT; \ No newline at end of file diff --git a/Numscript.g4 b/Numscript.g4 index bec09e6b..8ed837f3 100644 --- a/Numscript.g4 +++ b/Numscript.g4 @@ -1,46 +1,9 @@ grammar Numscript; // Tokens -WS: [ \t\r\n]+ -> skip; -NEWLINE: [\r\n]+; -MULTILINE_COMMENT: '/*' (MULTILINE_COMMENT | .)*? '*/' -> skip; -LINE_COMMENT: '//' .*? NEWLINE -> skip; - -VARS: 'vars'; -MAX: 'max'; -SOURCE: 'source'; -DESTINATION: 'destination'; -SEND: 'send'; -FROM: 'from'; -UP: 'up'; -TO: 'to'; -REMAINING: 'remaining'; -ALLOWING: 'allowing'; -UNBOUNDED: 'unbounded'; -OVERDRAFT: 'overdraft'; -KEPT: 'kept'; -SAVE: 'save'; -LPARENS: '('; -RPARENS: ')'; -LBRACKET: '['; -RBRACKET: ']'; -LBRACE: '{'; -RBRACE: '}'; -COMMA: ','; -EQ: '='; -STAR: '*'; -MINUS: '-'; - -RATIO_PORTION_LITERAL: [0-9]+ [ ]? '/' [ ]? [0-9]+; -PERCENTAGE_PORTION_LITERAL: [0-9]+ ('.' [0-9]+)? '%'; - -STRING: '"' ('\\"' | ~[\r\n"])* '"'; - -IDENTIFIER: [a-z]+ [a-z_]*; -NUMBER: MINUS? [0-9]+ ('_' [0-9]+)*; -VARIABLE_NAME: '$' [a-z_]+ [a-z0-9_]*; -ACCOUNT: '@' [a-zA-Z0-9_-]+ (':' [a-zA-Z0-9_-]+)*; -ASSET: [A-Z/0-9]+; +options { + tokenVocab = 'Lexer'; +} monetaryLit: LBRACKET (asset = valueExpr) (amt = valueExpr) RBRACKET; @@ -49,15 +12,19 @@ portion: RATIO_PORTION_LITERAL # ratio | PERCENTAGE_PORTION_LITERAL # percentage; +accountLiteralPart: + ACCOUNT_TEXT # accountTextPart + | VARIABLE_NAME_ACC # accountVarPart; + valueExpr: - VARIABLE_NAME # variableExpr - | ASSET # assetLiteral - | STRING # stringLiteral - | ACCOUNT # accountLiteral - | NUMBER # numberLiteral - | monetaryLit # monetaryLiteral - | portion # portionLiteral - | left = valueExpr op = ('+' | '-') right = valueExpr # infixExpr; + VARIABLE_NAME_DEFAULT # variableExpr + | ASSET # assetLiteral + | STRING # stringLiteral + | ACCOUNT_START accountLiteralPart (COLON accountLiteralPart)* # accountLiteral + | NUMBER # numberLiteral + | monetaryLit # monetaryLiteral + | portion # portionLiteral + | left = valueExpr op = (PLUS | MINUS) right = valueExpr # infixExpr; functionCallArgs: valueExpr ( COMMA valueExpr)*; functionCall: @@ -65,7 +32,7 @@ functionCall: varOrigin: EQ functionCall; varDeclaration: - type_ = IDENTIFIER name = VARIABLE_NAME varOrigin?; + type_ = IDENTIFIER name = VARIABLE_NAME_DEFAULT varOrigin?; varsDeclaration: VARS LBRACE varDeclaration* RBRACE; program: varsDeclaration? statement* EOF; @@ -73,9 +40,9 @@ program: varsDeclaration? statement* EOF; sentAllLit: LBRACKET (asset = valueExpr) STAR RBRACKET; allotment: - portion # portionedAllotment - | VARIABLE_NAME # portionVariable - | REMAINING # remainingAllotment; + portion # portionedAllotment + | VARIABLE_NAME_DEFAULT # portionVariable + | REMAINING # remainingAllotment; source: address = valueExpr ALLOWING UNBOUNDED OVERDRAFT # srcAccountUnboundedOverdraft diff --git a/generate-parser.sh b/generate-parser.sh index c2869e49..d24e180f 100644 --- a/generate-parser.sh +++ b/generate-parser.sh @@ -1 +1,2 @@ -antlr4 -Dlanguage=Go Numscript.g4 -o internal/parser/antlr +antlr4 -Dlanguage=Go Lexer.g4 Numscript.g4 -o internal/parser/antlrParser -package antlrParser +mv internal/parser/antlrParser/_lexer.go internal/parser/antlrParser/lexer.go diff --git a/internal/analysis/check.go b/internal/analysis/check.go index eeb4717d..b281cb01 100644 --- a/internal/analysis/check.go +++ b/internal/analysis/check.go @@ -358,7 +358,12 @@ func (res *CheckResult) checkExpression(lit parser.ValueExpr, requiredType strin res.assertHasType(lit, requiredType, TypeMonetary) res.checkExpression(lit.Asset, TypeAsset) res.checkExpression(lit.Amount, TypeNumber) - case *parser.AccountLiteral: + case *parser.AccountInterpLiteral: + for _, part := range lit.Parts { + if v, ok := part.(*parser.Variable); ok { + res.checkExpression(v, TypeAny) + } + } res.assertHasType(lit, requiredType, TypeAccount) case *parser.RatioLiteral: res.assertHasType(lit, requiredType, TypePortion) @@ -413,7 +418,7 @@ func (res *CheckResult) checkSource(source parser.Source) { switch source := source.(type) { case *parser.SourceAccount: res.checkExpression(source.ValueExpr, TypeAccount) - if account, ok := source.ValueExpr.(*parser.AccountLiteral); ok { + if account, ok := source.ValueExpr.(*parser.AccountInterpLiteral); ok { if account.IsWorld() && res.unboundedSend { res.Diagnostics = append(res.Diagnostics, Diagnostic{ Range: source.GetRange(), @@ -423,18 +428,18 @@ func (res *CheckResult) checkSource(source parser.Source) { res.unboundedAccountInSend = account } - if _, emptied := res.emptiedAccount[account.Name]; emptied && !account.IsWorld() { + if _, emptied := res.emptiedAccount[account.String()]; emptied && !account.IsWorld() { res.Diagnostics = append(res.Diagnostics, Diagnostic{ - Kind: &EmptiedAccount{Name: account.Name}, + Kind: &EmptiedAccount{Name: account.String()}, Range: account.Range, }) } - res.emptiedAccount[account.Name] = struct{}{} + res.emptiedAccount[account.String()] = struct{}{} } case *parser.SourceOverdraft: - if accountLiteral, ok := source.Address.(*parser.AccountLiteral); ok && accountLiteral.IsWorld() { + if accountLiteral, ok := source.Address.(*parser.AccountInterpLiteral); ok && accountLiteral.IsWorld() { res.Diagnostics = append(res.Diagnostics, Diagnostic{ Range: accountLiteral.Range, Kind: &InvalidWorldOverdraft{}, diff --git a/internal/analysis/check_test.go b/internal/analysis/check_test.go index c069320c..20ff80d1 100644 --- a/internal/analysis/check_test.go +++ b/internal/analysis/check_test.go @@ -344,6 +344,56 @@ send [EUR/2 $n] ( ) } +func TestNoUnusedOnStringInterp(t *testing.T) { + t.Parallel() + + input := `vars { number $id } + +send [EUR/2 *] ( + source = @user:$id:pending + destination = @dest +)` + + program := parser.Parse(input).Value + + diagnostics := analysis.CheckProgram(program).Diagnostics + require.Empty(t, diagnostics) + +} + +func TestWrongTypeInsideAccountInterp(t *testing.T) { + t.Skip("TODO formalize a better type system to model this easy") + + t.Parallel() + + input := `vars { monetary $m } + +send [EUR/2 *] ( + source = @user:$m + destination = @dest +)` + + program := parser.Parse(input).Value + + diagnostics := analysis.CheckProgram(program).Diagnostics + + require.Len(t, diagnostics, 1, "diagnostics=%#v\n", diagnostics) + + d1 := diagnostics[0] + assert.Equal(t, + &analysis.TypeMismatch{ + Expected: "number|account|string", + Got: "monetary", + }, + d1.Kind, + ) + + assert.Equal(t, + parser.RangeOfIndexed(input, "$n", 1), + d1.Range, + ) +} + func TestWrongTypeForCap(t *testing.T) { t.Parallel() diff --git a/internal/analysis/hover.go b/internal/analysis/hover.go index 56ae6737..0eb22d4f 100644 --- a/internal/analysis/hover.go +++ b/internal/analysis/hover.go @@ -145,6 +145,17 @@ func hoverOnExpression(lit parser.ValueExpr, position parser.Position) Hover { } switch lit := lit.(type) { + case *parser.AccountInterpLiteral: + for _, part := range lit.Parts { + if v, ok := part.(*parser.Variable); ok { + + hover := hoverOnExpression(v, position) + if hover != nil { + return hover + } + } + } + case *parser.Variable: return &VariableHover{ Range: lit.Range, diff --git a/internal/analysis/hover_test.go b/internal/analysis/hover_test.go index ba5cf943..3a7328b0 100644 --- a/internal/analysis/hover_test.go +++ b/internal/analysis/hover_test.go @@ -181,6 +181,33 @@ send [C 10] ( require.NotNil(t, resolved) } +func TestHoverOnStringInterp(t *testing.T) { + input := `vars { number $id } + +send [ASSET *] ( + source = @world + destination = @user:$id +) +` + + rng := parser.RangeOfIndexed(input, "$id", 1) + + program := parser.Parse(input).Value + hover := analysis.HoverOn(program, rng.Start) + require.NotNil(t, hover) + + variableHover, ok := hover.(*analysis.VariableHover) + require.True(t, ok, "Expected VariableHover") + + require.Equal(t, rng, variableHover.Range) + + checkResult := analysis.CheckProgram(program) + require.NotNil(t, variableHover.Node) + + resolved := checkResult.ResolveVar(variableHover.Node) + require.NotNil(t, resolved) +} + func TestHoverOnDestinationInorderRemaining(t *testing.T) { input := `vars { account $dest } diff --git a/internal/interpreter/evaluate_expr.go b/internal/interpreter/evaluate_expr.go index 4c5db739..fabacee2 100644 --- a/internal/interpreter/evaluate_expr.go +++ b/internal/interpreter/evaluate_expr.go @@ -2,6 +2,7 @@ package interpreter import ( "math/big" + "strings" "github.com/formancehq/numscript/internal/parser" "github.com/formancehq/numscript/internal/utils" @@ -11,8 +12,28 @@ func (st *programState) evaluateExpr(expr parser.ValueExpr) (Value, InterpreterE switch expr := expr.(type) { case *parser.AssetLiteral: return Asset(expr.Asset), nil - case *parser.AccountLiteral: - return AccountAddress(expr.Name), nil + case *parser.AccountInterpLiteral: + var parts []string + for _, part := range expr.Parts { + switch part := part.(type) { + case parser.AccountTextPart: + parts = append(parts, part.Name) + case *parser.Variable: + value, err := st.evaluateExpr(part) + if err != nil { + return nil, err + } + strValue, err := castToString(value, expr.Range) + if err != nil { + return nil, err + } + parts = append(parts, strValue) + } + } + name := strings.Join(parts, ":") + // TODO validate valid names + return AccountAddress(name), nil + case *parser.StringLiteral: return String(expr.String), nil case *parser.RatioLiteral: @@ -124,3 +145,18 @@ func (st *programState) subOp(left parser.ValueExpr, right parser.ValueExpr) (Va return (*leftValue).evalSub(st, right) } + +func castToString(v Value, rng parser.Range) (string, InterpreterError) { + switch v := v.(type) { + case AccountAddress: + return v.String(), nil + case String: + return v.String(), nil + case MonetaryInt: + return v.String(), nil + + default: + // No asset nor ratio can be implicitly cast to string + return "", CannotCastToString{Value: v, Range: rng} + } +} diff --git a/internal/interpreter/interpreter_error.go b/internal/interpreter/interpreter_error.go index c819f1a4..186e3dce 100644 --- a/internal/interpreter/interpreter_error.go +++ b/internal/interpreter/interpreter_error.go @@ -193,3 +193,12 @@ type ExperimentalFeature struct { func (e ExperimentalFeature) Error() string { return fmt.Sprintf("this feature is experimental. You need the '%s' feature flag to enable it", e.FlagName) } + +type CannotCastToString struct { + parser.Range + Value Value +} + +func (e CannotCastToString) Error() string { + return fmt.Sprintf("Cannot cast this value to string: %s", e.Value) +} diff --git a/internal/interpreter/interpreter_test.go b/internal/interpreter/interpreter_test.go index 8a200fb1..de6864b0 100644 --- a/internal/interpreter/interpreter_test.go +++ b/internal/interpreter/interpreter_test.go @@ -3543,3 +3543,33 @@ func TestSubMonetaries(t *testing.T) { } test(t, tc) } + +func TestAccountInterp(t *testing.T) { + script := ` + vars { + number $id + string $status + account $acc + } + set_tx_meta("k", @acc:$id:$status:$acc) + ` + + tc := NewTestCase() + tc.setVarsFromJSON(t, ` + { + "id": "42", + "status": "pending", + "acc": "user:001" + } + `) + + tc.compile(t, script) + + tc.expected = CaseResult{ + Postings: []Posting{}, + TxMetadata: map[string]machine.Value{ + "k": machine.AccountAddress("acc:42:pending:user:001"), + }, + } + test(t, tc) +} diff --git a/internal/parser/__snapshots__/parser_fault_tolerance_test.snap b/internal/parser/__snapshots__/parser_fault_tolerance_test.snap index cbe089ec..926f4b12 100755 --- a/internal/parser/__snapshots__/parser_fault_tolerance_test.snap +++ b/internal/parser/__snapshots__/parser_fault_tolerance_test.snap @@ -63,15 +63,29 @@ parser.Program{ &parser.SendStatement{ Range: parser.Range{ Start: parser.Position{}, - End: parser.Position{Character:1, Line:5}, + End: parser.Position{Character:17, Line:4}, }, SentValue: nil, Source: &parser.SourceInorder{ Range: parser.Range{ Start: parser.Position{Character:11, Line:1}, - End: parser.Position{Character:3, Line:3}, + End: parser.Position{Character:17, Line:4}, + }, + Sources: { + &parser.SourceAccount{ + ValueExpr: &parser.AccountInterpLiteral{ + Range: parser.Range{ + Start: parser.Position{Character:1, Line:2}, + End: parser.Position{Character:13, Line:4}, + }, + Parts: { + parser.AccountTextPart{Name:"destination"}, + }, + }, + }, + nil, + nil, }, - Sources: nil, }, Destination: nil, }, @@ -115,12 +129,14 @@ parser.Program{ }, }, Source: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:13, Line:1}, End: parser.Position{Character:15, Line:1}, }, - Name: "a", + Parts: { + parser.AccountTextPart{Name:"a"}, + }, }, }, Destination: nil, @@ -173,12 +189,14 @@ parser.Program{ Cap: nil, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:18, Line:2}, End: parser.Position{Character:20, Line:2}, }, - Name: "d", + Parts: { + parser.AccountTextPart{Name:"d"}, + }, }, }, }, @@ -253,12 +271,14 @@ parser.Program{ }, }, Source: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:11, Line:1}, End: parser.Position{Character:13, Line:1}, }, - Name: "a", + Parts: { + parser.AccountTextPart{Name:"a"}, + }, }, }, Destination: &parser.DestinationInorder{ diff --git a/internal/parser/__snapshots__/parser_test.snap b/internal/parser/__snapshots__/parser_test.snap index 78f2bc2e..85028791 100755 --- a/internal/parser/__snapshots__/parser_test.snap +++ b/internal/parser/__snapshots__/parser_test.snap @@ -34,21 +34,25 @@ parser.Program{ }, }, Source: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:11, Line:1}, End: parser.Position{Character:15, Line:1}, }, - Name: "src", + Parts: { + parser.AccountTextPart{Name:"src"}, + }, }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:16, Line:2}, End: parser.Position{Character:21, Line:2}, }, - Name: "dest", + Parts: { + parser.AccountTextPart{Name:"dest"}, + }, }, }, }, @@ -175,24 +179,28 @@ parser.Program{ }, }, From: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:22, Line:1}, End: parser.Position{Character:25, Line:1}, }, - Name: "s1", + Parts: { + parser.AccountTextPart{Name:"s1"}, + }, }, }, }, }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:16, Line:2}, End: parser.Position{Character:18, Line:2}, }, - Name: "d", + Parts: { + parser.AccountTextPart{Name:"d"}, + }, }, }, }, @@ -261,12 +269,14 @@ parser.Program{ }, }, From: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:13, Line:2}, End: parser.Position{Character:16, Line:2}, }, - Name: "s1", + Parts: { + parser.AccountTextPart{Name:"s1"}, + }, }, }, }, @@ -290,12 +300,14 @@ parser.Program{ }, }, From: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:10, Line:3}, End: parser.Position{Character:13, Line:3}, }, - Name: "s2", + Parts: { + parser.AccountTextPart{Name:"s2"}, + }, }, }, }, @@ -311,24 +323,28 @@ parser.Program{ }, }, From: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:16, Line:4}, End: parser.Position{Character:19, Line:4}, }, - Name: "s3", + Parts: { + parser.AccountTextPart{Name:"s3"}, + }, }, }, }, }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:16, Line:6}, End: parser.Position{Character:18, Line:6}, }, - Name: "d", + Parts: { + parser.AccountTextPart{Name:"d"}, + }, }, }, }, @@ -397,24 +413,28 @@ parser.Program{ }, }, From: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:24, Line:1}, End: parser.Position{Character:26, Line:1}, }, - Name: "s", + Parts: { + parser.AccountTextPart{Name:"s"}, + }, }, }, }, }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:16, Line:2}, End: parser.Position{Character:18, Line:2}, }, - Name: "d", + Parts: { + parser.AccountTextPart{Name:"d"}, + }, }, }, }, @@ -458,12 +478,14 @@ parser.Program{ }, }, Source: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:11, Line:1}, End: parser.Position{Character:13, Line:1}, }, - Name: "s", + Parts: { + parser.AccountTextPart{Name:"s"}, + }, }, }, Destination: &parser.DestinationAllotment{ @@ -493,12 +515,14 @@ parser.Program{ }, To: &parser.DestinationTo{ Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:25, Line:2}, End: parser.Position{Character:27, Line:2}, }, - Name: "d", + Parts: { + parser.AccountTextPart{Name:"d"}, + }, }, }, }, @@ -551,12 +575,14 @@ parser.Program{ End: parser.Position{Character:35, Line:1}, }, From: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:31, Line:1}, End: parser.Position{Character:35, Line:1}, }, - Name: "src", + Parts: { + parser.AccountTextPart{Name:"src"}, + }, }, }, Cap: &parser.MonetaryLiteral{ @@ -581,12 +607,14 @@ parser.Program{ }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:16, Line:2}, End: parser.Position{Character:21, Line:2}, }, - Name: "dest", + Parts: { + parser.AccountTextPart{Name:"dest"}, + }, }, }, }, @@ -635,12 +663,14 @@ parser.Program{ End: parser.Position{Character:32, Line:1}, }, From: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:28, Line:1}, End: parser.Position{Character:32, Line:1}, }, - Name: "src", + Parts: { + parser.AccountTextPart{Name:"src"}, + }, }, }, Cap: &parser.Variable{ @@ -652,12 +682,14 @@ parser.Program{ }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:16, Line:2}, End: parser.Position{Character:21, Line:2}, }, - Name: "dest", + Parts: { + parser.AccountTextPart{Name:"dest"}, + }, }, }, }, @@ -712,12 +744,14 @@ parser.Program{ End: parser.Position{Character:27, Line:2}, }, From: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:23, Line:2}, End: parser.Position{Character:27, Line:2}, }, - Name: "src", + Parts: { + parser.AccountTextPart{Name:"src"}, + }, }, }, Cap: &parser.MonetaryLiteral{ @@ -742,32 +776,38 @@ parser.Program{ }, }, &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:1, Line:3}, End: parser.Position{Character:3, Line:3}, }, - Name: "a", + Parts: { + parser.AccountTextPart{Name:"a"}, + }, }, }, &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:1, Line:4}, End: parser.Position{Character:3, Line:4}, }, - Name: "b", + Parts: { + parser.AccountTextPart{Name:"b"}, + }, }, }, }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:16, Line:6}, End: parser.Position{Character:21, Line:6}, }, - Name: "dest", + Parts: { + parser.AccountTextPart{Name:"dest"}, + }, }, }, }, @@ -811,21 +851,25 @@ parser.Program{ }, }, Source: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:27, Line:1}, End: parser.Position{Character:31, Line:1}, }, - Name: "src", + Parts: { + parser.AccountTextPart{Name:"src"}, + }, }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:46, Line:1}, End: parser.Position{Character:51, Line:1}, }, - Name: "dest", + Parts: { + parser.AccountTextPart{Name:"dest"}, + }, }, }, }, @@ -861,21 +905,25 @@ parser.Program{ }, }, Source: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:27, Line:2}, End: parser.Position{Character:31, Line:2}, }, - Name: "src", + Parts: { + parser.AccountTextPart{Name:"src"}, + }, }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:46, Line:2}, End: parser.Position{Character:51, Line:2}, }, - Name: "dest", + Parts: { + parser.AccountTextPart{Name:"dest"}, + }, }, }, }, @@ -938,21 +986,25 @@ parser.Program{ }, }, Source: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:11, Line:1}, End: parser.Position{Character:13, Line:1}, }, - Name: "a", + Parts: { + parser.AccountTextPart{Name:"a"}, + }, }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:16, Line:2}, End: parser.Position{Character:18, Line:2}, }, - Name: "b", + Parts: { + parser.AccountTextPart{Name:"b"}, + }, }, }, }, @@ -996,12 +1048,14 @@ parser.Program{ }, }, Source: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:11, Line:1}, End: parser.Position{Character:13, Line:1}, }, - Name: "s", + Parts: { + parser.AccountTextPart{Name:"s"}, + }, }, }, Destination: &parser.DestinationAllotment{ @@ -1031,12 +1085,14 @@ parser.Program{ }, To: &parser.DestinationTo{ Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:10, Line:3}, End: parser.Position{Character:12, Line:3}, }, - Name: "d", + Parts: { + parser.AccountTextPart{Name:"d"}, + }, }, }, }, @@ -1054,12 +1110,14 @@ parser.Program{ }, To: &parser.DestinationTo{ Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:14, Line:4}, End: parser.Position{Character:17, Line:4}, }, - Name: "d2", + Parts: { + parser.AccountTextPart{Name:"d2"}, + }, }, }, }, @@ -1125,24 +1183,28 @@ parser.Program{ Name: "x", }, From: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:9, Line:2}, End: parser.Position{Character:11, Line:2}, }, - Name: "a", + Parts: { + parser.AccountTextPart{Name:"a"}, + }, }, }, }, }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:16, Line:4}, End: parser.Position{Character:18, Line:4}, }, - Name: "d", + Parts: { + parser.AccountTextPart{Name:"d"}, + }, }, }, }, @@ -1177,22 +1239,26 @@ parser.Program{ Start: parser.Position{Character:10, Line:1}, End: parser.Position{Character:43, Line:1}, }, - Address: &parser.AccountLiteral{ + Address: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:10, Line:1}, End: parser.Position{Character:14, Line:1}, }, - Name: "src", + Parts: { + parser.AccountTextPart{Name:"src"}, + }, }, Bounded: (*parser.ValueExpr)(nil), }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:15, Line:2}, End: parser.Position{Character:20, Line:2}, }, - Name: "dest", + Parts: { + parser.AccountTextPart{Name:"dest"}, + }, }, }, }, @@ -1237,12 +1303,14 @@ parser.Program{ Bounded: (*parser.ValueExpr)(nil), }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:15, Line:2}, End: parser.Position{Character:20, Line:2}, }, - Name: "dest", + Parts: { + parser.AccountTextPart{Name:"dest"}, + }, }, }, }, @@ -1306,12 +1374,14 @@ parser.Program{ }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:15, Line:2}, End: parser.Position{Character:20, Line:2}, }, - Name: "dest", + Parts: { + parser.AccountTextPart{Name:"dest"}, + }, }, }, }, @@ -1358,12 +1428,14 @@ parser.Program{ Name: "example_fn", }, Args: { - &parser.AccountLiteral{ + &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:11, Line:0}, End: parser.Position{Character:19, Line:0}, }, - Name: "example", + Parts: { + parser.AccountTextPart{Name:"example"}, + }, }, }, }, @@ -1484,12 +1556,14 @@ parser.Program{ Name: "origin_fn", }, Args: { - &parser.AccountLiteral{ + &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:30, Line:2}, End: parser.Position{Character:41, Line:2}, }, - Name: "my_account", + Parts: { + parser.AccountTextPart{Name:"my_account"}, + }, }, &parser.StringLiteral{ Range: parser.Range{ @@ -1548,32 +1622,38 @@ parser.Program{ }, Sources: { &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:13, Line:1}, End: parser.Position{Character:16, Line:1}, }, - Name: "s1", + Parts: { + parser.AccountTextPart{Name:"s1"}, + }, }, }, &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:17, Line:1}, End: parser.Position{Character:20, Line:1}, }, - Name: "s2", + Parts: { + parser.AccountTextPart{Name:"s2"}, + }, }, }, }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:16, Line:2}, End: parser.Position{Character:18, Line:2}, }, - Name: "d", + Parts: { + parser.AccountTextPart{Name:"d"}, + }, }, }, }, @@ -1604,12 +1684,14 @@ parser.Program{ }, }, Source: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:11, Line:1}, End: parser.Position{Character:13, Line:1}, }, - Name: "s", + Parts: { + parser.AccountTextPart{Name:"s"}, + }, }, }, Destination: &parser.DestinationInorder{ @@ -1632,12 +1714,14 @@ parser.Program{ }, To: &parser.DestinationTo{ Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:12, Line:3}, End: parser.Position{Character:15, Line:3}, }, - Name: "d1", + Parts: { + parser.AccountTextPart{Name:"d1"}, + }, }, }, }, @@ -1677,12 +1761,14 @@ parser.Program{ }, Remaining: &parser.DestinationTo{ Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:14, Line:5}, End: parser.Position{Character:17, Line:5}, }, - Name: "d3", + Parts: { + parser.AccountTextPart{Name:"d3"}, + }, }, }, }, @@ -1715,21 +1801,25 @@ parser.Program{ }, }, Source: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:10, Line:1}, End: parser.Position{Character:12, Line:1}, }, - Name: "a", + Parts: { + parser.AccountTextPart{Name:"a"}, + }, }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:15, Line:2}, End: parser.Position{Character:17, Line:2}, }, - Name: "b", + Parts: { + parser.AccountTextPart{Name:"b"}, + }, }, }, }, @@ -1773,12 +1863,14 @@ parser.Program{ }, }, Source: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:11, Line:1}, End: parser.Position{Character:13, Line:1}, }, - Name: "s", + Parts: { + parser.AccountTextPart{Name:"s"}, + }, }, }, Destination: &parser.DestinationAllotment{ @@ -1843,12 +1935,14 @@ parser.Program{ }, }, Source: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:11, Line:2}, End: parser.Position{Character:17, Line:2}, }, - Name: "world", + Parts: { + parser.AccountTextPart{Name:"world"}, + }, }, }, Destination: &parser.DestinationAllotment{ @@ -1878,12 +1972,15 @@ parser.Program{ }, To: &parser.DestinationTo{ Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:13, Line:4}, End: parser.Position{Character:22, Line:4}, }, - Name: "player:1", + Parts: { + parser.AccountTextPart{Name:"player"}, + parser.AccountTextPart{Name:"1"}, + }, }, }, }, @@ -1897,13 +1994,13 @@ parser.Program{ [TestShowErrorLines - 1] Got errors while parsing: -mismatched input 'err' expecting {'max', '[', '{', RATIO_PORTION_LITERAL, PERCENTAGE_PORTION_LITERAL, STRING, NUMBER, VARIABLE_NAME, ACCOUNT, ASSET} +mismatched input 'err' expecting {'max', '[', '{', RATIO_PORTION_LITERAL, PERCENTAGE_PORTION_LITERAL, STRING, NUMBER, ASSET, '@', VARIABLE_NAME_DEFAULT} 0 | send [EUR/2 100] ( 1 | source = err | ~~ 2 | destination = ee -mismatched input 'ee' expecting {'[', '{', RATIO_PORTION_LITERAL, PERCENTAGE_PORTION_LITERAL, STRING, NUMBER, VARIABLE_NAME, ACCOUNT, ASSET} +mismatched input 'ee' expecting {'[', '{', RATIO_PORTION_LITERAL, PERCENTAGE_PORTION_LITERAL, STRING, NUMBER, ASSET, '@', VARIABLE_NAME_DEFAULT} 1 | source = err 2 | destination = ee | ~ @@ -1948,21 +2045,25 @@ parser.Program{ }, }, Source: &parser.SourceAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:11, Line:1}, End: parser.Position{Character:15, Line:1}, }, - Name: "src", + Parts: { + parser.AccountTextPart{Name:"src"}, + }, }, }, Destination: &parser.DestinationAccount{ - ValueExpr: &parser.AccountLiteral{ + ValueExpr: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:16, Line:2}, End: parser.Position{Character:21, Line:2}, }, - Name: "dest", + Parts: { + parser.AccountTextPart{Name:"dest"}, + }, }, }, }, @@ -2005,12 +2106,14 @@ parser.Program{ }, }, }, - Amount: &parser.AccountLiteral{ + Amount: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:22, Line:1}, End: parser.Position{Character:28, Line:1}, }, - Name: "alice", + Parts: { + parser.AccountTextPart{Name:"alice"}, + }, }, }, }, @@ -2039,12 +2142,14 @@ parser.Program{ Asset: "EUR/2", }, }, - Amount: &parser.AccountLiteral{ + Amount: &parser.AccountInterpLiteral{ Range: parser.Range{ Start: parser.Position{Character:20, Line:1}, End: parser.Position{Character:26, Line:1}, }, - Name: "alice", + Parts: { + parser.AccountTextPart{Name:"alice"}, + }, }, }, }, @@ -2301,3 +2406,87 @@ parser.Program{ }, } --- + +[TestStringTemplate - 1] +parser.Program{ + Vars: nil, + Statements: { + &parser.FnCall{ + Range: parser.Range{ + Start: parser.Position{}, + End: parser.Position{Character:18, Line:0}, + }, + Caller: &parser.FnCallIdentifier{ + Range: parser.Range{ + Start: parser.Position{}, + End: parser.Position{Character:11, Line:0}, + }, + Name: "set_tx_meta", + }, + Args: { + &parser.NumberLiteral{ + Range: parser.Range{ + Start: parser.Position{Character:12, Line:0}, + End: parser.Position{Character:13, Line:0}, + }, + Number: 0, + }, + &parser.NumberLiteral{ + Range: parser.Range{ + Start: parser.Position{Character:15, Line:0}, + End: parser.Position{Character:17, Line:0}, + }, + Number: 42, + }, + }, + }, + }, +} +--- + +[TestInterpAccount - 1] +parser.Program{ + Vars: nil, + Statements: { + &parser.FnCall{ + Range: parser.Range{ + Start: parser.Position{}, + End: parser.Position{Character:29, Line:0}, + }, + Caller: &parser.FnCallIdentifier{ + Range: parser.Range{ + Start: parser.Position{}, + End: parser.Position{Character:11, Line:0}, + }, + Name: "set_tx_meta", + }, + Args: { + &parser.AccountInterpLiteral{ + Range: parser.Range{ + Start: parser.Position{Character:12, Line:0}, + End: parser.Position{Character:24, Line:0}, + }, + Parts: { + parser.AccountTextPart{Name:"abc"}, + parser.AccountTextPart{Name:"cde"}, + &parser.Variable{ + Range: parser.Range{ + Start: parser.Position{Character:21, Line:0}, + End: parser.Position{Character:24, Line:0}, + }, + Name: "id", + }, + }, + }, + &parser.NumberLiteral{ + Range: parser.Range{ + Start: parser.Position{Character:26, Line:0}, + End: parser.Position{Character:28, Line:0}, + }, + Number: 42, + }, + }, + }, + }, +} +--- diff --git a/internal/parser/antlr/Numscript.interp b/internal/parser/antlr/Numscript.interp deleted file mode 100644 index 56d0de53..00000000 --- a/internal/parser/antlr/Numscript.interp +++ /dev/null @@ -1,104 +0,0 @@ -token literal names: -null -'+' -null -null -null -null -'vars' -'max' -'source' -'destination' -'send' -'from' -'up' -'to' -'remaining' -'allowing' -'unbounded' -'overdraft' -'kept' -'save' -'(' -')' -'[' -']' -'{' -'}' -',' -'=' -'*' -'-' -null -null -null -null -null -null -null -null - -token symbolic names: -null -null -WS -NEWLINE -MULTILINE_COMMENT -LINE_COMMENT -VARS -MAX -SOURCE -DESTINATION -SEND -FROM -UP -TO -REMAINING -ALLOWING -UNBOUNDED -OVERDRAFT -KEPT -SAVE -LPARENS -RPARENS -LBRACKET -RBRACKET -LBRACE -RBRACE -COMMA -EQ -STAR -MINUS -RATIO_PORTION_LITERAL -PERCENTAGE_PORTION_LITERAL -STRING -IDENTIFIER -NUMBER -VARIABLE_NAME -ACCOUNT -ASSET - -rule names: -monetaryLit -portion -valueExpr -functionCallArgs -functionCall -varOrigin -varDeclaration -varsDeclaration -program -sentAllLit -allotment -source -allotmentClauseSrc -keptOrDestination -destinationInOrderClause -destination -allotmentClauseDest -sentValue -statement - - -atn: -[4, 1, 37, 217, 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, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 3, 1, 46, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 56, 8, 2, 1, 2, 1, 2, 1, 2, 5, 2, 61, 8, 2, 10, 2, 12, 2, 64, 9, 2, 1, 3, 1, 3, 1, 3, 5, 3, 69, 8, 3, 10, 3, 12, 3, 72, 9, 3, 1, 4, 1, 4, 1, 4, 3, 4, 77, 8, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 3, 6, 87, 8, 6, 1, 7, 1, 7, 1, 7, 5, 7, 92, 8, 7, 10, 7, 12, 7, 95, 9, 7, 1, 7, 1, 7, 1, 8, 3, 8, 100, 8, 8, 1, 8, 5, 8, 103, 8, 8, 10, 8, 12, 8, 106, 9, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 3, 10, 118, 8, 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, 4, 11, 135, 8, 11, 11, 11, 12, 11, 136, 1, 11, 1, 11, 1, 11, 1, 11, 5, 11, 143, 8, 11, 10, 11, 12, 11, 146, 9, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 154, 8, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 3, 13, 163, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 4, 15, 172, 8, 15, 11, 15, 12, 15, 173, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15, 180, 8, 15, 10, 15, 12, 15, 183, 9, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 189, 8, 15, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 3, 17, 196, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 215, 8, 18, 1, 18, 0, 1, 4, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 0, 2, 2, 0, 1, 1, 29, 29, 2, 0, 17, 17, 33, 33, 228, 0, 38, 1, 0, 0, 0, 2, 45, 1, 0, 0, 0, 4, 55, 1, 0, 0, 0, 6, 65, 1, 0, 0, 0, 8, 73, 1, 0, 0, 0, 10, 80, 1, 0, 0, 0, 12, 83, 1, 0, 0, 0, 14, 88, 1, 0, 0, 0, 16, 99, 1, 0, 0, 0, 18, 109, 1, 0, 0, 0, 20, 117, 1, 0, 0, 0, 22, 153, 1, 0, 0, 0, 24, 155, 1, 0, 0, 0, 26, 162, 1, 0, 0, 0, 28, 164, 1, 0, 0, 0, 30, 188, 1, 0, 0, 0, 32, 190, 1, 0, 0, 0, 34, 195, 1, 0, 0, 0, 36, 214, 1, 0, 0, 0, 38, 39, 5, 22, 0, 0, 39, 40, 3, 4, 2, 0, 40, 41, 3, 4, 2, 0, 41, 42, 5, 23, 0, 0, 42, 1, 1, 0, 0, 0, 43, 46, 5, 30, 0, 0, 44, 46, 5, 31, 0, 0, 45, 43, 1, 0, 0, 0, 45, 44, 1, 0, 0, 0, 46, 3, 1, 0, 0, 0, 47, 48, 6, 2, -1, 0, 48, 56, 5, 35, 0, 0, 49, 56, 5, 37, 0, 0, 50, 56, 5, 32, 0, 0, 51, 56, 5, 36, 0, 0, 52, 56, 5, 34, 0, 0, 53, 56, 3, 0, 0, 0, 54, 56, 3, 2, 1, 0, 55, 47, 1, 0, 0, 0, 55, 49, 1, 0, 0, 0, 55, 50, 1, 0, 0, 0, 55, 51, 1, 0, 0, 0, 55, 52, 1, 0, 0, 0, 55, 53, 1, 0, 0, 0, 55, 54, 1, 0, 0, 0, 56, 62, 1, 0, 0, 0, 57, 58, 10, 1, 0, 0, 58, 59, 7, 0, 0, 0, 59, 61, 3, 4, 2, 2, 60, 57, 1, 0, 0, 0, 61, 64, 1, 0, 0, 0, 62, 60, 1, 0, 0, 0, 62, 63, 1, 0, 0, 0, 63, 5, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 65, 70, 3, 4, 2, 0, 66, 67, 5, 26, 0, 0, 67, 69, 3, 4, 2, 0, 68, 66, 1, 0, 0, 0, 69, 72, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 7, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 73, 74, 7, 1, 0, 0, 74, 76, 5, 20, 0, 0, 75, 77, 3, 6, 3, 0, 76, 75, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, 78, 79, 5, 21, 0, 0, 79, 9, 1, 0, 0, 0, 80, 81, 5, 27, 0, 0, 81, 82, 3, 8, 4, 0, 82, 11, 1, 0, 0, 0, 83, 84, 5, 33, 0, 0, 84, 86, 5, 35, 0, 0, 85, 87, 3, 10, 5, 0, 86, 85, 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, 87, 13, 1, 0, 0, 0, 88, 89, 5, 6, 0, 0, 89, 93, 5, 24, 0, 0, 90, 92, 3, 12, 6, 0, 91, 90, 1, 0, 0, 0, 92, 95, 1, 0, 0, 0, 93, 91, 1, 0, 0, 0, 93, 94, 1, 0, 0, 0, 94, 96, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 96, 97, 5, 25, 0, 0, 97, 15, 1, 0, 0, 0, 98, 100, 3, 14, 7, 0, 99, 98, 1, 0, 0, 0, 99, 100, 1, 0, 0, 0, 100, 104, 1, 0, 0, 0, 101, 103, 3, 36, 18, 0, 102, 101, 1, 0, 0, 0, 103, 106, 1, 0, 0, 0, 104, 102, 1, 0, 0, 0, 104, 105, 1, 0, 0, 0, 105, 107, 1, 0, 0, 0, 106, 104, 1, 0, 0, 0, 107, 108, 5, 0, 0, 1, 108, 17, 1, 0, 0, 0, 109, 110, 5, 22, 0, 0, 110, 111, 3, 4, 2, 0, 111, 112, 5, 28, 0, 0, 112, 113, 5, 23, 0, 0, 113, 19, 1, 0, 0, 0, 114, 118, 3, 2, 1, 0, 115, 118, 5, 35, 0, 0, 116, 118, 5, 14, 0, 0, 117, 114, 1, 0, 0, 0, 117, 115, 1, 0, 0, 0, 117, 116, 1, 0, 0, 0, 118, 21, 1, 0, 0, 0, 119, 120, 3, 4, 2, 0, 120, 121, 5, 15, 0, 0, 121, 122, 5, 16, 0, 0, 122, 123, 5, 17, 0, 0, 123, 154, 1, 0, 0, 0, 124, 125, 3, 4, 2, 0, 125, 126, 5, 15, 0, 0, 126, 127, 5, 17, 0, 0, 127, 128, 5, 12, 0, 0, 128, 129, 5, 13, 0, 0, 129, 130, 3, 4, 2, 0, 130, 154, 1, 0, 0, 0, 131, 154, 3, 4, 2, 0, 132, 134, 5, 24, 0, 0, 133, 135, 3, 24, 12, 0, 134, 133, 1, 0, 0, 0, 135, 136, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 136, 137, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 139, 5, 25, 0, 0, 139, 154, 1, 0, 0, 0, 140, 144, 5, 24, 0, 0, 141, 143, 3, 22, 11, 0, 142, 141, 1, 0, 0, 0, 143, 146, 1, 0, 0, 0, 144, 142, 1, 0, 0, 0, 144, 145, 1, 0, 0, 0, 145, 147, 1, 0, 0, 0, 146, 144, 1, 0, 0, 0, 147, 154, 5, 25, 0, 0, 148, 149, 5, 7, 0, 0, 149, 150, 3, 4, 2, 0, 150, 151, 5, 11, 0, 0, 151, 152, 3, 22, 11, 0, 152, 154, 1, 0, 0, 0, 153, 119, 1, 0, 0, 0, 153, 124, 1, 0, 0, 0, 153, 131, 1, 0, 0, 0, 153, 132, 1, 0, 0, 0, 153, 140, 1, 0, 0, 0, 153, 148, 1, 0, 0, 0, 154, 23, 1, 0, 0, 0, 155, 156, 3, 20, 10, 0, 156, 157, 5, 11, 0, 0, 157, 158, 3, 22, 11, 0, 158, 25, 1, 0, 0, 0, 159, 160, 5, 13, 0, 0, 160, 163, 3, 30, 15, 0, 161, 163, 5, 18, 0, 0, 162, 159, 1, 0, 0, 0, 162, 161, 1, 0, 0, 0, 163, 27, 1, 0, 0, 0, 164, 165, 5, 7, 0, 0, 165, 166, 3, 4, 2, 0, 166, 167, 3, 26, 13, 0, 167, 29, 1, 0, 0, 0, 168, 189, 3, 4, 2, 0, 169, 171, 5, 24, 0, 0, 170, 172, 3, 32, 16, 0, 171, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, 173, 171, 1, 0, 0, 0, 173, 174, 1, 0, 0, 0, 174, 175, 1, 0, 0, 0, 175, 176, 5, 25, 0, 0, 176, 189, 1, 0, 0, 0, 177, 181, 5, 24, 0, 0, 178, 180, 3, 28, 14, 0, 179, 178, 1, 0, 0, 0, 180, 183, 1, 0, 0, 0, 181, 179, 1, 0, 0, 0, 181, 182, 1, 0, 0, 0, 182, 184, 1, 0, 0, 0, 183, 181, 1, 0, 0, 0, 184, 185, 5, 14, 0, 0, 185, 186, 3, 26, 13, 0, 186, 187, 5, 25, 0, 0, 187, 189, 1, 0, 0, 0, 188, 168, 1, 0, 0, 0, 188, 169, 1, 0, 0, 0, 188, 177, 1, 0, 0, 0, 189, 31, 1, 0, 0, 0, 190, 191, 3, 20, 10, 0, 191, 192, 3, 26, 13, 0, 192, 33, 1, 0, 0, 0, 193, 196, 3, 4, 2, 0, 194, 196, 3, 18, 9, 0, 195, 193, 1, 0, 0, 0, 195, 194, 1, 0, 0, 0, 196, 35, 1, 0, 0, 0, 197, 198, 5, 10, 0, 0, 198, 199, 3, 34, 17, 0, 199, 200, 5, 20, 0, 0, 200, 201, 5, 8, 0, 0, 201, 202, 5, 27, 0, 0, 202, 203, 3, 22, 11, 0, 203, 204, 5, 9, 0, 0, 204, 205, 5, 27, 0, 0, 205, 206, 3, 30, 15, 0, 206, 207, 5, 21, 0, 0, 207, 215, 1, 0, 0, 0, 208, 209, 5, 19, 0, 0, 209, 210, 3, 34, 17, 0, 210, 211, 5, 11, 0, 0, 211, 212, 3, 4, 2, 0, 212, 215, 1, 0, 0, 0, 213, 215, 3, 8, 4, 0, 214, 197, 1, 0, 0, 0, 214, 208, 1, 0, 0, 0, 214, 213, 1, 0, 0, 0, 215, 37, 1, 0, 0, 0, 19, 45, 55, 62, 70, 76, 86, 93, 99, 104, 117, 136, 144, 153, 162, 173, 181, 188, 195, 214] \ No newline at end of file diff --git a/internal/parser/antlr/Numscript.tokens b/internal/parser/antlr/Numscript.tokens deleted file mode 100644 index 9005dee2..00000000 --- a/internal/parser/antlr/Numscript.tokens +++ /dev/null @@ -1,62 +0,0 @@ -T__0=1 -WS=2 -NEWLINE=3 -MULTILINE_COMMENT=4 -LINE_COMMENT=5 -VARS=6 -MAX=7 -SOURCE=8 -DESTINATION=9 -SEND=10 -FROM=11 -UP=12 -TO=13 -REMAINING=14 -ALLOWING=15 -UNBOUNDED=16 -OVERDRAFT=17 -KEPT=18 -SAVE=19 -LPARENS=20 -RPARENS=21 -LBRACKET=22 -RBRACKET=23 -LBRACE=24 -RBRACE=25 -COMMA=26 -EQ=27 -STAR=28 -MINUS=29 -RATIO_PORTION_LITERAL=30 -PERCENTAGE_PORTION_LITERAL=31 -STRING=32 -IDENTIFIER=33 -NUMBER=34 -VARIABLE_NAME=35 -ACCOUNT=36 -ASSET=37 -'+'=1 -'vars'=6 -'max'=7 -'source'=8 -'destination'=9 -'send'=10 -'from'=11 -'up'=12 -'to'=13 -'remaining'=14 -'allowing'=15 -'unbounded'=16 -'overdraft'=17 -'kept'=18 -'save'=19 -'('=20 -')'=21 -'['=22 -']'=23 -'{'=24 -'}'=25 -','=26 -'='=27 -'*'=28 -'-'=29 diff --git a/internal/parser/antlr/NumscriptLexer.interp b/internal/parser/antlr/NumscriptLexer.interp deleted file mode 100644 index 67c5da21..00000000 --- a/internal/parser/antlr/NumscriptLexer.interp +++ /dev/null @@ -1,128 +0,0 @@ -token literal names: -null -'+' -null -null -null -null -'vars' -'max' -'source' -'destination' -'send' -'from' -'up' -'to' -'remaining' -'allowing' -'unbounded' -'overdraft' -'kept' -'save' -'(' -')' -'[' -']' -'{' -'}' -',' -'=' -'*' -'-' -null -null -null -null -null -null -null -null - -token symbolic names: -null -null -WS -NEWLINE -MULTILINE_COMMENT -LINE_COMMENT -VARS -MAX -SOURCE -DESTINATION -SEND -FROM -UP -TO -REMAINING -ALLOWING -UNBOUNDED -OVERDRAFT -KEPT -SAVE -LPARENS -RPARENS -LBRACKET -RBRACKET -LBRACE -RBRACE -COMMA -EQ -STAR -MINUS -RATIO_PORTION_LITERAL -PERCENTAGE_PORTION_LITERAL -STRING -IDENTIFIER -NUMBER -VARIABLE_NAME -ACCOUNT -ASSET - -rule names: -T__0 -WS -NEWLINE -MULTILINE_COMMENT -LINE_COMMENT -VARS -MAX -SOURCE -DESTINATION -SEND -FROM -UP -TO -REMAINING -ALLOWING -UNBOUNDED -OVERDRAFT -KEPT -SAVE -LPARENS -RPARENS -LBRACKET -RBRACKET -LBRACE -RBRACE -COMMA -EQ -STAR -MINUS -RATIO_PORTION_LITERAL -PERCENTAGE_PORTION_LITERAL -STRING -IDENTIFIER -NUMBER -VARIABLE_NAME -ACCOUNT -ASSET - -channel names: -DEFAULT_TOKEN_CHANNEL -HIDDEN - -mode names: -DEFAULT_MODE - -atn: -[4, 0, 37, 337, 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, 1, 0, 1, 0, 1, 1, 4, 1, 79, 8, 1, 11, 1, 12, 1, 80, 1, 1, 1, 1, 1, 2, 4, 2, 86, 8, 2, 11, 2, 12, 2, 87, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 95, 8, 3, 10, 3, 12, 3, 98, 9, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 5, 4, 109, 8, 4, 10, 4, 12, 4, 112, 9, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 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, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 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, 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, 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, 17, 1, 17, 1, 18, 1, 18, 1, 18, 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, 28, 1, 28, 1, 29, 4, 29, 232, 8, 29, 11, 29, 12, 29, 233, 1, 29, 3, 29, 237, 8, 29, 1, 29, 1, 29, 3, 29, 241, 8, 29, 1, 29, 4, 29, 244, 8, 29, 11, 29, 12, 29, 245, 1, 30, 4, 30, 249, 8, 30, 11, 30, 12, 30, 250, 1, 30, 1, 30, 4, 30, 255, 8, 30, 11, 30, 12, 30, 256, 3, 30, 259, 8, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 5, 31, 267, 8, 31, 10, 31, 12, 31, 270, 9, 31, 1, 31, 1, 31, 1, 32, 4, 32, 275, 8, 32, 11, 32, 12, 32, 276, 1, 32, 5, 32, 280, 8, 32, 10, 32, 12, 32, 283, 9, 32, 1, 33, 3, 33, 286, 8, 33, 1, 33, 4, 33, 289, 8, 33, 11, 33, 12, 33, 290, 1, 33, 1, 33, 4, 33, 295, 8, 33, 11, 33, 12, 33, 296, 5, 33, 299, 8, 33, 10, 33, 12, 33, 302, 9, 33, 1, 34, 1, 34, 4, 34, 306, 8, 34, 11, 34, 12, 34, 307, 1, 34, 5, 34, 311, 8, 34, 10, 34, 12, 34, 314, 9, 34, 1, 35, 1, 35, 4, 35, 318, 8, 35, 11, 35, 12, 35, 319, 1, 35, 1, 35, 4, 35, 324, 8, 35, 11, 35, 12, 35, 325, 5, 35, 328, 8, 35, 10, 35, 12, 35, 331, 9, 35, 1, 36, 4, 36, 334, 8, 36, 11, 36, 12, 36, 335, 2, 96, 110, 0, 37, 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, 1, 0, 10, 3, 0, 9, 10, 13, 13, 32, 32, 2, 0, 10, 10, 13, 13, 1, 0, 48, 57, 1, 0, 32, 32, 3, 0, 10, 10, 13, 13, 34, 34, 1, 0, 97, 122, 2, 0, 95, 95, 97, 122, 3, 0, 48, 57, 95, 95, 97, 122, 5, 0, 45, 45, 48, 57, 65, 90, 95, 95, 97, 122, 2, 0, 47, 57, 65, 90, 362, 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, 1, 75, 1, 0, 0, 0, 3, 78, 1, 0, 0, 0, 5, 85, 1, 0, 0, 0, 7, 89, 1, 0, 0, 0, 9, 104, 1, 0, 0, 0, 11, 117, 1, 0, 0, 0, 13, 122, 1, 0, 0, 0, 15, 126, 1, 0, 0, 0, 17, 133, 1, 0, 0, 0, 19, 145, 1, 0, 0, 0, 21, 150, 1, 0, 0, 0, 23, 155, 1, 0, 0, 0, 25, 158, 1, 0, 0, 0, 27, 161, 1, 0, 0, 0, 29, 171, 1, 0, 0, 0, 31, 180, 1, 0, 0, 0, 33, 190, 1, 0, 0, 0, 35, 200, 1, 0, 0, 0, 37, 205, 1, 0, 0, 0, 39, 210, 1, 0, 0, 0, 41, 212, 1, 0, 0, 0, 43, 214, 1, 0, 0, 0, 45, 216, 1, 0, 0, 0, 47, 218, 1, 0, 0, 0, 49, 220, 1, 0, 0, 0, 51, 222, 1, 0, 0, 0, 53, 224, 1, 0, 0, 0, 55, 226, 1, 0, 0, 0, 57, 228, 1, 0, 0, 0, 59, 231, 1, 0, 0, 0, 61, 248, 1, 0, 0, 0, 63, 262, 1, 0, 0, 0, 65, 274, 1, 0, 0, 0, 67, 285, 1, 0, 0, 0, 69, 303, 1, 0, 0, 0, 71, 315, 1, 0, 0, 0, 73, 333, 1, 0, 0, 0, 75, 76, 5, 43, 0, 0, 76, 2, 1, 0, 0, 0, 77, 79, 7, 0, 0, 0, 78, 77, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 83, 6, 1, 0, 0, 83, 4, 1, 0, 0, 0, 84, 86, 7, 1, 0, 0, 85, 84, 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, 87, 85, 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 6, 1, 0, 0, 0, 89, 90, 5, 47, 0, 0, 90, 91, 5, 42, 0, 0, 91, 96, 1, 0, 0, 0, 92, 95, 3, 7, 3, 0, 93, 95, 9, 0, 0, 0, 94, 92, 1, 0, 0, 0, 94, 93, 1, 0, 0, 0, 95, 98, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 96, 94, 1, 0, 0, 0, 97, 99, 1, 0, 0, 0, 98, 96, 1, 0, 0, 0, 99, 100, 5, 42, 0, 0, 100, 101, 5, 47, 0, 0, 101, 102, 1, 0, 0, 0, 102, 103, 6, 3, 0, 0, 103, 8, 1, 0, 0, 0, 104, 105, 5, 47, 0, 0, 105, 106, 5, 47, 0, 0, 106, 110, 1, 0, 0, 0, 107, 109, 9, 0, 0, 0, 108, 107, 1, 0, 0, 0, 109, 112, 1, 0, 0, 0, 110, 111, 1, 0, 0, 0, 110, 108, 1, 0, 0, 0, 111, 113, 1, 0, 0, 0, 112, 110, 1, 0, 0, 0, 113, 114, 3, 5, 2, 0, 114, 115, 1, 0, 0, 0, 115, 116, 6, 4, 0, 0, 116, 10, 1, 0, 0, 0, 117, 118, 5, 118, 0, 0, 118, 119, 5, 97, 0, 0, 119, 120, 5, 114, 0, 0, 120, 121, 5, 115, 0, 0, 121, 12, 1, 0, 0, 0, 122, 123, 5, 109, 0, 0, 123, 124, 5, 97, 0, 0, 124, 125, 5, 120, 0, 0, 125, 14, 1, 0, 0, 0, 126, 127, 5, 115, 0, 0, 127, 128, 5, 111, 0, 0, 128, 129, 5, 117, 0, 0, 129, 130, 5, 114, 0, 0, 130, 131, 5, 99, 0, 0, 131, 132, 5, 101, 0, 0, 132, 16, 1, 0, 0, 0, 133, 134, 5, 100, 0, 0, 134, 135, 5, 101, 0, 0, 135, 136, 5, 115, 0, 0, 136, 137, 5, 116, 0, 0, 137, 138, 5, 105, 0, 0, 138, 139, 5, 110, 0, 0, 139, 140, 5, 97, 0, 0, 140, 141, 5, 116, 0, 0, 141, 142, 5, 105, 0, 0, 142, 143, 5, 111, 0, 0, 143, 144, 5, 110, 0, 0, 144, 18, 1, 0, 0, 0, 145, 146, 5, 115, 0, 0, 146, 147, 5, 101, 0, 0, 147, 148, 5, 110, 0, 0, 148, 149, 5, 100, 0, 0, 149, 20, 1, 0, 0, 0, 150, 151, 5, 102, 0, 0, 151, 152, 5, 114, 0, 0, 152, 153, 5, 111, 0, 0, 153, 154, 5, 109, 0, 0, 154, 22, 1, 0, 0, 0, 155, 156, 5, 117, 0, 0, 156, 157, 5, 112, 0, 0, 157, 24, 1, 0, 0, 0, 158, 159, 5, 116, 0, 0, 159, 160, 5, 111, 0, 0, 160, 26, 1, 0, 0, 0, 161, 162, 5, 114, 0, 0, 162, 163, 5, 101, 0, 0, 163, 164, 5, 109, 0, 0, 164, 165, 5, 97, 0, 0, 165, 166, 5, 105, 0, 0, 166, 167, 5, 110, 0, 0, 167, 168, 5, 105, 0, 0, 168, 169, 5, 110, 0, 0, 169, 170, 5, 103, 0, 0, 170, 28, 1, 0, 0, 0, 171, 172, 5, 97, 0, 0, 172, 173, 5, 108, 0, 0, 173, 174, 5, 108, 0, 0, 174, 175, 5, 111, 0, 0, 175, 176, 5, 119, 0, 0, 176, 177, 5, 105, 0, 0, 177, 178, 5, 110, 0, 0, 178, 179, 5, 103, 0, 0, 179, 30, 1, 0, 0, 0, 180, 181, 5, 117, 0, 0, 181, 182, 5, 110, 0, 0, 182, 183, 5, 98, 0, 0, 183, 184, 5, 111, 0, 0, 184, 185, 5, 117, 0, 0, 185, 186, 5, 110, 0, 0, 186, 187, 5, 100, 0, 0, 187, 188, 5, 101, 0, 0, 188, 189, 5, 100, 0, 0, 189, 32, 1, 0, 0, 0, 190, 191, 5, 111, 0, 0, 191, 192, 5, 118, 0, 0, 192, 193, 5, 101, 0, 0, 193, 194, 5, 114, 0, 0, 194, 195, 5, 100, 0, 0, 195, 196, 5, 114, 0, 0, 196, 197, 5, 97, 0, 0, 197, 198, 5, 102, 0, 0, 198, 199, 5, 116, 0, 0, 199, 34, 1, 0, 0, 0, 200, 201, 5, 107, 0, 0, 201, 202, 5, 101, 0, 0, 202, 203, 5, 112, 0, 0, 203, 204, 5, 116, 0, 0, 204, 36, 1, 0, 0, 0, 205, 206, 5, 115, 0, 0, 206, 207, 5, 97, 0, 0, 207, 208, 5, 118, 0, 0, 208, 209, 5, 101, 0, 0, 209, 38, 1, 0, 0, 0, 210, 211, 5, 40, 0, 0, 211, 40, 1, 0, 0, 0, 212, 213, 5, 41, 0, 0, 213, 42, 1, 0, 0, 0, 214, 215, 5, 91, 0, 0, 215, 44, 1, 0, 0, 0, 216, 217, 5, 93, 0, 0, 217, 46, 1, 0, 0, 0, 218, 219, 5, 123, 0, 0, 219, 48, 1, 0, 0, 0, 220, 221, 5, 125, 0, 0, 221, 50, 1, 0, 0, 0, 222, 223, 5, 44, 0, 0, 223, 52, 1, 0, 0, 0, 224, 225, 5, 61, 0, 0, 225, 54, 1, 0, 0, 0, 226, 227, 5, 42, 0, 0, 227, 56, 1, 0, 0, 0, 228, 229, 5, 45, 0, 0, 229, 58, 1, 0, 0, 0, 230, 232, 7, 2, 0, 0, 231, 230, 1, 0, 0, 0, 232, 233, 1, 0, 0, 0, 233, 231, 1, 0, 0, 0, 233, 234, 1, 0, 0, 0, 234, 236, 1, 0, 0, 0, 235, 237, 7, 3, 0, 0, 236, 235, 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 238, 1, 0, 0, 0, 238, 240, 5, 47, 0, 0, 239, 241, 7, 3, 0, 0, 240, 239, 1, 0, 0, 0, 240, 241, 1, 0, 0, 0, 241, 243, 1, 0, 0, 0, 242, 244, 7, 2, 0, 0, 243, 242, 1, 0, 0, 0, 244, 245, 1, 0, 0, 0, 245, 243, 1, 0, 0, 0, 245, 246, 1, 0, 0, 0, 246, 60, 1, 0, 0, 0, 247, 249, 7, 2, 0, 0, 248, 247, 1, 0, 0, 0, 249, 250, 1, 0, 0, 0, 250, 248, 1, 0, 0, 0, 250, 251, 1, 0, 0, 0, 251, 258, 1, 0, 0, 0, 252, 254, 5, 46, 0, 0, 253, 255, 7, 2, 0, 0, 254, 253, 1, 0, 0, 0, 255, 256, 1, 0, 0, 0, 256, 254, 1, 0, 0, 0, 256, 257, 1, 0, 0, 0, 257, 259, 1, 0, 0, 0, 258, 252, 1, 0, 0, 0, 258, 259, 1, 0, 0, 0, 259, 260, 1, 0, 0, 0, 260, 261, 5, 37, 0, 0, 261, 62, 1, 0, 0, 0, 262, 268, 5, 34, 0, 0, 263, 264, 5, 92, 0, 0, 264, 267, 5, 34, 0, 0, 265, 267, 8, 4, 0, 0, 266, 263, 1, 0, 0, 0, 266, 265, 1, 0, 0, 0, 267, 270, 1, 0, 0, 0, 268, 266, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, 271, 1, 0, 0, 0, 270, 268, 1, 0, 0, 0, 271, 272, 5, 34, 0, 0, 272, 64, 1, 0, 0, 0, 273, 275, 7, 5, 0, 0, 274, 273, 1, 0, 0, 0, 275, 276, 1, 0, 0, 0, 276, 274, 1, 0, 0, 0, 276, 277, 1, 0, 0, 0, 277, 281, 1, 0, 0, 0, 278, 280, 7, 6, 0, 0, 279, 278, 1, 0, 0, 0, 280, 283, 1, 0, 0, 0, 281, 279, 1, 0, 0, 0, 281, 282, 1, 0, 0, 0, 282, 66, 1, 0, 0, 0, 283, 281, 1, 0, 0, 0, 284, 286, 3, 57, 28, 0, 285, 284, 1, 0, 0, 0, 285, 286, 1, 0, 0, 0, 286, 288, 1, 0, 0, 0, 287, 289, 7, 2, 0, 0, 288, 287, 1, 0, 0, 0, 289, 290, 1, 0, 0, 0, 290, 288, 1, 0, 0, 0, 290, 291, 1, 0, 0, 0, 291, 300, 1, 0, 0, 0, 292, 294, 5, 95, 0, 0, 293, 295, 7, 2, 0, 0, 294, 293, 1, 0, 0, 0, 295, 296, 1, 0, 0, 0, 296, 294, 1, 0, 0, 0, 296, 297, 1, 0, 0, 0, 297, 299, 1, 0, 0, 0, 298, 292, 1, 0, 0, 0, 299, 302, 1, 0, 0, 0, 300, 298, 1, 0, 0, 0, 300, 301, 1, 0, 0, 0, 301, 68, 1, 0, 0, 0, 302, 300, 1, 0, 0, 0, 303, 305, 5, 36, 0, 0, 304, 306, 7, 6, 0, 0, 305, 304, 1, 0, 0, 0, 306, 307, 1, 0, 0, 0, 307, 305, 1, 0, 0, 0, 307, 308, 1, 0, 0, 0, 308, 312, 1, 0, 0, 0, 309, 311, 7, 7, 0, 0, 310, 309, 1, 0, 0, 0, 311, 314, 1, 0, 0, 0, 312, 310, 1, 0, 0, 0, 312, 313, 1, 0, 0, 0, 313, 70, 1, 0, 0, 0, 314, 312, 1, 0, 0, 0, 315, 317, 5, 64, 0, 0, 316, 318, 7, 8, 0, 0, 317, 316, 1, 0, 0, 0, 318, 319, 1, 0, 0, 0, 319, 317, 1, 0, 0, 0, 319, 320, 1, 0, 0, 0, 320, 329, 1, 0, 0, 0, 321, 323, 5, 58, 0, 0, 322, 324, 7, 8, 0, 0, 323, 322, 1, 0, 0, 0, 324, 325, 1, 0, 0, 0, 325, 323, 1, 0, 0, 0, 325, 326, 1, 0, 0, 0, 326, 328, 1, 0, 0, 0, 327, 321, 1, 0, 0, 0, 328, 331, 1, 0, 0, 0, 329, 327, 1, 0, 0, 0, 329, 330, 1, 0, 0, 0, 330, 72, 1, 0, 0, 0, 331, 329, 1, 0, 0, 0, 332, 334, 7, 9, 0, 0, 333, 332, 1, 0, 0, 0, 334, 335, 1, 0, 0, 0, 335, 333, 1, 0, 0, 0, 335, 336, 1, 0, 0, 0, 336, 74, 1, 0, 0, 0, 27, 0, 80, 87, 94, 96, 110, 233, 236, 240, 245, 250, 256, 258, 266, 268, 276, 281, 285, 290, 296, 300, 307, 312, 319, 325, 329, 335, 1, 6, 0, 0] \ No newline at end of file diff --git a/internal/parser/antlr/NumscriptLexer.tokens b/internal/parser/antlr/NumscriptLexer.tokens deleted file mode 100644 index 9005dee2..00000000 --- a/internal/parser/antlr/NumscriptLexer.tokens +++ /dev/null @@ -1,62 +0,0 @@ -T__0=1 -WS=2 -NEWLINE=3 -MULTILINE_COMMENT=4 -LINE_COMMENT=5 -VARS=6 -MAX=7 -SOURCE=8 -DESTINATION=9 -SEND=10 -FROM=11 -UP=12 -TO=13 -REMAINING=14 -ALLOWING=15 -UNBOUNDED=16 -OVERDRAFT=17 -KEPT=18 -SAVE=19 -LPARENS=20 -RPARENS=21 -LBRACKET=22 -RBRACKET=23 -LBRACE=24 -RBRACE=25 -COMMA=26 -EQ=27 -STAR=28 -MINUS=29 -RATIO_PORTION_LITERAL=30 -PERCENTAGE_PORTION_LITERAL=31 -STRING=32 -IDENTIFIER=33 -NUMBER=34 -VARIABLE_NAME=35 -ACCOUNT=36 -ASSET=37 -'+'=1 -'vars'=6 -'max'=7 -'source'=8 -'destination'=9 -'send'=10 -'from'=11 -'up'=12 -'to'=13 -'remaining'=14 -'allowing'=15 -'unbounded'=16 -'overdraft'=17 -'kept'=18 -'save'=19 -'('=20 -')'=21 -'['=22 -']'=23 -'{'=24 -'}'=25 -','=26 -'='=27 -'*'=28 -'-'=29 diff --git a/internal/parser/antlr/numscript_lexer.go b/internal/parser/antlr/numscript_lexer.go deleted file mode 100644 index 6107b0db..00000000 --- a/internal/parser/antlr/numscript_lexer.go +++ /dev/null @@ -1,300 +0,0 @@ -// Code generated from Numscript.g4 by ANTLR 4.13.1. DO NOT EDIT. - -package parser - -import ( - "fmt" - "github.com/antlr4-go/antlr/v4" - "sync" - "unicode" -) - -// Suppress unused import error -var _ = fmt.Printf -var _ = sync.Once{} -var _ = unicode.IsLetter - -type NumscriptLexer struct { - *antlr.BaseLexer - channelNames []string - modeNames []string - // TODO: EOF string -} - -var NumscriptLexerLexerStaticData struct { - once sync.Once - serializedATN []int32 - ChannelNames []string - ModeNames []string - LiteralNames []string - SymbolicNames []string - RuleNames []string - PredictionContextCache *antlr.PredictionContextCache - atn *antlr.ATN - decisionToDFA []*antlr.DFA -} - -func numscriptlexerLexerInit() { - staticData := &NumscriptLexerLexerStaticData - staticData.ChannelNames = []string{ - "DEFAULT_TOKEN_CHANNEL", "HIDDEN", - } - staticData.ModeNames = []string{ - "DEFAULT_MODE", - } - staticData.LiteralNames = []string{ - "", "'+'", "", "", "", "", "'vars'", "'max'", "'source'", "'destination'", - "'send'", "'from'", "'up'", "'to'", "'remaining'", "'allowing'", "'unbounded'", - "'overdraft'", "'kept'", "'save'", "'('", "')'", "'['", "']'", "'{'", - "'}'", "','", "'='", "'*'", "'-'", - } - staticData.SymbolicNames = []string{ - "", "", "WS", "NEWLINE", "MULTILINE_COMMENT", "LINE_COMMENT", "VARS", - "MAX", "SOURCE", "DESTINATION", "SEND", "FROM", "UP", "TO", "REMAINING", - "ALLOWING", "UNBOUNDED", "OVERDRAFT", "KEPT", "SAVE", "LPARENS", "RPARENS", - "LBRACKET", "RBRACKET", "LBRACE", "RBRACE", "COMMA", "EQ", "STAR", "MINUS", - "RATIO_PORTION_LITERAL", "PERCENTAGE_PORTION_LITERAL", "STRING", "IDENTIFIER", - "NUMBER", "VARIABLE_NAME", "ACCOUNT", "ASSET", - } - staticData.RuleNames = []string{ - "T__0", "WS", "NEWLINE", "MULTILINE_COMMENT", "LINE_COMMENT", "VARS", - "MAX", "SOURCE", "DESTINATION", "SEND", "FROM", "UP", "TO", "REMAINING", - "ALLOWING", "UNBOUNDED", "OVERDRAFT", "KEPT", "SAVE", "LPARENS", "RPARENS", - "LBRACKET", "RBRACKET", "LBRACE", "RBRACE", "COMMA", "EQ", "STAR", "MINUS", - "RATIO_PORTION_LITERAL", "PERCENTAGE_PORTION_LITERAL", "STRING", "IDENTIFIER", - "NUMBER", "VARIABLE_NAME", "ACCOUNT", "ASSET", - } - staticData.PredictionContextCache = antlr.NewPredictionContextCache() - staticData.serializedATN = []int32{ - 4, 0, 37, 337, 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, 1, 0, 1, 0, 1, 1, 4, 1, 79, 8, 1, 11, 1, 12, 1, 80, 1, 1, 1, 1, - 1, 2, 4, 2, 86, 8, 2, 11, 2, 12, 2, 87, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 5, - 3, 95, 8, 3, 10, 3, 12, 3, 98, 9, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, - 1, 4, 1, 4, 1, 4, 5, 4, 109, 8, 4, 10, 4, 12, 4, 112, 9, 4, 1, 4, 1, 4, - 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 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, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, - 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 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, 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, 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, - 17, 1, 17, 1, 18, 1, 18, 1, 18, 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, 28, 1, 28, 1, 29, 4, 29, 232, 8, 29, 11, 29, - 12, 29, 233, 1, 29, 3, 29, 237, 8, 29, 1, 29, 1, 29, 3, 29, 241, 8, 29, - 1, 29, 4, 29, 244, 8, 29, 11, 29, 12, 29, 245, 1, 30, 4, 30, 249, 8, 30, - 11, 30, 12, 30, 250, 1, 30, 1, 30, 4, 30, 255, 8, 30, 11, 30, 12, 30, 256, - 3, 30, 259, 8, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 5, 31, 267, - 8, 31, 10, 31, 12, 31, 270, 9, 31, 1, 31, 1, 31, 1, 32, 4, 32, 275, 8, - 32, 11, 32, 12, 32, 276, 1, 32, 5, 32, 280, 8, 32, 10, 32, 12, 32, 283, - 9, 32, 1, 33, 3, 33, 286, 8, 33, 1, 33, 4, 33, 289, 8, 33, 11, 33, 12, - 33, 290, 1, 33, 1, 33, 4, 33, 295, 8, 33, 11, 33, 12, 33, 296, 5, 33, 299, - 8, 33, 10, 33, 12, 33, 302, 9, 33, 1, 34, 1, 34, 4, 34, 306, 8, 34, 11, - 34, 12, 34, 307, 1, 34, 5, 34, 311, 8, 34, 10, 34, 12, 34, 314, 9, 34, - 1, 35, 1, 35, 4, 35, 318, 8, 35, 11, 35, 12, 35, 319, 1, 35, 1, 35, 4, - 35, 324, 8, 35, 11, 35, 12, 35, 325, 5, 35, 328, 8, 35, 10, 35, 12, 35, - 331, 9, 35, 1, 36, 4, 36, 334, 8, 36, 11, 36, 12, 36, 335, 2, 96, 110, - 0, 37, 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, - 1, 0, 10, 3, 0, 9, 10, 13, 13, 32, 32, 2, 0, 10, 10, 13, 13, 1, 0, 48, - 57, 1, 0, 32, 32, 3, 0, 10, 10, 13, 13, 34, 34, 1, 0, 97, 122, 2, 0, 95, - 95, 97, 122, 3, 0, 48, 57, 95, 95, 97, 122, 5, 0, 45, 45, 48, 57, 65, 90, - 95, 95, 97, 122, 2, 0, 47, 57, 65, 90, 362, 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, 1, 75, 1, 0, 0, 0, 3, 78, 1, 0, 0, 0, 5, 85, 1, 0, 0, 0, - 7, 89, 1, 0, 0, 0, 9, 104, 1, 0, 0, 0, 11, 117, 1, 0, 0, 0, 13, 122, 1, - 0, 0, 0, 15, 126, 1, 0, 0, 0, 17, 133, 1, 0, 0, 0, 19, 145, 1, 0, 0, 0, - 21, 150, 1, 0, 0, 0, 23, 155, 1, 0, 0, 0, 25, 158, 1, 0, 0, 0, 27, 161, - 1, 0, 0, 0, 29, 171, 1, 0, 0, 0, 31, 180, 1, 0, 0, 0, 33, 190, 1, 0, 0, - 0, 35, 200, 1, 0, 0, 0, 37, 205, 1, 0, 0, 0, 39, 210, 1, 0, 0, 0, 41, 212, - 1, 0, 0, 0, 43, 214, 1, 0, 0, 0, 45, 216, 1, 0, 0, 0, 47, 218, 1, 0, 0, - 0, 49, 220, 1, 0, 0, 0, 51, 222, 1, 0, 0, 0, 53, 224, 1, 0, 0, 0, 55, 226, - 1, 0, 0, 0, 57, 228, 1, 0, 0, 0, 59, 231, 1, 0, 0, 0, 61, 248, 1, 0, 0, - 0, 63, 262, 1, 0, 0, 0, 65, 274, 1, 0, 0, 0, 67, 285, 1, 0, 0, 0, 69, 303, - 1, 0, 0, 0, 71, 315, 1, 0, 0, 0, 73, 333, 1, 0, 0, 0, 75, 76, 5, 43, 0, - 0, 76, 2, 1, 0, 0, 0, 77, 79, 7, 0, 0, 0, 78, 77, 1, 0, 0, 0, 79, 80, 1, - 0, 0, 0, 80, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, - 83, 6, 1, 0, 0, 83, 4, 1, 0, 0, 0, 84, 86, 7, 1, 0, 0, 85, 84, 1, 0, 0, - 0, 86, 87, 1, 0, 0, 0, 87, 85, 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 6, 1, - 0, 0, 0, 89, 90, 5, 47, 0, 0, 90, 91, 5, 42, 0, 0, 91, 96, 1, 0, 0, 0, - 92, 95, 3, 7, 3, 0, 93, 95, 9, 0, 0, 0, 94, 92, 1, 0, 0, 0, 94, 93, 1, - 0, 0, 0, 95, 98, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 96, 94, 1, 0, 0, 0, 97, - 99, 1, 0, 0, 0, 98, 96, 1, 0, 0, 0, 99, 100, 5, 42, 0, 0, 100, 101, 5, - 47, 0, 0, 101, 102, 1, 0, 0, 0, 102, 103, 6, 3, 0, 0, 103, 8, 1, 0, 0, - 0, 104, 105, 5, 47, 0, 0, 105, 106, 5, 47, 0, 0, 106, 110, 1, 0, 0, 0, - 107, 109, 9, 0, 0, 0, 108, 107, 1, 0, 0, 0, 109, 112, 1, 0, 0, 0, 110, - 111, 1, 0, 0, 0, 110, 108, 1, 0, 0, 0, 111, 113, 1, 0, 0, 0, 112, 110, - 1, 0, 0, 0, 113, 114, 3, 5, 2, 0, 114, 115, 1, 0, 0, 0, 115, 116, 6, 4, - 0, 0, 116, 10, 1, 0, 0, 0, 117, 118, 5, 118, 0, 0, 118, 119, 5, 97, 0, - 0, 119, 120, 5, 114, 0, 0, 120, 121, 5, 115, 0, 0, 121, 12, 1, 0, 0, 0, - 122, 123, 5, 109, 0, 0, 123, 124, 5, 97, 0, 0, 124, 125, 5, 120, 0, 0, - 125, 14, 1, 0, 0, 0, 126, 127, 5, 115, 0, 0, 127, 128, 5, 111, 0, 0, 128, - 129, 5, 117, 0, 0, 129, 130, 5, 114, 0, 0, 130, 131, 5, 99, 0, 0, 131, - 132, 5, 101, 0, 0, 132, 16, 1, 0, 0, 0, 133, 134, 5, 100, 0, 0, 134, 135, - 5, 101, 0, 0, 135, 136, 5, 115, 0, 0, 136, 137, 5, 116, 0, 0, 137, 138, - 5, 105, 0, 0, 138, 139, 5, 110, 0, 0, 139, 140, 5, 97, 0, 0, 140, 141, - 5, 116, 0, 0, 141, 142, 5, 105, 0, 0, 142, 143, 5, 111, 0, 0, 143, 144, - 5, 110, 0, 0, 144, 18, 1, 0, 0, 0, 145, 146, 5, 115, 0, 0, 146, 147, 5, - 101, 0, 0, 147, 148, 5, 110, 0, 0, 148, 149, 5, 100, 0, 0, 149, 20, 1, - 0, 0, 0, 150, 151, 5, 102, 0, 0, 151, 152, 5, 114, 0, 0, 152, 153, 5, 111, - 0, 0, 153, 154, 5, 109, 0, 0, 154, 22, 1, 0, 0, 0, 155, 156, 5, 117, 0, - 0, 156, 157, 5, 112, 0, 0, 157, 24, 1, 0, 0, 0, 158, 159, 5, 116, 0, 0, - 159, 160, 5, 111, 0, 0, 160, 26, 1, 0, 0, 0, 161, 162, 5, 114, 0, 0, 162, - 163, 5, 101, 0, 0, 163, 164, 5, 109, 0, 0, 164, 165, 5, 97, 0, 0, 165, - 166, 5, 105, 0, 0, 166, 167, 5, 110, 0, 0, 167, 168, 5, 105, 0, 0, 168, - 169, 5, 110, 0, 0, 169, 170, 5, 103, 0, 0, 170, 28, 1, 0, 0, 0, 171, 172, - 5, 97, 0, 0, 172, 173, 5, 108, 0, 0, 173, 174, 5, 108, 0, 0, 174, 175, - 5, 111, 0, 0, 175, 176, 5, 119, 0, 0, 176, 177, 5, 105, 0, 0, 177, 178, - 5, 110, 0, 0, 178, 179, 5, 103, 0, 0, 179, 30, 1, 0, 0, 0, 180, 181, 5, - 117, 0, 0, 181, 182, 5, 110, 0, 0, 182, 183, 5, 98, 0, 0, 183, 184, 5, - 111, 0, 0, 184, 185, 5, 117, 0, 0, 185, 186, 5, 110, 0, 0, 186, 187, 5, - 100, 0, 0, 187, 188, 5, 101, 0, 0, 188, 189, 5, 100, 0, 0, 189, 32, 1, - 0, 0, 0, 190, 191, 5, 111, 0, 0, 191, 192, 5, 118, 0, 0, 192, 193, 5, 101, - 0, 0, 193, 194, 5, 114, 0, 0, 194, 195, 5, 100, 0, 0, 195, 196, 5, 114, - 0, 0, 196, 197, 5, 97, 0, 0, 197, 198, 5, 102, 0, 0, 198, 199, 5, 116, - 0, 0, 199, 34, 1, 0, 0, 0, 200, 201, 5, 107, 0, 0, 201, 202, 5, 101, 0, - 0, 202, 203, 5, 112, 0, 0, 203, 204, 5, 116, 0, 0, 204, 36, 1, 0, 0, 0, - 205, 206, 5, 115, 0, 0, 206, 207, 5, 97, 0, 0, 207, 208, 5, 118, 0, 0, - 208, 209, 5, 101, 0, 0, 209, 38, 1, 0, 0, 0, 210, 211, 5, 40, 0, 0, 211, - 40, 1, 0, 0, 0, 212, 213, 5, 41, 0, 0, 213, 42, 1, 0, 0, 0, 214, 215, 5, - 91, 0, 0, 215, 44, 1, 0, 0, 0, 216, 217, 5, 93, 0, 0, 217, 46, 1, 0, 0, - 0, 218, 219, 5, 123, 0, 0, 219, 48, 1, 0, 0, 0, 220, 221, 5, 125, 0, 0, - 221, 50, 1, 0, 0, 0, 222, 223, 5, 44, 0, 0, 223, 52, 1, 0, 0, 0, 224, 225, - 5, 61, 0, 0, 225, 54, 1, 0, 0, 0, 226, 227, 5, 42, 0, 0, 227, 56, 1, 0, - 0, 0, 228, 229, 5, 45, 0, 0, 229, 58, 1, 0, 0, 0, 230, 232, 7, 2, 0, 0, - 231, 230, 1, 0, 0, 0, 232, 233, 1, 0, 0, 0, 233, 231, 1, 0, 0, 0, 233, - 234, 1, 0, 0, 0, 234, 236, 1, 0, 0, 0, 235, 237, 7, 3, 0, 0, 236, 235, - 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 238, 1, 0, 0, 0, 238, 240, 5, 47, - 0, 0, 239, 241, 7, 3, 0, 0, 240, 239, 1, 0, 0, 0, 240, 241, 1, 0, 0, 0, - 241, 243, 1, 0, 0, 0, 242, 244, 7, 2, 0, 0, 243, 242, 1, 0, 0, 0, 244, - 245, 1, 0, 0, 0, 245, 243, 1, 0, 0, 0, 245, 246, 1, 0, 0, 0, 246, 60, 1, - 0, 0, 0, 247, 249, 7, 2, 0, 0, 248, 247, 1, 0, 0, 0, 249, 250, 1, 0, 0, - 0, 250, 248, 1, 0, 0, 0, 250, 251, 1, 0, 0, 0, 251, 258, 1, 0, 0, 0, 252, - 254, 5, 46, 0, 0, 253, 255, 7, 2, 0, 0, 254, 253, 1, 0, 0, 0, 255, 256, - 1, 0, 0, 0, 256, 254, 1, 0, 0, 0, 256, 257, 1, 0, 0, 0, 257, 259, 1, 0, - 0, 0, 258, 252, 1, 0, 0, 0, 258, 259, 1, 0, 0, 0, 259, 260, 1, 0, 0, 0, - 260, 261, 5, 37, 0, 0, 261, 62, 1, 0, 0, 0, 262, 268, 5, 34, 0, 0, 263, - 264, 5, 92, 0, 0, 264, 267, 5, 34, 0, 0, 265, 267, 8, 4, 0, 0, 266, 263, - 1, 0, 0, 0, 266, 265, 1, 0, 0, 0, 267, 270, 1, 0, 0, 0, 268, 266, 1, 0, - 0, 0, 268, 269, 1, 0, 0, 0, 269, 271, 1, 0, 0, 0, 270, 268, 1, 0, 0, 0, - 271, 272, 5, 34, 0, 0, 272, 64, 1, 0, 0, 0, 273, 275, 7, 5, 0, 0, 274, - 273, 1, 0, 0, 0, 275, 276, 1, 0, 0, 0, 276, 274, 1, 0, 0, 0, 276, 277, - 1, 0, 0, 0, 277, 281, 1, 0, 0, 0, 278, 280, 7, 6, 0, 0, 279, 278, 1, 0, - 0, 0, 280, 283, 1, 0, 0, 0, 281, 279, 1, 0, 0, 0, 281, 282, 1, 0, 0, 0, - 282, 66, 1, 0, 0, 0, 283, 281, 1, 0, 0, 0, 284, 286, 3, 57, 28, 0, 285, - 284, 1, 0, 0, 0, 285, 286, 1, 0, 0, 0, 286, 288, 1, 0, 0, 0, 287, 289, - 7, 2, 0, 0, 288, 287, 1, 0, 0, 0, 289, 290, 1, 0, 0, 0, 290, 288, 1, 0, - 0, 0, 290, 291, 1, 0, 0, 0, 291, 300, 1, 0, 0, 0, 292, 294, 5, 95, 0, 0, - 293, 295, 7, 2, 0, 0, 294, 293, 1, 0, 0, 0, 295, 296, 1, 0, 0, 0, 296, - 294, 1, 0, 0, 0, 296, 297, 1, 0, 0, 0, 297, 299, 1, 0, 0, 0, 298, 292, - 1, 0, 0, 0, 299, 302, 1, 0, 0, 0, 300, 298, 1, 0, 0, 0, 300, 301, 1, 0, - 0, 0, 301, 68, 1, 0, 0, 0, 302, 300, 1, 0, 0, 0, 303, 305, 5, 36, 0, 0, - 304, 306, 7, 6, 0, 0, 305, 304, 1, 0, 0, 0, 306, 307, 1, 0, 0, 0, 307, - 305, 1, 0, 0, 0, 307, 308, 1, 0, 0, 0, 308, 312, 1, 0, 0, 0, 309, 311, - 7, 7, 0, 0, 310, 309, 1, 0, 0, 0, 311, 314, 1, 0, 0, 0, 312, 310, 1, 0, - 0, 0, 312, 313, 1, 0, 0, 0, 313, 70, 1, 0, 0, 0, 314, 312, 1, 0, 0, 0, - 315, 317, 5, 64, 0, 0, 316, 318, 7, 8, 0, 0, 317, 316, 1, 0, 0, 0, 318, - 319, 1, 0, 0, 0, 319, 317, 1, 0, 0, 0, 319, 320, 1, 0, 0, 0, 320, 329, - 1, 0, 0, 0, 321, 323, 5, 58, 0, 0, 322, 324, 7, 8, 0, 0, 323, 322, 1, 0, - 0, 0, 324, 325, 1, 0, 0, 0, 325, 323, 1, 0, 0, 0, 325, 326, 1, 0, 0, 0, - 326, 328, 1, 0, 0, 0, 327, 321, 1, 0, 0, 0, 328, 331, 1, 0, 0, 0, 329, - 327, 1, 0, 0, 0, 329, 330, 1, 0, 0, 0, 330, 72, 1, 0, 0, 0, 331, 329, 1, - 0, 0, 0, 332, 334, 7, 9, 0, 0, 333, 332, 1, 0, 0, 0, 334, 335, 1, 0, 0, - 0, 335, 333, 1, 0, 0, 0, 335, 336, 1, 0, 0, 0, 336, 74, 1, 0, 0, 0, 27, - 0, 80, 87, 94, 96, 110, 233, 236, 240, 245, 250, 256, 258, 266, 268, 276, - 281, 285, 290, 296, 300, 307, 312, 319, 325, 329, 335, 1, 6, 0, 0, - } - deserializer := antlr.NewATNDeserializer(nil) - staticData.atn = deserializer.Deserialize(staticData.serializedATN) - atn := staticData.atn - staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState)) - decisionToDFA := staticData.decisionToDFA - for index, state := range atn.DecisionToState { - decisionToDFA[index] = antlr.NewDFA(state, index) - } -} - -// NumscriptLexerInit initializes any static state used to implement NumscriptLexer. By default the -// static state used to implement the lexer is lazily initialized during the first call to -// NewNumscriptLexer(). You can call this function if you wish to initialize the static state ahead -// of time. -func NumscriptLexerInit() { - staticData := &NumscriptLexerLexerStaticData - staticData.once.Do(numscriptlexerLexerInit) -} - -// NewNumscriptLexer produces a new lexer instance for the optional input antlr.CharStream. -func NewNumscriptLexer(input antlr.CharStream) *NumscriptLexer { - NumscriptLexerInit() - l := new(NumscriptLexer) - l.BaseLexer = antlr.NewBaseLexer(input) - staticData := &NumscriptLexerLexerStaticData - l.Interpreter = antlr.NewLexerATNSimulator(l, staticData.atn, staticData.decisionToDFA, staticData.PredictionContextCache) - l.channelNames = staticData.ChannelNames - l.modeNames = staticData.ModeNames - l.RuleNames = staticData.RuleNames - l.LiteralNames = staticData.LiteralNames - l.SymbolicNames = staticData.SymbolicNames - l.GrammarFileName = "Numscript.g4" - // TODO: l.EOF = antlr.TokenEOF - - return l -} - -// NumscriptLexer tokens. -const ( - NumscriptLexerT__0 = 1 - NumscriptLexerWS = 2 - NumscriptLexerNEWLINE = 3 - NumscriptLexerMULTILINE_COMMENT = 4 - NumscriptLexerLINE_COMMENT = 5 - NumscriptLexerVARS = 6 - NumscriptLexerMAX = 7 - NumscriptLexerSOURCE = 8 - NumscriptLexerDESTINATION = 9 - NumscriptLexerSEND = 10 - NumscriptLexerFROM = 11 - NumscriptLexerUP = 12 - NumscriptLexerTO = 13 - NumscriptLexerREMAINING = 14 - NumscriptLexerALLOWING = 15 - NumscriptLexerUNBOUNDED = 16 - NumscriptLexerOVERDRAFT = 17 - NumscriptLexerKEPT = 18 - NumscriptLexerSAVE = 19 - NumscriptLexerLPARENS = 20 - NumscriptLexerRPARENS = 21 - NumscriptLexerLBRACKET = 22 - NumscriptLexerRBRACKET = 23 - NumscriptLexerLBRACE = 24 - NumscriptLexerRBRACE = 25 - NumscriptLexerCOMMA = 26 - NumscriptLexerEQ = 27 - NumscriptLexerSTAR = 28 - NumscriptLexerMINUS = 29 - NumscriptLexerRATIO_PORTION_LITERAL = 30 - NumscriptLexerPERCENTAGE_PORTION_LITERAL = 31 - NumscriptLexerSTRING = 32 - NumscriptLexerIDENTIFIER = 33 - NumscriptLexerNUMBER = 34 - NumscriptLexerVARIABLE_NAME = 35 - NumscriptLexerACCOUNT = 36 - NumscriptLexerASSET = 37 -) diff --git a/internal/parser/antlrParser/Lexer.interp b/internal/parser/antlrParser/Lexer.interp new file mode 100644 index 00000000..5cd7d25c --- /dev/null +++ b/internal/parser/antlrParser/Lexer.interp @@ -0,0 +1,139 @@ +token literal names: +null +null +null +null +null +'vars' +'max' +'source' +'destination' +'send' +'from' +'up' +'to' +'remaining' +'allowing' +'unbounded' +'overdraft' +'kept' +'save' +'(' +')' +'[' +']' +'{' +'}' +',' +'=' +'*' +'+' +'-' +null +null +null +null +null +null +'@' +':' +null +null +null + +token symbolic names: +null +WS +NEWLINE +MULTILINE_COMMENT +LINE_COMMENT +VARS +MAX +SOURCE +DESTINATION +SEND +FROM +UP +TO +REMAINING +ALLOWING +UNBOUNDED +OVERDRAFT +KEPT +SAVE +LPARENS +RPARENS +LBRACKET +RBRACKET +LBRACE +RBRACE +COMMA +EQ +STAR +PLUS +MINUS +RATIO_PORTION_LITERAL +PERCENTAGE_PORTION_LITERAL +STRING +IDENTIFIER +NUMBER +ASSET +ACCOUNT_START +COLON +ACCOUNT_TEXT +VARIABLE_NAME_ACC +VARIABLE_NAME_DEFAULT + +rule names: +WS +NEWLINE +MULTILINE_COMMENT +LINE_COMMENT +VARS +MAX +SOURCE +DESTINATION +SEND +FROM +UP +TO +REMAINING +ALLOWING +UNBOUNDED +OVERDRAFT +KEPT +SAVE +LPARENS +RPARENS +LBRACKET +RBRACKET +LBRACE +RBRACE +COMMA +EQ +STAR +PLUS +MINUS +RATIO_PORTION_LITERAL +PERCENTAGE_PORTION_LITERAL +STRING +IDENTIFIER +NUMBER +ASSET +ACCOUNT_START +COLON +VARIABLE_NAME_FRAMGMENT +ACCOUNT_TEXT +VARIABLE_NAME_ACC +VARIABLE_NAME_DEFAULT + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE +ACCOUNT_MODE + +atn: +[4, 0, 40, 350, 6, -1, 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, 1, 0, 4, 0, 86, 8, 0, 11, 0, 12, 0, 87, 1, 0, 1, 0, 1, 1, 4, 1, 93, 8, 1, 11, 1, 12, 1, 94, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 102, 8, 2, 10, 2, 12, 2, 105, 9, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 116, 8, 3, 10, 3, 12, 3, 119, 9, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 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, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 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, 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, 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, 17, 1, 17, 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, 28, 1, 28, 1, 29, 4, 29, 241, 8, 29, 11, 29, 12, 29, 242, 1, 29, 3, 29, 246, 8, 29, 1, 29, 1, 29, 3, 29, 250, 8, 29, 1, 29, 4, 29, 253, 8, 29, 11, 29, 12, 29, 254, 1, 30, 4, 30, 258, 8, 30, 11, 30, 12, 30, 259, 1, 30, 1, 30, 4, 30, 264, 8, 30, 11, 30, 12, 30, 265, 3, 30, 268, 8, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 5, 31, 276, 8, 31, 10, 31, 12, 31, 279, 9, 31, 1, 31, 1, 31, 1, 32, 4, 32, 284, 8, 32, 11, 32, 12, 32, 285, 1, 32, 5, 32, 289, 8, 32, 10, 32, 12, 32, 292, 9, 32, 1, 33, 3, 33, 295, 8, 33, 1, 33, 4, 33, 298, 8, 33, 11, 33, 12, 33, 299, 1, 33, 1, 33, 4, 33, 304, 8, 33, 11, 33, 12, 33, 305, 5, 33, 308, 8, 33, 10, 33, 12, 33, 311, 9, 33, 1, 34, 4, 34, 314, 8, 34, 11, 34, 12, 34, 315, 1, 35, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 37, 1, 37, 4, 37, 328, 8, 37, 11, 37, 12, 37, 329, 1, 37, 5, 37, 333, 8, 37, 10, 37, 12, 37, 336, 9, 37, 1, 38, 4, 38, 339, 8, 38, 11, 38, 12, 38, 340, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 2, 103, 117, 0, 41, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18, 9, 20, 10, 22, 11, 24, 12, 26, 13, 28, 14, 30, 15, 32, 16, 34, 17, 36, 18, 38, 19, 40, 20, 42, 21, 44, 22, 46, 23, 48, 24, 50, 25, 52, 26, 54, 27, 56, 28, 58, 29, 60, 30, 62, 31, 64, 32, 66, 33, 68, 34, 70, 35, 72, 36, 74, 37, 76, 0, 78, 38, 80, 39, 82, 40, 2, 0, 1, 10, 3, 0, 9, 10, 13, 13, 32, 32, 2, 0, 10, 10, 13, 13, 1, 0, 48, 57, 1, 0, 32, 32, 3, 0, 10, 10, 13, 13, 34, 34, 1, 0, 97, 122, 2, 0, 95, 95, 97, 122, 2, 0, 47, 57, 65, 90, 3, 0, 48, 57, 95, 95, 97, 122, 5, 0, 45, 45, 48, 57, 65, 90, 95, 95, 97, 122, 371, 0, 2, 1, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 6, 1, 0, 0, 0, 0, 8, 1, 0, 0, 0, 0, 10, 1, 0, 0, 0, 0, 12, 1, 0, 0, 0, 0, 14, 1, 0, 0, 0, 0, 16, 1, 0, 0, 0, 0, 18, 1, 0, 0, 0, 0, 20, 1, 0, 0, 0, 0, 22, 1, 0, 0, 0, 0, 24, 1, 0, 0, 0, 0, 26, 1, 0, 0, 0, 0, 28, 1, 0, 0, 0, 0, 30, 1, 0, 0, 0, 0, 32, 1, 0, 0, 0, 0, 34, 1, 0, 0, 0, 0, 36, 1, 0, 0, 0, 0, 38, 1, 0, 0, 0, 0, 40, 1, 0, 0, 0, 0, 42, 1, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 46, 1, 0, 0, 0, 0, 48, 1, 0, 0, 0, 0, 50, 1, 0, 0, 0, 0, 52, 1, 0, 0, 0, 0, 54, 1, 0, 0, 0, 0, 56, 1, 0, 0, 0, 0, 58, 1, 0, 0, 0, 0, 60, 1, 0, 0, 0, 0, 62, 1, 0, 0, 0, 0, 64, 1, 0, 0, 0, 0, 66, 1, 0, 0, 0, 0, 68, 1, 0, 0, 0, 0, 70, 1, 0, 0, 0, 0, 72, 1, 0, 0, 0, 0, 74, 1, 0, 0, 0, 0, 82, 1, 0, 0, 0, 1, 78, 1, 0, 0, 0, 1, 80, 1, 0, 0, 0, 2, 85, 1, 0, 0, 0, 4, 92, 1, 0, 0, 0, 6, 96, 1, 0, 0, 0, 8, 111, 1, 0, 0, 0, 10, 124, 1, 0, 0, 0, 12, 129, 1, 0, 0, 0, 14, 133, 1, 0, 0, 0, 16, 140, 1, 0, 0, 0, 18, 152, 1, 0, 0, 0, 20, 157, 1, 0, 0, 0, 22, 162, 1, 0, 0, 0, 24, 165, 1, 0, 0, 0, 26, 168, 1, 0, 0, 0, 28, 178, 1, 0, 0, 0, 30, 187, 1, 0, 0, 0, 32, 197, 1, 0, 0, 0, 34, 207, 1, 0, 0, 0, 36, 212, 1, 0, 0, 0, 38, 217, 1, 0, 0, 0, 40, 219, 1, 0, 0, 0, 42, 221, 1, 0, 0, 0, 44, 223, 1, 0, 0, 0, 46, 225, 1, 0, 0, 0, 48, 227, 1, 0, 0, 0, 50, 229, 1, 0, 0, 0, 52, 231, 1, 0, 0, 0, 54, 233, 1, 0, 0, 0, 56, 235, 1, 0, 0, 0, 58, 237, 1, 0, 0, 0, 60, 240, 1, 0, 0, 0, 62, 257, 1, 0, 0, 0, 64, 271, 1, 0, 0, 0, 66, 283, 1, 0, 0, 0, 68, 294, 1, 0, 0, 0, 70, 313, 1, 0, 0, 0, 72, 317, 1, 0, 0, 0, 74, 321, 1, 0, 0, 0, 76, 325, 1, 0, 0, 0, 78, 338, 1, 0, 0, 0, 80, 344, 1, 0, 0, 0, 82, 348, 1, 0, 0, 0, 84, 86, 7, 0, 0, 0, 85, 84, 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, 87, 85, 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 90, 6, 0, 0, 0, 90, 3, 1, 0, 0, 0, 91, 93, 7, 1, 0, 0, 92, 91, 1, 0, 0, 0, 93, 94, 1, 0, 0, 0, 94, 92, 1, 0, 0, 0, 94, 95, 1, 0, 0, 0, 95, 5, 1, 0, 0, 0, 96, 97, 5, 47, 0, 0, 97, 98, 5, 42, 0, 0, 98, 103, 1, 0, 0, 0, 99, 102, 3, 6, 2, 0, 100, 102, 9, 0, 0, 0, 101, 99, 1, 0, 0, 0, 101, 100, 1, 0, 0, 0, 102, 105, 1, 0, 0, 0, 103, 104, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 104, 106, 1, 0, 0, 0, 105, 103, 1, 0, 0, 0, 106, 107, 5, 42, 0, 0, 107, 108, 5, 47, 0, 0, 108, 109, 1, 0, 0, 0, 109, 110, 6, 2, 0, 0, 110, 7, 1, 0, 0, 0, 111, 112, 5, 47, 0, 0, 112, 113, 5, 47, 0, 0, 113, 117, 1, 0, 0, 0, 114, 116, 9, 0, 0, 0, 115, 114, 1, 0, 0, 0, 116, 119, 1, 0, 0, 0, 117, 118, 1, 0, 0, 0, 117, 115, 1, 0, 0, 0, 118, 120, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 120, 121, 3, 4, 1, 0, 121, 122, 1, 0, 0, 0, 122, 123, 6, 3, 0, 0, 123, 9, 1, 0, 0, 0, 124, 125, 5, 118, 0, 0, 125, 126, 5, 97, 0, 0, 126, 127, 5, 114, 0, 0, 127, 128, 5, 115, 0, 0, 128, 11, 1, 0, 0, 0, 129, 130, 5, 109, 0, 0, 130, 131, 5, 97, 0, 0, 131, 132, 5, 120, 0, 0, 132, 13, 1, 0, 0, 0, 133, 134, 5, 115, 0, 0, 134, 135, 5, 111, 0, 0, 135, 136, 5, 117, 0, 0, 136, 137, 5, 114, 0, 0, 137, 138, 5, 99, 0, 0, 138, 139, 5, 101, 0, 0, 139, 15, 1, 0, 0, 0, 140, 141, 5, 100, 0, 0, 141, 142, 5, 101, 0, 0, 142, 143, 5, 115, 0, 0, 143, 144, 5, 116, 0, 0, 144, 145, 5, 105, 0, 0, 145, 146, 5, 110, 0, 0, 146, 147, 5, 97, 0, 0, 147, 148, 5, 116, 0, 0, 148, 149, 5, 105, 0, 0, 149, 150, 5, 111, 0, 0, 150, 151, 5, 110, 0, 0, 151, 17, 1, 0, 0, 0, 152, 153, 5, 115, 0, 0, 153, 154, 5, 101, 0, 0, 154, 155, 5, 110, 0, 0, 155, 156, 5, 100, 0, 0, 156, 19, 1, 0, 0, 0, 157, 158, 5, 102, 0, 0, 158, 159, 5, 114, 0, 0, 159, 160, 5, 111, 0, 0, 160, 161, 5, 109, 0, 0, 161, 21, 1, 0, 0, 0, 162, 163, 5, 117, 0, 0, 163, 164, 5, 112, 0, 0, 164, 23, 1, 0, 0, 0, 165, 166, 5, 116, 0, 0, 166, 167, 5, 111, 0, 0, 167, 25, 1, 0, 0, 0, 168, 169, 5, 114, 0, 0, 169, 170, 5, 101, 0, 0, 170, 171, 5, 109, 0, 0, 171, 172, 5, 97, 0, 0, 172, 173, 5, 105, 0, 0, 173, 174, 5, 110, 0, 0, 174, 175, 5, 105, 0, 0, 175, 176, 5, 110, 0, 0, 176, 177, 5, 103, 0, 0, 177, 27, 1, 0, 0, 0, 178, 179, 5, 97, 0, 0, 179, 180, 5, 108, 0, 0, 180, 181, 5, 108, 0, 0, 181, 182, 5, 111, 0, 0, 182, 183, 5, 119, 0, 0, 183, 184, 5, 105, 0, 0, 184, 185, 5, 110, 0, 0, 185, 186, 5, 103, 0, 0, 186, 29, 1, 0, 0, 0, 187, 188, 5, 117, 0, 0, 188, 189, 5, 110, 0, 0, 189, 190, 5, 98, 0, 0, 190, 191, 5, 111, 0, 0, 191, 192, 5, 117, 0, 0, 192, 193, 5, 110, 0, 0, 193, 194, 5, 100, 0, 0, 194, 195, 5, 101, 0, 0, 195, 196, 5, 100, 0, 0, 196, 31, 1, 0, 0, 0, 197, 198, 5, 111, 0, 0, 198, 199, 5, 118, 0, 0, 199, 200, 5, 101, 0, 0, 200, 201, 5, 114, 0, 0, 201, 202, 5, 100, 0, 0, 202, 203, 5, 114, 0, 0, 203, 204, 5, 97, 0, 0, 204, 205, 5, 102, 0, 0, 205, 206, 5, 116, 0, 0, 206, 33, 1, 0, 0, 0, 207, 208, 5, 107, 0, 0, 208, 209, 5, 101, 0, 0, 209, 210, 5, 112, 0, 0, 210, 211, 5, 116, 0, 0, 211, 35, 1, 0, 0, 0, 212, 213, 5, 115, 0, 0, 213, 214, 5, 97, 0, 0, 214, 215, 5, 118, 0, 0, 215, 216, 5, 101, 0, 0, 216, 37, 1, 0, 0, 0, 217, 218, 5, 40, 0, 0, 218, 39, 1, 0, 0, 0, 219, 220, 5, 41, 0, 0, 220, 41, 1, 0, 0, 0, 221, 222, 5, 91, 0, 0, 222, 43, 1, 0, 0, 0, 223, 224, 5, 93, 0, 0, 224, 45, 1, 0, 0, 0, 225, 226, 5, 123, 0, 0, 226, 47, 1, 0, 0, 0, 227, 228, 5, 125, 0, 0, 228, 49, 1, 0, 0, 0, 229, 230, 5, 44, 0, 0, 230, 51, 1, 0, 0, 0, 231, 232, 5, 61, 0, 0, 232, 53, 1, 0, 0, 0, 233, 234, 5, 42, 0, 0, 234, 55, 1, 0, 0, 0, 235, 236, 5, 43, 0, 0, 236, 57, 1, 0, 0, 0, 237, 238, 5, 45, 0, 0, 238, 59, 1, 0, 0, 0, 239, 241, 7, 2, 0, 0, 240, 239, 1, 0, 0, 0, 241, 242, 1, 0, 0, 0, 242, 240, 1, 0, 0, 0, 242, 243, 1, 0, 0, 0, 243, 245, 1, 0, 0, 0, 244, 246, 7, 3, 0, 0, 245, 244, 1, 0, 0, 0, 245, 246, 1, 0, 0, 0, 246, 247, 1, 0, 0, 0, 247, 249, 5, 47, 0, 0, 248, 250, 7, 3, 0, 0, 249, 248, 1, 0, 0, 0, 249, 250, 1, 0, 0, 0, 250, 252, 1, 0, 0, 0, 251, 253, 7, 2, 0, 0, 252, 251, 1, 0, 0, 0, 253, 254, 1, 0, 0, 0, 254, 252, 1, 0, 0, 0, 254, 255, 1, 0, 0, 0, 255, 61, 1, 0, 0, 0, 256, 258, 7, 2, 0, 0, 257, 256, 1, 0, 0, 0, 258, 259, 1, 0, 0, 0, 259, 257, 1, 0, 0, 0, 259, 260, 1, 0, 0, 0, 260, 267, 1, 0, 0, 0, 261, 263, 5, 46, 0, 0, 262, 264, 7, 2, 0, 0, 263, 262, 1, 0, 0, 0, 264, 265, 1, 0, 0, 0, 265, 263, 1, 0, 0, 0, 265, 266, 1, 0, 0, 0, 266, 268, 1, 0, 0, 0, 267, 261, 1, 0, 0, 0, 267, 268, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, 270, 5, 37, 0, 0, 270, 63, 1, 0, 0, 0, 271, 277, 5, 34, 0, 0, 272, 273, 5, 92, 0, 0, 273, 276, 5, 34, 0, 0, 274, 276, 8, 4, 0, 0, 275, 272, 1, 0, 0, 0, 275, 274, 1, 0, 0, 0, 276, 279, 1, 0, 0, 0, 277, 275, 1, 0, 0, 0, 277, 278, 1, 0, 0, 0, 278, 280, 1, 0, 0, 0, 279, 277, 1, 0, 0, 0, 280, 281, 5, 34, 0, 0, 281, 65, 1, 0, 0, 0, 282, 284, 7, 5, 0, 0, 283, 282, 1, 0, 0, 0, 284, 285, 1, 0, 0, 0, 285, 283, 1, 0, 0, 0, 285, 286, 1, 0, 0, 0, 286, 290, 1, 0, 0, 0, 287, 289, 7, 6, 0, 0, 288, 287, 1, 0, 0, 0, 289, 292, 1, 0, 0, 0, 290, 288, 1, 0, 0, 0, 290, 291, 1, 0, 0, 0, 291, 67, 1, 0, 0, 0, 292, 290, 1, 0, 0, 0, 293, 295, 3, 58, 28, 0, 294, 293, 1, 0, 0, 0, 294, 295, 1, 0, 0, 0, 295, 297, 1, 0, 0, 0, 296, 298, 7, 2, 0, 0, 297, 296, 1, 0, 0, 0, 298, 299, 1, 0, 0, 0, 299, 297, 1, 0, 0, 0, 299, 300, 1, 0, 0, 0, 300, 309, 1, 0, 0, 0, 301, 303, 5, 95, 0, 0, 302, 304, 7, 2, 0, 0, 303, 302, 1, 0, 0, 0, 304, 305, 1, 0, 0, 0, 305, 303, 1, 0, 0, 0, 305, 306, 1, 0, 0, 0, 306, 308, 1, 0, 0, 0, 307, 301, 1, 0, 0, 0, 308, 311, 1, 0, 0, 0, 309, 307, 1, 0, 0, 0, 309, 310, 1, 0, 0, 0, 310, 69, 1, 0, 0, 0, 311, 309, 1, 0, 0, 0, 312, 314, 7, 7, 0, 0, 313, 312, 1, 0, 0, 0, 314, 315, 1, 0, 0, 0, 315, 313, 1, 0, 0, 0, 315, 316, 1, 0, 0, 0, 316, 71, 1, 0, 0, 0, 317, 318, 5, 64, 0, 0, 318, 319, 1, 0, 0, 0, 319, 320, 6, 35, 1, 0, 320, 73, 1, 0, 0, 0, 321, 322, 5, 58, 0, 0, 322, 323, 1, 0, 0, 0, 323, 324, 6, 36, 1, 0, 324, 75, 1, 0, 0, 0, 325, 327, 5, 36, 0, 0, 326, 328, 7, 6, 0, 0, 327, 326, 1, 0, 0, 0, 328, 329, 1, 0, 0, 0, 329, 327, 1, 0, 0, 0, 329, 330, 1, 0, 0, 0, 330, 334, 1, 0, 0, 0, 331, 333, 7, 8, 0, 0, 332, 331, 1, 0, 0, 0, 333, 336, 1, 0, 0, 0, 334, 332, 1, 0, 0, 0, 334, 335, 1, 0, 0, 0, 335, 77, 1, 0, 0, 0, 336, 334, 1, 0, 0, 0, 337, 339, 7, 9, 0, 0, 338, 337, 1, 0, 0, 0, 339, 340, 1, 0, 0, 0, 340, 338, 1, 0, 0, 0, 340, 341, 1, 0, 0, 0, 341, 342, 1, 0, 0, 0, 342, 343, 6, 38, 2, 0, 343, 79, 1, 0, 0, 0, 344, 345, 3, 76, 37, 0, 345, 346, 1, 0, 0, 0, 346, 347, 6, 39, 2, 0, 347, 81, 1, 0, 0, 0, 348, 349, 3, 76, 37, 0, 349, 83, 1, 0, 0, 0, 26, 0, 1, 87, 94, 101, 103, 117, 242, 245, 249, 254, 259, 265, 267, 275, 277, 285, 290, 294, 299, 305, 309, 315, 329, 334, 340, 3, 6, 0, 0, 5, 1, 0, 4, 0, 0] \ No newline at end of file diff --git a/internal/parser/antlrParser/Lexer.tokens b/internal/parser/antlrParser/Lexer.tokens new file mode 100644 index 00000000..dc80dc39 --- /dev/null +++ b/internal/parser/antlrParser/Lexer.tokens @@ -0,0 +1,67 @@ +WS=1 +NEWLINE=2 +MULTILINE_COMMENT=3 +LINE_COMMENT=4 +VARS=5 +MAX=6 +SOURCE=7 +DESTINATION=8 +SEND=9 +FROM=10 +UP=11 +TO=12 +REMAINING=13 +ALLOWING=14 +UNBOUNDED=15 +OVERDRAFT=16 +KEPT=17 +SAVE=18 +LPARENS=19 +RPARENS=20 +LBRACKET=21 +RBRACKET=22 +LBRACE=23 +RBRACE=24 +COMMA=25 +EQ=26 +STAR=27 +PLUS=28 +MINUS=29 +RATIO_PORTION_LITERAL=30 +PERCENTAGE_PORTION_LITERAL=31 +STRING=32 +IDENTIFIER=33 +NUMBER=34 +ASSET=35 +ACCOUNT_START=36 +COLON=37 +ACCOUNT_TEXT=38 +VARIABLE_NAME_ACC=39 +VARIABLE_NAME_DEFAULT=40 +'vars'=5 +'max'=6 +'source'=7 +'destination'=8 +'send'=9 +'from'=10 +'up'=11 +'to'=12 +'remaining'=13 +'allowing'=14 +'unbounded'=15 +'overdraft'=16 +'kept'=17 +'save'=18 +'('=19 +')'=20 +'['=21 +']'=22 +'{'=23 +'}'=24 +','=25 +'='=26 +'*'=27 +'+'=28 +'-'=29 +'@'=36 +':'=37 diff --git a/internal/parser/antlrParser/Numscript.interp b/internal/parser/antlrParser/Numscript.interp new file mode 100644 index 00000000..0e5f2957 --- /dev/null +++ b/internal/parser/antlrParser/Numscript.interp @@ -0,0 +1,111 @@ +token literal names: +null +null +null +null +null +'vars' +'max' +'source' +'destination' +'send' +'from' +'up' +'to' +'remaining' +'allowing' +'unbounded' +'overdraft' +'kept' +'save' +'(' +')' +'[' +']' +'{' +'}' +',' +'=' +'*' +'+' +'-' +null +null +null +null +null +null +'@' +':' +null +null +null + +token symbolic names: +null +WS +NEWLINE +MULTILINE_COMMENT +LINE_COMMENT +VARS +MAX +SOURCE +DESTINATION +SEND +FROM +UP +TO +REMAINING +ALLOWING +UNBOUNDED +OVERDRAFT +KEPT +SAVE +LPARENS +RPARENS +LBRACKET +RBRACKET +LBRACE +RBRACE +COMMA +EQ +STAR +PLUS +MINUS +RATIO_PORTION_LITERAL +PERCENTAGE_PORTION_LITERAL +STRING +IDENTIFIER +NUMBER +ASSET +ACCOUNT_START +COLON +ACCOUNT_TEXT +VARIABLE_NAME_ACC +VARIABLE_NAME_DEFAULT + +rule names: +monetaryLit +portion +accountLiteralPart +valueExpr +functionCallArgs +functionCall +varOrigin +varDeclaration +varsDeclaration +program +sentAllLit +allotment +source +allotmentClauseSrc +keptOrDestination +destinationInOrderClause +destination +allotmentClauseDest +sentValue +statement + + +atn: +[4, 1, 40, 231, 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, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 3, 1, 48, 8, 1, 1, 2, 1, 2, 3, 2, 52, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 62, 8, 3, 10, 3, 12, 3, 65, 9, 3, 1, 3, 1, 3, 1, 3, 3, 3, 70, 8, 3, 1, 3, 1, 3, 1, 3, 5, 3, 75, 8, 3, 10, 3, 12, 3, 78, 9, 3, 1, 4, 1, 4, 1, 4, 5, 4, 83, 8, 4, 10, 4, 12, 4, 86, 9, 4, 1, 5, 1, 5, 1, 5, 3, 5, 91, 8, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 3, 7, 101, 8, 7, 1, 8, 1, 8, 1, 8, 5, 8, 106, 8, 8, 10, 8, 12, 8, 109, 9, 8, 1, 8, 1, 8, 1, 9, 3, 9, 114, 8, 9, 1, 9, 5, 9, 117, 8, 9, 10, 9, 12, 9, 120, 9, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 3, 11, 132, 8, 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, 4, 12, 149, 8, 12, 11, 12, 12, 12, 150, 1, 12, 1, 12, 1, 12, 1, 12, 5, 12, 157, 8, 12, 10, 12, 12, 12, 160, 9, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 168, 8, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 3, 14, 177, 8, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 4, 16, 186, 8, 16, 11, 16, 12, 16, 187, 1, 16, 1, 16, 1, 16, 1, 16, 5, 16, 194, 8, 16, 10, 16, 12, 16, 197, 9, 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 203, 8, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 3, 18, 210, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 229, 8, 19, 1, 19, 0, 1, 6, 20, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 0, 2, 1, 0, 28, 29, 2, 0, 16, 16, 33, 33, 243, 0, 40, 1, 0, 0, 0, 2, 47, 1, 0, 0, 0, 4, 51, 1, 0, 0, 0, 6, 69, 1, 0, 0, 0, 8, 79, 1, 0, 0, 0, 10, 87, 1, 0, 0, 0, 12, 94, 1, 0, 0, 0, 14, 97, 1, 0, 0, 0, 16, 102, 1, 0, 0, 0, 18, 113, 1, 0, 0, 0, 20, 123, 1, 0, 0, 0, 22, 131, 1, 0, 0, 0, 24, 167, 1, 0, 0, 0, 26, 169, 1, 0, 0, 0, 28, 176, 1, 0, 0, 0, 30, 178, 1, 0, 0, 0, 32, 202, 1, 0, 0, 0, 34, 204, 1, 0, 0, 0, 36, 209, 1, 0, 0, 0, 38, 228, 1, 0, 0, 0, 40, 41, 5, 21, 0, 0, 41, 42, 3, 6, 3, 0, 42, 43, 3, 6, 3, 0, 43, 44, 5, 22, 0, 0, 44, 1, 1, 0, 0, 0, 45, 48, 5, 30, 0, 0, 46, 48, 5, 31, 0, 0, 47, 45, 1, 0, 0, 0, 47, 46, 1, 0, 0, 0, 48, 3, 1, 0, 0, 0, 49, 52, 5, 38, 0, 0, 50, 52, 5, 39, 0, 0, 51, 49, 1, 0, 0, 0, 51, 50, 1, 0, 0, 0, 52, 5, 1, 0, 0, 0, 53, 54, 6, 3, -1, 0, 54, 70, 5, 40, 0, 0, 55, 70, 5, 35, 0, 0, 56, 70, 5, 32, 0, 0, 57, 58, 5, 36, 0, 0, 58, 63, 3, 4, 2, 0, 59, 60, 5, 37, 0, 0, 60, 62, 3, 4, 2, 0, 61, 59, 1, 0, 0, 0, 62, 65, 1, 0, 0, 0, 63, 61, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, 64, 70, 1, 0, 0, 0, 65, 63, 1, 0, 0, 0, 66, 70, 5, 34, 0, 0, 67, 70, 3, 0, 0, 0, 68, 70, 3, 2, 1, 0, 69, 53, 1, 0, 0, 0, 69, 55, 1, 0, 0, 0, 69, 56, 1, 0, 0, 0, 69, 57, 1, 0, 0, 0, 69, 66, 1, 0, 0, 0, 69, 67, 1, 0, 0, 0, 69, 68, 1, 0, 0, 0, 70, 76, 1, 0, 0, 0, 71, 72, 10, 1, 0, 0, 72, 73, 7, 0, 0, 0, 73, 75, 3, 6, 3, 2, 74, 71, 1, 0, 0, 0, 75, 78, 1, 0, 0, 0, 76, 74, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 7, 1, 0, 0, 0, 78, 76, 1, 0, 0, 0, 79, 84, 3, 6, 3, 0, 80, 81, 5, 25, 0, 0, 81, 83, 3, 6, 3, 0, 82, 80, 1, 0, 0, 0, 83, 86, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 84, 85, 1, 0, 0, 0, 85, 9, 1, 0, 0, 0, 86, 84, 1, 0, 0, 0, 87, 88, 7, 1, 0, 0, 88, 90, 5, 19, 0, 0, 89, 91, 3, 8, 4, 0, 90, 89, 1, 0, 0, 0, 90, 91, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 93, 5, 20, 0, 0, 93, 11, 1, 0, 0, 0, 94, 95, 5, 26, 0, 0, 95, 96, 3, 10, 5, 0, 96, 13, 1, 0, 0, 0, 97, 98, 5, 33, 0, 0, 98, 100, 5, 40, 0, 0, 99, 101, 3, 12, 6, 0, 100, 99, 1, 0, 0, 0, 100, 101, 1, 0, 0, 0, 101, 15, 1, 0, 0, 0, 102, 103, 5, 5, 0, 0, 103, 107, 5, 23, 0, 0, 104, 106, 3, 14, 7, 0, 105, 104, 1, 0, 0, 0, 106, 109, 1, 0, 0, 0, 107, 105, 1, 0, 0, 0, 107, 108, 1, 0, 0, 0, 108, 110, 1, 0, 0, 0, 109, 107, 1, 0, 0, 0, 110, 111, 5, 24, 0, 0, 111, 17, 1, 0, 0, 0, 112, 114, 3, 16, 8, 0, 113, 112, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 118, 1, 0, 0, 0, 115, 117, 3, 38, 19, 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, 0, 0, 1, 122, 19, 1, 0, 0, 0, 123, 124, 5, 21, 0, 0, 124, 125, 3, 6, 3, 0, 125, 126, 5, 27, 0, 0, 126, 127, 5, 22, 0, 0, 127, 21, 1, 0, 0, 0, 128, 132, 3, 2, 1, 0, 129, 132, 5, 40, 0, 0, 130, 132, 5, 13, 0, 0, 131, 128, 1, 0, 0, 0, 131, 129, 1, 0, 0, 0, 131, 130, 1, 0, 0, 0, 132, 23, 1, 0, 0, 0, 133, 134, 3, 6, 3, 0, 134, 135, 5, 14, 0, 0, 135, 136, 5, 15, 0, 0, 136, 137, 5, 16, 0, 0, 137, 168, 1, 0, 0, 0, 138, 139, 3, 6, 3, 0, 139, 140, 5, 14, 0, 0, 140, 141, 5, 16, 0, 0, 141, 142, 5, 11, 0, 0, 142, 143, 5, 12, 0, 0, 143, 144, 3, 6, 3, 0, 144, 168, 1, 0, 0, 0, 145, 168, 3, 6, 3, 0, 146, 148, 5, 23, 0, 0, 147, 149, 3, 26, 13, 0, 148, 147, 1, 0, 0, 0, 149, 150, 1, 0, 0, 0, 150, 148, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 152, 1, 0, 0, 0, 152, 153, 5, 24, 0, 0, 153, 168, 1, 0, 0, 0, 154, 158, 5, 23, 0, 0, 155, 157, 3, 24, 12, 0, 156, 155, 1, 0, 0, 0, 157, 160, 1, 0, 0, 0, 158, 156, 1, 0, 0, 0, 158, 159, 1, 0, 0, 0, 159, 161, 1, 0, 0, 0, 160, 158, 1, 0, 0, 0, 161, 168, 5, 24, 0, 0, 162, 163, 5, 6, 0, 0, 163, 164, 3, 6, 3, 0, 164, 165, 5, 10, 0, 0, 165, 166, 3, 24, 12, 0, 166, 168, 1, 0, 0, 0, 167, 133, 1, 0, 0, 0, 167, 138, 1, 0, 0, 0, 167, 145, 1, 0, 0, 0, 167, 146, 1, 0, 0, 0, 167, 154, 1, 0, 0, 0, 167, 162, 1, 0, 0, 0, 168, 25, 1, 0, 0, 0, 169, 170, 3, 22, 11, 0, 170, 171, 5, 10, 0, 0, 171, 172, 3, 24, 12, 0, 172, 27, 1, 0, 0, 0, 173, 174, 5, 12, 0, 0, 174, 177, 3, 32, 16, 0, 175, 177, 5, 17, 0, 0, 176, 173, 1, 0, 0, 0, 176, 175, 1, 0, 0, 0, 177, 29, 1, 0, 0, 0, 178, 179, 5, 6, 0, 0, 179, 180, 3, 6, 3, 0, 180, 181, 3, 28, 14, 0, 181, 31, 1, 0, 0, 0, 182, 203, 3, 6, 3, 0, 183, 185, 5, 23, 0, 0, 184, 186, 3, 34, 17, 0, 185, 184, 1, 0, 0, 0, 186, 187, 1, 0, 0, 0, 187, 185, 1, 0, 0, 0, 187, 188, 1, 0, 0, 0, 188, 189, 1, 0, 0, 0, 189, 190, 5, 24, 0, 0, 190, 203, 1, 0, 0, 0, 191, 195, 5, 23, 0, 0, 192, 194, 3, 30, 15, 0, 193, 192, 1, 0, 0, 0, 194, 197, 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, 195, 196, 1, 0, 0, 0, 196, 198, 1, 0, 0, 0, 197, 195, 1, 0, 0, 0, 198, 199, 5, 13, 0, 0, 199, 200, 3, 28, 14, 0, 200, 201, 5, 24, 0, 0, 201, 203, 1, 0, 0, 0, 202, 182, 1, 0, 0, 0, 202, 183, 1, 0, 0, 0, 202, 191, 1, 0, 0, 0, 203, 33, 1, 0, 0, 0, 204, 205, 3, 22, 11, 0, 205, 206, 3, 28, 14, 0, 206, 35, 1, 0, 0, 0, 207, 210, 3, 6, 3, 0, 208, 210, 3, 20, 10, 0, 209, 207, 1, 0, 0, 0, 209, 208, 1, 0, 0, 0, 210, 37, 1, 0, 0, 0, 211, 212, 5, 9, 0, 0, 212, 213, 3, 36, 18, 0, 213, 214, 5, 19, 0, 0, 214, 215, 5, 7, 0, 0, 215, 216, 5, 26, 0, 0, 216, 217, 3, 24, 12, 0, 217, 218, 5, 8, 0, 0, 218, 219, 5, 26, 0, 0, 219, 220, 3, 32, 16, 0, 220, 221, 5, 20, 0, 0, 221, 229, 1, 0, 0, 0, 222, 223, 5, 18, 0, 0, 223, 224, 3, 36, 18, 0, 224, 225, 5, 10, 0, 0, 225, 226, 3, 6, 3, 0, 226, 229, 1, 0, 0, 0, 227, 229, 3, 10, 5, 0, 228, 211, 1, 0, 0, 0, 228, 222, 1, 0, 0, 0, 228, 227, 1, 0, 0, 0, 229, 39, 1, 0, 0, 0, 21, 47, 51, 63, 69, 76, 84, 90, 100, 107, 113, 118, 131, 150, 158, 167, 176, 187, 195, 202, 209, 228] \ No newline at end of file diff --git a/internal/parser/antlrParser/Numscript.tokens b/internal/parser/antlrParser/Numscript.tokens new file mode 100644 index 00000000..dc80dc39 --- /dev/null +++ b/internal/parser/antlrParser/Numscript.tokens @@ -0,0 +1,67 @@ +WS=1 +NEWLINE=2 +MULTILINE_COMMENT=3 +LINE_COMMENT=4 +VARS=5 +MAX=6 +SOURCE=7 +DESTINATION=8 +SEND=9 +FROM=10 +UP=11 +TO=12 +REMAINING=13 +ALLOWING=14 +UNBOUNDED=15 +OVERDRAFT=16 +KEPT=17 +SAVE=18 +LPARENS=19 +RPARENS=20 +LBRACKET=21 +RBRACKET=22 +LBRACE=23 +RBRACE=24 +COMMA=25 +EQ=26 +STAR=27 +PLUS=28 +MINUS=29 +RATIO_PORTION_LITERAL=30 +PERCENTAGE_PORTION_LITERAL=31 +STRING=32 +IDENTIFIER=33 +NUMBER=34 +ASSET=35 +ACCOUNT_START=36 +COLON=37 +ACCOUNT_TEXT=38 +VARIABLE_NAME_ACC=39 +VARIABLE_NAME_DEFAULT=40 +'vars'=5 +'max'=6 +'source'=7 +'destination'=8 +'send'=9 +'from'=10 +'up'=11 +'to'=12 +'remaining'=13 +'allowing'=14 +'unbounded'=15 +'overdraft'=16 +'kept'=17 +'save'=18 +'('=19 +')'=20 +'['=21 +']'=22 +'{'=23 +'}'=24 +','=25 +'='=26 +'*'=27 +'+'=28 +'-'=29 +'@'=36 +':'=37 diff --git a/internal/parser/antlrParser/lexer.go b/internal/parser/antlrParser/lexer.go new file mode 100644 index 00000000..ca27a19a --- /dev/null +++ b/internal/parser/antlrParser/lexer.go @@ -0,0 +1,314 @@ +// Code generated from Lexer.g4 by ANTLR 4.13.1. DO NOT EDIT. + +package antlrParser + +import ( + "fmt" + "github.com/antlr4-go/antlr/v4" + "sync" + "unicode" +) + +// Suppress unused import error +var _ = fmt.Printf +var _ = sync.Once{} +var _ = unicode.IsLetter + +type Lexer struct { + *antlr.BaseLexer + channelNames []string + modeNames []string + // TODO: EOF string +} + +var LexerLexerStaticData struct { + once sync.Once + serializedATN []int32 + ChannelNames []string + ModeNames []string + LiteralNames []string + SymbolicNames []string + RuleNames []string + PredictionContextCache *antlr.PredictionContextCache + atn *antlr.ATN + decisionToDFA []*antlr.DFA +} + +func lexerLexerInit() { + staticData := &LexerLexerStaticData + staticData.ChannelNames = []string{ + "DEFAULT_TOKEN_CHANNEL", "HIDDEN", + } + staticData.ModeNames = []string{ + "DEFAULT_MODE", "ACCOUNT_MODE", + } + staticData.LiteralNames = []string{ + "", "", "", "", "", "'vars'", "'max'", "'source'", "'destination'", + "'send'", "'from'", "'up'", "'to'", "'remaining'", "'allowing'", "'unbounded'", + "'overdraft'", "'kept'", "'save'", "'('", "')'", "'['", "']'", "'{'", + "'}'", "','", "'='", "'*'", "'+'", "'-'", "", "", "", "", "", "", "'@'", + "':'", + } + staticData.SymbolicNames = []string{ + "", "WS", "NEWLINE", "MULTILINE_COMMENT", "LINE_COMMENT", "VARS", "MAX", + "SOURCE", "DESTINATION", "SEND", "FROM", "UP", "TO", "REMAINING", "ALLOWING", + "UNBOUNDED", "OVERDRAFT", "KEPT", "SAVE", "LPARENS", "RPARENS", "LBRACKET", + "RBRACKET", "LBRACE", "RBRACE", "COMMA", "EQ", "STAR", "PLUS", "MINUS", + "RATIO_PORTION_LITERAL", "PERCENTAGE_PORTION_LITERAL", "STRING", "IDENTIFIER", + "NUMBER", "ASSET", "ACCOUNT_START", "COLON", "ACCOUNT_TEXT", "VARIABLE_NAME_ACC", + "VARIABLE_NAME_DEFAULT", + } + staticData.RuleNames = []string{ + "WS", "NEWLINE", "MULTILINE_COMMENT", "LINE_COMMENT", "VARS", "MAX", + "SOURCE", "DESTINATION", "SEND", "FROM", "UP", "TO", "REMAINING", "ALLOWING", + "UNBOUNDED", "OVERDRAFT", "KEPT", "SAVE", "LPARENS", "RPARENS", "LBRACKET", + "RBRACKET", "LBRACE", "RBRACE", "COMMA", "EQ", "STAR", "PLUS", "MINUS", + "RATIO_PORTION_LITERAL", "PERCENTAGE_PORTION_LITERAL", "STRING", "IDENTIFIER", + "NUMBER", "ASSET", "ACCOUNT_START", "COLON", "VARIABLE_NAME_FRAMGMENT", + "ACCOUNT_TEXT", "VARIABLE_NAME_ACC", "VARIABLE_NAME_DEFAULT", + } + staticData.PredictionContextCache = antlr.NewPredictionContextCache() + staticData.serializedATN = []int32{ + 4, 0, 40, 350, 6, -1, 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, + 1, 0, 4, 0, 86, 8, 0, 11, 0, 12, 0, 87, 1, 0, 1, 0, 1, 1, 4, 1, 93, 8, + 1, 11, 1, 12, 1, 94, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 102, 8, 2, 10, + 2, 12, 2, 105, 9, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, + 3, 5, 3, 116, 8, 3, 10, 3, 12, 3, 119, 9, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, + 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 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, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, + 9, 1, 9, 1, 10, 1, 10, 1, 10, 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, 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, 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, 17, + 1, 17, 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, 28, 1, 28, 1, 29, 4, 29, 241, 8, 29, 11, 29, 12, + 29, 242, 1, 29, 3, 29, 246, 8, 29, 1, 29, 1, 29, 3, 29, 250, 8, 29, 1, + 29, 4, 29, 253, 8, 29, 11, 29, 12, 29, 254, 1, 30, 4, 30, 258, 8, 30, 11, + 30, 12, 30, 259, 1, 30, 1, 30, 4, 30, 264, 8, 30, 11, 30, 12, 30, 265, + 3, 30, 268, 8, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 5, 31, 276, + 8, 31, 10, 31, 12, 31, 279, 9, 31, 1, 31, 1, 31, 1, 32, 4, 32, 284, 8, + 32, 11, 32, 12, 32, 285, 1, 32, 5, 32, 289, 8, 32, 10, 32, 12, 32, 292, + 9, 32, 1, 33, 3, 33, 295, 8, 33, 1, 33, 4, 33, 298, 8, 33, 11, 33, 12, + 33, 299, 1, 33, 1, 33, 4, 33, 304, 8, 33, 11, 33, 12, 33, 305, 5, 33, 308, + 8, 33, 10, 33, 12, 33, 311, 9, 33, 1, 34, 4, 34, 314, 8, 34, 11, 34, 12, + 34, 315, 1, 35, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 37, + 1, 37, 4, 37, 328, 8, 37, 11, 37, 12, 37, 329, 1, 37, 5, 37, 333, 8, 37, + 10, 37, 12, 37, 336, 9, 37, 1, 38, 4, 38, 339, 8, 38, 11, 38, 12, 38, 340, + 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 2, 103, 117, 0, + 41, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18, 9, 20, 10, + 22, 11, 24, 12, 26, 13, 28, 14, 30, 15, 32, 16, 34, 17, 36, 18, 38, 19, + 40, 20, 42, 21, 44, 22, 46, 23, 48, 24, 50, 25, 52, 26, 54, 27, 56, 28, + 58, 29, 60, 30, 62, 31, 64, 32, 66, 33, 68, 34, 70, 35, 72, 36, 74, 37, + 76, 0, 78, 38, 80, 39, 82, 40, 2, 0, 1, 10, 3, 0, 9, 10, 13, 13, 32, 32, + 2, 0, 10, 10, 13, 13, 1, 0, 48, 57, 1, 0, 32, 32, 3, 0, 10, 10, 13, 13, + 34, 34, 1, 0, 97, 122, 2, 0, 95, 95, 97, 122, 2, 0, 47, 57, 65, 90, 3, + 0, 48, 57, 95, 95, 97, 122, 5, 0, 45, 45, 48, 57, 65, 90, 95, 95, 97, 122, + 371, 0, 2, 1, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 6, 1, 0, 0, 0, 0, 8, 1, 0, + 0, 0, 0, 10, 1, 0, 0, 0, 0, 12, 1, 0, 0, 0, 0, 14, 1, 0, 0, 0, 0, 16, 1, + 0, 0, 0, 0, 18, 1, 0, 0, 0, 0, 20, 1, 0, 0, 0, 0, 22, 1, 0, 0, 0, 0, 24, + 1, 0, 0, 0, 0, 26, 1, 0, 0, 0, 0, 28, 1, 0, 0, 0, 0, 30, 1, 0, 0, 0, 0, + 32, 1, 0, 0, 0, 0, 34, 1, 0, 0, 0, 0, 36, 1, 0, 0, 0, 0, 38, 1, 0, 0, 0, + 0, 40, 1, 0, 0, 0, 0, 42, 1, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 46, 1, 0, 0, + 0, 0, 48, 1, 0, 0, 0, 0, 50, 1, 0, 0, 0, 0, 52, 1, 0, 0, 0, 0, 54, 1, 0, + 0, 0, 0, 56, 1, 0, 0, 0, 0, 58, 1, 0, 0, 0, 0, 60, 1, 0, 0, 0, 0, 62, 1, + 0, 0, 0, 0, 64, 1, 0, 0, 0, 0, 66, 1, 0, 0, 0, 0, 68, 1, 0, 0, 0, 0, 70, + 1, 0, 0, 0, 0, 72, 1, 0, 0, 0, 0, 74, 1, 0, 0, 0, 0, 82, 1, 0, 0, 0, 1, + 78, 1, 0, 0, 0, 1, 80, 1, 0, 0, 0, 2, 85, 1, 0, 0, 0, 4, 92, 1, 0, 0, 0, + 6, 96, 1, 0, 0, 0, 8, 111, 1, 0, 0, 0, 10, 124, 1, 0, 0, 0, 12, 129, 1, + 0, 0, 0, 14, 133, 1, 0, 0, 0, 16, 140, 1, 0, 0, 0, 18, 152, 1, 0, 0, 0, + 20, 157, 1, 0, 0, 0, 22, 162, 1, 0, 0, 0, 24, 165, 1, 0, 0, 0, 26, 168, + 1, 0, 0, 0, 28, 178, 1, 0, 0, 0, 30, 187, 1, 0, 0, 0, 32, 197, 1, 0, 0, + 0, 34, 207, 1, 0, 0, 0, 36, 212, 1, 0, 0, 0, 38, 217, 1, 0, 0, 0, 40, 219, + 1, 0, 0, 0, 42, 221, 1, 0, 0, 0, 44, 223, 1, 0, 0, 0, 46, 225, 1, 0, 0, + 0, 48, 227, 1, 0, 0, 0, 50, 229, 1, 0, 0, 0, 52, 231, 1, 0, 0, 0, 54, 233, + 1, 0, 0, 0, 56, 235, 1, 0, 0, 0, 58, 237, 1, 0, 0, 0, 60, 240, 1, 0, 0, + 0, 62, 257, 1, 0, 0, 0, 64, 271, 1, 0, 0, 0, 66, 283, 1, 0, 0, 0, 68, 294, + 1, 0, 0, 0, 70, 313, 1, 0, 0, 0, 72, 317, 1, 0, 0, 0, 74, 321, 1, 0, 0, + 0, 76, 325, 1, 0, 0, 0, 78, 338, 1, 0, 0, 0, 80, 344, 1, 0, 0, 0, 82, 348, + 1, 0, 0, 0, 84, 86, 7, 0, 0, 0, 85, 84, 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, + 87, 85, 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 90, 6, + 0, 0, 0, 90, 3, 1, 0, 0, 0, 91, 93, 7, 1, 0, 0, 92, 91, 1, 0, 0, 0, 93, + 94, 1, 0, 0, 0, 94, 92, 1, 0, 0, 0, 94, 95, 1, 0, 0, 0, 95, 5, 1, 0, 0, + 0, 96, 97, 5, 47, 0, 0, 97, 98, 5, 42, 0, 0, 98, 103, 1, 0, 0, 0, 99, 102, + 3, 6, 2, 0, 100, 102, 9, 0, 0, 0, 101, 99, 1, 0, 0, 0, 101, 100, 1, 0, + 0, 0, 102, 105, 1, 0, 0, 0, 103, 104, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, + 104, 106, 1, 0, 0, 0, 105, 103, 1, 0, 0, 0, 106, 107, 5, 42, 0, 0, 107, + 108, 5, 47, 0, 0, 108, 109, 1, 0, 0, 0, 109, 110, 6, 2, 0, 0, 110, 7, 1, + 0, 0, 0, 111, 112, 5, 47, 0, 0, 112, 113, 5, 47, 0, 0, 113, 117, 1, 0, + 0, 0, 114, 116, 9, 0, 0, 0, 115, 114, 1, 0, 0, 0, 116, 119, 1, 0, 0, 0, + 117, 118, 1, 0, 0, 0, 117, 115, 1, 0, 0, 0, 118, 120, 1, 0, 0, 0, 119, + 117, 1, 0, 0, 0, 120, 121, 3, 4, 1, 0, 121, 122, 1, 0, 0, 0, 122, 123, + 6, 3, 0, 0, 123, 9, 1, 0, 0, 0, 124, 125, 5, 118, 0, 0, 125, 126, 5, 97, + 0, 0, 126, 127, 5, 114, 0, 0, 127, 128, 5, 115, 0, 0, 128, 11, 1, 0, 0, + 0, 129, 130, 5, 109, 0, 0, 130, 131, 5, 97, 0, 0, 131, 132, 5, 120, 0, + 0, 132, 13, 1, 0, 0, 0, 133, 134, 5, 115, 0, 0, 134, 135, 5, 111, 0, 0, + 135, 136, 5, 117, 0, 0, 136, 137, 5, 114, 0, 0, 137, 138, 5, 99, 0, 0, + 138, 139, 5, 101, 0, 0, 139, 15, 1, 0, 0, 0, 140, 141, 5, 100, 0, 0, 141, + 142, 5, 101, 0, 0, 142, 143, 5, 115, 0, 0, 143, 144, 5, 116, 0, 0, 144, + 145, 5, 105, 0, 0, 145, 146, 5, 110, 0, 0, 146, 147, 5, 97, 0, 0, 147, + 148, 5, 116, 0, 0, 148, 149, 5, 105, 0, 0, 149, 150, 5, 111, 0, 0, 150, + 151, 5, 110, 0, 0, 151, 17, 1, 0, 0, 0, 152, 153, 5, 115, 0, 0, 153, 154, + 5, 101, 0, 0, 154, 155, 5, 110, 0, 0, 155, 156, 5, 100, 0, 0, 156, 19, + 1, 0, 0, 0, 157, 158, 5, 102, 0, 0, 158, 159, 5, 114, 0, 0, 159, 160, 5, + 111, 0, 0, 160, 161, 5, 109, 0, 0, 161, 21, 1, 0, 0, 0, 162, 163, 5, 117, + 0, 0, 163, 164, 5, 112, 0, 0, 164, 23, 1, 0, 0, 0, 165, 166, 5, 116, 0, + 0, 166, 167, 5, 111, 0, 0, 167, 25, 1, 0, 0, 0, 168, 169, 5, 114, 0, 0, + 169, 170, 5, 101, 0, 0, 170, 171, 5, 109, 0, 0, 171, 172, 5, 97, 0, 0, + 172, 173, 5, 105, 0, 0, 173, 174, 5, 110, 0, 0, 174, 175, 5, 105, 0, 0, + 175, 176, 5, 110, 0, 0, 176, 177, 5, 103, 0, 0, 177, 27, 1, 0, 0, 0, 178, + 179, 5, 97, 0, 0, 179, 180, 5, 108, 0, 0, 180, 181, 5, 108, 0, 0, 181, + 182, 5, 111, 0, 0, 182, 183, 5, 119, 0, 0, 183, 184, 5, 105, 0, 0, 184, + 185, 5, 110, 0, 0, 185, 186, 5, 103, 0, 0, 186, 29, 1, 0, 0, 0, 187, 188, + 5, 117, 0, 0, 188, 189, 5, 110, 0, 0, 189, 190, 5, 98, 0, 0, 190, 191, + 5, 111, 0, 0, 191, 192, 5, 117, 0, 0, 192, 193, 5, 110, 0, 0, 193, 194, + 5, 100, 0, 0, 194, 195, 5, 101, 0, 0, 195, 196, 5, 100, 0, 0, 196, 31, + 1, 0, 0, 0, 197, 198, 5, 111, 0, 0, 198, 199, 5, 118, 0, 0, 199, 200, 5, + 101, 0, 0, 200, 201, 5, 114, 0, 0, 201, 202, 5, 100, 0, 0, 202, 203, 5, + 114, 0, 0, 203, 204, 5, 97, 0, 0, 204, 205, 5, 102, 0, 0, 205, 206, 5, + 116, 0, 0, 206, 33, 1, 0, 0, 0, 207, 208, 5, 107, 0, 0, 208, 209, 5, 101, + 0, 0, 209, 210, 5, 112, 0, 0, 210, 211, 5, 116, 0, 0, 211, 35, 1, 0, 0, + 0, 212, 213, 5, 115, 0, 0, 213, 214, 5, 97, 0, 0, 214, 215, 5, 118, 0, + 0, 215, 216, 5, 101, 0, 0, 216, 37, 1, 0, 0, 0, 217, 218, 5, 40, 0, 0, + 218, 39, 1, 0, 0, 0, 219, 220, 5, 41, 0, 0, 220, 41, 1, 0, 0, 0, 221, 222, + 5, 91, 0, 0, 222, 43, 1, 0, 0, 0, 223, 224, 5, 93, 0, 0, 224, 45, 1, 0, + 0, 0, 225, 226, 5, 123, 0, 0, 226, 47, 1, 0, 0, 0, 227, 228, 5, 125, 0, + 0, 228, 49, 1, 0, 0, 0, 229, 230, 5, 44, 0, 0, 230, 51, 1, 0, 0, 0, 231, + 232, 5, 61, 0, 0, 232, 53, 1, 0, 0, 0, 233, 234, 5, 42, 0, 0, 234, 55, + 1, 0, 0, 0, 235, 236, 5, 43, 0, 0, 236, 57, 1, 0, 0, 0, 237, 238, 5, 45, + 0, 0, 238, 59, 1, 0, 0, 0, 239, 241, 7, 2, 0, 0, 240, 239, 1, 0, 0, 0, + 241, 242, 1, 0, 0, 0, 242, 240, 1, 0, 0, 0, 242, 243, 1, 0, 0, 0, 243, + 245, 1, 0, 0, 0, 244, 246, 7, 3, 0, 0, 245, 244, 1, 0, 0, 0, 245, 246, + 1, 0, 0, 0, 246, 247, 1, 0, 0, 0, 247, 249, 5, 47, 0, 0, 248, 250, 7, 3, + 0, 0, 249, 248, 1, 0, 0, 0, 249, 250, 1, 0, 0, 0, 250, 252, 1, 0, 0, 0, + 251, 253, 7, 2, 0, 0, 252, 251, 1, 0, 0, 0, 253, 254, 1, 0, 0, 0, 254, + 252, 1, 0, 0, 0, 254, 255, 1, 0, 0, 0, 255, 61, 1, 0, 0, 0, 256, 258, 7, + 2, 0, 0, 257, 256, 1, 0, 0, 0, 258, 259, 1, 0, 0, 0, 259, 257, 1, 0, 0, + 0, 259, 260, 1, 0, 0, 0, 260, 267, 1, 0, 0, 0, 261, 263, 5, 46, 0, 0, 262, + 264, 7, 2, 0, 0, 263, 262, 1, 0, 0, 0, 264, 265, 1, 0, 0, 0, 265, 263, + 1, 0, 0, 0, 265, 266, 1, 0, 0, 0, 266, 268, 1, 0, 0, 0, 267, 261, 1, 0, + 0, 0, 267, 268, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, 270, 5, 37, 0, 0, + 270, 63, 1, 0, 0, 0, 271, 277, 5, 34, 0, 0, 272, 273, 5, 92, 0, 0, 273, + 276, 5, 34, 0, 0, 274, 276, 8, 4, 0, 0, 275, 272, 1, 0, 0, 0, 275, 274, + 1, 0, 0, 0, 276, 279, 1, 0, 0, 0, 277, 275, 1, 0, 0, 0, 277, 278, 1, 0, + 0, 0, 278, 280, 1, 0, 0, 0, 279, 277, 1, 0, 0, 0, 280, 281, 5, 34, 0, 0, + 281, 65, 1, 0, 0, 0, 282, 284, 7, 5, 0, 0, 283, 282, 1, 0, 0, 0, 284, 285, + 1, 0, 0, 0, 285, 283, 1, 0, 0, 0, 285, 286, 1, 0, 0, 0, 286, 290, 1, 0, + 0, 0, 287, 289, 7, 6, 0, 0, 288, 287, 1, 0, 0, 0, 289, 292, 1, 0, 0, 0, + 290, 288, 1, 0, 0, 0, 290, 291, 1, 0, 0, 0, 291, 67, 1, 0, 0, 0, 292, 290, + 1, 0, 0, 0, 293, 295, 3, 58, 28, 0, 294, 293, 1, 0, 0, 0, 294, 295, 1, + 0, 0, 0, 295, 297, 1, 0, 0, 0, 296, 298, 7, 2, 0, 0, 297, 296, 1, 0, 0, + 0, 298, 299, 1, 0, 0, 0, 299, 297, 1, 0, 0, 0, 299, 300, 1, 0, 0, 0, 300, + 309, 1, 0, 0, 0, 301, 303, 5, 95, 0, 0, 302, 304, 7, 2, 0, 0, 303, 302, + 1, 0, 0, 0, 304, 305, 1, 0, 0, 0, 305, 303, 1, 0, 0, 0, 305, 306, 1, 0, + 0, 0, 306, 308, 1, 0, 0, 0, 307, 301, 1, 0, 0, 0, 308, 311, 1, 0, 0, 0, + 309, 307, 1, 0, 0, 0, 309, 310, 1, 0, 0, 0, 310, 69, 1, 0, 0, 0, 311, 309, + 1, 0, 0, 0, 312, 314, 7, 7, 0, 0, 313, 312, 1, 0, 0, 0, 314, 315, 1, 0, + 0, 0, 315, 313, 1, 0, 0, 0, 315, 316, 1, 0, 0, 0, 316, 71, 1, 0, 0, 0, + 317, 318, 5, 64, 0, 0, 318, 319, 1, 0, 0, 0, 319, 320, 6, 35, 1, 0, 320, + 73, 1, 0, 0, 0, 321, 322, 5, 58, 0, 0, 322, 323, 1, 0, 0, 0, 323, 324, + 6, 36, 1, 0, 324, 75, 1, 0, 0, 0, 325, 327, 5, 36, 0, 0, 326, 328, 7, 6, + 0, 0, 327, 326, 1, 0, 0, 0, 328, 329, 1, 0, 0, 0, 329, 327, 1, 0, 0, 0, + 329, 330, 1, 0, 0, 0, 330, 334, 1, 0, 0, 0, 331, 333, 7, 8, 0, 0, 332, + 331, 1, 0, 0, 0, 333, 336, 1, 0, 0, 0, 334, 332, 1, 0, 0, 0, 334, 335, + 1, 0, 0, 0, 335, 77, 1, 0, 0, 0, 336, 334, 1, 0, 0, 0, 337, 339, 7, 9, + 0, 0, 338, 337, 1, 0, 0, 0, 339, 340, 1, 0, 0, 0, 340, 338, 1, 0, 0, 0, + 340, 341, 1, 0, 0, 0, 341, 342, 1, 0, 0, 0, 342, 343, 6, 38, 2, 0, 343, + 79, 1, 0, 0, 0, 344, 345, 3, 76, 37, 0, 345, 346, 1, 0, 0, 0, 346, 347, + 6, 39, 2, 0, 347, 81, 1, 0, 0, 0, 348, 349, 3, 76, 37, 0, 349, 83, 1, 0, + 0, 0, 26, 0, 1, 87, 94, 101, 103, 117, 242, 245, 249, 254, 259, 265, 267, + 275, 277, 285, 290, 294, 299, 305, 309, 315, 329, 334, 340, 3, 6, 0, 0, + 5, 1, 0, 4, 0, 0, + } + deserializer := antlr.NewATNDeserializer(nil) + staticData.atn = deserializer.Deserialize(staticData.serializedATN) + atn := staticData.atn + staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState)) + decisionToDFA := staticData.decisionToDFA + for index, state := range atn.DecisionToState { + decisionToDFA[index] = antlr.NewDFA(state, index) + } +} + +// LexerInit initializes any static state used to implement Lexer. By default the +// static state used to implement the lexer is lazily initialized during the first call to +// NewLexer(). You can call this function if you wish to initialize the static state ahead +// of time. +func LexerInit() { + staticData := &LexerLexerStaticData + staticData.once.Do(lexerLexerInit) +} + +// NewLexer produces a new lexer instance for the optional input antlr.CharStream. +func NewLexer(input antlr.CharStream) *Lexer { + LexerInit() + l := new(Lexer) + l.BaseLexer = antlr.NewBaseLexer(input) + staticData := &LexerLexerStaticData + l.Interpreter = antlr.NewLexerATNSimulator(l, staticData.atn, staticData.decisionToDFA, staticData.PredictionContextCache) + l.channelNames = staticData.ChannelNames + l.modeNames = staticData.ModeNames + l.RuleNames = staticData.RuleNames + l.LiteralNames = staticData.LiteralNames + l.SymbolicNames = staticData.SymbolicNames + l.GrammarFileName = "Lexer.g4" + // TODO: l.EOF = antlr.TokenEOF + + return l +} + +// Lexer tokens. +const ( + LexerWS = 1 + LexerNEWLINE = 2 + LexerMULTILINE_COMMENT = 3 + LexerLINE_COMMENT = 4 + LexerVARS = 5 + LexerMAX = 6 + LexerSOURCE = 7 + LexerDESTINATION = 8 + LexerSEND = 9 + LexerFROM = 10 + LexerUP = 11 + LexerTO = 12 + LexerREMAINING = 13 + LexerALLOWING = 14 + LexerUNBOUNDED = 15 + LexerOVERDRAFT = 16 + LexerKEPT = 17 + LexerSAVE = 18 + LexerLPARENS = 19 + LexerRPARENS = 20 + LexerLBRACKET = 21 + LexerRBRACKET = 22 + LexerLBRACE = 23 + LexerRBRACE = 24 + LexerCOMMA = 25 + LexerEQ = 26 + LexerSTAR = 27 + LexerPLUS = 28 + LexerMINUS = 29 + LexerRATIO_PORTION_LITERAL = 30 + LexerPERCENTAGE_PORTION_LITERAL = 31 + LexerSTRING = 32 + LexerIDENTIFIER = 33 + LexerNUMBER = 34 + LexerASSET = 35 + LexerACCOUNT_START = 36 + LexerCOLON = 37 + LexerACCOUNT_TEXT = 38 + LexerVARIABLE_NAME_ACC = 39 + LexerVARIABLE_NAME_DEFAULT = 40 +) + +// LexerACCOUNT_MODE is the Lexer mode. +const LexerACCOUNT_MODE = 1 diff --git a/internal/parser/antlr/numscript_base_listener.go b/internal/parser/antlrParser/numscript_base_listener.go similarity index 95% rename from internal/parser/antlr/numscript_base_listener.go rename to internal/parser/antlrParser/numscript_base_listener.go index 64794ef9..415ebbc7 100644 --- a/internal/parser/antlr/numscript_base_listener.go +++ b/internal/parser/antlrParser/numscript_base_listener.go @@ -1,7 +1,6 @@ // Code generated from Numscript.g4 by ANTLR 4.13.1. DO NOT EDIT. -package parser // Numscript - +package antlrParser // Numscript import "github.com/antlr4-go/antlr/v4" // BaseNumscriptListener is a complete listener for a parse tree produced by NumscriptParser. @@ -39,6 +38,18 @@ func (s *BaseNumscriptListener) EnterPercentage(ctx *PercentageContext) {} // ExitPercentage is called when production percentage is exited. func (s *BaseNumscriptListener) ExitPercentage(ctx *PercentageContext) {} +// EnterAccountTextPart is called when production accountTextPart is entered. +func (s *BaseNumscriptListener) EnterAccountTextPart(ctx *AccountTextPartContext) {} + +// ExitAccountTextPart is called when production accountTextPart is exited. +func (s *BaseNumscriptListener) ExitAccountTextPart(ctx *AccountTextPartContext) {} + +// EnterAccountVarPart is called when production accountVarPart is entered. +func (s *BaseNumscriptListener) EnterAccountVarPart(ctx *AccountVarPartContext) {} + +// ExitAccountVarPart is called when production accountVarPart is exited. +func (s *BaseNumscriptListener) ExitAccountVarPart(ctx *AccountVarPartContext) {} + // EnterVariableExpr is called when production variableExpr is entered. func (s *BaseNumscriptListener) EnterVariableExpr(ctx *VariableExprContext) {} diff --git a/internal/parser/antlr/numscript_listener.go b/internal/parser/antlrParser/numscript_listener.go similarity index 94% rename from internal/parser/antlr/numscript_listener.go rename to internal/parser/antlrParser/numscript_listener.go index 9bb6d3dc..9c248089 100644 --- a/internal/parser/antlr/numscript_listener.go +++ b/internal/parser/antlrParser/numscript_listener.go @@ -1,7 +1,6 @@ // Code generated from Numscript.g4 by ANTLR 4.13.1. DO NOT EDIT. -package parser // Numscript - +package antlrParser // Numscript import "github.com/antlr4-go/antlr/v4" // NumscriptListener is a complete listener for a parse tree produced by NumscriptParser. @@ -17,6 +16,12 @@ type NumscriptListener interface { // EnterPercentage is called when entering the percentage production. EnterPercentage(c *PercentageContext) + // EnterAccountTextPart is called when entering the accountTextPart production. + EnterAccountTextPart(c *AccountTextPartContext) + + // EnterAccountVarPart is called when entering the accountVarPart production. + EnterAccountVarPart(c *AccountVarPartContext) + // EnterVariableExpr is called when entering the variableExpr production. EnterVariableExpr(c *VariableExprContext) @@ -137,6 +142,12 @@ type NumscriptListener interface { // ExitPercentage is called when exiting the percentage production. ExitPercentage(c *PercentageContext) + // ExitAccountTextPart is called when exiting the accountTextPart production. + ExitAccountTextPart(c *AccountTextPartContext) + + // ExitAccountVarPart is called when exiting the accountVarPart production. + ExitAccountVarPart(c *AccountVarPartContext) + // ExitVariableExpr is called when exiting the variableExpr production. ExitVariableExpr(c *VariableExprContext) diff --git a/internal/parser/antlr/numscript_parser.go b/internal/parser/antlrParser/numscript_parser.go similarity index 83% rename from internal/parser/antlr/numscript_parser.go rename to internal/parser/antlrParser/numscript_parser.go index 542cd8b8..eb3de13a 100644 --- a/internal/parser/antlr/numscript_parser.go +++ b/internal/parser/antlrParser/numscript_parser.go @@ -1,7 +1,6 @@ // Code generated from Numscript.g4 by ANTLR 4.13.1. DO NOT EDIT. -package parser // Numscript - +package antlrParser // Numscript import ( "fmt" "strconv" @@ -33,120 +32,130 @@ var NumscriptParserStaticData struct { func numscriptParserInit() { staticData := &NumscriptParserStaticData staticData.LiteralNames = []string{ - "", "'+'", "", "", "", "", "'vars'", "'max'", "'source'", "'destination'", + "", "", "", "", "", "'vars'", "'max'", "'source'", "'destination'", "'send'", "'from'", "'up'", "'to'", "'remaining'", "'allowing'", "'unbounded'", "'overdraft'", "'kept'", "'save'", "'('", "')'", "'['", "']'", "'{'", - "'}'", "','", "'='", "'*'", "'-'", + "'}'", "','", "'='", "'*'", "'+'", "'-'", "", "", "", "", "", "", "'@'", + "':'", } staticData.SymbolicNames = []string{ - "", "", "WS", "NEWLINE", "MULTILINE_COMMENT", "LINE_COMMENT", "VARS", - "MAX", "SOURCE", "DESTINATION", "SEND", "FROM", "UP", "TO", "REMAINING", - "ALLOWING", "UNBOUNDED", "OVERDRAFT", "KEPT", "SAVE", "LPARENS", "RPARENS", - "LBRACKET", "RBRACKET", "LBRACE", "RBRACE", "COMMA", "EQ", "STAR", "MINUS", + "", "WS", "NEWLINE", "MULTILINE_COMMENT", "LINE_COMMENT", "VARS", "MAX", + "SOURCE", "DESTINATION", "SEND", "FROM", "UP", "TO", "REMAINING", "ALLOWING", + "UNBOUNDED", "OVERDRAFT", "KEPT", "SAVE", "LPARENS", "RPARENS", "LBRACKET", + "RBRACKET", "LBRACE", "RBRACE", "COMMA", "EQ", "STAR", "PLUS", "MINUS", "RATIO_PORTION_LITERAL", "PERCENTAGE_PORTION_LITERAL", "STRING", "IDENTIFIER", - "NUMBER", "VARIABLE_NAME", "ACCOUNT", "ASSET", + "NUMBER", "ASSET", "ACCOUNT_START", "COLON", "ACCOUNT_TEXT", "VARIABLE_NAME_ACC", + "VARIABLE_NAME_DEFAULT", } staticData.RuleNames = []string{ - "monetaryLit", "portion", "valueExpr", "functionCallArgs", "functionCall", - "varOrigin", "varDeclaration", "varsDeclaration", "program", "sentAllLit", - "allotment", "source", "allotmentClauseSrc", "keptOrDestination", "destinationInOrderClause", - "destination", "allotmentClauseDest", "sentValue", "statement", + "monetaryLit", "portion", "accountLiteralPart", "valueExpr", "functionCallArgs", + "functionCall", "varOrigin", "varDeclaration", "varsDeclaration", "program", + "sentAllLit", "allotment", "source", "allotmentClauseSrc", "keptOrDestination", + "destinationInOrderClause", "destination", "allotmentClauseDest", "sentValue", + "statement", } staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ - 4, 1, 37, 217, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, + 4, 1, 40, 231, 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, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 1, 1, 1, 3, 1, 46, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, - 2, 3, 2, 56, 8, 2, 1, 2, 1, 2, 1, 2, 5, 2, 61, 8, 2, 10, 2, 12, 2, 64, - 9, 2, 1, 3, 1, 3, 1, 3, 5, 3, 69, 8, 3, 10, 3, 12, 3, 72, 9, 3, 1, 4, 1, - 4, 1, 4, 3, 4, 77, 8, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, - 3, 6, 87, 8, 6, 1, 7, 1, 7, 1, 7, 5, 7, 92, 8, 7, 10, 7, 12, 7, 95, 9, - 7, 1, 7, 1, 7, 1, 8, 3, 8, 100, 8, 8, 1, 8, 5, 8, 103, 8, 8, 10, 8, 12, - 8, 106, 9, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, - 10, 3, 10, 118, 8, 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, 4, 11, 135, 8, - 11, 11, 11, 12, 11, 136, 1, 11, 1, 11, 1, 11, 1, 11, 5, 11, 143, 8, 11, - 10, 11, 12, 11, 146, 9, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, - 11, 154, 8, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 3, 13, - 163, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 4, 15, 172, - 8, 15, 11, 15, 12, 15, 173, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15, 180, 8, - 15, 10, 15, 12, 15, 183, 9, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 189, - 8, 15, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 3, 17, 196, 8, 17, 1, 18, 1, - 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, - 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 215, 8, 18, 1, 18, 0, 1, 4, 19, - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, - 0, 2, 2, 0, 1, 1, 29, 29, 2, 0, 17, 17, 33, 33, 228, 0, 38, 1, 0, 0, 0, - 2, 45, 1, 0, 0, 0, 4, 55, 1, 0, 0, 0, 6, 65, 1, 0, 0, 0, 8, 73, 1, 0, 0, - 0, 10, 80, 1, 0, 0, 0, 12, 83, 1, 0, 0, 0, 14, 88, 1, 0, 0, 0, 16, 99, - 1, 0, 0, 0, 18, 109, 1, 0, 0, 0, 20, 117, 1, 0, 0, 0, 22, 153, 1, 0, 0, - 0, 24, 155, 1, 0, 0, 0, 26, 162, 1, 0, 0, 0, 28, 164, 1, 0, 0, 0, 30, 188, - 1, 0, 0, 0, 32, 190, 1, 0, 0, 0, 34, 195, 1, 0, 0, 0, 36, 214, 1, 0, 0, - 0, 38, 39, 5, 22, 0, 0, 39, 40, 3, 4, 2, 0, 40, 41, 3, 4, 2, 0, 41, 42, - 5, 23, 0, 0, 42, 1, 1, 0, 0, 0, 43, 46, 5, 30, 0, 0, 44, 46, 5, 31, 0, - 0, 45, 43, 1, 0, 0, 0, 45, 44, 1, 0, 0, 0, 46, 3, 1, 0, 0, 0, 47, 48, 6, - 2, -1, 0, 48, 56, 5, 35, 0, 0, 49, 56, 5, 37, 0, 0, 50, 56, 5, 32, 0, 0, - 51, 56, 5, 36, 0, 0, 52, 56, 5, 34, 0, 0, 53, 56, 3, 0, 0, 0, 54, 56, 3, - 2, 1, 0, 55, 47, 1, 0, 0, 0, 55, 49, 1, 0, 0, 0, 55, 50, 1, 0, 0, 0, 55, - 51, 1, 0, 0, 0, 55, 52, 1, 0, 0, 0, 55, 53, 1, 0, 0, 0, 55, 54, 1, 0, 0, - 0, 56, 62, 1, 0, 0, 0, 57, 58, 10, 1, 0, 0, 58, 59, 7, 0, 0, 0, 59, 61, - 3, 4, 2, 2, 60, 57, 1, 0, 0, 0, 61, 64, 1, 0, 0, 0, 62, 60, 1, 0, 0, 0, - 62, 63, 1, 0, 0, 0, 63, 5, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 65, 70, 3, 4, - 2, 0, 66, 67, 5, 26, 0, 0, 67, 69, 3, 4, 2, 0, 68, 66, 1, 0, 0, 0, 69, - 72, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 7, 1, 0, 0, - 0, 72, 70, 1, 0, 0, 0, 73, 74, 7, 1, 0, 0, 74, 76, 5, 20, 0, 0, 75, 77, - 3, 6, 3, 0, 76, 75, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, - 78, 79, 5, 21, 0, 0, 79, 9, 1, 0, 0, 0, 80, 81, 5, 27, 0, 0, 81, 82, 3, - 8, 4, 0, 82, 11, 1, 0, 0, 0, 83, 84, 5, 33, 0, 0, 84, 86, 5, 35, 0, 0, - 85, 87, 3, 10, 5, 0, 86, 85, 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, 87, 13, 1, - 0, 0, 0, 88, 89, 5, 6, 0, 0, 89, 93, 5, 24, 0, 0, 90, 92, 3, 12, 6, 0, - 91, 90, 1, 0, 0, 0, 92, 95, 1, 0, 0, 0, 93, 91, 1, 0, 0, 0, 93, 94, 1, - 0, 0, 0, 94, 96, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 96, 97, 5, 25, 0, 0, 97, - 15, 1, 0, 0, 0, 98, 100, 3, 14, 7, 0, 99, 98, 1, 0, 0, 0, 99, 100, 1, 0, - 0, 0, 100, 104, 1, 0, 0, 0, 101, 103, 3, 36, 18, 0, 102, 101, 1, 0, 0, - 0, 103, 106, 1, 0, 0, 0, 104, 102, 1, 0, 0, 0, 104, 105, 1, 0, 0, 0, 105, - 107, 1, 0, 0, 0, 106, 104, 1, 0, 0, 0, 107, 108, 5, 0, 0, 1, 108, 17, 1, - 0, 0, 0, 109, 110, 5, 22, 0, 0, 110, 111, 3, 4, 2, 0, 111, 112, 5, 28, - 0, 0, 112, 113, 5, 23, 0, 0, 113, 19, 1, 0, 0, 0, 114, 118, 3, 2, 1, 0, - 115, 118, 5, 35, 0, 0, 116, 118, 5, 14, 0, 0, 117, 114, 1, 0, 0, 0, 117, - 115, 1, 0, 0, 0, 117, 116, 1, 0, 0, 0, 118, 21, 1, 0, 0, 0, 119, 120, 3, - 4, 2, 0, 120, 121, 5, 15, 0, 0, 121, 122, 5, 16, 0, 0, 122, 123, 5, 17, - 0, 0, 123, 154, 1, 0, 0, 0, 124, 125, 3, 4, 2, 0, 125, 126, 5, 15, 0, 0, - 126, 127, 5, 17, 0, 0, 127, 128, 5, 12, 0, 0, 128, 129, 5, 13, 0, 0, 129, - 130, 3, 4, 2, 0, 130, 154, 1, 0, 0, 0, 131, 154, 3, 4, 2, 0, 132, 134, - 5, 24, 0, 0, 133, 135, 3, 24, 12, 0, 134, 133, 1, 0, 0, 0, 135, 136, 1, - 0, 0, 0, 136, 134, 1, 0, 0, 0, 136, 137, 1, 0, 0, 0, 137, 138, 1, 0, 0, - 0, 138, 139, 5, 25, 0, 0, 139, 154, 1, 0, 0, 0, 140, 144, 5, 24, 0, 0, - 141, 143, 3, 22, 11, 0, 142, 141, 1, 0, 0, 0, 143, 146, 1, 0, 0, 0, 144, - 142, 1, 0, 0, 0, 144, 145, 1, 0, 0, 0, 145, 147, 1, 0, 0, 0, 146, 144, - 1, 0, 0, 0, 147, 154, 5, 25, 0, 0, 148, 149, 5, 7, 0, 0, 149, 150, 3, 4, - 2, 0, 150, 151, 5, 11, 0, 0, 151, 152, 3, 22, 11, 0, 152, 154, 1, 0, 0, - 0, 153, 119, 1, 0, 0, 0, 153, 124, 1, 0, 0, 0, 153, 131, 1, 0, 0, 0, 153, - 132, 1, 0, 0, 0, 153, 140, 1, 0, 0, 0, 153, 148, 1, 0, 0, 0, 154, 23, 1, - 0, 0, 0, 155, 156, 3, 20, 10, 0, 156, 157, 5, 11, 0, 0, 157, 158, 3, 22, - 11, 0, 158, 25, 1, 0, 0, 0, 159, 160, 5, 13, 0, 0, 160, 163, 3, 30, 15, - 0, 161, 163, 5, 18, 0, 0, 162, 159, 1, 0, 0, 0, 162, 161, 1, 0, 0, 0, 163, - 27, 1, 0, 0, 0, 164, 165, 5, 7, 0, 0, 165, 166, 3, 4, 2, 0, 166, 167, 3, - 26, 13, 0, 167, 29, 1, 0, 0, 0, 168, 189, 3, 4, 2, 0, 169, 171, 5, 24, - 0, 0, 170, 172, 3, 32, 16, 0, 171, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, - 0, 173, 171, 1, 0, 0, 0, 173, 174, 1, 0, 0, 0, 174, 175, 1, 0, 0, 0, 175, - 176, 5, 25, 0, 0, 176, 189, 1, 0, 0, 0, 177, 181, 5, 24, 0, 0, 178, 180, - 3, 28, 14, 0, 179, 178, 1, 0, 0, 0, 180, 183, 1, 0, 0, 0, 181, 179, 1, - 0, 0, 0, 181, 182, 1, 0, 0, 0, 182, 184, 1, 0, 0, 0, 183, 181, 1, 0, 0, - 0, 184, 185, 5, 14, 0, 0, 185, 186, 3, 26, 13, 0, 186, 187, 5, 25, 0, 0, - 187, 189, 1, 0, 0, 0, 188, 168, 1, 0, 0, 0, 188, 169, 1, 0, 0, 0, 188, - 177, 1, 0, 0, 0, 189, 31, 1, 0, 0, 0, 190, 191, 3, 20, 10, 0, 191, 192, - 3, 26, 13, 0, 192, 33, 1, 0, 0, 0, 193, 196, 3, 4, 2, 0, 194, 196, 3, 18, - 9, 0, 195, 193, 1, 0, 0, 0, 195, 194, 1, 0, 0, 0, 196, 35, 1, 0, 0, 0, - 197, 198, 5, 10, 0, 0, 198, 199, 3, 34, 17, 0, 199, 200, 5, 20, 0, 0, 200, - 201, 5, 8, 0, 0, 201, 202, 5, 27, 0, 0, 202, 203, 3, 22, 11, 0, 203, 204, - 5, 9, 0, 0, 204, 205, 5, 27, 0, 0, 205, 206, 3, 30, 15, 0, 206, 207, 5, - 21, 0, 0, 207, 215, 1, 0, 0, 0, 208, 209, 5, 19, 0, 0, 209, 210, 3, 34, - 17, 0, 210, 211, 5, 11, 0, 0, 211, 212, 3, 4, 2, 0, 212, 215, 1, 0, 0, - 0, 213, 215, 3, 8, 4, 0, 214, 197, 1, 0, 0, 0, 214, 208, 1, 0, 0, 0, 214, - 213, 1, 0, 0, 0, 215, 37, 1, 0, 0, 0, 19, 45, 55, 62, 70, 76, 86, 93, 99, - 104, 117, 136, 144, 153, 162, 173, 181, 188, 195, 214, + 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 1, 1, 1, 3, 1, 48, 8, 1, 1, 2, 1, 2, 3, 2, 52, 8, 2, + 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 62, 8, 3, 10, 3, + 12, 3, 65, 9, 3, 1, 3, 1, 3, 1, 3, 3, 3, 70, 8, 3, 1, 3, 1, 3, 1, 3, 5, + 3, 75, 8, 3, 10, 3, 12, 3, 78, 9, 3, 1, 4, 1, 4, 1, 4, 5, 4, 83, 8, 4, + 10, 4, 12, 4, 86, 9, 4, 1, 5, 1, 5, 1, 5, 3, 5, 91, 8, 5, 1, 5, 1, 5, 1, + 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 3, 7, 101, 8, 7, 1, 8, 1, 8, 1, 8, 5, + 8, 106, 8, 8, 10, 8, 12, 8, 109, 9, 8, 1, 8, 1, 8, 1, 9, 3, 9, 114, 8, + 9, 1, 9, 5, 9, 117, 8, 9, 10, 9, 12, 9, 120, 9, 9, 1, 9, 1, 9, 1, 10, 1, + 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 3, 11, 132, 8, 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, 4, 12, 149, 8, 12, 11, 12, 12, 12, 150, 1, 12, + 1, 12, 1, 12, 1, 12, 5, 12, 157, 8, 12, 10, 12, 12, 12, 160, 9, 12, 1, + 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 168, 8, 12, 1, 13, 1, 13, + 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 3, 14, 177, 8, 14, 1, 15, 1, 15, 1, + 15, 1, 15, 1, 16, 1, 16, 1, 16, 4, 16, 186, 8, 16, 11, 16, 12, 16, 187, + 1, 16, 1, 16, 1, 16, 1, 16, 5, 16, 194, 8, 16, 10, 16, 12, 16, 197, 9, + 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 203, 8, 16, 1, 17, 1, 17, 1, 17, + 1, 18, 1, 18, 3, 18, 210, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, + 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, + 1, 19, 3, 19, 229, 8, 19, 1, 19, 0, 1, 6, 20, 0, 2, 4, 6, 8, 10, 12, 14, + 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 0, 2, 1, 0, 28, 29, 2, + 0, 16, 16, 33, 33, 243, 0, 40, 1, 0, 0, 0, 2, 47, 1, 0, 0, 0, 4, 51, 1, + 0, 0, 0, 6, 69, 1, 0, 0, 0, 8, 79, 1, 0, 0, 0, 10, 87, 1, 0, 0, 0, 12, + 94, 1, 0, 0, 0, 14, 97, 1, 0, 0, 0, 16, 102, 1, 0, 0, 0, 18, 113, 1, 0, + 0, 0, 20, 123, 1, 0, 0, 0, 22, 131, 1, 0, 0, 0, 24, 167, 1, 0, 0, 0, 26, + 169, 1, 0, 0, 0, 28, 176, 1, 0, 0, 0, 30, 178, 1, 0, 0, 0, 32, 202, 1, + 0, 0, 0, 34, 204, 1, 0, 0, 0, 36, 209, 1, 0, 0, 0, 38, 228, 1, 0, 0, 0, + 40, 41, 5, 21, 0, 0, 41, 42, 3, 6, 3, 0, 42, 43, 3, 6, 3, 0, 43, 44, 5, + 22, 0, 0, 44, 1, 1, 0, 0, 0, 45, 48, 5, 30, 0, 0, 46, 48, 5, 31, 0, 0, + 47, 45, 1, 0, 0, 0, 47, 46, 1, 0, 0, 0, 48, 3, 1, 0, 0, 0, 49, 52, 5, 38, + 0, 0, 50, 52, 5, 39, 0, 0, 51, 49, 1, 0, 0, 0, 51, 50, 1, 0, 0, 0, 52, + 5, 1, 0, 0, 0, 53, 54, 6, 3, -1, 0, 54, 70, 5, 40, 0, 0, 55, 70, 5, 35, + 0, 0, 56, 70, 5, 32, 0, 0, 57, 58, 5, 36, 0, 0, 58, 63, 3, 4, 2, 0, 59, + 60, 5, 37, 0, 0, 60, 62, 3, 4, 2, 0, 61, 59, 1, 0, 0, 0, 62, 65, 1, 0, + 0, 0, 63, 61, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, 64, 70, 1, 0, 0, 0, 65, 63, + 1, 0, 0, 0, 66, 70, 5, 34, 0, 0, 67, 70, 3, 0, 0, 0, 68, 70, 3, 2, 1, 0, + 69, 53, 1, 0, 0, 0, 69, 55, 1, 0, 0, 0, 69, 56, 1, 0, 0, 0, 69, 57, 1, + 0, 0, 0, 69, 66, 1, 0, 0, 0, 69, 67, 1, 0, 0, 0, 69, 68, 1, 0, 0, 0, 70, + 76, 1, 0, 0, 0, 71, 72, 10, 1, 0, 0, 72, 73, 7, 0, 0, 0, 73, 75, 3, 6, + 3, 2, 74, 71, 1, 0, 0, 0, 75, 78, 1, 0, 0, 0, 76, 74, 1, 0, 0, 0, 76, 77, + 1, 0, 0, 0, 77, 7, 1, 0, 0, 0, 78, 76, 1, 0, 0, 0, 79, 84, 3, 6, 3, 0, + 80, 81, 5, 25, 0, 0, 81, 83, 3, 6, 3, 0, 82, 80, 1, 0, 0, 0, 83, 86, 1, + 0, 0, 0, 84, 82, 1, 0, 0, 0, 84, 85, 1, 0, 0, 0, 85, 9, 1, 0, 0, 0, 86, + 84, 1, 0, 0, 0, 87, 88, 7, 1, 0, 0, 88, 90, 5, 19, 0, 0, 89, 91, 3, 8, + 4, 0, 90, 89, 1, 0, 0, 0, 90, 91, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 93, + 5, 20, 0, 0, 93, 11, 1, 0, 0, 0, 94, 95, 5, 26, 0, 0, 95, 96, 3, 10, 5, + 0, 96, 13, 1, 0, 0, 0, 97, 98, 5, 33, 0, 0, 98, 100, 5, 40, 0, 0, 99, 101, + 3, 12, 6, 0, 100, 99, 1, 0, 0, 0, 100, 101, 1, 0, 0, 0, 101, 15, 1, 0, + 0, 0, 102, 103, 5, 5, 0, 0, 103, 107, 5, 23, 0, 0, 104, 106, 3, 14, 7, + 0, 105, 104, 1, 0, 0, 0, 106, 109, 1, 0, 0, 0, 107, 105, 1, 0, 0, 0, 107, + 108, 1, 0, 0, 0, 108, 110, 1, 0, 0, 0, 109, 107, 1, 0, 0, 0, 110, 111, + 5, 24, 0, 0, 111, 17, 1, 0, 0, 0, 112, 114, 3, 16, 8, 0, 113, 112, 1, 0, + 0, 0, 113, 114, 1, 0, 0, 0, 114, 118, 1, 0, 0, 0, 115, 117, 3, 38, 19, + 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, 0, 0, 1, 122, 19, 1, 0, 0, 0, 123, 124, 5, 21, 0, 0, 124, 125, 3, 6, + 3, 0, 125, 126, 5, 27, 0, 0, 126, 127, 5, 22, 0, 0, 127, 21, 1, 0, 0, 0, + 128, 132, 3, 2, 1, 0, 129, 132, 5, 40, 0, 0, 130, 132, 5, 13, 0, 0, 131, + 128, 1, 0, 0, 0, 131, 129, 1, 0, 0, 0, 131, 130, 1, 0, 0, 0, 132, 23, 1, + 0, 0, 0, 133, 134, 3, 6, 3, 0, 134, 135, 5, 14, 0, 0, 135, 136, 5, 15, + 0, 0, 136, 137, 5, 16, 0, 0, 137, 168, 1, 0, 0, 0, 138, 139, 3, 6, 3, 0, + 139, 140, 5, 14, 0, 0, 140, 141, 5, 16, 0, 0, 141, 142, 5, 11, 0, 0, 142, + 143, 5, 12, 0, 0, 143, 144, 3, 6, 3, 0, 144, 168, 1, 0, 0, 0, 145, 168, + 3, 6, 3, 0, 146, 148, 5, 23, 0, 0, 147, 149, 3, 26, 13, 0, 148, 147, 1, + 0, 0, 0, 149, 150, 1, 0, 0, 0, 150, 148, 1, 0, 0, 0, 150, 151, 1, 0, 0, + 0, 151, 152, 1, 0, 0, 0, 152, 153, 5, 24, 0, 0, 153, 168, 1, 0, 0, 0, 154, + 158, 5, 23, 0, 0, 155, 157, 3, 24, 12, 0, 156, 155, 1, 0, 0, 0, 157, 160, + 1, 0, 0, 0, 158, 156, 1, 0, 0, 0, 158, 159, 1, 0, 0, 0, 159, 161, 1, 0, + 0, 0, 160, 158, 1, 0, 0, 0, 161, 168, 5, 24, 0, 0, 162, 163, 5, 6, 0, 0, + 163, 164, 3, 6, 3, 0, 164, 165, 5, 10, 0, 0, 165, 166, 3, 24, 12, 0, 166, + 168, 1, 0, 0, 0, 167, 133, 1, 0, 0, 0, 167, 138, 1, 0, 0, 0, 167, 145, + 1, 0, 0, 0, 167, 146, 1, 0, 0, 0, 167, 154, 1, 0, 0, 0, 167, 162, 1, 0, + 0, 0, 168, 25, 1, 0, 0, 0, 169, 170, 3, 22, 11, 0, 170, 171, 5, 10, 0, + 0, 171, 172, 3, 24, 12, 0, 172, 27, 1, 0, 0, 0, 173, 174, 5, 12, 0, 0, + 174, 177, 3, 32, 16, 0, 175, 177, 5, 17, 0, 0, 176, 173, 1, 0, 0, 0, 176, + 175, 1, 0, 0, 0, 177, 29, 1, 0, 0, 0, 178, 179, 5, 6, 0, 0, 179, 180, 3, + 6, 3, 0, 180, 181, 3, 28, 14, 0, 181, 31, 1, 0, 0, 0, 182, 203, 3, 6, 3, + 0, 183, 185, 5, 23, 0, 0, 184, 186, 3, 34, 17, 0, 185, 184, 1, 0, 0, 0, + 186, 187, 1, 0, 0, 0, 187, 185, 1, 0, 0, 0, 187, 188, 1, 0, 0, 0, 188, + 189, 1, 0, 0, 0, 189, 190, 5, 24, 0, 0, 190, 203, 1, 0, 0, 0, 191, 195, + 5, 23, 0, 0, 192, 194, 3, 30, 15, 0, 193, 192, 1, 0, 0, 0, 194, 197, 1, + 0, 0, 0, 195, 193, 1, 0, 0, 0, 195, 196, 1, 0, 0, 0, 196, 198, 1, 0, 0, + 0, 197, 195, 1, 0, 0, 0, 198, 199, 5, 13, 0, 0, 199, 200, 3, 28, 14, 0, + 200, 201, 5, 24, 0, 0, 201, 203, 1, 0, 0, 0, 202, 182, 1, 0, 0, 0, 202, + 183, 1, 0, 0, 0, 202, 191, 1, 0, 0, 0, 203, 33, 1, 0, 0, 0, 204, 205, 3, + 22, 11, 0, 205, 206, 3, 28, 14, 0, 206, 35, 1, 0, 0, 0, 207, 210, 3, 6, + 3, 0, 208, 210, 3, 20, 10, 0, 209, 207, 1, 0, 0, 0, 209, 208, 1, 0, 0, + 0, 210, 37, 1, 0, 0, 0, 211, 212, 5, 9, 0, 0, 212, 213, 3, 36, 18, 0, 213, + 214, 5, 19, 0, 0, 214, 215, 5, 7, 0, 0, 215, 216, 5, 26, 0, 0, 216, 217, + 3, 24, 12, 0, 217, 218, 5, 8, 0, 0, 218, 219, 5, 26, 0, 0, 219, 220, 3, + 32, 16, 0, 220, 221, 5, 20, 0, 0, 221, 229, 1, 0, 0, 0, 222, 223, 5, 18, + 0, 0, 223, 224, 3, 36, 18, 0, 224, 225, 5, 10, 0, 0, 225, 226, 3, 6, 3, + 0, 226, 229, 1, 0, 0, 0, 227, 229, 3, 10, 5, 0, 228, 211, 1, 0, 0, 0, 228, + 222, 1, 0, 0, 0, 228, 227, 1, 0, 0, 0, 229, 39, 1, 0, 0, 0, 21, 47, 51, + 63, 69, 76, 84, 90, 100, 107, 113, 118, 131, 150, 158, 167, 176, 187, 195, + 202, 209, 228, } deserializer := antlr.NewATNDeserializer(nil) staticData.atn = deserializer.Deserialize(staticData.serializedATN) @@ -185,66 +194,70 @@ func NewNumscriptParser(input antlr.TokenStream) *NumscriptParser { // NumscriptParser tokens. const ( NumscriptParserEOF = antlr.TokenEOF - NumscriptParserT__0 = 1 - NumscriptParserWS = 2 - NumscriptParserNEWLINE = 3 - NumscriptParserMULTILINE_COMMENT = 4 - NumscriptParserLINE_COMMENT = 5 - NumscriptParserVARS = 6 - NumscriptParserMAX = 7 - NumscriptParserSOURCE = 8 - NumscriptParserDESTINATION = 9 - NumscriptParserSEND = 10 - NumscriptParserFROM = 11 - NumscriptParserUP = 12 - NumscriptParserTO = 13 - NumscriptParserREMAINING = 14 - NumscriptParserALLOWING = 15 - NumscriptParserUNBOUNDED = 16 - NumscriptParserOVERDRAFT = 17 - NumscriptParserKEPT = 18 - NumscriptParserSAVE = 19 - NumscriptParserLPARENS = 20 - NumscriptParserRPARENS = 21 - NumscriptParserLBRACKET = 22 - NumscriptParserRBRACKET = 23 - NumscriptParserLBRACE = 24 - NumscriptParserRBRACE = 25 - NumscriptParserCOMMA = 26 - NumscriptParserEQ = 27 - NumscriptParserSTAR = 28 + NumscriptParserWS = 1 + NumscriptParserNEWLINE = 2 + NumscriptParserMULTILINE_COMMENT = 3 + NumscriptParserLINE_COMMENT = 4 + NumscriptParserVARS = 5 + NumscriptParserMAX = 6 + NumscriptParserSOURCE = 7 + NumscriptParserDESTINATION = 8 + NumscriptParserSEND = 9 + NumscriptParserFROM = 10 + NumscriptParserUP = 11 + NumscriptParserTO = 12 + NumscriptParserREMAINING = 13 + NumscriptParserALLOWING = 14 + NumscriptParserUNBOUNDED = 15 + NumscriptParserOVERDRAFT = 16 + NumscriptParserKEPT = 17 + NumscriptParserSAVE = 18 + NumscriptParserLPARENS = 19 + NumscriptParserRPARENS = 20 + NumscriptParserLBRACKET = 21 + NumscriptParserRBRACKET = 22 + NumscriptParserLBRACE = 23 + NumscriptParserRBRACE = 24 + NumscriptParserCOMMA = 25 + NumscriptParserEQ = 26 + NumscriptParserSTAR = 27 + NumscriptParserPLUS = 28 NumscriptParserMINUS = 29 NumscriptParserRATIO_PORTION_LITERAL = 30 NumscriptParserPERCENTAGE_PORTION_LITERAL = 31 NumscriptParserSTRING = 32 NumscriptParserIDENTIFIER = 33 NumscriptParserNUMBER = 34 - NumscriptParserVARIABLE_NAME = 35 - NumscriptParserACCOUNT = 36 - NumscriptParserASSET = 37 + NumscriptParserASSET = 35 + NumscriptParserACCOUNT_START = 36 + NumscriptParserCOLON = 37 + NumscriptParserACCOUNT_TEXT = 38 + NumscriptParserVARIABLE_NAME_ACC = 39 + NumscriptParserVARIABLE_NAME_DEFAULT = 40 ) // NumscriptParser rules. const ( NumscriptParserRULE_monetaryLit = 0 NumscriptParserRULE_portion = 1 - NumscriptParserRULE_valueExpr = 2 - NumscriptParserRULE_functionCallArgs = 3 - NumscriptParserRULE_functionCall = 4 - NumscriptParserRULE_varOrigin = 5 - NumscriptParserRULE_varDeclaration = 6 - NumscriptParserRULE_varsDeclaration = 7 - NumscriptParserRULE_program = 8 - NumscriptParserRULE_sentAllLit = 9 - NumscriptParserRULE_allotment = 10 - NumscriptParserRULE_source = 11 - NumscriptParserRULE_allotmentClauseSrc = 12 - NumscriptParserRULE_keptOrDestination = 13 - NumscriptParserRULE_destinationInOrderClause = 14 - NumscriptParserRULE_destination = 15 - NumscriptParserRULE_allotmentClauseDest = 16 - NumscriptParserRULE_sentValue = 17 - NumscriptParserRULE_statement = 18 + NumscriptParserRULE_accountLiteralPart = 2 + NumscriptParserRULE_valueExpr = 3 + NumscriptParserRULE_functionCallArgs = 4 + NumscriptParserRULE_functionCall = 5 + NumscriptParserRULE_varOrigin = 6 + NumscriptParserRULE_varDeclaration = 7 + NumscriptParserRULE_varsDeclaration = 8 + NumscriptParserRULE_program = 9 + NumscriptParserRULE_sentAllLit = 10 + NumscriptParserRULE_allotment = 11 + NumscriptParserRULE_source = 12 + NumscriptParserRULE_allotmentClauseSrc = 13 + NumscriptParserRULE_keptOrDestination = 14 + NumscriptParserRULE_destinationInOrderClause = 15 + NumscriptParserRULE_destination = 16 + NumscriptParserRULE_allotmentClauseDest = 17 + NumscriptParserRULE_sentValue = 18 + NumscriptParserRULE_statement = 19 ) // IMonetaryLitContext is an interface to support dynamic dispatch. @@ -392,7 +405,7 @@ func (p *NumscriptParser) MonetaryLit() (localctx IMonetaryLitContext) { p.EnterRule(localctx, 0, NumscriptParserRULE_monetaryLit) p.EnterOuterAlt(localctx, 1) { - p.SetState(38) + p.SetState(40) p.Match(NumscriptParserLBRACKET) if p.HasError() { // Recognition error - abort rule @@ -401,7 +414,7 @@ func (p *NumscriptParser) MonetaryLit() (localctx IMonetaryLitContext) { } { - p.SetState(39) + p.SetState(41) var _x = p.valueExpr(0) @@ -409,7 +422,7 @@ func (p *NumscriptParser) MonetaryLit() (localctx IMonetaryLitContext) { } { - p.SetState(40) + p.SetState(42) var _x = p.valueExpr(0) @@ -417,7 +430,7 @@ func (p *NumscriptParser) MonetaryLit() (localctx IMonetaryLitContext) { } { - p.SetState(41) + p.SetState(43) p.Match(NumscriptParserRBRACKET) if p.HasError() { // Recognition error - abort rule @@ -563,7 +576,7 @@ func (s *RatioContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) Portion() (localctx IPortionContext) { localctx = NewPortionContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 2, NumscriptParserRULE_portion) - p.SetState(45) + p.SetState(47) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -574,7 +587,7 @@ func (p *NumscriptParser) Portion() (localctx IPortionContext) { localctx = NewRatioContext(p, localctx) p.EnterOuterAlt(localctx, 1) { - p.SetState(43) + p.SetState(45) p.Match(NumscriptParserRATIO_PORTION_LITERAL) if p.HasError() { // Recognition error - abort rule @@ -586,7 +599,7 @@ func (p *NumscriptParser) Portion() (localctx IPortionContext) { localctx = NewPercentageContext(p, localctx) p.EnterOuterAlt(localctx, 2) { - p.SetState(44) + p.SetState(46) p.Match(NumscriptParserPERCENTAGE_PORTION_LITERAL) if p.HasError() { // Recognition error - abort rule @@ -612,6 +625,180 @@ errorExit: goto errorExit // Trick to prevent compiler error if the label is not used } +// IAccountLiteralPartContext is an interface to support dynamic dispatch. +type IAccountLiteralPartContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + // IsAccountLiteralPartContext differentiates from other interfaces. + IsAccountLiteralPartContext() +} + +type AccountLiteralPartContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyAccountLiteralPartContext() *AccountLiteralPartContext { + var p = new(AccountLiteralPartContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = NumscriptParserRULE_accountLiteralPart + return p +} + +func InitEmptyAccountLiteralPartContext(p *AccountLiteralPartContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = NumscriptParserRULE_accountLiteralPart +} + +func (*AccountLiteralPartContext) IsAccountLiteralPartContext() {} + +func NewAccountLiteralPartContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AccountLiteralPartContext { + var p = new(AccountLiteralPartContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = NumscriptParserRULE_accountLiteralPart + + return p +} + +func (s *AccountLiteralPartContext) GetParser() antlr.Parser { return s.parser } + +func (s *AccountLiteralPartContext) CopyAll(ctx *AccountLiteralPartContext) { + s.CopyFrom(&ctx.BaseParserRuleContext) +} + +func (s *AccountLiteralPartContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *AccountLiteralPartContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +type AccountVarPartContext struct { + AccountLiteralPartContext +} + +func NewAccountVarPartContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *AccountVarPartContext { + var p = new(AccountVarPartContext) + + InitEmptyAccountLiteralPartContext(&p.AccountLiteralPartContext) + p.parser = parser + p.CopyAll(ctx.(*AccountLiteralPartContext)) + + return p +} + +func (s *AccountVarPartContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *AccountVarPartContext) VARIABLE_NAME_ACC() antlr.TerminalNode { + return s.GetToken(NumscriptParserVARIABLE_NAME_ACC, 0) +} + +func (s *AccountVarPartContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(NumscriptListener); ok { + listenerT.EnterAccountVarPart(s) + } +} + +func (s *AccountVarPartContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(NumscriptListener); ok { + listenerT.ExitAccountVarPart(s) + } +} + +type AccountTextPartContext struct { + AccountLiteralPartContext +} + +func NewAccountTextPartContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *AccountTextPartContext { + var p = new(AccountTextPartContext) + + InitEmptyAccountLiteralPartContext(&p.AccountLiteralPartContext) + p.parser = parser + p.CopyAll(ctx.(*AccountLiteralPartContext)) + + return p +} + +func (s *AccountTextPartContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *AccountTextPartContext) ACCOUNT_TEXT() antlr.TerminalNode { + return s.GetToken(NumscriptParserACCOUNT_TEXT, 0) +} + +func (s *AccountTextPartContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(NumscriptListener); ok { + listenerT.EnterAccountTextPart(s) + } +} + +func (s *AccountTextPartContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(NumscriptListener); ok { + listenerT.ExitAccountTextPart(s) + } +} + +func (p *NumscriptParser) AccountLiteralPart() (localctx IAccountLiteralPartContext) { + localctx = NewAccountLiteralPartContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 4, NumscriptParserRULE_accountLiteralPart) + p.SetState(51) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + + switch p.GetTokenStream().LA(1) { + case NumscriptParserACCOUNT_TEXT: + localctx = NewAccountTextPartContext(p, localctx) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(49) + p.Match(NumscriptParserACCOUNT_TEXT) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case NumscriptParserVARIABLE_NAME_ACC: + localctx = NewAccountVarPartContext(p, localctx) + p.EnterOuterAlt(localctx, 2) + { + p.SetState(50) + p.Match(NumscriptParserVARIABLE_NAME_ACC) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + default: + p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + goto errorExit + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + // IValueExprContext is an interface to support dynamic dispatch. type IValueExprContext interface { antlr.ParserRuleContext @@ -684,8 +871,8 @@ func (s *VariableExprContext) GetRuleContext() antlr.RuleContext { return s } -func (s *VariableExprContext) VARIABLE_NAME() antlr.TerminalNode { - return s.GetToken(NumscriptParserVARIABLE_NAME, 0) +func (s *VariableExprContext) VARIABLE_NAME_DEFAULT() antlr.TerminalNode { + return s.GetToken(NumscriptParserVARIABLE_NAME_DEFAULT, 0) } func (s *VariableExprContext) EnterRule(listener antlr.ParseTreeListener) { @@ -820,6 +1007,10 @@ func (s *InfixExprContext) ValueExpr(i int) IValueExprContext { return t.(IValueExprContext) } +func (s *InfixExprContext) PLUS() antlr.TerminalNode { + return s.GetToken(NumscriptParserPLUS, 0) +} + func (s *InfixExprContext) MINUS() antlr.TerminalNode { return s.GetToken(NumscriptParserMINUS, 0) } @@ -922,8 +1113,57 @@ func (s *AccountLiteralContext) GetRuleContext() antlr.RuleContext { return s } -func (s *AccountLiteralContext) ACCOUNT() antlr.TerminalNode { - return s.GetToken(NumscriptParserACCOUNT, 0) +func (s *AccountLiteralContext) ACCOUNT_START() antlr.TerminalNode { + return s.GetToken(NumscriptParserACCOUNT_START, 0) +} + +func (s *AccountLiteralContext) AllAccountLiteralPart() []IAccountLiteralPartContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IAccountLiteralPartContext); ok { + len++ + } + } + + tst := make([]IAccountLiteralPartContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IAccountLiteralPartContext); ok { + tst[i] = t.(IAccountLiteralPartContext) + i++ + } + } + + return tst +} + +func (s *AccountLiteralContext) AccountLiteralPart(i int) IAccountLiteralPartContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IAccountLiteralPartContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IAccountLiteralPartContext) +} + +func (s *AccountLiteralContext) AllCOLON() []antlr.TerminalNode { + return s.GetTokens(NumscriptParserCOLON) +} + +func (s *AccountLiteralContext) COLON(i int) antlr.TerminalNode { + return s.GetToken(NumscriptParserCOLON, i) } func (s *AccountLiteralContext) EnterRule(listener antlr.ParseTreeListener) { @@ -1029,28 +1269,28 @@ func (p *NumscriptParser) valueExpr(_p int) (localctx IValueExprContext) { localctx = NewValueExprContext(p, p.GetParserRuleContext(), _parentState) var _prevctx IValueExprContext = localctx var _ antlr.ParserRuleContext = _prevctx // TODO: To prevent unused variable warning. - _startState := 4 - p.EnterRecursionRule(localctx, 4, NumscriptParserRULE_valueExpr, _p) + _startState := 6 + p.EnterRecursionRule(localctx, 6, NumscriptParserRULE_valueExpr, _p) var _la int var _alt int p.EnterOuterAlt(localctx, 1) - p.SetState(55) + p.SetState(69) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } switch p.GetTokenStream().LA(1) { - case NumscriptParserVARIABLE_NAME: + case NumscriptParserVARIABLE_NAME_DEFAULT: localctx = NewVariableExprContext(p, localctx) p.SetParserRuleContext(localctx) _prevctx = localctx { - p.SetState(48) - p.Match(NumscriptParserVARIABLE_NAME) + p.SetState(54) + p.Match(NumscriptParserVARIABLE_NAME_DEFAULT) if p.HasError() { // Recognition error - abort rule goto errorExit @@ -1062,7 +1302,7 @@ func (p *NumscriptParser) valueExpr(_p int) (localctx IValueExprContext) { p.SetParserRuleContext(localctx) _prevctx = localctx { - p.SetState(49) + p.SetState(55) p.Match(NumscriptParserASSET) if p.HasError() { // Recognition error - abort rule @@ -1075,7 +1315,7 @@ func (p *NumscriptParser) valueExpr(_p int) (localctx IValueExprContext) { p.SetParserRuleContext(localctx) _prevctx = localctx { - p.SetState(50) + p.SetState(56) p.Match(NumscriptParserSTRING) if p.HasError() { // Recognition error - abort rule @@ -1083,25 +1323,64 @@ func (p *NumscriptParser) valueExpr(_p int) (localctx IValueExprContext) { } } - case NumscriptParserACCOUNT: + case NumscriptParserACCOUNT_START: localctx = NewAccountLiteralContext(p, localctx) p.SetParserRuleContext(localctx) _prevctx = localctx { - p.SetState(51) - p.Match(NumscriptParserACCOUNT) + p.SetState(57) + p.Match(NumscriptParserACCOUNT_START) if p.HasError() { // Recognition error - abort rule goto errorExit } } + { + p.SetState(58) + p.AccountLiteralPart() + } + p.SetState(63) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 2, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } + for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { + if _alt == 1 { + { + p.SetState(59) + p.Match(NumscriptParserCOLON) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(60) + p.AccountLiteralPart() + } + + } + p.SetState(65) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 2, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } + } case NumscriptParserNUMBER: localctx = NewNumberLiteralContext(p, localctx) p.SetParserRuleContext(localctx) _prevctx = localctx { - p.SetState(52) + p.SetState(66) p.Match(NumscriptParserNUMBER) if p.HasError() { // Recognition error - abort rule @@ -1114,7 +1393,7 @@ func (p *NumscriptParser) valueExpr(_p int) (localctx IValueExprContext) { p.SetParserRuleContext(localctx) _prevctx = localctx { - p.SetState(53) + p.SetState(67) p.MonetaryLit() } @@ -1123,7 +1402,7 @@ func (p *NumscriptParser) valueExpr(_p int) (localctx IValueExprContext) { p.SetParserRuleContext(localctx) _prevctx = localctx { - p.SetState(54) + p.SetState(68) p.Portion() } @@ -1132,12 +1411,12 @@ func (p *NumscriptParser) valueExpr(_p int) (localctx IValueExprContext) { goto errorExit } p.GetParserRuleContext().SetStop(p.GetTokenStream().LT(-1)) - p.SetState(62) + p.SetState(76) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 2, p.GetParserRuleContext()) + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 4, p.GetParserRuleContext()) if p.HasError() { goto errorExit } @@ -1151,14 +1430,14 @@ func (p *NumscriptParser) valueExpr(_p int) (localctx IValueExprContext) { localctx.(*InfixExprContext).left = _prevctx p.PushNewRecursionContext(localctx, _startState, NumscriptParserRULE_valueExpr) - p.SetState(57) + p.SetState(71) if !(p.Precpred(p.GetParserRuleContext(), 1)) { p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 1)", "")) goto errorExit } { - p.SetState(58) + p.SetState(72) var _lt = p.GetTokenStream().LT(1) @@ -1166,7 +1445,7 @@ func (p *NumscriptParser) valueExpr(_p int) (localctx IValueExprContext) { _la = p.GetTokenStream().LA(1) - if !(_la == NumscriptParserT__0 || _la == NumscriptParserMINUS) { + if !(_la == NumscriptParserPLUS || _la == NumscriptParserMINUS) { var _ri = p.GetErrorHandler().RecoverInline(p) localctx.(*InfixExprContext).op = _ri @@ -1176,7 +1455,7 @@ func (p *NumscriptParser) valueExpr(_p int) (localctx IValueExprContext) { } } { - p.SetState(59) + p.SetState(73) var _x = p.valueExpr(2) @@ -1184,12 +1463,12 @@ func (p *NumscriptParser) valueExpr(_p int) (localctx IValueExprContext) { } } - p.SetState(64) + p.SetState(78) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 2, p.GetParserRuleContext()) + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 4, p.GetParserRuleContext()) if p.HasError() { goto errorExit } @@ -1328,15 +1607,15 @@ func (s *FunctionCallArgsContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) FunctionCallArgs() (localctx IFunctionCallArgsContext) { localctx = NewFunctionCallArgsContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 6, NumscriptParserRULE_functionCallArgs) + p.EnterRule(localctx, 8, NumscriptParserRULE_functionCallArgs) var _la int p.EnterOuterAlt(localctx, 1) { - p.SetState(65) + p.SetState(79) p.valueExpr(0) } - p.SetState(70) + p.SetState(84) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1345,7 +1624,7 @@ func (p *NumscriptParser) FunctionCallArgs() (localctx IFunctionCallArgsContext) for _la == NumscriptParserCOMMA { { - p.SetState(66) + p.SetState(80) p.Match(NumscriptParserCOMMA) if p.HasError() { // Recognition error - abort rule @@ -1353,11 +1632,11 @@ func (p *NumscriptParser) FunctionCallArgs() (localctx IFunctionCallArgsContext) } } { - p.SetState(67) + p.SetState(81) p.valueExpr(0) } - p.SetState(72) + p.SetState(86) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1493,12 +1772,12 @@ func (s *FunctionCallContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) FunctionCall() (localctx IFunctionCallContext) { localctx = NewFunctionCallContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 8, NumscriptParserRULE_functionCall) + p.EnterRule(localctx, 10, NumscriptParserRULE_functionCall) var _la int p.EnterOuterAlt(localctx, 1) { - p.SetState(73) + p.SetState(87) var _lt = p.GetTokenStream().LT(1) @@ -1516,29 +1795,29 @@ func (p *NumscriptParser) FunctionCall() (localctx IFunctionCallContext) { } } { - p.SetState(74) + p.SetState(88) p.Match(NumscriptParserLPARENS) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(76) + p.SetState(90) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - if (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&265218424832) != 0 { + if (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&1227289001984) != 0 { { - p.SetState(75) + p.SetState(89) p.FunctionCallArgs() } } { - p.SetState(78) + p.SetState(92) p.Match(NumscriptParserRPARENS) if p.HasError() { // Recognition error - abort rule @@ -1648,10 +1927,10 @@ func (s *VarOriginContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) VarOrigin() (localctx IVarOriginContext) { localctx = NewVarOriginContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 10, NumscriptParserRULE_varOrigin) + p.EnterRule(localctx, 12, NumscriptParserRULE_varOrigin) p.EnterOuterAlt(localctx, 1) { - p.SetState(80) + p.SetState(94) p.Match(NumscriptParserEQ) if p.HasError() { // Recognition error - abort rule @@ -1659,7 +1938,7 @@ func (p *NumscriptParser) VarOrigin() (localctx IVarOriginContext) { } } { - p.SetState(81) + p.SetState(95) p.FunctionCall() } @@ -1697,7 +1976,7 @@ type IVarDeclarationContext interface { // Getter signatures IDENTIFIER() antlr.TerminalNode - VARIABLE_NAME() antlr.TerminalNode + VARIABLE_NAME_DEFAULT() antlr.TerminalNode VarOrigin() IVarOriginContext // IsVarDeclarationContext differentiates from other interfaces. @@ -1750,8 +2029,8 @@ func (s *VarDeclarationContext) IDENTIFIER() antlr.TerminalNode { return s.GetToken(NumscriptParserIDENTIFIER, 0) } -func (s *VarDeclarationContext) VARIABLE_NAME() antlr.TerminalNode { - return s.GetToken(NumscriptParserVARIABLE_NAME, 0) +func (s *VarDeclarationContext) VARIABLE_NAME_DEFAULT() antlr.TerminalNode { + return s.GetToken(NumscriptParserVARIABLE_NAME_DEFAULT, 0) } func (s *VarDeclarationContext) VarOrigin() IVarOriginContext { @@ -1792,12 +2071,12 @@ func (s *VarDeclarationContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) VarDeclaration() (localctx IVarDeclarationContext) { localctx = NewVarDeclarationContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 12, NumscriptParserRULE_varDeclaration) + p.EnterRule(localctx, 14, NumscriptParserRULE_varDeclaration) var _la int p.EnterOuterAlt(localctx, 1) { - p.SetState(83) + p.SetState(97) var _m = p.Match(NumscriptParserIDENTIFIER) @@ -1808,9 +2087,9 @@ func (p *NumscriptParser) VarDeclaration() (localctx IVarDeclarationContext) { } } { - p.SetState(84) + p.SetState(98) - var _m = p.Match(NumscriptParserVARIABLE_NAME) + var _m = p.Match(NumscriptParserVARIABLE_NAME_DEFAULT) localctx.(*VarDeclarationContext).name = _m if p.HasError() { @@ -1818,7 +2097,7 @@ func (p *NumscriptParser) VarDeclaration() (localctx IVarDeclarationContext) { goto errorExit } } - p.SetState(86) + p.SetState(100) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1827,7 +2106,7 @@ func (p *NumscriptParser) VarDeclaration() (localctx IVarDeclarationContext) { if _la == NumscriptParserEQ { { - p.SetState(85) + p.SetState(99) p.VarOrigin() } @@ -1971,12 +2250,12 @@ func (s *VarsDeclarationContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) VarsDeclaration() (localctx IVarsDeclarationContext) { localctx = NewVarsDeclarationContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 14, NumscriptParserRULE_varsDeclaration) + p.EnterRule(localctx, 16, NumscriptParserRULE_varsDeclaration) var _la int p.EnterOuterAlt(localctx, 1) { - p.SetState(88) + p.SetState(102) p.Match(NumscriptParserVARS) if p.HasError() { // Recognition error - abort rule @@ -1984,14 +2263,14 @@ func (p *NumscriptParser) VarsDeclaration() (localctx IVarsDeclarationContext) { } } { - p.SetState(89) + p.SetState(103) p.Match(NumscriptParserLBRACE) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(93) + p.SetState(107) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2000,11 +2279,11 @@ func (p *NumscriptParser) VarsDeclaration() (localctx IVarsDeclarationContext) { for _la == NumscriptParserIDENTIFIER { { - p.SetState(90) + p.SetState(104) p.VarDeclaration() } - p.SetState(95) + p.SetState(109) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2012,7 +2291,7 @@ func (p *NumscriptParser) VarsDeclaration() (localctx IVarsDeclarationContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(96) + p.SetState(110) p.Match(NumscriptParserRBRACE) if p.HasError() { // Recognition error - abort rule @@ -2165,11 +2444,11 @@ func (s *ProgramContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) Program() (localctx IProgramContext) { localctx = NewProgramContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 16, NumscriptParserRULE_program) + p.EnterRule(localctx, 18, NumscriptParserRULE_program) var _la int p.EnterOuterAlt(localctx, 1) - p.SetState(99) + p.SetState(113) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2178,25 +2457,25 @@ func (p *NumscriptParser) Program() (localctx IProgramContext) { if _la == NumscriptParserVARS { { - p.SetState(98) + p.SetState(112) p.VarsDeclaration() } } - p.SetState(104) + p.SetState(118) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&8590590976) != 0 { + for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&8590262784) != 0 { { - p.SetState(101) + p.SetState(115) p.Statement() } - p.SetState(106) + p.SetState(120) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2204,7 +2483,7 @@ func (p *NumscriptParser) Program() (localctx IProgramContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(107) + p.SetState(121) p.Match(NumscriptParserEOF) if p.HasError() { // Recognition error - abort rule @@ -2335,10 +2614,10 @@ func (s *SentAllLitContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) SentAllLit() (localctx ISentAllLitContext) { localctx = NewSentAllLitContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 18, NumscriptParserRULE_sentAllLit) + p.EnterRule(localctx, 20, NumscriptParserRULE_sentAllLit) p.EnterOuterAlt(localctx, 1) { - p.SetState(109) + p.SetState(123) p.Match(NumscriptParserLBRACKET) if p.HasError() { // Recognition error - abort rule @@ -2347,7 +2626,7 @@ func (p *NumscriptParser) SentAllLit() (localctx ISentAllLitContext) { } { - p.SetState(110) + p.SetState(124) var _x = p.valueExpr(0) @@ -2355,7 +2634,7 @@ func (p *NumscriptParser) SentAllLit() (localctx ISentAllLitContext) { } { - p.SetState(111) + p.SetState(125) p.Match(NumscriptParserSTAR) if p.HasError() { // Recognition error - abort rule @@ -2363,7 +2642,7 @@ func (p *NumscriptParser) SentAllLit() (localctx ISentAllLitContext) { } } { - p.SetState(112) + p.SetState(126) p.Match(NumscriptParserRBRACKET) if p.HasError() { // Recognition error - abort rule @@ -2536,8 +2815,8 @@ func (s *PortionVariableContext) GetRuleContext() antlr.RuleContext { return s } -func (s *PortionVariableContext) VARIABLE_NAME() antlr.TerminalNode { - return s.GetToken(NumscriptParserVARIABLE_NAME, 0) +func (s *PortionVariableContext) VARIABLE_NAME_DEFAULT() antlr.TerminalNode { + return s.GetToken(NumscriptParserVARIABLE_NAME_DEFAULT, 0) } func (s *PortionVariableContext) EnterRule(listener antlr.ParseTreeListener) { @@ -2554,8 +2833,8 @@ func (s *PortionVariableContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) Allotment() (localctx IAllotmentContext) { localctx = NewAllotmentContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 20, NumscriptParserRULE_allotment) - p.SetState(117) + p.EnterRule(localctx, 22, NumscriptParserRULE_allotment) + p.SetState(131) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2566,16 +2845,16 @@ func (p *NumscriptParser) Allotment() (localctx IAllotmentContext) { localctx = NewPortionedAllotmentContext(p, localctx) p.EnterOuterAlt(localctx, 1) { - p.SetState(114) + p.SetState(128) p.Portion() } - case NumscriptParserVARIABLE_NAME: + case NumscriptParserVARIABLE_NAME_DEFAULT: localctx = NewPortionVariableContext(p, localctx) p.EnterOuterAlt(localctx, 2) { - p.SetState(115) - p.Match(NumscriptParserVARIABLE_NAME) + p.SetState(129) + p.Match(NumscriptParserVARIABLE_NAME_DEFAULT) if p.HasError() { // Recognition error - abort rule goto errorExit @@ -2586,7 +2865,7 @@ func (p *NumscriptParser) Allotment() (localctx IAllotmentContext) { localctx = NewRemainingAllotmentContext(p, localctx) p.EnterOuterAlt(localctx, 3) { - p.SetState(116) + p.SetState(130) p.Match(NumscriptParserREMAINING) if p.HasError() { // Recognition error - abort rule @@ -3107,28 +3386,28 @@ func (s *SrcAccountContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) Source() (localctx ISourceContext) { localctx = NewSourceContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 22, NumscriptParserRULE_source) + p.EnterRule(localctx, 24, NumscriptParserRULE_source) var _la int - p.SetState(153) + p.SetState(167) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 12, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 14, p.GetParserRuleContext()) { case 1: localctx = NewSrcAccountUnboundedOverdraftContext(p, localctx) p.EnterOuterAlt(localctx, 1) { - p.SetState(119) + p.SetState(133) var _x = p.valueExpr(0) localctx.(*SrcAccountUnboundedOverdraftContext).address = _x } { - p.SetState(120) + p.SetState(134) p.Match(NumscriptParserALLOWING) if p.HasError() { // Recognition error - abort rule @@ -3136,7 +3415,7 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { } } { - p.SetState(121) + p.SetState(135) p.Match(NumscriptParserUNBOUNDED) if p.HasError() { // Recognition error - abort rule @@ -3144,7 +3423,7 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { } } { - p.SetState(122) + p.SetState(136) p.Match(NumscriptParserOVERDRAFT) if p.HasError() { // Recognition error - abort rule @@ -3156,14 +3435,14 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { localctx = NewSrcAccountBoundedOverdraftContext(p, localctx) p.EnterOuterAlt(localctx, 2) { - p.SetState(124) + p.SetState(138) var _x = p.valueExpr(0) localctx.(*SrcAccountBoundedOverdraftContext).address = _x } { - p.SetState(125) + p.SetState(139) p.Match(NumscriptParserALLOWING) if p.HasError() { // Recognition error - abort rule @@ -3171,7 +3450,7 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { } } { - p.SetState(126) + p.SetState(140) p.Match(NumscriptParserOVERDRAFT) if p.HasError() { // Recognition error - abort rule @@ -3179,7 +3458,7 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { } } { - p.SetState(127) + p.SetState(141) p.Match(NumscriptParserUP) if p.HasError() { // Recognition error - abort rule @@ -3187,7 +3466,7 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { } } { - p.SetState(128) + p.SetState(142) p.Match(NumscriptParserTO) if p.HasError() { // Recognition error - abort rule @@ -3195,7 +3474,7 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { } } { - p.SetState(129) + p.SetState(143) var _x = p.valueExpr(0) @@ -3206,7 +3485,7 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { localctx = NewSrcAccountContext(p, localctx) p.EnterOuterAlt(localctx, 3) { - p.SetState(131) + p.SetState(145) p.valueExpr(0) } @@ -3214,27 +3493,27 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { localctx = NewSrcAllotmentContext(p, localctx) p.EnterOuterAlt(localctx, 4) { - p.SetState(132) + p.SetState(146) p.Match(NumscriptParserLBRACE) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(134) + p.SetState(148) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - for ok := true; ok; ok = ((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&37580980224) != 0) { + for ok := true; ok; ok = ((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&1102732861440) != 0) { { - p.SetState(133) + p.SetState(147) p.AllotmentClauseSrc() } - p.SetState(136) + p.SetState(150) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -3242,7 +3521,7 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(138) + p.SetState(152) p.Match(NumscriptParserRBRACE) if p.HasError() { // Recognition error - abort rule @@ -3254,27 +3533,27 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { localctx = NewSrcInorderContext(p, localctx) p.EnterOuterAlt(localctx, 5) { - p.SetState(140) + p.SetState(154) p.Match(NumscriptParserLBRACE) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(144) + p.SetState(158) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&265235202176) != 0 { + for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&1227297390656) != 0 { { - p.SetState(141) + p.SetState(155) p.Source() } - p.SetState(146) + p.SetState(160) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -3282,7 +3561,7 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(147) + p.SetState(161) p.Match(NumscriptParserRBRACE) if p.HasError() { // Recognition error - abort rule @@ -3294,7 +3573,7 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { localctx = NewSrcCappedContext(p, localctx) p.EnterOuterAlt(localctx, 6) { - p.SetState(148) + p.SetState(162) p.Match(NumscriptParserMAX) if p.HasError() { // Recognition error - abort rule @@ -3302,14 +3581,14 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { } } { - p.SetState(149) + p.SetState(163) var _x = p.valueExpr(0) localctx.(*SrcCappedContext).cap_ = _x } { - p.SetState(150) + p.SetState(164) p.Match(NumscriptParserFROM) if p.HasError() { // Recognition error - abort rule @@ -3317,7 +3596,7 @@ func (p *NumscriptParser) Source() (localctx ISourceContext) { } } { - p.SetState(151) + p.SetState(165) p.Source() } @@ -3444,14 +3723,14 @@ func (s *AllotmentClauseSrcContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) AllotmentClauseSrc() (localctx IAllotmentClauseSrcContext) { localctx = NewAllotmentClauseSrcContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 24, NumscriptParserRULE_allotmentClauseSrc) + p.EnterRule(localctx, 26, NumscriptParserRULE_allotmentClauseSrc) p.EnterOuterAlt(localctx, 1) { - p.SetState(155) + p.SetState(169) p.Allotment() } { - p.SetState(156) + p.SetState(170) p.Match(NumscriptParserFROM) if p.HasError() { // Recognition error - abort rule @@ -3459,7 +3738,7 @@ func (p *NumscriptParser) AllotmentClauseSrc() (localctx IAllotmentClauseSrcCont } } { - p.SetState(157) + p.SetState(171) p.Source() } @@ -3616,8 +3895,8 @@ func (s *DestinationToContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) KeptOrDestination() (localctx IKeptOrDestinationContext) { localctx = NewKeptOrDestinationContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 26, NumscriptParserRULE_keptOrDestination) - p.SetState(162) + p.EnterRule(localctx, 28, NumscriptParserRULE_keptOrDestination) + p.SetState(176) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -3628,7 +3907,7 @@ func (p *NumscriptParser) KeptOrDestination() (localctx IKeptOrDestinationContex localctx = NewDestinationToContext(p, localctx) p.EnterOuterAlt(localctx, 1) { - p.SetState(159) + p.SetState(173) p.Match(NumscriptParserTO) if p.HasError() { // Recognition error - abort rule @@ -3636,7 +3915,7 @@ func (p *NumscriptParser) KeptOrDestination() (localctx IKeptOrDestinationContex } } { - p.SetState(160) + p.SetState(174) p.Destination() } @@ -3644,7 +3923,7 @@ func (p *NumscriptParser) KeptOrDestination() (localctx IKeptOrDestinationContex localctx = NewDestinationKeptContext(p, localctx) p.EnterOuterAlt(localctx, 2) { - p.SetState(161) + p.SetState(175) p.Match(NumscriptParserKEPT) if p.HasError() { // Recognition error - abort rule @@ -3776,10 +4055,10 @@ func (s *DestinationInOrderClauseContext) ExitRule(listener antlr.ParseTreeListe func (p *NumscriptParser) DestinationInOrderClause() (localctx IDestinationInOrderClauseContext) { localctx = NewDestinationInOrderClauseContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 28, NumscriptParserRULE_destinationInOrderClause) + p.EnterRule(localctx, 30, NumscriptParserRULE_destinationInOrderClause) p.EnterOuterAlt(localctx, 1) { - p.SetState(164) + p.SetState(178) p.Match(NumscriptParserMAX) if p.HasError() { // Recognition error - abort rule @@ -3787,11 +4066,11 @@ func (p *NumscriptParser) DestinationInOrderClause() (localctx IDestinationInOrd } } { - p.SetState(165) + p.SetState(179) p.valueExpr(0) } { - p.SetState(166) + p.SetState(180) p.KeptOrDestination() } @@ -4088,21 +4367,21 @@ func (s *DestAllotmentContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) Destination() (localctx IDestinationContext) { localctx = NewDestinationContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 30, NumscriptParserRULE_destination) + p.EnterRule(localctx, 32, NumscriptParserRULE_destination) var _la int - p.SetState(188) + p.SetState(202) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 16, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 18, p.GetParserRuleContext()) { case 1: localctx = NewDestAccountContext(p, localctx) p.EnterOuterAlt(localctx, 1) { - p.SetState(168) + p.SetState(182) p.valueExpr(0) } @@ -4110,27 +4389,27 @@ func (p *NumscriptParser) Destination() (localctx IDestinationContext) { localctx = NewDestAllotmentContext(p, localctx) p.EnterOuterAlt(localctx, 2) { - p.SetState(169) + p.SetState(183) p.Match(NumscriptParserLBRACE) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(171) + p.SetState(185) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } _la = p.GetTokenStream().LA(1) - for ok := true; ok; ok = ((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&37580980224) != 0) { + for ok := true; ok; ok = ((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&1102732861440) != 0) { { - p.SetState(170) + p.SetState(184) p.AllotmentClauseDest() } - p.SetState(173) + p.SetState(187) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -4138,7 +4417,7 @@ func (p *NumscriptParser) Destination() (localctx IDestinationContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(175) + p.SetState(189) p.Match(NumscriptParserRBRACE) if p.HasError() { // Recognition error - abort rule @@ -4150,14 +4429,14 @@ func (p *NumscriptParser) Destination() (localctx IDestinationContext) { localctx = NewDestInorderContext(p, localctx) p.EnterOuterAlt(localctx, 3) { - p.SetState(177) + p.SetState(191) p.Match(NumscriptParserLBRACE) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(181) + p.SetState(195) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -4166,11 +4445,11 @@ func (p *NumscriptParser) Destination() (localctx IDestinationContext) { for _la == NumscriptParserMAX { { - p.SetState(178) + p.SetState(192) p.DestinationInOrderClause() } - p.SetState(183) + p.SetState(197) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -4178,7 +4457,7 @@ func (p *NumscriptParser) Destination() (localctx IDestinationContext) { _la = p.GetTokenStream().LA(1) } { - p.SetState(184) + p.SetState(198) p.Match(NumscriptParserREMAINING) if p.HasError() { // Recognition error - abort rule @@ -4186,11 +4465,11 @@ func (p *NumscriptParser) Destination() (localctx IDestinationContext) { } } { - p.SetState(185) + p.SetState(199) p.KeptOrDestination() } { - p.SetState(186) + p.SetState(200) p.Match(NumscriptParserRBRACE) if p.HasError() { // Recognition error - abort rule @@ -4316,14 +4595,14 @@ func (s *AllotmentClauseDestContext) ExitRule(listener antlr.ParseTreeListener) func (p *NumscriptParser) AllotmentClauseDest() (localctx IAllotmentClauseDestContext) { localctx = NewAllotmentClauseDestContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 32, NumscriptParserRULE_allotmentClauseDest) + p.EnterRule(localctx, 34, NumscriptParserRULE_allotmentClauseDest) p.EnterOuterAlt(localctx, 1) { - p.SetState(190) + p.SetState(204) p.Allotment() } { - p.SetState(191) + p.SetState(205) p.KeptOrDestination() } @@ -4488,19 +4767,19 @@ func (s *SentLiteralContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) SentValue() (localctx ISentValueContext) { localctx = NewSentValueContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 34, NumscriptParserRULE_sentValue) - p.SetState(195) + p.EnterRule(localctx, 36, NumscriptParserRULE_sentValue) + p.SetState(209) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 17, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 19, p.GetParserRuleContext()) { case 1: localctx = NewSentLiteralContext(p, localctx) p.EnterOuterAlt(localctx, 1) { - p.SetState(193) + p.SetState(207) p.valueExpr(0) } @@ -4508,7 +4787,7 @@ func (p *NumscriptParser) SentValue() (localctx ISentValueContext) { localctx = NewSentAllContext(p, localctx) p.EnterOuterAlt(localctx, 2) { - p.SetState(194) + p.SetState(208) p.SentAllLit() } @@ -4807,8 +5086,8 @@ func (s *FnCallStatementContext) ExitRule(listener antlr.ParseTreeListener) { func (p *NumscriptParser) Statement() (localctx IStatementContext) { localctx = NewStatementContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 36, NumscriptParserRULE_statement) - p.SetState(214) + p.EnterRule(localctx, 38, NumscriptParserRULE_statement) + p.SetState(228) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -4819,7 +5098,7 @@ func (p *NumscriptParser) Statement() (localctx IStatementContext) { localctx = NewSendStatementContext(p, localctx) p.EnterOuterAlt(localctx, 1) { - p.SetState(197) + p.SetState(211) p.Match(NumscriptParserSEND) if p.HasError() { // Recognition error - abort rule @@ -4827,11 +5106,11 @@ func (p *NumscriptParser) Statement() (localctx IStatementContext) { } } { - p.SetState(198) + p.SetState(212) p.SentValue() } { - p.SetState(199) + p.SetState(213) p.Match(NumscriptParserLPARENS) if p.HasError() { // Recognition error - abort rule @@ -4839,7 +5118,7 @@ func (p *NumscriptParser) Statement() (localctx IStatementContext) { } } { - p.SetState(200) + p.SetState(214) p.Match(NumscriptParserSOURCE) if p.HasError() { // Recognition error - abort rule @@ -4847,7 +5126,7 @@ func (p *NumscriptParser) Statement() (localctx IStatementContext) { } } { - p.SetState(201) + p.SetState(215) p.Match(NumscriptParserEQ) if p.HasError() { // Recognition error - abort rule @@ -4855,11 +5134,11 @@ func (p *NumscriptParser) Statement() (localctx IStatementContext) { } } { - p.SetState(202) + p.SetState(216) p.Source() } { - p.SetState(203) + p.SetState(217) p.Match(NumscriptParserDESTINATION) if p.HasError() { // Recognition error - abort rule @@ -4867,7 +5146,7 @@ func (p *NumscriptParser) Statement() (localctx IStatementContext) { } } { - p.SetState(204) + p.SetState(218) p.Match(NumscriptParserEQ) if p.HasError() { // Recognition error - abort rule @@ -4875,11 +5154,11 @@ func (p *NumscriptParser) Statement() (localctx IStatementContext) { } } { - p.SetState(205) + p.SetState(219) p.Destination() } { - p.SetState(206) + p.SetState(220) p.Match(NumscriptParserRPARENS) if p.HasError() { // Recognition error - abort rule @@ -4891,7 +5170,7 @@ func (p *NumscriptParser) Statement() (localctx IStatementContext) { localctx = NewSaveStatementContext(p, localctx) p.EnterOuterAlt(localctx, 2) { - p.SetState(208) + p.SetState(222) p.Match(NumscriptParserSAVE) if p.HasError() { // Recognition error - abort rule @@ -4899,11 +5178,11 @@ func (p *NumscriptParser) Statement() (localctx IStatementContext) { } } { - p.SetState(209) + p.SetState(223) p.SentValue() } { - p.SetState(210) + p.SetState(224) p.Match(NumscriptParserFROM) if p.HasError() { // Recognition error - abort rule @@ -4911,7 +5190,7 @@ func (p *NumscriptParser) Statement() (localctx IStatementContext) { } } { - p.SetState(211) + p.SetState(225) p.valueExpr(0) } @@ -4919,7 +5198,7 @@ func (p *NumscriptParser) Statement() (localctx IStatementContext) { localctx = NewFnCallStatementContext(p, localctx) p.EnterOuterAlt(localctx, 3) { - p.SetState(213) + p.SetState(227) p.FunctionCall() } @@ -4943,7 +5222,7 @@ errorExit: func (p *NumscriptParser) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool { switch ruleIndex { - case 2: + case 3: var t *ValueExprContext = nil if localctx != nil { t = localctx.(*ValueExprContext) diff --git a/internal/parser/ast.go b/internal/parser/ast.go index 7e70de89..34f40566 100644 --- a/internal/parser/ast.go +++ b/internal/parser/ast.go @@ -2,6 +2,7 @@ package parser import ( "math/big" + "strings" ) type ValueExpr interface { @@ -9,14 +10,14 @@ type ValueExpr interface { valueExpr() } -func (*Variable) valueExpr() {} -func (*AssetLiteral) valueExpr() {} -func (*MonetaryLiteral) valueExpr() {} -func (*AccountLiteral) valueExpr() {} -func (*RatioLiteral) valueExpr() {} -func (*NumberLiteral) valueExpr() {} -func (*StringLiteral) valueExpr() {} -func (*BinaryInfix) valueExpr() {} +func (*Variable) valueExpr() {} +func (*AssetLiteral) valueExpr() {} +func (*MonetaryLiteral) valueExpr() {} +func (*AccountInterpLiteral) valueExpr() {} +func (*RatioLiteral) valueExpr() {} +func (*NumberLiteral) valueExpr() {} +func (*StringLiteral) valueExpr() {} +func (*BinaryInfix) valueExpr() {} type InfixOperator string @@ -47,9 +48,9 @@ type ( Amount ValueExpr } - AccountLiteral struct { + AccountInterpLiteral struct { Range - Name string + Parts []AccountNamePart } RatioLiteral struct { @@ -71,12 +72,41 @@ type ( } ) +type AccountNamePart interface{ accountNamePart() } +type AccountTextPart struct{ Name string } + +func (AccountTextPart) accountNamePart() {} +func (*Variable) accountNamePart() {} + func (r RatioLiteral) ToRatio() *big.Rat { return new(big.Rat).SetFrac(r.Numerator, r.Denominator) } -func (a *AccountLiteral) IsWorld() bool { - return a.Name == "world" +func (a AccountInterpLiteral) IsWorld() bool { + if len(a.Parts) != 1 { + return false + } + switch part := a.Parts[0].(type) { + case AccountTextPart: + return part.Name == "world" + + default: + return false + } +} + +func (expr AccountInterpLiteral) String() string { + // TODO we might want to parse this instead of computing it + var parts []string + for _, part := range expr.Parts { + switch part := part.(type) { + case AccountTextPart: + parts = append(parts, part.Name) + case *Variable: + parts = append(parts, "$"+part.Name) + } + } + return strings.Join(parts, ":") } // Source exprs diff --git a/internal/parser/parser.go b/internal/parser/parser.go index ddc8962c..9eafd787 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - parser "github.com/formancehq/numscript/internal/parser/antlr" + "github.com/formancehq/numscript/internal/parser/antlrParser" "github.com/formancehq/numscript/internal/utils" "github.com/antlr4-go/antlr/v4" @@ -49,17 +49,17 @@ func Parse(input string) ParseResult { listener := &ErrorListener{} is := antlr.NewInputStream(input) - lexer := parser.NewNumscriptLexer(is) + lexer := antlrParser.NewLexer(is) lexer.RemoveErrorListeners() lexer.AddErrorListener(listener) stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel) - parser := parser.NewNumscriptParser(stream) - parser.RemoveErrorListeners() - parser.AddErrorListener(listener) + p := antlrParser.NewNumscriptParser(stream) + p.RemoveErrorListeners() + p.AddErrorListener(listener) - parsed := parseProgram(parser.Program()) + parsed := parseProgram(p.Program()) return ParseResult{ Source: input, @@ -76,7 +76,7 @@ func ParseErrorsToString(errors []ParserError, source string) string { return buf } -func parseVarsDeclaration(varsCtx parser.IVarsDeclarationContext) []VarDeclaration { +func parseVarsDeclaration(varsCtx antlrParser.IVarsDeclarationContext) []VarDeclaration { if varsCtx == nil { return nil } @@ -91,7 +91,7 @@ func parseVarsDeclaration(varsCtx parser.IVarsDeclarationContext) []VarDeclarati return vars } -func parseProgram(programCtx parser.IProgramContext) Program { +func parseProgram(programCtx antlrParser.IProgramContext) Program { vars := parseVarsDeclaration(programCtx.VarsDeclaration()) var statements []Statement @@ -105,7 +105,7 @@ func parseProgram(programCtx parser.IProgramContext) Program { } } -func parseVarDeclaration(varDecl parser.IVarDeclarationContext) *VarDeclaration { +func parseVarDeclaration(varDecl antlrParser.IVarDeclarationContext) *VarDeclaration { if varDecl == nil { return nil } @@ -147,7 +147,7 @@ func parseVarType(tk antlr.Token) *TypeDecl { } } -func parseSource(sourceCtx parser.ISourceContext) Source { +func parseSource(sourceCtx antlrParser.ISourceContext) Source { if sourceCtx == nil { return nil } @@ -155,12 +155,12 @@ func parseSource(sourceCtx parser.ISourceContext) Source { range_ := ctxToRange(sourceCtx) switch sourceCtx := sourceCtx.(type) { - case *parser.SrcAccountContext: + case *antlrParser.SrcAccountContext: return &SourceAccount{ ValueExpr: parseValueExpr(sourceCtx.ValueExpr()), } - case *parser.SrcInorderContext: + case *antlrParser.SrcInorderContext: var sources []Source for _, sourceCtx := range sourceCtx.AllSource() { sources = append(sources, parseSource(sourceCtx)) @@ -170,7 +170,7 @@ func parseSource(sourceCtx parser.ISourceContext) Source { Sources: sources, } - case *parser.SrcAllotmentContext: + case *antlrParser.SrcAllotmentContext: var items []SourceAllotmentItem for _, itemCtx := range sourceCtx.AllAllotmentClauseSrc() { item := SourceAllotmentItem{ @@ -185,20 +185,20 @@ func parseSource(sourceCtx parser.ISourceContext) Source { Items: items, } - case *parser.SrcCappedContext: + case *antlrParser.SrcCappedContext: return &SourceCapped{ Range: range_, From: parseSource(sourceCtx.Source()), Cap: parseValueExpr(sourceCtx.GetCap_()), } - case *parser.SrcAccountUnboundedOverdraftContext: + case *antlrParser.SrcAccountUnboundedOverdraftContext: return &SourceOverdraft{ Range: ctxToRange(sourceCtx), Address: parseValueExpr(sourceCtx.GetAddress()), } - case *parser.SrcAccountBoundedOverdraftContext: + case *antlrParser.SrcAccountBoundedOverdraftContext: varMon := parseValueExpr(sourceCtx.GetMaxOvedraft()) return &SourceOverdraft{ @@ -207,7 +207,7 @@ func parseSource(sourceCtx parser.ISourceContext) Source { Bounded: &varMon, } - case *parser.SourceContext: + case *antlrParser.SourceContext: return nil default: @@ -271,20 +271,20 @@ func parsePercentageRatio(source string, range_ Range) *RatioLiteral { } } -func parseAllotment(allotmentCtx parser.IAllotmentContext) AllotmentValue { +func parseAllotment(allotmentCtx antlrParser.IAllotmentContext) AllotmentValue { switch allotmentCtx := allotmentCtx.(type) { - case *parser.PortionedAllotmentContext: + case *antlrParser.PortionedAllotmentContext: return parsePortionSource(allotmentCtx.Portion()) - case *parser.RemainingAllotmentContext: + case *antlrParser.RemainingAllotmentContext: return &RemainingAllotment{ Range: ctxToRange(allotmentCtx), } - case *parser.PortionVariableContext: + case *antlrParser.PortionVariableContext: return variableLiteralFromCtx(allotmentCtx) - case *parser.AllotmentContext: + case *antlrParser.AllotmentContext: return nil default: @@ -292,7 +292,7 @@ func parseAllotment(allotmentCtx parser.IAllotmentContext) AllotmentValue { } } -func parseStringLiteralCtx(stringCtx *parser.StringLiteralContext) *StringLiteral { +func parseStringLiteralCtx(stringCtx *antlrParser.StringLiteralContext) *StringLiteral { rawStr := stringCtx.GetText() // Remove leading and trailing '"' innerStr := rawStr[1 : len(rawStr)-1] @@ -302,37 +302,50 @@ func parseStringLiteralCtx(stringCtx *parser.StringLiteralContext) *StringLitera } } -func parseValueExpr(valueExprCtx parser.IValueExprContext) ValueExpr { +func parseValueExpr(valueExprCtx antlrParser.IValueExprContext) ValueExpr { switch valueExprCtx := valueExprCtx.(type) { - case *parser.AccountLiteralContext: - return &AccountLiteral{ - Range: ctxToRange(valueExprCtx), - // Discard the '@' - Name: valueExprCtx.GetText()[1:], + case *antlrParser.AccountLiteralContext: + litRng := ctxToRange(valueExprCtx) + + var parts []AccountNamePart + for _, accLit := range valueExprCtx.AllAccountLiteralPart() { + varPartText := accLit.GetText() + switch accLit := accLit.(type) { + case *antlrParser.AccountTextPartContext: + parts = append(parts, AccountTextPart{Name: varPartText}) + case *antlrParser.AccountVarPartContext: + v := parseVarLiteral(accLit.VARIABLE_NAME_ACC().GetSymbol()) + parts = append(parts, v) + } + } + + return &AccountInterpLiteral{ + Range: litRng, + Parts: parts, } - case *parser.MonetaryLiteralContext: + case *antlrParser.MonetaryLiteralContext: return parseMonetaryLit(valueExprCtx.MonetaryLit()) - case *parser.AssetLiteralContext: + case *antlrParser.AssetLiteralContext: return &AssetLiteral{ Range: ctxToRange(valueExprCtx), Asset: valueExprCtx.GetText(), } - case *parser.NumberLiteralContext: + case *antlrParser.NumberLiteralContext: return parseNumberLiteral(valueExprCtx.NUMBER()) - case *parser.PortionLiteralContext: + case *antlrParser.PortionLiteralContext: return parsePortionSource(valueExprCtx.Portion()) - case *parser.VariableExprContext: + case *antlrParser.VariableExprContext: return variableLiteralFromCtx(valueExprCtx) - case *parser.StringLiteralContext: + case *antlrParser.StringLiteralContext: return parseStringLiteralCtx(valueExprCtx) - case *parser.InfixExprContext: + case *antlrParser.InfixExprContext: return &BinaryInfix{ Range: ctxToRange(valueExprCtx), Operator: InfixOperator(valueExprCtx.GetOp().GetText()), @@ -340,7 +353,7 @@ func parseValueExpr(valueExprCtx parser.IValueExprContext) ValueExpr { Right: parseValueExpr(valueExprCtx.GetRight()), } - case nil, *parser.ValueExprContext: + case nil, *antlrParser.ValueExprContext: return nil default: @@ -358,15 +371,15 @@ func variableLiteralFromCtx(ctx antlr.ParserRuleContext) *Variable { } } -func parsePortionSource(portionCtx parser.IPortionContext) *RatioLiteral { +func parsePortionSource(portionCtx antlrParser.IPortionContext) *RatioLiteral { switch portionCtx.(type) { - case *parser.RatioContext: + case *antlrParser.RatioContext: return parseRatio(portionCtx.GetText(), ctxToRange(portionCtx)) - case *parser.PercentageContext: + case *antlrParser.PercentageContext: return parsePercentageRatio(portionCtx.GetText(), ctxToRange(portionCtx)) - case *parser.PortionContext: + case *antlrParser.PortionContext: return nil default: @@ -374,7 +387,7 @@ func parsePortionSource(portionCtx parser.IPortionContext) *RatioLiteral { } } -func parseDestination(destCtx parser.IDestinationContext) Destination { +func parseDestination(destCtx antlrParser.IDestinationContext) Destination { if destCtx == nil { return nil } @@ -382,12 +395,12 @@ func parseDestination(destCtx parser.IDestinationContext) Destination { range_ := ctxToRange(destCtx) switch destCtx := destCtx.(type) { - case *parser.DestAccountContext: + case *antlrParser.DestAccountContext: return &DestinationAccount{ ValueExpr: parseValueExpr(destCtx.ValueExpr()), } - case *parser.DestInorderContext: + case *antlrParser.DestInorderContext: var inorderClauses []DestinationInorderClause for _, destInorderClause := range destCtx.AllDestinationInOrderClause() { inorderClauses = append(inorderClauses, parseDestinationInorderClause(destInorderClause)) @@ -399,7 +412,7 @@ func parseDestination(destCtx parser.IDestinationContext) Destination { Remaining: parseKeptOrDestination(destCtx.KeptOrDestination()), } - case *parser.DestAllotmentContext: + case *antlrParser.DestAllotmentContext: var items []DestinationAllotmentItem for _, itemCtx := range destCtx.AllAllotmentClauseDest() { item := DestinationAllotmentItem{ @@ -414,7 +427,7 @@ func parseDestination(destCtx parser.IDestinationContext) Destination { Items: items, } - case *parser.DestinationContext: + case *antlrParser.DestinationContext: return nil default: @@ -423,7 +436,7 @@ func parseDestination(destCtx parser.IDestinationContext) Destination { } -func parseDestinationInorderClause(clauseCtx parser.IDestinationInOrderClauseContext) DestinationInorderClause { +func parseDestinationInorderClause(clauseCtx antlrParser.IDestinationInOrderClauseContext) DestinationInorderClause { return DestinationInorderClause{ Range: ctxToRange(clauseCtx), Cap: parseValueExpr(clauseCtx.ValueExpr()), @@ -431,21 +444,21 @@ func parseDestinationInorderClause(clauseCtx parser.IDestinationInOrderClauseCon } } -func parseKeptOrDestination(clauseCtx parser.IKeptOrDestinationContext) KeptOrDestination { +func parseKeptOrDestination(clauseCtx antlrParser.IKeptOrDestinationContext) KeptOrDestination { if clauseCtx == nil { return nil } switch clauseCtx := clauseCtx.(type) { - case *parser.DestinationToContext: + case *antlrParser.DestinationToContext: return &DestinationTo{ Destination: parseDestination(clauseCtx.Destination()), } - case *parser.DestinationKeptContext: + case *antlrParser.DestinationKeptContext: return &DestinationKept{ Range: ctxToRange(clauseCtx), } - case *parser.KeptOrDestinationContext: + case *antlrParser.KeptOrDestinationContext: return nil default: @@ -454,20 +467,20 @@ func parseKeptOrDestination(clauseCtx parser.IKeptOrDestinationContext) KeptOrDe } -func parseDestinationAllotment(allotmentCtx parser.IAllotmentContext) AllotmentValue { +func parseDestinationAllotment(allotmentCtx antlrParser.IAllotmentContext) AllotmentValue { switch allotmentCtx := allotmentCtx.(type) { - case *parser.RemainingAllotmentContext: + case *antlrParser.RemainingAllotmentContext: return &RemainingAllotment{ Range: ctxToRange(allotmentCtx), } - case *parser.PortionedAllotmentContext: + case *antlrParser.PortionedAllotmentContext: return parseDestinationPortion(allotmentCtx.Portion()) - case *parser.PortionVariableContext: + case *antlrParser.PortionVariableContext: return variableLiteralFromCtx(allotmentCtx) - case *parser.AllotmentContext: + case *antlrParser.AllotmentContext: return nil default: @@ -475,15 +488,15 @@ func parseDestinationAllotment(allotmentCtx parser.IAllotmentContext) AllotmentV } } -func parseDestinationPortion(portionCtx parser.IPortionContext) AllotmentValue { +func parseDestinationPortion(portionCtx antlrParser.IPortionContext) AllotmentValue { switch portionCtx.(type) { - case *parser.RatioContext: + case *antlrParser.RatioContext: return parseRatio(portionCtx.GetText(), ctxToRange(portionCtx)) - case *parser.PercentageContext: + case *antlrParser.PercentageContext: return parsePercentageRatio(portionCtx.GetText(), ctxToRange(portionCtx)) - case *parser.PortionContext: + case *antlrParser.PortionContext: return nil default: @@ -491,7 +504,7 @@ func parseDestinationPortion(portionCtx parser.IPortionContext) AllotmentValue { } } -func parseFnArgs(fnCallArgCtx parser.IFunctionCallArgsContext) []ValueExpr { +func parseFnArgs(fnCallArgCtx antlrParser.IFunctionCallArgsContext) []ValueExpr { if fnCallArgCtx == nil { return nil } @@ -503,7 +516,7 @@ func parseFnArgs(fnCallArgCtx parser.IFunctionCallArgsContext) []ValueExpr { return args } -func parseFnCall(fnCallCtx parser.IFunctionCallContext) *FnCall { +func parseFnCall(fnCallCtx antlrParser.IFunctionCallContext) *FnCall { if fnCallCtx == nil { return nil } @@ -525,7 +538,7 @@ func parseFnCall(fnCallCtx parser.IFunctionCallContext) *FnCall { } } -func parseSaveStatement(saveCtx *parser.SaveStatementContext) *SaveStatement { +func parseSaveStatement(saveCtx *antlrParser.SaveStatementContext) *SaveStatement { return &SaveStatement{ Range: ctxToRange(saveCtx), SentValue: parseSentValue(saveCtx.SentValue()), @@ -533,18 +546,18 @@ func parseSaveStatement(saveCtx *parser.SaveStatementContext) *SaveStatement { } } -func parseStatement(statementCtx parser.IStatementContext) Statement { +func parseStatement(statementCtx antlrParser.IStatementContext) Statement { switch statementCtx := statementCtx.(type) { - case *parser.SendStatementContext: + case *antlrParser.SendStatementContext: return parseSendStatement(statementCtx) - case *parser.SaveStatementContext: + case *antlrParser.SaveStatementContext: return parseSaveStatement(statementCtx) - case *parser.FnCallStatementContext: + case *antlrParser.FnCallStatementContext: return parseFnCall(statementCtx.FunctionCall()) - case *parser.StatementContext: + case *antlrParser.StatementContext: return nil default: @@ -552,20 +565,20 @@ func parseStatement(statementCtx parser.IStatementContext) Statement { } } -func parseSentValue(statementCtx parser.ISentValueContext) SentValue { +func parseSentValue(statementCtx antlrParser.ISentValueContext) SentValue { switch statementCtx := statementCtx.(type) { - case *parser.SentLiteralContext: + case *antlrParser.SentLiteralContext: return &SentValueLiteral{ Range: ctxToRange(statementCtx), Monetary: parseValueExpr(statementCtx.ValueExpr()), } - case *parser.SentAllContext: + case *antlrParser.SentAllContext: return &SentValueAll{ Range: ctxToRange(statementCtx), Asset: parseValueExpr(statementCtx.SentAllLit().GetAsset()), } - case *parser.SentValueContext: + case *antlrParser.SentValueContext: return nil default: @@ -574,7 +587,7 @@ func parseSentValue(statementCtx parser.ISentValueContext) SentValue { } -func parseSendStatement(statementCtx *parser.SendStatementContext) *SendStatement { +func parseSendStatement(statementCtx *antlrParser.SendStatementContext) *SendStatement { return &SendStatement{ Source: parseSource(statementCtx.Source()), Destination: parseDestination(statementCtx.Destination()), @@ -598,7 +611,7 @@ func parseNumberLiteral(numNode antlr.TerminalNode) *NumberLiteral { } } -func parseMonetaryLit(monetaryLitCtx parser.IMonetaryLitContext) *MonetaryLiteral { +func parseMonetaryLit(monetaryLitCtx antlrParser.IMonetaryLitContext) *MonetaryLiteral { if monetaryLitCtx.GetAmt() == nil { return nil } diff --git a/internal/parser/parser_test.go b/internal/parser/parser_test.go index d03f6d62..f2c3547a 100644 --- a/internal/parser/parser_test.go +++ b/internal/parser/parser_test.go @@ -336,3 +336,21 @@ set_tx_meta("k1", 1 + 2 - 3) require.Len(t, p.Errors, 0) snaps.MatchSnapshot(t, p.Value) } + +func TestStringTemplate(t *testing.T) { + p := parser.Parse( + "set_tx_meta(0, 42)", + ) + + require.Len(t, p.Errors, 0) + snaps.MatchSnapshot(t, p.Value) +} + +func TestInterpAccount(t *testing.T) { + p := parser.Parse( + "set_tx_meta(@abc:cde:$id, 42)", + ) + + require.Len(t, p.Errors, 0) + snaps.MatchSnapshot(t, p.Value) +}