Mercurial > hg > octave-lyh
comparison src/lex.h @ 1826:b14829582cc4
[project @ 1996-02-02 03:05:07 by jwe]
author | jwe |
---|---|
date | Fri, 02 Feb 1996 03:07:27 +0000 |
parents | 611d403c7f3d |
children | 7d2982b55242 |
comparison
equal
deleted
inserted
replaced
1825:8219d9b7cb73 | 1826:b14829582cc4 |
---|---|
48 | 48 |
49 #define TOK_RETURN(tok) \ | 49 #define TOK_RETURN(tok) \ |
50 do \ | 50 do \ |
51 { \ | 51 { \ |
52 current_input_column += yyleng; \ | 52 current_input_column += yyleng; \ |
53 quote_is_transpose = 0; \ | 53 lexer_flags.quote_is_transpose = 0; \ |
54 cant_be_identifier = 0; \ | 54 lexer_flags.cant_be_identifier = 0; \ |
55 convert_spaces_to_comma = 1; \ | 55 lexer_flags.convert_spaces_to_comma = 1; \ |
56 return (tok); \ | 56 return (tok); \ |
57 } \ | 57 } \ |
58 while (0) | 58 while (0) |
59 | 59 |
60 #define TOK_PUSH_AND_RETURN(name,tok) \ | 60 #define TOK_PUSH_AND_RETURN(name,tok) \ |
71 do \ | 71 do \ |
72 { \ | 72 { \ |
73 yylval.tok_val = new token (input_line_number, current_input_column); \ | 73 yylval.tok_val = new token (input_line_number, current_input_column); \ |
74 token_stack.push (yylval.tok_val); \ | 74 token_stack.push (yylval.tok_val); \ |
75 current_input_column += yyleng; \ | 75 current_input_column += yyleng; \ |
76 quote_is_transpose = 0; \ | 76 lexer_flags.quote_is_transpose = 0; \ |
77 cant_be_identifier = 0; \ | 77 lexer_flags.cant_be_identifier = 0; \ |
78 convert_spaces_to_comma = convert; \ | 78 lexer_flags.convert_spaces_to_comma = convert; \ |
79 return (tok); \ | 79 return (tok); \ |
80 } \ | 80 } \ |
81 while (0) | 81 while (0) |
82 | |
83 // XXX FIXME XXX -- these input buffer things should be members of an | |
84 // parser input stream class. | |
82 | 85 |
83 typedef struct yy_buffer_state *YY_BUFFER_STATE; | 86 typedef struct yy_buffer_state *YY_BUFFER_STATE; |
84 | 87 |
85 // Associate a buffer with a new file to read. | 88 // Associate a buffer with a new file to read. |
86 extern YY_BUFFER_STATE create_buffer (FILE *f); | 89 extern YY_BUFFER_STATE create_buffer (FILE *f); |
99 | 102 |
100 // Delete a buffer (for unwind-prot). | 103 // Delete a buffer (for unwind-prot). |
101 extern void delete_input_buffer (void *buf); | 104 extern void delete_input_buffer (void *buf); |
102 | 105 |
103 // See if a function file has extra garbage after the end statement. | 106 // See if a function file has extra garbage after the end statement. |
107 // This needs to be defined in lex.l so that it can use yyinput() but | |
108 // it must be called from parse.y. | |
104 extern void check_for_garbage_after_fcn_def (void); | 109 extern void check_for_garbage_after_fcn_def (void); |
105 | 110 |
106 // Return transpose or start a string? | 111 // For communication between the lexer and parser. |
107 extern int quote_is_transpose; | 112 |
108 | 113 class lexical_feedback |
109 // Nonzero means we thing we are looking at the beginning of a | 114 { |
110 // function definition. | 115 public: |
111 extern int beginning_of_function; | 116 |
117 lexical_feedback (void) { init (); } | |
118 | |
119 ~lexical_feedback (void) { } | |
120 | |
121 void init (void); | |
122 | |
123 // Nonzero means we thing we are looking at the beginning of a | |
124 // function definition. | |
125 int beginning_of_function; | |
126 | |
127 // Brace level count. | |
128 int braceflag; | |
129 | |
130 // Another context hack, this time for the plot command's `using', | |
131 // `title', and `with' keywords. | |
132 int cant_be_identifier; | |
133 | |
134 // Nonzero means that we should convert spaces to a comma inside a | |
135 // matrix definition. | |
136 int convert_spaces_to_comma; | |
137 | |
138 // Nonzero means we're in the middle of defining a function. | |
139 int defining_func; | |
140 | |
141 // GAG. Stupid kludge so that [[1,2][3,4]] will work. | |
142 int do_comma_insert; | |
143 | |
144 // Nonzero means we think we are looking at a set command. | |
145 int doing_set; | |
146 | |
147 // Nonzero means we're in the middle of defining a conditional | |
148 // expression. | |
149 int iffing; | |
150 | |
151 // Nonzero means we're looking at the range part of a plot command. | |
152 int in_plot_range; | |
153 | |
154 // Nonzero means we're looking at the using part of a plot command. | |
155 int in_plot_using; | |
156 | |
157 // Nonzero means we're looking at the style part of a plot command. | |
158 int in_plot_style; | |
159 | |
160 // Nonzero means we're looking at an indirect reference to a | |
161 // structure element. | |
162 int looking_at_indirect_ref; | |
163 | |
164 // Nonzero means we're in the middle of defining a loop. | |
165 int looping; | |
166 | |
167 // Nonzero means we need to do some extra lookahead to avoid being | |
168 // screwed by bogus function syntax. | |
169 int maybe_screwed; | |
170 | |
171 // Nonzero means we need to do some extra lookahead to avoid being | |
172 // screwed by bogus function syntax. | |
173 int maybe_screwed_again; | |
174 | |
175 // Nonzero means we've seen something that means we must be past the | |
176 // range part of a plot command. | |
177 int past_plot_range; | |
178 | |
179 // Nonzero means we're working on a plot command. | |
180 int plotting; | |
181 | |
182 // Return transpose or start a string? | |
183 int quote_is_transpose; | |
184 | |
185 private: | |
186 | |
187 lexical_feedback (const lexical_feedback&); | |
188 | |
189 lexical_feedback& operator = (const lexical_feedback&); | |
190 }; | |
191 | |
192 // Flags that need to be shared between the lexer and parser. | |
193 extern lexical_feedback lexer_flags; | |
112 | 194 |
113 #endif | 195 #endif |
114 | 196 |
115 /* | 197 /* |
116 ;;; Local Variables: *** | 198 ;;; Local Variables: *** |