diff --git a/analyzers/test/test.y b/analyzers/test/test.y index 9b851b9..c36c4cf 100644 --- a/analyzers/test/test.y +++ b/analyzers/test/test.y @@ -301,6 +301,7 @@ func_types: type: int_types { } + | slice_types | arr_types { } | struct_types { } | func_types { } @@ -316,6 +317,7 @@ type: // literals literal: STRING_LITERAL { } + | slice_literal | arr_literal { } | struct_literal { } | func_literal { } @@ -371,6 +373,13 @@ arr_types: arr_element: IDENTIFIER LBRACK NUMBER RBRACK +// slices +slice_literal: + LBRACK RBRACK type LBRACE math_expr_or_literals_list_or_empty RBRACE + +slice_types: + LBRACK RBRACK type + // functions func_literal: diff --git a/tests/test_arrays.txt b/tests/test_arrays.txt index 092070b..0605801 100644 --- a/tests/test_arrays.txt +++ b/tests/test_arrays.txt @@ -19,4 +19,13 @@ func main() { arr[1] = [4]int{3, 2, 5, 4}; arr[1] = "test"; + // СЛАЙСЫ + var slice1 []int; + var slice2 = []int{}; + slice6 := []int{}; + slice7 := []int{1, 2, 3}; + slice7[2] = 123; + + slice8, slice8 = []int{1,2,3,4}, []int{1,2,3,4}; + } \ No newline at end of file