Ruby 3.5.0dev (2025-01-10 revision 5fab31b15e32622c4b71d1d347a41937e9f9c212)
ruby_parser.h
1#ifndef INTERNAL_RUBY_PARSE_H
2#define INTERNAL_RUBY_PARSE_H
3
4#include "internal.h"
5#include "internal/bignum.h"
6#include "internal/compilers.h"
7#include "internal/complex.h"
8#include "internal/parse.h"
9#include "internal/rational.h"
10#include "rubyparser.h"
11#include "vm.h"
12
14 VALUE str;
15 long ptr;
16};
17
18RUBY_SYMBOL_EXPORT_BEGIN
19#ifdef UNIVERSAL_PARSER
20const rb_parser_config_t *rb_ruby_parser_config(void);
21rb_parser_t *rb_parser_params_new(void);
22#endif
23VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
24VALUE rb_parser_new(void);
25VALUE rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
26VALUE rb_str_new_parser_string(rb_parser_string_t *str);
27VALUE rb_str_new_mutable_parser_string(rb_parser_string_t *str);
28rb_parser_string_t *rb_parser_lex_get_str(struct parser_params *p, struct lex_pointer_string *ptr_str);
29
30VALUE rb_node_str_string_val(const NODE *);
31VALUE rb_node_sym_string_val(const NODE *);
32VALUE rb_node_dstr_string_val(const NODE *);
33VALUE rb_node_regx_string_val(const NODE *);
34VALUE rb_node_dregx_string_val(const NODE *);
35VALUE rb_node_line_lineno_val(const NODE *);
36VALUE rb_node_file_path_val(const NODE *);
37VALUE rb_node_encoding_val(const NODE *);
38
39VALUE rb_node_integer_literal_val(const NODE *);
40VALUE rb_node_float_literal_val(const NODE *);
41VALUE rb_node_rational_literal_val(const NODE *);
42VALUE rb_node_imaginary_literal_val(const NODE *);
43RUBY_SYMBOL_EXPORT_END
44
45VALUE rb_parser_end_seen_p(VALUE);
46VALUE rb_parser_encoding(VALUE);
47VALUE rb_parser_set_yydebug(VALUE, VALUE);
48VALUE rb_parser_build_script_lines_from(rb_parser_ary_t *script_lines);
49void rb_parser_set_options(VALUE, int, int, int, int);
50VALUE rb_parser_load_file(VALUE parser, VALUE name);
51void rb_parser_set_script_lines(VALUE vparser);
52void rb_parser_error_tolerant(VALUE vparser);
53void rb_parser_keep_tokens(VALUE vparser);
54
55VALUE rb_parser_compile_string(VALUE, const char*, VALUE, int);
56VALUE rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
57VALUE rb_parser_compile_generic(VALUE vparser, rb_parser_lex_gets_func *lex_gets, VALUE fname, VALUE input, int line);
58VALUE rb_parser_compile_array(VALUE vparser, VALUE fname, VALUE array, int start);
59
60enum lex_state_bits {
61 EXPR_BEG_bit, /* ignore newline, +/- is a sign. */
62 EXPR_END_bit, /* newline significant, +/- is an operator. */
63 EXPR_ENDARG_bit, /* ditto, and unbound braces. */
64 EXPR_ENDFN_bit, /* ditto, and unbound braces. */
65 EXPR_ARG_bit, /* newline significant, +/- is an operator. */
66 EXPR_CMDARG_bit, /* newline significant, +/- is an operator. */
67 EXPR_MID_bit, /* newline significant, +/- is an operator. */
68 EXPR_FNAME_bit, /* ignore newline, no reserved words. */
69 EXPR_DOT_bit, /* right after `.', `&.' or `::', no reserved words. */
70 EXPR_CLASS_bit, /* immediate after `class', no here document. */
71 EXPR_LABEL_bit, /* flag bit, label is allowed. */
72 EXPR_LABELED_bit, /* flag bit, just after a label. */
73 EXPR_FITEM_bit, /* symbol literal as FNAME. */
74 EXPR_MAX_STATE
75};
76/* examine combinations */
77enum lex_state_e {
78#define DEF_EXPR(n) EXPR_##n = (1 << EXPR_##n##_bit)
79 DEF_EXPR(BEG),
80 DEF_EXPR(END),
81 DEF_EXPR(ENDARG),
82 DEF_EXPR(ENDFN),
83 DEF_EXPR(ARG),
84 DEF_EXPR(CMDARG),
85 DEF_EXPR(MID),
86 DEF_EXPR(FNAME),
87 DEF_EXPR(DOT),
88 DEF_EXPR(CLASS),
89 DEF_EXPR(LABEL),
90 DEF_EXPR(LABELED),
91 DEF_EXPR(FITEM),
92 EXPR_VALUE = EXPR_BEG,
93 EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS),
94 EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG),
95 EXPR_END_ANY = (EXPR_END | EXPR_ENDARG | EXPR_ENDFN),
96 EXPR_NONE = 0
97};
98
99VALUE rb_ruby_ast_new(const NODE *const root);
100rb_ast_t *rb_ruby_ast_data_get(VALUE ast_value);
101
102#endif /* INTERNAL_RUBY_PARSE_H */
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40