diff --git a/asdl/pybase.py b/asdl/pybase.py index e323bc2cd..d6a3bcfa7 100644 --- a/asdl/pybase.py +++ b/asdl/pybase.py @@ -1,5 +1,5 @@ #!/usr/bin/env python2 -"""pybase.py.""" +"""asdl/pybase.py is a runtime library for ASDL in Python""" from __future__ import print_function from mycpp import mylib @@ -10,21 +10,16 @@ from asdl.runtime import TraversalState -class Obj(object): - # NOTE: We're using CAPS for these static fields, since they are constant at - # runtime after metaprogramming. - ASDL_TYPE = None # Used for type checking - - class SimpleObj(int): - """Base type of simple sum types.""" - # TODO: Get rid of this indirection? Although mycpp might use it. + """Base type of simple sum types, which are integers.""" + # TODO: Get rid of this class? mycpp uses it to tell if it should generate + # h8_id or h8_id*. pass -class CompoundObj(Obj): - # The tag is set for variant types, which are subclasses of sum - # types. Never set for product types. +class CompoundObj(object): + # The tag is set for variant types, which are subclasses of sum types. + # It's not set for product types. _type_tag = 0 # Starts at 1. Zero is invalid def PrettyTree(self, do_abbrev, trav=None): @@ -33,6 +28,8 @@ def PrettyTree(self, do_abbrev, trav=None): def __repr__(self): # type: () -> str + """Print this ASDL object nicely.""" + # TODO: Break this circular dependency. from asdl import format as fmt