module Rucc::Parser::While
Private Instance Methods
read_while_stmt()
click to toggle source
@param [Token] tok @return [Node]
# File lib/rucc/parser/while.rb, line 9 def read_while_stmt expect!('(') cond = read_boolean_expr expect!(')') b = @label_gen.next e = @label_gen.next body = nil # declaration for ruby with_jump_labels(b, e) { body = read_stmt } v = [] v.push(Node.ast_dest(b)) v.push(Node.ast_if(cond, body, Node.ast_jump(e))) v.push(Node.ast_jump(b)) v.push(Node.ast_dest(e)) Node.ast_compound_stmt(v) end