コード例 #1
0
ファイル: Cau4ASTGeneration.py プロジェクト: khangsk/PPL
 def visitOperand(self, ctx: MCParser.OperandContext):
     # if ctx.getChildCount() == 3:
     #     return ctx.exp().accept(self) # generate code for the third right hand side
     # elif ctx.INTLIT():
     #     return IntLit(int(ctx.INTLIT().getText())) # return a IntLit object
     # print(ctx.BOOLIT().getText(), type(ctx.BOOLIT().getText()))
     # if ctx.BOOLIT().getText() == 'true': return True
     # else: return False # return a BoolLit object
     # return BoolLit(ctx.BOOLIT().getText())
     return self.visit(ctx.exp()) if ctx.getChildCount() == 3 else IntLit(
         int(ctx.INTLIT().getText())) if ctx.INTLIT(
         ) else True if ctx.BOOLIT().getText() == 'true' else False
コード例 #2
0
 def visitOperand(self, ctx: MCParser.OperandContext):
     if ctx.getChildCount() == 3:
         return None  # generate code for the third right hand side
     elif ctx.INTLIT():
         return None  # return a IntLit object
     return None  # return a BoolLit object