Commit 481ae50c authored by Benjamin Peterson's avatar Benjamin Peterson

construct fields in the right order (closes #15517)

Patch from Taihyun Hwang.
parent 0efcf99c
...@@ -476,6 +476,7 @@ Michael Hudson ...@@ -476,6 +476,7 @@ Michael Hudson
Jim Hugunin Jim Hugunin
Greg Humphreys Greg Humphreys
Eric Huss Eric Huss
Taihyun Hwang
Jeremy Hylton Jeremy Hylton
Gerhard Häring Gerhard Häring
Fredrik Håård Fredrik Håård
...@@ -1174,4 +1175,3 @@ Uwe Zessin ...@@ -1174,4 +1175,3 @@ Uwe Zessin
Kai Zhu Kai Zhu
Tarek Ziadé Tarek Ziadé
Peter Åstrand Peter Åstrand
...@@ -156,15 +156,11 @@ class ASDLParser(spark.GenericParser, object): ...@@ -156,15 +156,11 @@ class ASDLParser(spark.GenericParser, object):
if id.value != "attributes": if id.value != "attributes":
raise ASDLSyntaxError(id.lineno, raise ASDLSyntaxError(id.lineno,
msg="expected attributes, found %s" % id) msg="expected attributes, found %s" % id)
if attributes:
attributes.reverse()
return Sum(sum, attributes) return Sum(sum, attributes)
def p_product(self, info): def p_product(self, info):
" product ::= ( fields ) " " product ::= ( fields ) "
_0, fields, _1 = info _0, fields, _1 = info
# XXX can't I just construct things in the right order?
fields.reverse()
return Product(fields) return Product(fields)
def p_sum_0(self, constructor): def p_sum_0(self, constructor):
...@@ -188,8 +184,6 @@ class ASDLParser(spark.GenericParser, object): ...@@ -188,8 +184,6 @@ class ASDLParser(spark.GenericParser, object):
def p_constructor_1(self, info): def p_constructor_1(self, info):
" constructor ::= Id ( fields ) " " constructor ::= Id ( fields ) "
id, _0, fields, _1 = info id, _0, fields, _1 = info
# XXX can't I just construct things in the right order?
fields.reverse()
return Constructor(id, fields) return Constructor(id, fields)
def p_fields_0(self, field): def p_fields_0(self, field):
...@@ -197,8 +191,8 @@ class ASDLParser(spark.GenericParser, object): ...@@ -197,8 +191,8 @@ class ASDLParser(spark.GenericParser, object):
return [field[0]] return [field[0]]
def p_fields_1(self, info): def p_fields_1(self, info):
" fields ::= field , fields " " fields ::= fields , field "
field, _, fields = info fields, _, field = info
return fields + [field] return fields + [field]
def p_field_0(self, type_): def p_field_0(self, type_):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment