1#ifndef RUBY_RUBYPARSER_H
2#define RUBY_RUBYPARSER_H 1
10#ifdef UNIVERSAL_PARSER
12#define rb_encoding void
13#define OnigCodePoint unsigned int
16#include "parser_value.h"
141#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
143#elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
144# define FLEX_ARY_LEN 0
146# define FLEX_ARY_LEN 1
152 ID ids[FLEX_ARY_LEN];
176 struct RNode *nd_body;
183 struct RNode *nd_head;
184 struct RNode *nd_end;
185 struct RNode *nd_next;
191 struct RNode *nd_cond;
192 struct RNode *nd_body;
193 struct RNode *nd_else;
199 struct RNode *nd_cond;
200 struct RNode *nd_body;
201 struct RNode *nd_else;
207 struct RNode *nd_head;
208 struct RNode *nd_body;
214 struct RNode *nd_head;
215 struct RNode *nd_body;
221 struct RNode *nd_head;
222 struct RNode *nd_body;
228 struct RNode *nd_head;
229 struct RNode *nd_body;
230 struct RNode *nd_next;
236 struct RNode *nd_head;
237 struct RNode *nd_body;
238 struct RNode *nd_next;
245 struct RNode *nd_cond;
246 struct RNode *nd_body;
253 struct RNode *nd_cond;
254 struct RNode *nd_body;
262 struct RNode *nd_body;
263 struct RNode *nd_iter;
269 struct RNode *nd_body;
270 struct RNode *nd_iter;
276 struct RNode *nd_var;
283 struct RNode *nd_chain;
284 struct RNode *nd_stts;
290 struct RNode *nd_chain;
291 struct RNode *nd_stts;
297 struct RNode *nd_chain;
307 struct RNode *nd_body;
313 struct RNode *nd_head;
314 struct RNode *nd_resq;
315 struct RNode *nd_else;
321 struct RNode *nd_head;
322 struct RNode *nd_body;
323 struct RNode *nd_args;
329 struct RNode *nd_head;
330 struct RNode *nd_resq;
331 struct RNode *nd_ensr;
338 struct RNode *nd_1st;
339 struct RNode *nd_2nd;
345 struct RNode *nd_1st;
346 struct RNode *nd_2nd;
352 struct RNode *nd_head;
353 struct RNode *nd_value;
354 struct RNode *nd_args;
361 struct RNode *nd_value;
368 struct RNode *nd_value;
375 struct RNode *nd_value;
382 struct RNode *nd_value;
389 struct RNode *nd_value;
390 struct RNode *nd_else;
397 struct RNode *nd_value;
403 struct RNode *nd_recv;
405 struct RNode *nd_index;
406 struct RNode *nd_rvalue;
412 struct RNode *nd_recv;
413 struct RNode *nd_value;
422 struct RNode *nd_head;
423 struct RNode *nd_value;
429 struct RNode *nd_head;
430 struct RNode *nd_value;
436 struct RNode *nd_head;
437 struct RNode *nd_value;
444 struct RNode *nd_recv;
446 struct RNode *nd_args;
452 struct RNode *nd_recv;
454 struct RNode *nd_args;
461 struct RNode *nd_args;
473 struct RNode *nd_recv;
475 struct RNode *nd_args;
481 struct RNode *nd_args;
503 struct RNode *nd_head;
506 struct RNode *nd_end;
508 struct RNode *nd_next;
518 struct RNode *nd_head;
520 struct RNode *nd_next;
526 struct RNode *nd_head;
533 struct RNode *nd_stts;
539 struct RNode *nd_head;
600 struct RNode *nd_recv;
601 struct RNode *nd_value;
602 struct RNode *nd_args;
608 struct RNode *nd_recv;
609 struct RNode *nd_value;
631 struct RNode *nd_end;
653 struct RNode *nd_body;
667 struct RNode *nd_body;
686 unsigned int no_kwarg: 1;
687 unsigned int ruby2_keywords: 1;
688 unsigned int forwarding: 1;
702 struct RNode *nd_next;
708 struct RNode *nd_body;
715 struct RNode *nd_body;
722 struct RNode *nd_1st;
723 struct RNode *nd_2nd;
729 struct RNode *nd_head;
730 struct RNode *nd_body;
736 struct RNode *nd_head;
737 struct RNode *nd_body;
743 struct RNode *nd_head;
749 struct RNode *nd_head;
750 struct RNode *nd_body;
757 struct RNode *nd_defn;
763 struct RNode *nd_recv;
765 struct RNode *nd_defn;
771 struct RNode *nd_1st;
772 struct RNode *nd_2nd;
785 struct RNode *nd_undef;
791 struct RNode *nd_cpath;
792 struct RNode *nd_body;
793 struct RNode *nd_super;
799 struct RNode *nd_cpath;
800 struct RNode *nd_body;
806 struct RNode *nd_recv;
807 struct RNode *nd_body;
813 struct RNode *nd_head;
827 struct RNode *nd_beg;
828 struct RNode *nd_end;
834 struct RNode *nd_beg;
835 struct RNode *nd_end;
841 struct RNode *nd_beg;
842 struct RNode *nd_end;
848 struct RNode *nd_beg;
849 struct RNode *nd_end;
877 struct RNode *nd_head;
883 struct RNode *nd_body;
897 struct RNode *nd_recv;
899 struct RNode *nd_args;
905 struct RNode *nd_body;
911 struct RNode *nd_pconst;
920 struct RNode *nd_pconst;
921 struct RNode *nd_pkwargs;
922 struct RNode *nd_pkwrestarg;
928 struct RNode *nd_pconst;
938#define RNODE(obj) ((struct RNode *)(obj))
940#define RNODE_SCOPE(node) ((struct RNode_SCOPE *)(node))
941#define RNODE_BLOCK(node) ((struct RNode_BLOCK *)(node))
942#define RNODE_IF(node) ((struct RNode_IF *)(node))
943#define RNODE_UNLESS(node) ((struct RNode_UNLESS *)(node))
944#define RNODE_CASE(node) ((struct RNode_CASE *)(node))
945#define RNODE_CASE2(node) ((struct RNode_CASE2 *)(node))
946#define RNODE_CASE3(node) ((struct RNode_CASE3 *)(node))
947#define RNODE_WHEN(node) ((struct RNode_WHEN *)(node))
948#define RNODE_IN(node) ((struct RNode_IN *)(node))
949#define RNODE_WHILE(node) ((struct RNode_WHILE *)(node))
950#define RNODE_UNTIL(node) ((struct RNode_UNTIL *)(node))
951#define RNODE_ITER(node) ((struct RNode_ITER *)(node))
952#define RNODE_FOR(node) ((struct RNode_FOR *)(node))
953#define RNODE_FOR_MASGN(node) ((struct RNode_FOR_MASGN *)(node))
954#define RNODE_BREAK(node) ((struct RNode_BREAK *)(node))
955#define RNODE_NEXT(node) ((struct RNode_NEXT *)(node))
956#define RNODE_REDO(node) ((struct RNode_REDO *)(node))
957#define RNODE_RETRY(node) ((struct RNode_RETRY *)(node))
958#define RNODE_BEGIN(node) ((struct RNode_BEGIN *)(node))
959#define RNODE_RESCUE(node) ((struct RNode_RESCUE *)(node))
960#define RNODE_RESBODY(node) ((struct RNode_RESBODY *)(node))
961#define RNODE_ENSURE(node) ((struct RNode_ENSURE *)(node))
962#define RNODE_AND(node) ((struct RNode_AND *)(node))
963#define RNODE_OR(node) ((struct RNode_OR *)(node))
964#define RNODE_MASGN(node) ((struct RNode_MASGN *)(node))
965#define RNODE_LASGN(node) ((struct RNode_LASGN *)(node))
966#define RNODE_DASGN(node) ((struct RNode_DASGN *)(node))
967#define RNODE_GASGN(node) ((struct RNode_GASGN *)(node))
968#define RNODE_IASGN(node) ((struct RNode_IASGN *)(node))
969#define RNODE_CDECL(node) ((struct RNode_CDECL *)(node))
970#define RNODE_CVASGN(node) ((struct RNode_CVASGN *)(node))
971#define RNODE_OP_ASGN1(node) ((struct RNode_OP_ASGN1 *)(node))
972#define RNODE_OP_ASGN2(node) ((struct RNode_OP_ASGN2 *)(node))
973#define RNODE_OP_ASGN_AND(node) ((struct RNode_OP_ASGN_AND *)(node))
974#define RNODE_OP_ASGN_OR(node) ((struct RNode_OP_ASGN_OR *)(node))
975#define RNODE_OP_CDECL(node) ((struct RNode_OP_CDECL *)(node))
976#define RNODE_CALL(node) ((struct RNode_CALL *)(node))
977#define RNODE_OPCALL(node) ((struct RNode_OPCALL *)(node))
978#define RNODE_FCALL(node) ((struct RNode_FCALL *)(node))
979#define RNODE_VCALL(node) ((struct RNode_VCALL *)(node))
980#define RNODE_QCALL(node) ((struct RNode_QCALL *)(node))
981#define RNODE_SUPER(node) ((struct RNode_SUPER *)(node))
982#define RNODE_ZSUPER(node) ((struct RNode_ZSUPER *)(node))
983#define RNODE_LIST(node) ((struct RNode_LIST *)(node))
984#define RNODE_ZLIST(node) ((struct RNode_ZLIST *)(node))
985#define RNODE_HASH(node) ((struct RNode_HASH *)(node))
986#define RNODE_RETURN(node) ((struct RNode_RETURN *)(node))
987#define RNODE_YIELD(node) ((struct RNode_YIELD *)(node))
988#define RNODE_LVAR(node) ((struct RNode_LVAR *)(node))
989#define RNODE_DVAR(node) ((struct RNode_DVAR *)(node))
990#define RNODE_GVAR(node) ((struct RNode_GVAR *)(node))
991#define RNODE_IVAR(node) ((struct RNode_IVAR *)(node))
992#define RNODE_CONST(node) ((struct RNode_CONST *)(node))
993#define RNODE_CVAR(node) ((struct RNode_CVAR *)(node))
994#define RNODE_NTH_REF(node) ((struct RNode_NTH_REF *)(node))
995#define RNODE_BACK_REF(node) ((struct RNode_BACK_REF *)(node))
996#define RNODE_MATCH(node) ((struct RNode_MATCH *)(node))
997#define RNODE_MATCH2(node) ((struct RNode_MATCH2 *)(node))
998#define RNODE_MATCH3(node) ((struct RNode_MATCH3 *)(node))
999#define RNODE_LIT(node) ((struct RNode_LIT *)(node))
1000#define RNODE_STR(node) ((struct RNode_STR *)(node))
1001#define RNODE_DSTR(node) ((struct RNode_DSTR *)(node))
1002#define RNODE_XSTR(node) ((struct RNode_XSTR *)(node))
1003#define RNODE_DXSTR(node) ((struct RNode_DXSTR *)(node))
1004#define RNODE_EVSTR(node) ((struct RNode_EVSTR *)(node))
1005#define RNODE_DREGX(node) ((struct RNode_DREGX *)(node))
1006#define RNODE_ONCE(node) ((struct RNode_ONCE *)(node))
1007#define RNODE_ARGS(node) ((struct RNode_ARGS *)(node))
1008#define RNODE_ARGS_AUX(node) ((struct RNode_ARGS_AUX *)(node))
1009#define RNODE_OPT_ARG(node) ((struct RNode_OPT_ARG *)(node))
1010#define RNODE_KW_ARG(node) ((struct RNode_KW_ARG *)(node))
1011#define RNODE_POSTARG(node) ((struct RNode_POSTARG *)(node))
1012#define RNODE_ARGSCAT(node) ((struct RNode_ARGSCAT *)(node))
1013#define RNODE_ARGSPUSH(node) ((struct RNode_ARGSPUSH *)(node))
1014#define RNODE_SPLAT(node) ((struct RNode_SPLAT *)(node))
1015#define RNODE_BLOCK_PASS(node) ((struct RNode_BLOCK_PASS *)(node))
1016#define RNODE_DEFN(node) ((struct RNode_DEFN *)(node))
1017#define RNODE_DEFS(node) ((struct RNode_DEFS *)(node))
1018#define RNODE_ALIAS(node) ((struct RNode_ALIAS *)(node))
1019#define RNODE_VALIAS(node) ((struct RNode_VALIAS *)(node))
1020#define RNODE_UNDEF(node) ((struct RNode_UNDEF *)(node))
1021#define RNODE_CLASS(node) ((struct RNode_CLASS *)(node))
1022#define RNODE_MODULE(node) ((struct RNode_MODULE *)(node))
1023#define RNODE_SCLASS(node) ((struct RNode_SCLASS *)(node))
1024#define RNODE_COLON2(node) ((struct RNode_COLON2 *)(node))
1025#define RNODE_COLON3(node) ((struct RNode_COLON3 *)(node))
1026#define RNODE_DOT2(node) ((struct RNode_DOT2 *)(node))
1027#define RNODE_DOT3(node) ((struct RNode_DOT3 *)(node))
1028#define RNODE_FLIP2(node) ((struct RNode_FLIP2 *)(node))
1029#define RNODE_FLIP3(node) ((struct RNode_FLIP3 *)(node))
1030#define RNODE_SELF(node) ((struct RNode_SELF *)(node))
1031#define RNODE_NIL(node) ((struct RNode_NIL *)(node))
1032#define RNODE_TRUE(node) ((struct RNode_TRUE *)(node))
1033#define RNODE_FALSE(node) ((struct RNode_FALSE *)(node))
1034#define RNODE_ERRINFO(node) ((struct RNode_ERRINFO *)(node))
1035#define RNODE_DEFINED(node) ((struct RNode_DEFINED *)(node))
1036#define RNODE_POSTEXE(node) ((struct RNode_POSTEXE *)(node))
1037#define RNODE_DSYM(node) ((struct RNode_DSYM *)(node))
1038#define RNODE_ATTRASGN(node) ((struct RNode_ATTRASGN *)(node))
1039#define RNODE_LAMBDA(node) ((struct RNode_LAMBDA *)(node))
1040#define RNODE_ARYPTN(node) ((struct RNode_ARYPTN *)(node))
1041#define RNODE_HSHPTN(node) ((struct RNode_HSHPTN *)(node))
1042#define RNODE_FNDPTN(node) ((struct RNode_FNDPTN *)(node))
1045typedef struct RNode_RIPPER {
1053typedef struct RNode_RIPPER_VALUES {
1059} rb_node_ripper_values_t;
1061#define RNODE_RIPPER(node) ((struct RNode_RIPPER *)(node))
1062#define RNODE_RIPPER_VALUES(node) ((struct RNode_RIPPER_VALUES *)(node))
1070#define NODE_FL_NEWLINE (((VALUE)1)<<7)
1072#define NODE_TYPESHIFT 8
1073#define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
1075#define nd_fl_newline(n) (n)->flags & NODE_FL_NEWLINE
1076#define nd_set_fl_newline(n) (n)->flags |= NODE_FL_NEWLINE
1077#define nd_unset_fl_newline(n) (n)->flags &= ~NODE_FL_NEWLINE
1079#define nd_type(n) ((int) ((RNODE(n)->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
1080#define nd_set_type(n,t) \
1081 rb_node_set_type(n, t)
1082#define nd_init_type(n,t) \
1083 (n)->flags=(((n)->flags&~NODE_TYPEMASK)|((((unsigned long)(t))<<NODE_TYPESHIFT)&NODE_TYPEMASK))
1093 signed int frozen_string_literal:2;
1094 signed int coverage_enabled:2;
1110#ifndef INTERNAL_IMEMO_H
1114#ifdef UNIVERSAL_PARSER
1115typedef struct rb_parser_config_struct {
1125 void *(*malloc)(
size_t size);
1126 void *(*calloc)(
size_t number,
size_t size);
1127 void *(*realloc)(
void *ptr,
size_t newsiz);
1128 void (*free)(
void *ptr);
1129 void *(*alloc_n)(
size_t nelems,
size_t elemsiz);
1130 void *(*alloc)(
size_t elemsiz);
1131 void *(*realloc_n)(
void *ptr,
size_t newelems,
size_t newsiz);
1132 void *(*zalloc)(
size_t elemsiz);
1133 void *(*rb_memmove)(
void *dest,
const void *src,
size_t t,
size_t n);
1134 void *(*nonempty_memcpy)(
void *dest,
const void *src,
size_t t,
size_t n);
1135 void *(*xmalloc_mul_add)(
size_t x,
size_t y,
size_t z);
1148 int (*obj_frozen)(
VALUE obj);
1149 int (*type_p)(
VALUE, int);
1150 void (*obj_freeze_raw)(
VALUE obj);
1152 int (*fixnum_p)(
VALUE);
1153 int (*symbol_p)(
VALUE);
1159 VALUE (*ary_new)(void);
1161 VALUE (*ary_new_from_args)(
long n, ...);
1170 long (*array_len)(
VALUE a);
1174 VALUE (*sym_intern_ascii_cstr)(
const char *ptr);
1175 ID (*make_temporary_id)(
size_t n);
1176 int (*is_local_id)(
ID);
1177 int (*is_attrset_id)(
ID);
1178 int (*is_global_name_punct)(
const int c);
1179 int (*id_type)(
ID id);
1180 ID (*id_attrset)(
ID);
1181 ID (*intern)(
const char *name);
1182 ID (*intern2)(
const char *name,
long len);
1185 int (*is_notop_id)(
ID);
1186 int (*enc_symname_type)(
const char *name,
long len,
rb_encoding *enc,
unsigned int allowed_attrset);
1188 const char *(*id2name)(
ID id);
1195 VALUE (*str_catf)(
VALUE str, const
char *format, ...);
1196 VALUE (*str_cat_cstr)(
VALUE str, const
char *ptr);
1201 VALUE (*str_buf_cat)(
VALUE, const
char*,
long);
1202 void (*str_modify)(
VALUE str);
1203 void (*str_set_len)(
VALUE str,
long len);
1206 VALUE (*str_new)(const
char *ptr,
long len);
1207 VALUE (*str_new_cstr)(const
char *ptr);
1209 int (*is_ascii_string)(
VALUE str);
1214 VALUE (*str_vcatf)(
VALUE str, const
char *fmt, va_list ap);
1215 char *(*string_value_cstr)(volatile
VALUE *ptr);
1217 VALUE (*rb_sprintf)(const
char *format, ...);
1218 char *(*rstring_ptr)(
VALUE str);
1219 char *(*rstring_end)(
VALUE str);
1220 long (*rstring_len)(
VALUE str);
1221 VALUE (*filesystem_str_new_cstr)(const
char *ptr);
1226 VALUE (*hash_new)(
void);
1230 VALUE (*ident_hash_new)(
void);
1233 VALUE (*int2fix)(
long i);
1236 void (*bignum_negate)(
VALUE b);
1238 VALUE (*cstr_to_inum)(const
char *str,
int base,
int badcheck);
1241 VALUE (*float_new)(
double d);
1242 double (*float_value)(
VALUE v);
1245 int (*num2int)(
VALUE val);
1246 VALUE (*int_positive_pow)(
long x,
unsigned long y);
1247 VALUE (*int2num)(
int v);
1248 long (*fix2long)(
VALUE val);
1258 void (*rcomplex_set_real)(
VALUE cmp,
VALUE r);
1259 void (*rcomplex_set_imag)(
VALUE cmp,
VALUE i);
1264 int (*stderr_tty_p)(
void);
1265 void (*write_error_str)(
VALUE mesg);
1266 VALUE (*default_rs)(
void);
1273 VALUE (*debug_output_stdout)(
void);
1274 VALUE (*debug_output_stderr)(
void);
1278 int (*enc_isalnum)(OnigCodePoint c,
rb_encoding *enc);
1279 int (*enc_precise_mbclen)(const
char *p, const
char *e,
rb_encoding *enc);
1280 int (*mbclen_charfound_p)(
int len);
1282 char *(*enc_prev_char)(const
char *s, const
char *p, const
char *e,
rb_encoding *enc);
1289 int (*enc_mbcput)(
unsigned int c,
void *buf,
rb_encoding *enc);
1290 int (*char_to_option_kcode)(
int c,
int *option,
int *kcode);
1291 int (*ascii8bit_encindex)(
void);
1292 int (*enc_find_index)(const
char *name);
1294 VALUE (*enc_associate_index)(
VALUE obj,
int encindex);
1295 int (*enc_isspace)(OnigCodePoint c,
rb_encoding *enc);
1296 int enc_coderange_7bit;
1297 int enc_coderange_unknown;
1298 int enc_coderange_broken;
1301 int (*encoding_get)(
VALUE obj);
1302 void (*encoding_set)(
VALUE obj,
int encindex);
1303 int (*encoding_is_ascii8bit)(
VALUE obj);
1305 int (*enc_str_coderange)(
VALUE str);
1312 int (*local_defined)(
ID, const
void*);
1314 int (*dvar_defined)(
ID, const
void*);
1318 parser_st_index_t (*literal_hash)(
VALUE a);
1321 const
char *(*builtin_class_name)(
VALUE x);
1325 void (*raise)(
VALUE exc, const
char *fmt, ...);
1326 VALUE (*syntax_error_new)(
void);
1329 VALUE (*errinfo)(
void);
1330 void (*set_errinfo)(
VALUE err);
1331 void (*exc_raise)(
VALUE mesg);
1332 VALUE (*make_exception)(
int argc, const
VALUE *argv);
1335 void (*sized_xfree)(
void *x,
size_t size);
1336 void *(*sized_realloc_n)(
void *ptr,
size_t new_count,
size_t element_size,
size_t old_count);
1339 void (*gc_register_mark_object)(
VALUE object);
1340 void (*gc_guard)(
VALUE);
1341 void (*gc_mark)(
VALUE);
1342 void (*gc_mark_movable)(
VALUE ptr);
1346 VALUE (*reg_compile)(
VALUE str,
int options, const
char *sourcefile,
int sourceline);
1348 int (*memcicmp)(const
void *x, const
void *y,
long len);
1351 void (*compile_warn)(const
char *file,
int line, const
char *fmt, ...);
1352 void (*compile_warning)(const
char *file,
int line, const
char *fmt, ...);
1353 void (*bug)(const
char *fmt, ...);
1354 void (*fatal)(const
char *fmt, ...);
1355 VALUE (*verbose)(
void);
1358 VALUE (*make_backtrace)(
void);
1361 unsigned long (*
scan_hex)(const
char *start,
size_t len,
size_t *retlen);
1362 unsigned long (*
scan_oct)(const
char *start,
size_t len,
size_t *retlen);
1363 unsigned long (*scan_digits)(const
char *str, ssize_t
len,
int base,
size_t *retlen,
int *overflow);
1364 double (*
strtod)(const
char *s00,
char **se);
1368 int (*undef_p)(
VALUE);
1369 int (*rtest)(
VALUE obj);
1370 int (*nil_p)(
VALUE obj);
1371 int (*flonum_p)(
VALUE obj);
1377 VALUE mRubyVMFrozenCore;
1378 int (*long2int)(
long);
1379 int (*special_const_p)(
VALUE);
1380 int (*builtin_type)(
VALUE);
1382 VALUE (*node_case_when_optimizable_literal)(const
NODE *const node);
1385 VALUE (*static_id2sym)(
ID id);
1386 long (*str_coderange_scan_restartable)(const
char *s, const
char *e,
rb_encoding *enc,
int *cr);
1387} rb_parser_config_t;
1393RUBY_SYMBOL_EXPORT_BEGIN
1394void rb_ruby_parser_free(
void *ptr);
1397#ifdef UNIVERSAL_PARSER
1398rb_parser_config_t *rb_ruby_parser_config_new(
void *(*malloc)(
size_t size));
1399void rb_ruby_parser_config_free(rb_parser_config_t *config);
1400rb_parser_t *rb_ruby_parser_allocate(rb_parser_config_t *config);
1401rb_parser_t *rb_ruby_parser_new(rb_parser_config_t *config);
1403RUBY_SYMBOL_EXPORT_END
#define scan_hex(s, l, e)
Old name of ruby_scan_hex.
#define scan_oct(s, l, e)
Old name of ruby_scan_oct.
int capa
Designed capacity of the buffer.
int len
Length of the buffer.
#define strtod(s, e)
Just another name of ruby_strtod.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
uintptr_t VALUE
Type that represents a Ruby object.