Switch to "new-style" classes, because come on.

Ophis was originally written for Python 2.1, and it kind of shows.
Python 2.3 introduced booleans and optparse, so there's no reason
to not use new-style classes.
This commit is contained in:
Michael C. Martin 2012-06-01 00:24:51 -07:00
parent 1bbb2f1f1b
commit d955fe00a1
4 changed files with 7 additions and 7 deletions

View File

@ -9,7 +9,7 @@
import Ophis.Errors as Err
class Environment:
class Environment(object):
"""Environment class.
Controls the various scopes and global abstract execution variables."""
def __init__(self):

View File

@ -13,7 +13,7 @@ import os
# You may use, modify, and distribute this file under the MIT
# license: See README for details.
class Lexeme:
class Lexeme(object):
"Class for lexer tokens. Used by lexer and parser."
def __init__(self, type="UNKNOWN", value=None):
self.type = type.upper()
@ -137,7 +137,7 @@ def lex(point, line):
add_EOL()
return result
class ParseLine:
class ParseLine(object):
"Maintains the parse state of a line of code. Enables arbitrary lookahead."
def __init__(self, lexemes):
self.lexemes = lexemes

View File

@ -9,7 +9,7 @@
import Ophis.Errors as Err
class Node:
class Node(object):
"""The default IR Node
Instances of Node always have the three fields ppt(Program Point),
nodetype(a string), and data (a list)."""
@ -38,7 +38,7 @@ NullNode = Node("<none>", "None")
def SequenceNode(ppt, nodelist):
return Node(ppt, "SEQUENCE", *nodelist)
class Expr:
class Expr(object):
"""Base class for Ophis expressions
All expressions have a field called "data" and a boolean field
called "hardcoded". An expression is hardcoded if it has no

View File

@ -20,7 +20,7 @@ import Ophis.Macro as Macro
# The passes themselves
class Pass:
class Pass(object):
"""Superclass for all assembler passes. Automatically handles IR
types that modify the environent's structure, and by default
raises an error on anything else. Override visitUnknown in your
@ -67,7 +67,7 @@ class Pass:
print>>sys.stderr, "Current IR:"
print>>sys.stderr, node
class FixPoint:
class FixPoint(object):
"""A specialized class that is not a pass but can be run like one.
This class takes a list of passes and a "fixpoint" function."""
def __init__(self, name, passes, fixpoint):