comparison lwbasic/parser.c @ 31:574931d87abd

Created a function to prettyprint the current lexer token
author lost@l-w.ca
date Thu, 03 Feb 2011 21:28:24 -0700
parents bcd532a90e53
children 49d608aecc4d
comparison
equal deleted inserted replaced
30:bcd532a90e53 31:574931d87abd
82 goto noparms; 82 goto noparms;
83 83
84 paramagain: 84 paramagain:
85 if (state -> lexer_token != token_identifier) 85 if (state -> lexer_token != token_identifier)
86 { 86 {
87 lwb_error("Parameter name expected, got %d, %s\n", state -> lexer_token, state -> lexer_token_string); 87 lwb_error("Parameter name expected, got %s\n", lexer_return_token(state));
88 } 88 }
89 printf("Got <param> = %s\n", state -> lexer_token_string); 89 printf("Got <param> = %s\n", state -> lexer_token_string);
90 lexer(state); 90 lexer(state);
91 91
92 if (state -> lexer_token != token_kw_as) 92 if (state -> lexer_token != token_kw_as)
132 } 132 }
133 133
134 134
135 if (state -> lexer_token != token_eol) 135 if (state -> lexer_token != token_eol)
136 { 136 {
137 lwb_error("EOL expected; found %d, %s\n", state -> lexer_token, state -> lexer_token_string); 137 lwb_error("EOL expected; found %s\n", lexer_return_token(state));
138 } 138 }
139 139
140 140
141 printf("Sub/Func %s, vis %s\n", subname, vis ? "public" : "private"); 141 printf("Sub/Func %s, vis %s\n", subname, vis ? "public" : "private");
142 142
156 156
157 if (issub) 157 if (issub)
158 { 158 {
159 if (state -> lexer_token != token_kw_endsub) 159 if (state -> lexer_token != token_kw_endsub)
160 { 160 {
161 lwb_error("Expecting ENDSUB, got %d (%s)\n", state -> lexer_token, state -> lexer_token_string); 161 lwb_error("Expecting ENDSUB, got %s\n", lexer_return_token(state));
162 } 162 }
163 } 163 }
164 else 164 else
165 { 165 {
166 if (state -> lexer_token != token_kw_endfunction) 166 if (state -> lexer_token != token_kw_endfunction)
167 { 167 {
168 lwb_error("Expecting ENDFUNCTION, got %d (%s)\n", state -> lexer_token, state -> lexer_token_string); 168 lwb_error("Expecting ENDFUNCTION, got %s\n", lexer_return_token(state));
169 } 169 }
170 } 170 }
171 /* output function/sub epilog */ 171 /* output function/sub epilog */
172 emit_epilog(state, 0); 172 emit_epilog(state, 0);
173 173
204 /* EOF is allowed - end of parsing */ 204 /* EOF is allowed - end of parsing */
205 case token_eof: 205 case token_eof:
206 return; 206 return;
207 207
208 default: 208 default:
209 lwb_error("Invalid token %d, %s in global state\n", state -> lexer_token, state -> lexer_token_string); 209 lwb_error("Invalid token '%s' in global state\n", lexer_return_token(state));
210 } 210 }
211 } 211 }
212 } 212 }