15 #include "rubyparser.h"
16 #include "ruby/backward/2/attributes.h"
18 typedef void (*bug_report_func)(
const char *fmt, ...) RUBYPARSER_ATTRIBUTE_FORMAT(1, 2);
25 NODE *buf[FLEX_ARY_LEN];
29 node_buffer_elem_t *head;
30 node_buffer_elem_t *last;
44 RUBY_SYMBOL_EXPORT_BEGIN
46 #ifdef UNIVERSAL_PARSER
47 rb_ast_t *rb_ast_new(
const rb_parser_config_t *config);
51 size_t rb_ast_memsize(
const rb_ast_t*);
53 const char *ruby_node_name(
int node);
54 void rb_node_init(
NODE *n,
enum node_type
type);
56 void rb_ast_update_references(
rb_ast_t*);
58 NODE *rb_ast_newnode(
rb_ast_t*,
enum node_type
type,
size_t size,
size_t alignment);
63 VALUE rb_parser_dump_tree(
const NODE *node,
int comment);
65 const struct kwtable *rb_reserved_word(
const char *,
unsigned int);
68 PRINTF_ARGS(
void rb_parser_printf(
struct parser_params *parser,
const char *fmt, ...), 2, 3);
69 VALUE rb_node_set_type(
NODE *n,
enum node_type t);
71 RUBY_SYMBOL_EXPORT_END
73 #define NODE_LSHIFT (NODE_TYPESHIFT+7)
74 #define NODE_LMASK (((SIGNED_VALUE)1<<(sizeof(VALUE)*CHAR_BIT-NODE_LSHIFT))-1)
76 #define nd_line(n) (int)(((SIGNED_VALUE)(n)->flags)>>NODE_LSHIFT)
77 #define nd_set_line(n,l) \
78 (n)->flags=(((n)->flags&~((VALUE)(-1)<<NODE_LSHIFT))|((VALUE)((l)&NODE_LMASK)<<NODE_LSHIFT))
81 #define NODE_SPECIAL_REQUIRED_KEYWORD ((NODE *)-1)
82 #define NODE_REQUIRED_KEYWORD_P(node) ((node) == NODE_SPECIAL_REQUIRED_KEYWORD)
83 #define NODE_SPECIAL_NO_NAME_REST ((NODE *)-1)
84 #define NODE_NAMED_REST_P(node) ((node) != NODE_SPECIAL_NO_NAME_REST)
85 #define NODE_SPECIAL_EXCESSIVE_COMMA ((ID)1)
86 #define NODE_SPECIAL_NO_REST_KEYWORD ((NODE *)-1)
88 #define nd_code_loc(n) (&RNODE(n)->nd_loc)
89 #define nd_first_column(n) ((int)(RNODE(n)->nd_loc.beg_pos.column))
90 #define nd_set_first_column(n, v) (RNODE(n)->nd_loc.beg_pos.column = (v))
91 #define nd_first_lineno(n) ((int)(RNODE(n)->nd_loc.beg_pos.lineno))
92 #define nd_set_first_lineno(n, v) (RNODE(n)->nd_loc.beg_pos.lineno = (v))
93 #define nd_first_loc(n) (RNODE(n)->nd_loc.beg_pos)
94 #define nd_set_first_loc(n, v) (nd_first_loc(n) = (v))
96 #define nd_last_column(n) ((int)(RNODE(n)->nd_loc.end_pos.column))
97 #define nd_set_last_column(n, v) (RNODE(n)->nd_loc.end_pos.column = (v))
98 #define nd_last_lineno(n) ((int)(RNODE(n)->nd_loc.end_pos.lineno))
99 #define nd_set_last_lineno(n, v) (RNODE(n)->nd_loc.end_pos.lineno = (v))
100 #define nd_last_loc(n) (RNODE(n)->nd_loc.end_pos)
101 #define nd_set_last_loc(n, v) (nd_last_loc(n) = (v))
102 #define nd_node_id(n) (RNODE(n)->node_id)
103 #define nd_set_node_id(n,id) (RNODE(n)->node_id = (id))
106 nd_type_p(
const NODE *n,
enum node_type t)
108 return (
enum node_type)nd_type(n) == t;
VALUE type(ANYARGS)
ANYARGS-ed function type.
uintptr_t VALUE
Type that represents a Ruby object.