本文整理汇总了Python中oodle.G.G.options方法的典型用法代码示例。如果您正苦于以下问题:Python G.options方法的具体用法?Python G.options怎么用?Python G.options使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oodle.G.G
的用法示例。
在下文中一共展示了G.options方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from oodle.G import G [as 别名]
# 或者: from oodle.G.G import options [as 别名]
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())
示例2: printNoError
# 需要导入模块: from oodle.G import G [as 别名]
# 或者: from oodle.G.G import options [as 别名]
def printNoError(self, tok_name, txt=None):
'''Print non-error messages
@tok_name: token name
@txt: custom token text'''
#don't display tokens when -ds option is off
if not G.options().displayTokens():
return
self.printMsg(tok_name, txt)
示例3: buildBinary
# 需要导入模块: from oodle.G import G [as 别名]
# 或者: from oodle.G.G import options [as 别名]
def buildBinary(self, sopt=False):
'''generate the binary using GCC
if -S option is given, the generates a *.s assembly file instead'''
#make new file with .s extension
fn = G.options().getFileList()[-1]
fn = fn[:fn.rfind('.ood')]
asm_fn = fn + '.s'
bin_fn = fn
f = file(asm_fn, 'w')
#write asm to .s file
for l in self.asm_list:
f.write(l)
f.write('\n')
f.write('\t.data\n')
for l in self.asm_data_list:
f.write(l)
f.write('\n')
f.write('\t.text\n')
for l in self.asm_text_list:
f.write(l)
f.write('\n')
f.flush()
f.close()
#do not build the binary if -S is given
if sopt:
return
#compile asm with stdlib.c
proc = subprocess.Popen(['gcc', '-g', '-m32', '-o', bin_fn, 'stdlib.c', asm_fn])
proc.wait()
if proc.stderr:
print '------------------'
print 'GCC Error Output:'
print '------------------'
print proc.stderr
示例4: printFunc
# 需要导入模块: from oodle.G import G [as 别名]
# 或者: from oodle.G.G import options [as 别名]
def printFunc(self, f, node=None):
'''print the name of the node function and its node string
only works if 'printDebug()' is enabled'''
n = (': ' + node.toString().strip()) if node else ''
if G.options().printDebug():
print 'CodeGenx86: ' + f.__name__ + n
示例5: TypeMapBuilder
# 需要导入模块: from oodle.G import G [as 别名]
# 或者: from oodle.G.G import options [as 别名]
if G.errors().hasErrors():
G.errors().printErrors()
return
#Pass 1
#build the TypeMap for all the input
print 'Building Type Map...'
tp_map_builder = TypeMapBuilder()
st_node.apply(tp_map_builder) #invoke TypeMapBuilder traversal
#Pass 2
#perform semantic checks (new code)
print 'Error Checking...'
sem_check = SemanticChecker()
st_node.apply(sem_check) #invoke SemanticChecker traversal
if G.errors().hasErrors():
print str(G.typeMap())
G.errors().printErrors()
return
print 'Compiling...'
code_gen = CodeGenx86()
st_node.apply(code_gen)
code_gen.buildBinary(G.options().generateAssembly())
print 'DONE'
if __name__ == "__main__":
main()