ddff2c364d7dee2a891f5c39eacb462a83ceb95e
[ruby.git] / internal / ruby_parser.h
blobddff2c364d7dee2a891f5c39eacb462a83ceb95e
1 #ifndef INTERNAL_RUBY_PARSE_H
2 #define INTERNAL_RUBY_PARSE_H
4 #include "internal.h"
5 #include "internal/bignum.h"
6 #include "internal/compilers.h"
7 #include "internal/complex.h"
8 #include "internal/imemo.h"
9 #include "internal/rational.h"
10 #include "rubyparser.h"
11 #include "vm.h"
13 RUBY_SYMBOL_EXPORT_BEGIN
14 #ifdef UNIVERSAL_PARSER
15 rb_parser_t *rb_parser_params_allocate(void);
16 rb_parser_t *rb_parser_params_new(void);
17 #endif
18 VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
19 VALUE rb_parser_new(void);
20 rb_ast_t *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
21 RUBY_SYMBOL_EXPORT_END
23 VALUE rb_parser_end_seen_p(VALUE);
24 VALUE rb_parser_encoding(VALUE);
25 VALUE rb_parser_set_yydebug(VALUE, VALUE);
26 void rb_parser_set_options(VALUE, int, int, int, int);
27 void *rb_parser_load_file(VALUE parser, VALUE name);
28 void rb_parser_set_script_lines(VALUE vparser, VALUE lines_array);
29 void rb_parser_error_tolerant(VALUE vparser);
30 void rb_parser_keep_tokens(VALUE vparser);
32 rb_ast_t *rb_parser_compile_string(VALUE, const char*, VALUE, int);
33 rb_ast_t *rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
34 rb_ast_t *rb_parser_compile_generic(VALUE vparser, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int line);
36 enum lex_state_bits {
37 EXPR_BEG_bit, /* ignore newline, +/- is a sign. */
38 EXPR_END_bit, /* newline significant, +/- is an operator. */
39 EXPR_ENDARG_bit, /* ditto, and unbound braces. */
40 EXPR_ENDFN_bit, /* ditto, and unbound braces. */
41 EXPR_ARG_bit, /* newline significant, +/- is an operator. */
42 EXPR_CMDARG_bit, /* newline significant, +/- is an operator. */
43 EXPR_MID_bit, /* newline significant, +/- is an operator. */
44 EXPR_FNAME_bit, /* ignore newline, no reserved words. */
45 EXPR_DOT_bit, /* right after `.', `&.' or `::', no reserved words. */
46 EXPR_CLASS_bit, /* immediate after `class', no here document. */
47 EXPR_LABEL_bit, /* flag bit, label is allowed. */
48 EXPR_LABELED_bit, /* flag bit, just after a label. */
49 EXPR_FITEM_bit, /* symbol literal as FNAME. */
50 EXPR_MAX_STATE
52 /* examine combinations */
53 enum lex_state_e {
54 #define DEF_EXPR(n) EXPR_##n = (1 << EXPR_##n##_bit)
55 DEF_EXPR(BEG),
56 DEF_EXPR(END),
57 DEF_EXPR(ENDARG),
58 DEF_EXPR(ENDFN),
59 DEF_EXPR(ARG),
60 DEF_EXPR(CMDARG),
61 DEF_EXPR(MID),
62 DEF_EXPR(FNAME),
63 DEF_EXPR(DOT),
64 DEF_EXPR(CLASS),
65 DEF_EXPR(LABEL),
66 DEF_EXPR(LABELED),
67 DEF_EXPR(FITEM),
68 EXPR_VALUE = EXPR_BEG,
69 EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS),
70 EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG),
71 EXPR_END_ANY = (EXPR_END | EXPR_ENDARG | EXPR_ENDFN),
72 EXPR_NONE = 0
75 VALUE rb_node_sym_string_val(const NODE *);
76 VALUE rb_node_line_lineno_val(const NODE *);
77 VALUE rb_node_file_path_val(const NODE *);
79 VALUE rb_node_integer_literal_val(const NODE *);
80 VALUE rb_node_float_literal_val(const NODE *);
81 VALUE rb_node_rational_literal_val(const NODE *);
82 VALUE rb_node_imaginary_literal_val(const NODE *);
84 #endif /* INTERNAL_RUBY_PARSE_H */