コード例 #1
0
 def get_if(self):
     tok = self.lex.get_next_token()
     self.match(tok, TokenType.IF_KW_TOK)
     bool = self.get_boolean_expression()
     block1 = self.get_block()
     tok = self.lex.get_next_token()
     self.match(tok, TokenType.ELSE_KW_TOK)
     block2 = self.get_block()
     tok = self.lex.get_next_token()
     self.match(tok, TokenType.END_KW_TOK)
     return Statement.IfStatement(bool, block1, block2)
コード例 #2
0
 def Stmt(self, p):
     if len(p) == 7:
         return Statement.IfStatement(p[2], p[4], p[6])
     return Statement.IfStatement(p[2], p[4])