当前位置: 首页>>代码示例>>Python>>正文


Python Parser.output方法代码示例

本文整理汇总了Python中Parser.Parser.output方法的典型用法代码示例。如果您正苦于以下问题:Python Parser.output方法的具体用法?Python Parser.output怎么用?Python Parser.output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parser.Parser的用法示例。


在下文中一共展示了Parser.output方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Parser

# 需要导入模块: from Parser import Parser [as 别名]
# 或者: from Parser.Parser import output [as 别名]
#Author: Josh Wretlind
#Python Assignment #3
#Class: CSCI 410 - Elements of Computing Systems
#Written in: Python 2.7

import sys,string,os
from Parser import Parser

infile = sys.argv[1] # Sys.argv is the system argument list object
outfile = sys.argv[2]

parse = Parser(infile)
outfilecontents = ""
while parse.hasMoreCommands():
    parse.advance()
    outfilecontents += parse.output()
    
output = open(outfile, 'w')
output.write(outfilecontents)

parse.stats()
开发者ID:joshWretlind,项目名称:CSCI410-ElementsOfComputingSystems,代码行数:23,代码来源:jacklex.py

示例2: Parser

# 需要导入模块: from Parser import Parser [as 别名]
# 或者: from Parser.Parser import output [as 别名]
from Code import Code
from Symbol import Symbol


infile = sys.argv[1]  # Sys.argv is the system argument list object

outfile = infile.replace(".asm", ".hack")
parse = Parser(infile)
outfilecontents = ""
code = Code()
sym = Symbol()
i = 0
numOfNonLabelSymbols = 0
while parse.hasMoreCommands():
    parse.advance()
    parse.output()
    parse.stripwhitespace()
    if len(parse.parsedline) != 0 and parse.parsedline != "\n" and parse.commandType() == 2:
        if not sym.contains(parse.symbol()):
            sym.addEntry(parse.symbol(), str(i))
    if len(parse.parsedline) != 0 and parse.parsedline != "\n" and parse.commandType() != 2:
        i += 1

parse = Parser(infile)
while parse.hasMoreCommands():
    parse.advance()
    parse.output()
    parse.stripwhitespace()
    if (
        len(parse.parsedline) != 0
        and parse.parsedline != "\n"
开发者ID:joshWretlind,项目名称:CSCI410-ElementsOfComputingSystems,代码行数:33,代码来源:Assembler.py


注:本文中的Parser.Parser.output方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。