Example #1
2
def main(argv, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr):

    errors = 0

    if len(argv) > 1:

        for arg in argv[1:]:
            lexer = PorkLexer(ANTLRInputStream(open(arg)))
            parser = Pork(CommonTokenStream(lexer))
            parser.porkfile()
            errors += parser._state.syntaxErrors

            if not errors:
                if True:
                    for clazz in classDefs.values():
                        fileName = arg[arg.rfind('/') + 1:]
                        print 'setting file name to ' + fileName
                        clazz.setSourceFile(fileName)
                
                writeClasses()
                classDefs.clear()

    else:

        lexer = PorkLexer(ANTLRInputStream(stdin))
        parser = Pork(CommonTokenStream(lexer))
        parser.porkfile()
        errors = parser._state.syntaxErrors
    

        if not errors:
            writeClasses()
                    
    return errors
Example #2
1
    def setUp(self):

        # this is crap a sign that bug #31 is on the money
        classDefs.clear()

        lexer = PorkLexer(ANTLRInputStream(open(SOURCE_FILE)))
        parser = Pork(CommonTokenStream(lexer))
        parser.porkfile()

        self.clazz = classDefs["org.joellercoaster.pork.LineNumbers"]
        self.clazz.setSourceFile(SOURCE_FILE)