Skip to content

Commit 69bf85a

Browse files
committed
allow empty array
Signed-off-by: yaacov <[email protected]>
1 parent cb1c179 commit 69bf85a

File tree

4 files changed

+167
-135
lines changed

4 files changed

+167
-135
lines changed

v6/pkg/parser/tsl_parser.y

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ char *error_string = NULL;
6161
/* Nonterminal types */
6262
%type <node> input expr or_expr and_expr comparison_expr
6363
%type <node> additive_expr multiplicative_expr not_expr unary_expr
64-
%type <node> primary array_elements array
64+
%type <node> primary array_elements array opt_array_elements
6565

6666
%start input
6767

@@ -161,8 +161,13 @@ unary_expr:
161161
;
162162

163163
array:
164-
LPAREN array_elements RPAREN { $$ = $2; }
165-
| LBRACKET array_elements RBRACKET { $$ = $2; }
164+
LPAREN opt_array_elements RPAREN { $$ = $2; }
165+
| LBRACKET opt_array_elements RBRACKET { $$ = $2; }
166+
;
167+
168+
opt_array_elements:
169+
/* empty */ { $$ = ast_create_array(0, NULL); } /* Empty array */
170+
| array_elements { $$ = $1; }
166171
;
167172

168173
array_elements:
@@ -183,6 +188,7 @@ array_elements:
183188
free(elements);
184189
ast_free($1);
185190
}
191+
| array_elements COMMA { $$ = $1; } /* Trailing comma */
186192
;
187193

188194
primary:

0 commit comments

Comments
 (0)