本文整理汇总了Python中Analyzer.Analyzer.genBoolean方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.genBoolean方法的具体用法?Python Analyzer.genBoolean怎么用?Python Analyzer.genBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyzer.Analyzer
的用法示例。
在下文中一共展示了Analyzer.genBoolean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Parser
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import genBoolean [as 别名]
#.........这里部分代码省略.........
self.analyzer.genLabel(start_label)
self.booleanExpression()
self.analyzer.incrementLabel()
false_label = self.analyzer.getLabel()
self.analyzer.genBranchFalse(false_label)
self.match('MP_DO')
self.statement()
self.analyzer.genBranch(start_label)
self.analyzer.genLabel(false_label)
else:
self.error("while")
def forStatement(self):
ident_rec = {}
expression_rec = {}
if self.lookahead is 'MP_FOR': # 56 ForStatement -> "for" ControlVariable ":=" InitialValue StepValue FinalValue "do" Statement
self.match('MP_FOR')
ident_rec = self.controlVariable()
self.match('MP_ASSIGN')
expression_rec = self.initialValue()
self.analyzer.genAssign(ident_rec, expression_rec)
step = self.stepValue()
self.analyzer.incrementLabel()
start_label = self.analyzer.getLabel()
self.analyzer.incrementLabel()
false_label = self.analyzer.getLabel()
self.analyzer.genLabel(start_label)
self.finalValue()
self.analyzer.genPushId(ident_rec)
if(step == "to"):
self.analyzer.genBoolean(">=", ident_rec, expression_rec)
self.analyzer.genBranchFalse(false_label)
elif(step == "downto"):
self.analyzer.genBoolean("<=", ident_rec, expression_rec)
self.analyzer.genBranchFalse(false_label)
self.match('MP_DO')
self.statement()
if(step == "to"):
self.analyzer.genPushInt(str(1))
elif(step == "downto"):
self.analyzer.genPushInt(str(-1))
self.analyzer.genPushId(ident_rec)
self.analyzer.output("ADDS")
self.analyzer.genAssign(ident_rec, expression_rec)
self.analyzer.genBranch(start_label)
self.analyzer.genLabel(false_label)
else:
self.error("for")
def controlVariable(self):
identRec = {}
if self.lookahead is 'MP_IDENTIFIER': # 57 ControlVariable -> VariableIdentifier
id = self.variableIdentifier()
identRec = self.analyzer.processId(id)
identRec["lexeme"] = id
return identRec
else:
self.error("identifier")
def initialValue(self):