Skip to content

Commit

Permalink
[ASDL cleanup] Remove unnecessary Obj type
Browse files Browse the repository at this point in the history
Add comments.
  • Loading branch information
Andy C committed Jan 14, 2025
1 parent 69df0b2 commit 30ee4f3
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions asdl/pybase.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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):
Expand All @@ -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

Expand Down

0 comments on commit 30ee4f3

Please sign in to comment.