Add support for dot accessors to be numbers
This is an interesting special case in the old parser where numbers are allowed as dot accessors, but they are specifically convertred to being an item accessor during the parsing phase. We now support numbers being parsed for dot accessors in the new parser.
This commit is contained in:
parent
1907179e06
commit
639e8d2dff
@ -233,7 +233,7 @@ variable_accessor_call
|
||||
variable_accessor_dot
|
||||
=
|
||||
accessor_type:`dot`
|
||||
"." parameter:IDENTIFIER
|
||||
"." parameter:( IDENTIFIER | NUMBER_LITERAL )
|
||||
;
|
||||
|
||||
variable_accessor_call_parameters
|
||||
|
||||
@ -801,8 +801,12 @@ def parse_variable_accessor(node, ast):
|
||||
accessor_node = nodes.Getitem()
|
||||
accessor_node.arg = parse_variable(ast['parameter'])
|
||||
elif accessor_type == 'dot':
|
||||
accessor_node = nodes.Getattr()
|
||||
accessor_node.attr = ast['parameter']
|
||||
if isinstance(ast['parameter'], str):
|
||||
accessor_node = nodes.Getattr()
|
||||
accessor_node.attr = ast['parameter']
|
||||
else:
|
||||
accessor_node = nodes.Getitem()
|
||||
accessor_node.arg = parse_literal(ast['parameter'])
|
||||
elif accessor_type == 'call':
|
||||
accessor_node = parse_variable_accessor_call(ast)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user