From 57c2fea1cc38c851b4da33e27667c09c4095a1af Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 17 Oct 2024 18:06:48 +0200 Subject: [PATCH] Merge #77 --- .golangci.yml | 2 +- expressions/expressions.y | 2 +- expressions/scanner.go | 32 ++++++++++----------- expressions/statements_test.go | 4 +++ expressions/y.go | 51 +++++++++++++++++----------------- 5 files changed, 47 insertions(+), 44 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 5176bad..1b454d7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,7 +6,7 @@ issues: # go generate introduces these - path: expressions/scanner.go - linters: [deadcode, unused, varcheck, revive, stylecheck, gocritic, unconvert] + linters: [deadcode, unused, varcheck, revive, stylecheck, gocritic, unconvert, gofumpt] linters: enable-all: true disable: diff --git a/expressions/expressions.y b/expressions/expressions.y index 501ace9..3ca03b8 100644 --- a/expressions/expressions.y +++ b/expressions/expressions.y @@ -43,7 +43,7 @@ func init() { %% start: cond ';' { yylex.(*lexer).val = $1 } -| ASSIGN IDENTIFIER '=' filtered ';' { +| ASSIGN IDENTIFIER '=' cond ';' { yylex.(*lexer).Assignment = Assignment{$2, &expression{$4}} } | CYCLE cycle ';' { yylex.(*lexer).Cycle = $2 } diff --git a/expressions/scanner.go b/expressions/scanner.go index 28bc705..774a168 100644 --- a/expressions/scanner.go +++ b/expressions/scanner.go @@ -4,7 +4,7 @@ package expressions import "strconv" //line scanner.go:9 -var _expression_actions = []byte{ +var _expression_actions []byte = []byte{ 0, 1, 0, 1, 1, 1, 2, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, @@ -16,7 +16,7 @@ var _expression_actions = []byte{ 7, 2, 2, 8, 2, 2, 9, } -var _expression_key_offsets = []int16{ +var _expression_key_offsets []int16 = []int16{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, @@ -27,7 +27,7 @@ var _expression_key_offsets = []int16{ 283, 294, 305, } -var _expression_trans_keys = []byte{ +var _expression_trans_keys []byte = []byte{ 34, 115, 115, 105, 103, 110, 32, 111, 111, 112, 32, 39, 48, 57, 99, 119, 121, 99, 108, 101, 32, 104, 101, 110, @@ -69,7 +69,7 @@ var _expression_trans_keys = []byte{ 122, 37, } -var _expression_single_lengths = []byte{ +var _expression_single_lengths []byte = []byte{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19, @@ -80,7 +80,7 @@ var _expression_single_lengths = []byte{ 5, 5, 1, } -var _expression_range_lengths = []byte{ +var _expression_range_lengths []byte = []byte{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, @@ -91,7 +91,7 @@ var _expression_range_lengths = []byte{ 3, 3, 0, } -var _expression_index_offsets = []int16{ +var _expression_index_offsets []int16 = []int16{ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, @@ -102,7 +102,7 @@ var _expression_index_offsets = []int16{ 271, 280, 289, } -var _expression_indicies = []byte{ +var _expression_indicies []byte = []byte{ 2, 1, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 2, 13, @@ -142,7 +142,7 @@ var _expression_indicies = []byte{ 66, 85, 49, } -var _expression_trans_targs = []byte{ +var _expression_trans_targs []byte = []byte{ 23, 0, 23, 2, 3, 4, 5, 6, 23, 8, 9, 10, 23, 11, 23, 31, 14, 19, 15, 16, 17, 18, 23, 20, @@ -156,7 +156,7 @@ var _expression_trans_targs = []byte{ 37, 54, 37, 37, 57, 13, } -var _expression_trans_actions = []byte{ +var _expression_trans_actions []byte = []byte{ 47, 0, 15, 0, 0, 0, 0, 0, 7, 0, 0, 0, 11, 0, 45, 0, 0, 0, 0, 0, 0, 0, 9, 0, @@ -170,7 +170,7 @@ var _expression_trans_actions = []byte{ 66, 0, 54, 60, 0, 0, } -var _expression_to_state_actions = []byte{ +var _expression_to_state_actions []byte = []byte{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, @@ -181,7 +181,7 @@ var _expression_to_state_actions = []byte{ 0, 0, 0, } -var _expression_from_state_actions = []byte{ +var _expression_from_state_actions []byte = []byte{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, @@ -192,7 +192,7 @@ var _expression_from_state_actions = []byte{ 0, 0, 0, } -var _expression_eof_trans = []int16{ +var _expression_eof_trans []int16 = []int16{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, @@ -203,11 +203,9 @@ var _expression_eof_trans = []int16{ 67, 67, 50, } -const ( - expression_start int = 23 - expression_first_final int = 23 - expression_error int = -1 -) +const expression_start int = 23 +const expression_first_final int = 23 +const expression_error int = -1 const expression_en_main int = 23 diff --git a/expressions/statements_test.go b/expressions/statements_test.go index cdd74c8..195d2d4 100644 --- a/expressions/statements_test.go +++ b/expressions/statements_test.go @@ -12,6 +12,10 @@ func TestParseStatement(t *testing.T) { require.Equal(t, "a", stmt.Assignment.Variable) require.Implements(t, (*Expression)(nil), stmt.Assignment.ValueFn) + stmt, err = ParseStatement(AssignStatementSelector, "a = 1 == 1") + require.NoError(t, err) + require.Equal(t, "a", stmt.Assignment.Variable) + stmt, err = ParseStatement(CycleStatementSelector, "'a', 'b'") require.NoError(t, err) require.Equal(t, "", stmt.Cycle.Group) diff --git a/expressions/y.go b/expressions/y.go index 5d2c2ee..14dc9ed 100644 --- a/expressions/y.go +++ b/expressions/y.go @@ -101,37 +101,38 @@ var yyExca = [...]int8{ const yyPrivate = 57344 -const yyLast = 106 +const yyLast = 117 var yyAct = [...]int8{ - 9, 47, 42, 18, 8, 14, 15, 23, 10, 11, - 10, 11, 76, 34, 3, 4, 5, 6, 25, 25, - 60, 41, 43, 43, 38, 46, 44, 51, 52, 53, - 54, 55, 56, 57, 58, 12, 25, 12, 39, 62, - 26, 26, 24, 61, 77, 63, 62, 64, 45, 66, - 65, 68, 24, 14, 15, 71, 7, 25, 26, 69, - 70, 13, 27, 28, 31, 32, 72, 73, 75, 33, - 59, 36, 37, 30, 29, 25, 25, 80, 2, 26, - 81, 27, 28, 31, 32, 78, 79, 21, 33, 49, - 50, 35, 30, 29, 16, 19, 48, 26, 26, 1, - 74, 20, 40, 17, 22, 67, + 9, 47, 42, 18, 8, 2, 76, 23, 14, 15, + 10, 11, 43, 34, 3, 4, 5, 6, 35, 25, + 38, 10, 11, 60, 41, 43, 46, 51, 52, 53, + 54, 55, 56, 57, 58, 25, 25, 12, 44, 39, + 25, 26, 69, 24, 61, 62, 65, 63, 12, 66, + 64, 68, 45, 21, 7, 16, 48, 26, 26, 19, + 70, 77, 26, 14, 15, 72, 73, 1, 75, 36, + 37, 71, 78, 79, 74, 20, 25, 80, 14, 15, + 81, 27, 28, 31, 32, 40, 13, 17, 33, 59, + 49, 50, 30, 29, 25, 22, 67, 0, 26, 27, + 28, 31, 32, 0, 0, 0, 33, 0, 0, 0, + 30, 29, 0, 0, 0, 0, 26, } var yyPact = [...]int16{ - 6, -1000, 36, 89, 91, 82, 4, -1000, 20, 69, - -1000, -1000, 4, -1000, 4, 4, -2, 13, -6, -1000, - 1, 32, 0, 68, 84, -1000, 4, 4, 4, 4, - 4, 4, 4, 4, 50, -12, -1000, -1000, 4, -1000, - -1000, 91, -1000, 91, -1000, 4, -1000, -1000, 4, -1000, - 4, 29, 11, 11, 11, 11, 11, 11, 11, 4, - -1000, 30, 11, -5, -5, 20, 68, -16, 11, -1000, - 12, -1000, -1000, -1000, 80, -1000, 4, -1000, -1000, 4, - 11, 11, + 6, -1000, 61, 50, 55, 48, 17, -1000, 21, 87, + -1000, -1000, 17, -1000, 17, 17, -6, 14, -3, -1000, + 13, 36, 1, 28, 85, -1000, 17, 17, 17, 17, + 17, 17, 17, 17, 69, -9, -1000, -1000, 17, -1000, + -1000, 55, -1000, 55, -1000, 17, -1000, -1000, 17, -1000, + 17, 12, 33, 33, 33, 33, 33, 33, 33, 17, + -1000, 46, -16, -16, 21, 33, 28, -22, 33, -1000, + 29, -1000, -1000, -1000, 67, -1000, 17, -1000, -1000, 17, + 33, 33, } var yyPgo = [...]int8{ - 0, 0, 56, 4, 78, 105, 104, 1, 103, 102, - 2, 101, 100, 3, 99, + 0, 0, 54, 4, 5, 96, 95, 1, 87, 85, + 2, 75, 74, 3, 67, } var yyR1 = [...]int8{ @@ -157,7 +158,7 @@ var yyChk = [...]int16{ 23, 14, 15, 19, -1, -4, -2, -2, 26, 25, -9, 27, -10, 28, 25, 16, 25, -7, 28, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, 20, - 32, -3, -1, -13, -13, -3, -1, -5, -1, 30, + 32, -4, -13, -13, -3, -1, -1, -5, -1, 30, -1, 25, -10, -10, -12, -7, 28, 32, 5, 6, -1, -1, } @@ -169,7 +170,7 @@ var yyDef = [...]int8{ 0, 0, 0, 0, 25, 0, 39, 40, 0, 3, 6, 0, 8, 0, 4, 0, 5, 11, 0, 26, 0, 0, 31, 32, 33, 34, 35, 36, 37, 0, - 24, 0, 25, 9, 9, 16, 12, 27, 28, 22, + 24, 0, 9, 9, 16, 25, 12, 27, 28, 22, 0, 2, 7, 10, 15, 13, 0, 23, 17, 0, 29, 18, }