Exemplo n.º 1
0
 def visitIf_stmt(self, ctx: BKITParser.ProgramContext):
     list_stmt = ctx.list_statement().accept(self)
     ifthen_stmt = [(ctx.exp().accept(self), list_stmt[0], list_stmt[1])]
     else_if_stmt = list(map(lambda x: x.accept(self), ctx.else_if_stmt()))
     else_stmt = ([], [])
     if (ctx.else_stmt()):
         else_stmt = ctx.else_stmt().accept(self)
     return If(ifthen_stmt + else_if_stmt, else_stmt)
Exemplo n.º 2
0
 def visitDo_while_stmt(self, ctx: BKITParser.ProgramContext):
     list_stmt = ctx.list_statement().accept(self)
     return Dowhile(list_stmt, ctx.exp().accept(self))
Exemplo n.º 3
0
 def visitWhile_stmt(self, ctx: BKITParser.ProgramContext):
     list_stmt = ctx.list_statement().accept(self)
     return While(ctx.exp().accept(self), list_stmt)
Exemplo n.º 4
0
 def visitFor_stmt(self, ctx: BKITParser.ProgramContext):
     id = Id(ctx.ID().getText())
     # [exp1,exp2,exp3]
     exp_list = list(map(lambda x: x.accept(self), ctx.exp()))
     list_stmt = ctx.list_statement().accept(self)
     return For(id,  exp_list[0], exp_list[1], exp_list[2], list_stmt)
Exemplo n.º 5
0
 def visitElse_if_stmt(self, ctx: BKITParser.ProgramContext):
     list_stmt = ctx.list_statement().accept(self)
     return (ctx.exp().accept(self), list_stmt[0], list_stmt[1])
Exemplo n.º 6
0
 def visitElse_stmt(self, ctx: BKITParser.ProgramContext):
     return ctx.list_statement().accept(self)