🐐 Better array definition
This commit is contained in:
+11
-5
@@ -297,13 +297,10 @@ class Parser():
|
||||
else:
|
||||
return [calls[0]] + calls[2]
|
||||
|
||||
@self.pg.production('array_items : ')
|
||||
@self.pg.production('array_items : expression')
|
||||
@self.pg.production('array_items : expression SYMBOL_COMMA opt_newline array_items')
|
||||
def array_items(calls):
|
||||
if len(calls) == 0:
|
||||
return []
|
||||
elif len(calls) == 1:
|
||||
if len(calls) == 1:
|
||||
return [calls[0]]
|
||||
else:
|
||||
return [calls[0]] + calls[3]
|
||||
@@ -391,10 +388,19 @@ class Parser():
|
||||
def dict_literal(tokens):
|
||||
return ast_nodes.DataDict(tokens[3])
|
||||
|
||||
@self.pg.production('expression : SYMBOL_LBRACKET array_items SYMBOL_RBRACKET')
|
||||
@self.pg.production('expression : SYMBOL_LBRACKET SYMBOL_RBRACKET')
|
||||
@self.pg.production('expression : SYMBOL_LBRACKET newlines SYMBOL_RBRACKET')
|
||||
def array_empty(_):
|
||||
return ast_nodes.DataArray([])
|
||||
|
||||
@self.pg.production('expression : SYMBOL_LBRACKET array_items opt_newline SYMBOL_RBRACKET')
|
||||
def array(tokens):
|
||||
return ast_nodes.DataArray(tokens[1])
|
||||
|
||||
@self.pg.production('expression : SYMBOL_LBRACKET newlines array_items opt_newline SYMBOL_RBRACKET')
|
||||
def array_leading_newline(tokens):
|
||||
return ast_nodes.DataArray(tokens[2])
|
||||
|
||||
@self.pg.production('expression : SYMBOL_LBRACKET expression KEYWORD_VSQVE expression SYMBOL_RBRACKET')
|
||||
def range_array(tokens):
|
||||
return ast_nodes.DataRangeArray(tokens[1], tokens[3])
|
||||
|
||||
Reference in New Issue
Block a user