Ruby: internal/ruby_parser.h Source File

Ruby 3.3.5p100 (2024-09-03 revision ef084cc8f4958c1b6e4ead99136631bef6d8ddba)

ruby_parser.h
1#ifndef INTERNAL_RUBY_PARSE_H
2#define INTERNAL_RUBY_PARSE_H
3
4#include "internal.h"
5#include "internal/imemo.h"
6#include "rubyparser.h"
7#include "vm.h"
8
9RUBY_SYMBOL_EXPORT_BEGIN
10#ifdef UNIVERSAL_PARSER
11void rb_parser_config_initialize(rb_parser_config_t *config);
12#endif
13 VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
14 VALUE rb_parser_new(void);
15 rb_ast_t *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
16RUBY_SYMBOL_EXPORT_END
17
18 VALUE rb_parser_end_seen_p(VALUE);
19 VALUE rb_parser_encoding(VALUE);
20 VALUE rb_parser_set_yydebug(VALUE, VALUE);
21void rb_parser_set_options(VALUE, int, int, int, int);
22void *rb_parser_load_file(VALUE parser, VALUE name);
23void rb_parser_set_script_lines(VALUE vparser, VALUE lines_array);
24void rb_parser_error_tolerant(VALUE vparser);
25void rb_parser_keep_tokens(VALUE vparser);
26
27 rb_ast_t *rb_parser_compile_string(VALUE, const char*, VALUE, int);
28 rb_ast_t *rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
29 rb_ast_t *rb_parser_compile_generic(VALUE vparser, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int line);
30
31enum lex_state_bits {
32 EXPR_BEG_bit, /* ignore newline, +/- is a sign. */
33 EXPR_END_bit, /* newline significant, +/- is an operator. */
34 EXPR_ENDARG_bit, /* ditto, and unbound braces. */
35 EXPR_ENDFN_bit, /* ditto, and unbound braces. */
36 EXPR_ARG_bit, /* newline significant, +/- is an operator. */
37 EXPR_CMDARG_bit, /* newline significant, +/- is an operator. */
38 EXPR_MID_bit, /* newline significant, +/- is an operator. */
39 EXPR_FNAME_bit, /* ignore newline, no reserved words. */
40 EXPR_DOT_bit, /* right after `.', `&.' or `::', no reserved words. */
41 EXPR_CLASS_bit, /* immediate after `class', no here document. */
42 EXPR_LABEL_bit, /* flag bit, label is allowed. */
43 EXPR_LABELED_bit, /* flag bit, just after a label. */
44 EXPR_FITEM_bit, /* symbol literal as FNAME. */
45 EXPR_MAX_STATE
46};
47/* examine combinations */
48enum lex_state_e {
49#define DEF_EXPR(n) EXPR_##n = (1 << EXPR_##n##_bit)
50 DEF_EXPR(BEG),
51 DEF_EXPR(END),
52 DEF_EXPR(ENDARG),
53 DEF_EXPR(ENDFN),
54 DEF_EXPR(ARG),
55 DEF_EXPR(CMDARG),
56 DEF_EXPR(MID),
57 DEF_EXPR(FNAME),
58 DEF_EXPR(DOT),
59 DEF_EXPR(CLASS),
60 DEF_EXPR(LABEL),
61 DEF_EXPR(LABELED),
62 DEF_EXPR(FITEM),
63 EXPR_VALUE = EXPR_BEG,
64 EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS),
65 EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG),
66 EXPR_END_ANY = (EXPR_END | EXPR_ENDARG | EXPR_ENDFN),
67 EXPR_NONE = 0
68};
69#endif /* INTERNAL_RUBY_PARSE_H */
iseq_label_data
Definition compile.c:78
rb_ast_struct
Definition rubyparser.h:1096
rb_iseq_struct
Definition vm_core.h:534
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40