1 #ifndef INTERNAL_PARSE_H /*-*-C-*-vi:se ft=c:*/
2 #define INTERNAL_PARSE_H
4 * @author Ruby developers <ruby-core@ruby-lang.org>
5 * @copyright This file is a part of the programming language Ruby.
6 * Permission is hereby granted, to either redistribute and/or
7 * modify this file, provided that the conditions mentioned in the
8 * file COPYING are met. Consult the file for details.
9 * @brief Internal header for the parser.
12 #include "rubyparser.h"
13 #include "internal/static_assert.h"
15 #ifdef UNIVERSAL_PARSER
16 #define rb_encoding void
19 struct rb_iseq_struct
; /* in vm_core.h */
21 #define STRTERM_HEREDOC IMEMO_FL_USER0
23 /* structs for managing terminator of string literal and heredocment */
24 typedef struct rb_strterm_literal_struct
{
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
;
31 typedef struct rb_strterm_heredoc_struct
{
32 rb_parser_string_t
*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"` */
38 } rb_strterm_heredoc_t
;
40 #define HERETERM_LENGTH_MAX UINT_MAX
42 typedef struct rb_strterm_struct
{
45 rb_strterm_literal_t literal
;
46 rb_strterm_heredoc_t heredoc
;
51 void rb_ruby_parser_mark(void *ptr
);
52 size_t rb_ruby_parser_memsize(const void *ptr
);
54 void 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
);
56 void rb_ruby_parser_set_script_lines(rb_parser_t
*p
, VALUE lines_array
);
57 void 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
);
59 void 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
);
63 RUBY_SYMBOL_EXPORT_BEGIN
65 VALUE
rb_ruby_parser_encoding(rb_parser_t
*p
);
66 int rb_ruby_parser_end_seen_p(rb_parser_t
*p
);
67 int rb_ruby_parser_set_yydebug(rb_parser_t
*p
, int flag
);
68 rb_parser_string_t
*rb_str_to_parser_string(rb_parser_t
*p
, VALUE str
);
70 RUBY_SYMBOL_EXPORT_END
72 int 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
);
75 void ripper_parser_mark(void *ptr
);
76 void ripper_parser_free(void *ptr
);
77 size_t ripper_parser_memsize(const void *ptr
);
78 void ripper_error(struct parser_params
*p
);
79 VALUE
ripper_value(struct parser_params
*p
);
80 int rb_ruby_parser_get_yydebug(rb_parser_t
*p
);
81 void rb_ruby_parser_set_value(rb_parser_t
*p
, VALUE value
);
82 int rb_ruby_parser_error_p(rb_parser_t
*p
);
83 VALUE
rb_ruby_parser_debug_output(rb_parser_t
*p
);
84 void rb_ruby_parser_set_debug_output(rb_parser_t
*p
, VALUE output
);
85 VALUE
rb_ruby_parser_parsing_thread(rb_parser_t
*p
);
86 void rb_ruby_parser_set_parsing_thread(rb_parser_t
*p
, VALUE parsing_thread
);
87 void 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
);
88 VALUE
rb_ruby_parser_result(rb_parser_t
*p
);
89 rb_encoding
*rb_ruby_parser_enc(rb_parser_t
*p
);
90 VALUE
rb_ruby_parser_ruby_sourcefile_string(rb_parser_t
*p
);
91 int rb_ruby_parser_ruby_sourceline(rb_parser_t
*p
);
92 int rb_ruby_parser_lex_state(rb_parser_t
*p
);
93 void rb_ruby_ripper_parse0(rb_parser_t
*p
);
94 int rb_ruby_ripper_dedent_string(rb_parser_t
*p
, VALUE string
, int width
);
95 VALUE
rb_ruby_ripper_lex_get_str(rb_parser_t
*p
, VALUE s
);
96 int rb_ruby_ripper_initialized_p(rb_parser_t
*p
);
97 void rb_ruby_ripper_parser_initialize(rb_parser_t
*p
);
98 long rb_ruby_ripper_column(rb_parser_t
*p
);
99 long rb_ruby_ripper_token_len(rb_parser_t
*p
);
100 rb_parser_string_t
*rb_ruby_ripper_lex_lastline(rb_parser_t
*p
);
101 VALUE
rb_ruby_ripper_lex_state_name(struct parser_params
*p
, int state
);
102 struct parser_params
*rb_ruby_ripper_parser_allocate(void);
105 #ifdef UNIVERSAL_PARSER
109 #endif /* INTERNAL_PARSE_H */