class LOLCodeFileReader:
    """ Class to parse LOL Code Files """
    
    def __init__(self):
        """ Create the LOL Code Parser """
        self.parser = LOLCodeParser()
        
    def parseFile(self, filename):
        """ Parse the given file """
        inputFile = self.openLOLCodeFile(filename)
        for line in inputFile.readlines():
            self.parser.parse(line)
        self.generateOutputFile()
        
    def generateOutputFile(self):
        """ Generate Output File """
        cCodeLines = self.parser.getCCodeLines()
        outputFile = open("out.c", 'w')
        outputFile.writelines(cCodeLines)
        
    def openLOLCodeFile(self, filename):
        """ Return the opened file """
        return open(filename, 'r')
class LOLCodeTerminal:
    """ Acts as an in-console LOLCode Parser and initerpreter. """
    # I figured this could be a good way for us to start out with our Parsing
    # and what not -- CML
    # Also, LOLCodeTerminal may be a poor name for this
    
    def __init__(self):
        """ Do magic Initialization stuffz """
        self.parser = LOLCodeParser()
        
    def run(self):
        """ Runs the Interactive LOLCode Terminal Session """
        self.running = True
        while self.running:
            self.printLine()
            self.getAndValidateInput()
        
    def printLine(self):
        """ Prints the line header for the Interactive LOLCOde Terminal """
        print ">>>",
    
    def getAndValidateInput(self):
        """ Gets Validates input from the terminal """
        input = self.getInput()
        self.validateInput(input)
    
    def getInput(self):
        """ Waits for input and returns it """
        return raw_input()
    
    def validateInput(self, input):
        """ Validates input from the terminal """
        self.parser.parse(input)
        if input.upper() == "KTHXBYE":
            self.running = False
            
 def __init__(self):
     """ Create the LOL Code Parser """
     self.parser = LOLCodeParser()
 def __init__(self):
     """ Do magic Initialization stuffz """
     self.parser = LOLCodeParser()