Ruby 3.3.5p100 (2024-09-03 revision ef084cc8f4958c1b6e4ead99136631bef6d8ddba)
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 */
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(...)` */
30
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;
39
40#define HERETERM_LENGTH_MAX UINT_MAX
41
42typedef struct rb_strterm_struct {
43 VALUE flags;
44 union {
47 } u;
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);
55rb_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);
58rb_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);
60rb_ast_t* rb_ruby_parser_compile_generic(rb_parser_t *p, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int start);
61rb_ast_t* rb_ruby_parser_compile_string_path(rb_parser_t *p, VALUE f, VALUE s, int line);
62
63RUBY_SYMBOL_EXPORT_BEGIN
64
65VALUE 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);
78VALUE 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);
82VALUE rb_ruby_parser_debug_output(rb_parser_t *p);
83void rb_ruby_parser_set_debug_output(rb_parser_t *p, VALUE output);
84VALUE 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);
87VALUE rb_ruby_parser_result(rb_parser_t *p);
88rb_encoding *rb_ruby_parser_enc(rb_parser_t *p);
89VALUE 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);
94VALUE 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);
99VALUE rb_ruby_ripper_lex_lastline(rb_parser_t *p);
100VALUE 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 */
int len
Length of the buffer.
Definition io.h:8
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40