Change soft-fail to use the config, rather than env
[rbx.git] / shotgun / lib / grammar_internal.h
blob3685f11cef83a19d2173823871f4df40d05b0aac
1 #ifndef RBS_GRAMMAR_INTERNAL_H
2 #define RBS_GRAMMAR_INTERNAL_H
4 #include <stdbool.h>
6 #include "quark.h"
7 #include "bstrlib.h"
8 #include "shotgun/lib/shotgun.h"
10 #define ID quark
11 #define VALUE OBJECT
13 #include "shotgun/lib/var_table.h"
15 enum lex_state {
16 EXPR_BEG, /* ignore newline, +/- is a sign. */
17 EXPR_END, /* newline significant, +/- is a operator. */
18 EXPR_ARG, /* newline significant, +/- is a operator. */
19 EXPR_CMDARG, /* newline significant, +/- is a operator. */
20 EXPR_ENDARG, /* newline significant, +/- is a operator. */
21 EXPR_MID, /* newline significant, +/- is a operator. */
22 EXPR_FNAME, /* ignore newline, no reserved words. */
23 EXPR_DOT, /* right after `.' or `::', no reserved words. */
24 EXPR_CLASS, /* immediate after `class', no here document. */
27 #ifdef HAVE_LONG_LONG
28 typedef unsigned LONG_LONG stack_type;
29 #else
30 typedef unsigned long stack_type;
31 #endif
33 #include "shotgun/lib/grammar_node.h"
35 typedef struct rb_parse_state {
36 int end_seen;
37 int debug_lines;
38 int heredoc_end;
39 int command_start;
40 NODE *lex_strterm;
41 int class_nest;
42 int in_single;
43 int in_def;
44 int compile_for_eval;
45 ID cur_mid;
46 char *token_buffer;
47 int tokidx;
48 int toksiz;
49 int emit_warnings;
50 /* Mirror'ing the 1.8 parser, There are 2 input methods,
51 from IO and directly from a string. */
53 /* this function reads a line from lex_io and stores it in
54 * line_buffer.
56 bool (*lex_gets)();
57 bstring line_buffer;
59 /* If this is set, we use the io method. */
60 FILE *lex_io;
61 /* Otherwise, we use this. */
62 bstring lex_string;
63 bstring lex_lastline;
65 char *lex_pbeg;
66 char *lex_p;
67 char *lex_pend;
68 int lex_str_used;
70 enum lex_state lex_state;
71 int in_defined;
72 stack_type cond_stack;
73 stack_type cmdarg_stack;
75 void *lval; /* the parser's yylval */
77 ptr_array comments;
78 int column;
79 NODE *top;
80 ID *locals;
82 var_table variables;
83 var_table block_vars;
85 int ternary_colon;
87 void **memory_pools;
88 int pool_size, current_pool;
89 char *memory_cur;
90 char *memory_last_addr;
91 int memory_size;
93 STATE;
94 OBJECT error;
96 } rb_parse_state;
98 #define PARSE_STATE ((rb_parse_state*)parse_state)
99 #define PARSE_VAR(var) (PARSE_STATE->var)
100 #define ruby_debug_lines PARSE_VAR(debug_lines)
101 #define heredoc_end PARSE_VAR(heredoc_end)
102 #define command_start PARSE_VAR(command_start)
103 #define lex_strterm PARSE_VAR(lex_strterm)
104 #define class_nest PARSE_VAR(class_nest)
105 #define in_single PARSE_VAR(in_single)
106 #define in_def PARSE_VAR(in_def)
107 #define compile_for_eval PARSE_VAR(compile_for_eval)
108 #define cur_mid PARSE_VAR(cur_mid)
110 #define tokenbuf PARSE_VAR(token_buffer)
111 #define tokidx PARSE_VAR(tokidx)
112 #define toksiz PARSE_VAR(toksiz)
114 #endif /* __GRAMMER_INTERNAL_H__ */