static VALUE Bool_parse(VALUE klass, VALUE r_expr) { Node* ast; char* expr; if(NIL_P(klass)) { rb_raise(rb_eRuntimeError, "Bool klass was nil"); } // TODO: Verify that r_expr is a String expr = RSTRING_PTR(r_expr); ast = parse_ast(expr); if(ast != NULL) { VALUE result = transform(ast); free_ast(ast); return result; } else { rb_raise(rb_eParseError, "%s", last_error_msg); } }
AST *ParserContext::parse_block() { AST *ret = 0; if (curtok()->type() == tok_block_start) { eat_token(tok_block_start); if (curtok()->type() == tok_block_end) { ret = new AST(std::vector<const Statement*>()); } else { ret = parse_ast(true); } eat_token(tok_block_end); } else { std::vector<const Statement*> statements; statements.push_back(parse_statement()); ret = new AST(statements); } return ret; }