Beispiel #1
0
def main():
	if len(sys.argv) < 2:
		print "usage:"
		print "  java Oodle filename"
		return

	#HACK - add readint() and writeint() declarations
	G.typeMap().addExtern(ExternDecl('readint', 'int'))
	G.typeMap().addExtern(ExternDecl('writeint')).addParam(LocalVarDecl('i', 'int'))

	G.options().parseArgs(sys.argv[1:])

	flist = G.fileConcat ()
	for f in G.options().getFileList():
		flist.appendFile(f)

	st_node = None
	print 'Lexing...'
	lex = Lexer(flist.getConcatFile().getAbsolutePath())
	print 'Parsing...'
	par = Parser(lex)
	try:
		st_node = par.parse()
	except ParserException, e:
		G.errors().syntax().add(e.getMessage())
Beispiel #2
0
def main():
    if len(sys.argv) < 2:
        print "usage:"
        print "  java Oodle filename"
        return

    #HACK - add readint() and writeint() declarations
    G.typeMap().addExtern(ExternDecl('readint', 'int'))
    G.typeMap().addExtern(ExternDecl('writeint')).addParam(
        LocalVarDecl('i', 'int'))

    G.options().parseArgs(sys.argv[1:])

    flist = G.fileConcat()
    for f in G.options().getFileList():
        flist.appendFile(f)

    st_node = None
    print 'Lexing...'
    lex = Lexer(flist.getConcatFile().getAbsolutePath())
    print 'Parsing...'
    par = Parser(lex)
    try:
        st_node = par.parse()
    except ParserException, e:
        G.errors().syntax().add(e.getMessage())
Beispiel #3
0
	def printMsg(self, tok_name, txt=None):
		'''Do the actual making and printing of the message
		   @tok_name: token name
		   @txt: token text
		   @RETURN: the message'''
		tk = self.peek() #Token
		txt = ':' + tk.getText() if txt == None else "" 
		msg = G.fileConcat().correctNameAndNumber(tk.getLine()) + ',' + str(tk.getPos()) + ':' + tok_name + txt
		print msg
		return msg