From a559125a2d7af771784614b7a2092cc7fb707345 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Wed, 26 Jun 2024 22:45:16 +0100 Subject: array literals --- g.peg | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'g.peg') diff --git a/g.peg b/g.peg index dccf361..056ca7a 100644 --- a/g.peg +++ b/g.peg @@ -29,12 +29,18 @@ expr <- / n:number { $$ = n; } / i:ident { $$ = i; } / t:string { $$ = t; } + / a:array { $$ = a; } list <- { $$ = astnode_new_list(); } '(' ( e:expr { astnode_append(&$$, e); } )* ')' _ +array <- { $$ = astnode_new_arr(); } + '[' + ( e:expr { astnode_append(&$$, e); } + )* + ']' _ number <- < [0-9]+ > (! ident_char) _ { $$ = astnode_new_num(atoi($1)); } ident <- < ident_char+ > _ { $$ = astnode_new_ident($1); } -- cgit v1.2.3