Ruby: internal/parse.h Source File

Ruby 3.3.6p108 (2024-11-05 revision 75015d4c1f6965b5e85e96fb309f1f2129f933c0)

parse.h
1#ifndef INTERNAL_PARSE_H /*-*-C-*-vi:se ft=c:*/
2#define INTERNAL_PARSE_H
11#include <limits.h>
12#include "rubyparser.h"
13#include "internal/static_assert.h"
14
15#ifdef UNIVERSAL_PARSER
16#define rb_encoding void
17#endif
18
19struct rb_iseq_struct; /* in vm_core.h */
20
21#define STRTERM_HEREDOC IMEMO_FL_USER0
22
23/* structs for managing terminator of string literal and heredocment */
24 typedef struct rb_strterm_literal_struct {
25 long nest;
26 int func; /* STR_FUNC_* (e.g., STR_FUNC_ESCAPE and STR_FUNC_EXPAND) */
27 int paren; /* '(' of `%q(...)` */
28 int term; /* ')' of `%q(...)` */
29} rb_strterm_literal_t;
30
31 typedef struct rb_strterm_heredoc_struct {
32 VALUE lastline; /* the string of line that contains `<<"END"` */
33 long offset; /* the column of END in `<<"END"` */
34 int sourceline; /* lineno of the line that contains `<<"END"` */
35 unsigned length; /* the length of END in `<<"END"` */
36 uint8_t quote;
37 uint8_t func;
38} rb_strterm_heredoc_t;
39
40#define HERETERM_LENGTH_MAX UINT_MAX
41
42 typedef struct rb_strterm_struct {
43 VALUE flags;
44 union {
45 rb_strterm_literal_t literal;
46 rb_strterm_heredoc_t heredoc;
47 } u;
48} rb_strterm_t;
49
50/* parse.y */
51void rb_ruby_parser_mark(void *ptr);
52size_t rb_ruby_parser_memsize(const void *ptr);
53
54void rb_ruby_parser_set_options(rb_parser_t *p, int print, int loop, int chomp, int split);
55 rb_parser_t *rb_ruby_parser_set_context(rb_parser_t *p, const struct rb_iseq_struct *base, int main);
56void rb_ruby_parser_set_script_lines(rb_parser_t *p, VALUE lines_array);
57void rb_ruby_parser_error_tolerant(rb_parser_t *p);
58 rb_ast_t* rb_ruby_parser_compile_file_path(rb_parser_t *p, VALUE fname, VALUE file, int start);
59void rb_ruby_parser_keep_tokens(rb_parser_t *p);
60 rb_ast_t* rb_ruby_parser_compile_generic(rb_parser_t *p, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int start);
61 rb_ast_t* rb_ruby_parser_compile_string_path(rb_parser_t *p, VALUE f, VALUE s, int line);
62
63RUBY_SYMBOL_EXPORT_BEGIN
64
65 VALUE rb_ruby_parser_encoding(rb_parser_t *p);
66int rb_ruby_parser_end_seen_p(rb_parser_t *p);
67int rb_ruby_parser_set_yydebug(rb_parser_t *p, int flag);
68
69RUBY_SYMBOL_EXPORT_END
70
71int rb_reg_named_capture_assign_iter_impl(struct parser_params *p, const char *s, long len, rb_encoding *enc, NODE **succ_block, const rb_code_location_t *loc);
72
73#ifdef RIPPER
74void ripper_parser_mark(void *ptr);
75void ripper_parser_free(void *ptr);
76size_t ripper_parser_memsize(const void *ptr);
77void ripper_error(struct parser_params *p);
78 VALUE ripper_value(struct parser_params *p);
79int rb_ruby_parser_get_yydebug(rb_parser_t *p);
80void rb_ruby_parser_set_value(rb_parser_t *p, VALUE value);
81int rb_ruby_parser_error_p(rb_parser_t *p);
82 VALUE rb_ruby_parser_debug_output(rb_parser_t *p);
83void rb_ruby_parser_set_debug_output(rb_parser_t *p, VALUE output);
84 VALUE rb_ruby_parser_parsing_thread(rb_parser_t *p);
85void rb_ruby_parser_set_parsing_thread(rb_parser_t *p, VALUE parsing_thread);
86void rb_ruby_parser_ripper_initialize(rb_parser_t *p, VALUE (*gets)(struct parser_params*,VALUE), VALUE input, VALUE sourcefile_string, const char *sourcefile, int sourceline);
87 VALUE rb_ruby_parser_result(rb_parser_t *p);
88 rb_encoding *rb_ruby_parser_enc(rb_parser_t *p);
89 VALUE rb_ruby_parser_ruby_sourcefile_string(rb_parser_t *p);
90int rb_ruby_parser_ruby_sourceline(rb_parser_t *p);
91int rb_ruby_parser_lex_state(rb_parser_t *p);
92void rb_ruby_ripper_parse0(rb_parser_t *p);
93int rb_ruby_ripper_dedent_string(rb_parser_t *p, VALUE string, int width);
94 VALUE rb_ruby_ripper_lex_get_str(rb_parser_t *p, VALUE s);
95int rb_ruby_ripper_initialized_p(rb_parser_t *p);
96void rb_ruby_ripper_parser_initialize(rb_parser_t *p);
97long rb_ruby_ripper_column(rb_parser_t *p);
98long rb_ruby_ripper_token_len(rb_parser_t *p);
99 VALUE rb_ruby_ripper_lex_lastline(rb_parser_t *p);
100 VALUE rb_ruby_ripper_lex_state_name(struct parser_params *p, int state);
101struct parser_params *rb_ruby_ripper_parser_allocate(void);
102#endif
103
104#ifdef UNIVERSAL_PARSER
105#undef rb_encoding
106#endif
107
108#endif /* INTERNAL_PARSE_H */
len
int len
Length of the buffer.
Definition io.h:8
OnigEncodingTypeST
Definition onigmo.h:160
RNode
Definition rubyparser.h:166
parser_params
Definition parse.c:481
rb_ast_struct
Definition rubyparser.h:1096
rb_code_location_struct
Definition rubyparser.h:160
rb_iseq_struct
Definition vm_core.h:534
rb_strterm_heredoc_struct
Definition parse.h:31
rb_strterm_literal_struct
Definition parse.h:24
rb_strterm_struct
Definition parse.h:42
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40