comparison libinterp/parse-tree/lex.ll @ 16130:421dea028bbf

localize use of yyleng with lexical_feedback member function * lex.h, lex.ll (lexical_feedback::yyleng): New function. (lexical_feedback::handle_number, lexical_feedback::handle_identifier, lexical_feedback::handle_meta_identifier, lexical_feedback::handle_superclass_identifier): Use it.
author John W. Eaton <jwe@octave.org>
date Tue, 26 Feb 2013 16:15:12 -0500
parents 053b0364b507
children 2fd39ab12209
comparison
equal deleted inserted replaced
16129:053b0364b507 16130:421dea028bbf
1483 lexical_feedback::flex_yytext (void) 1483 lexical_feedback::flex_yytext (void)
1484 { 1484 {
1485 return yytext; 1485 return yytext;
1486 } 1486 }
1487 1487
1488 int
1489 lexical_feedback::flex_yyleng (void)
1490 {
1491 return yyleng;
1492 }
1493
1488 // GAG. 1494 // GAG.
1489 // 1495 //
1490 // If we're reading a matrix and the next character is '[', make sure 1496 // If we're reading a matrix and the next character is '[', make sure
1491 // that we insert a comma ahead of it. 1497 // that we insert a comma ahead of it.
1492 1498
2506 at_beginning_of_statement = false; 2512 at_beginning_of_statement = false;
2507 2513
2508 curr_lexer->push_token (new token (value, yytxt, input_line_number, 2514 curr_lexer->push_token (new token (value, yytxt, input_line_number,
2509 current_input_column)); 2515 current_input_column));
2510 2516
2511 current_input_column += yyleng; 2517 current_input_column += flex_yyleng ();
2512 2518
2513 do_comma_insert_check (); 2519 do_comma_insert_check ();
2514 } 2520 }
2515 2521
2516 // We have seen a backslash and need to find out if it should be 2522 // We have seen a backslash and need to find out if it should be
3238 cls.empty () ? 0 : &(symbol_table::insert (cls)), 3244 cls.empty () ? 0 : &(symbol_table::insert (cls)),
3239 pkg.empty () ? 0 : &(symbol_table::insert (pkg)), 3245 pkg.empty () ? 0 : &(symbol_table::insert (pkg)),
3240 input_line_number, current_input_column)); 3246 input_line_number, current_input_column));
3241 3247
3242 convert_spaces_to_comma = true; 3248 convert_spaces_to_comma = true;
3243 current_input_column += yyleng; 3249 current_input_column += flex_yyleng ();
3244 3250
3245 return SUPERCLASSREF; 3251 return SUPERCLASSREF;
3246 } 3252 }
3247 3253
3248 int 3254 int
3272 (new token (cls.empty () ? 0 : &(symbol_table::insert (cls)), 3278 (new token (cls.empty () ? 0 : &(symbol_table::insert (cls)),
3273 pkg.empty () ? 0 : &(symbol_table::insert (pkg)), 3279 pkg.empty () ? 0 : &(symbol_table::insert (pkg)),
3274 input_line_number, current_input_column)); 3280 input_line_number, current_input_column));
3275 3281
3276 convert_spaces_to_comma = true; 3282 convert_spaces_to_comma = true;
3277 current_input_column += yyleng; 3283 current_input_column += flex_yyleng ();
3278 3284
3279 return METAQUERY; 3285 return METAQUERY;
3280 } 3286 }
3281 3287
3282 // Figure out exactly what kind of token to return when we have seen 3288 // Figure out exactly what kind of token to return when we have seen
3290 3296
3291 char *yytxt = flex_yytext (); 3297 char *yytxt = flex_yytext ();
3292 3298
3293 std::string tok = strip_trailing_whitespace (yytxt); 3299 std::string tok = strip_trailing_whitespace (yytxt);
3294 3300
3295 int c = yytxt[yyleng-1]; 3301 int c = yytxt[flex_yyleng()-1];
3296 3302
3297 bool cont_is_spc = (eat_continuation () != lexical_feedback::NO_WHITESPACE); 3303 bool cont_is_spc = (eat_continuation () != lexical_feedback::NO_WHITESPACE);
3298 3304
3299 int spc_gobbled = (cont_is_spc || c == ' ' || c == '\t'); 3305 int spc_gobbled = (cont_is_spc || c == ' ' || c == '\t');
3300 3306
3314 3320
3315 quote_is_transpose = true; 3321 quote_is_transpose = true;
3316 convert_spaces_to_comma = true; 3322 convert_spaces_to_comma = true;
3317 looking_for_object_index = true; 3323 looking_for_object_index = true;
3318 3324
3319 current_input_column += yyleng; 3325 current_input_column += flex_yyleng ();
3320 3326
3321 return STRUCT_ELT; 3327 return STRUCT_ELT;
3322 } 3328 }
3323 3329
3324 at_beginning_of_statement = false; 3330 at_beginning_of_statement = false;
3345 else 3351 else
3346 { 3352 {
3347 curr_lexer->push_token (new token (tok, input_line_number, 3353 curr_lexer->push_token (new token (tok, input_line_number,
3348 current_input_column)); 3354 current_input_column));
3349 3355
3350 current_input_column += yyleng; 3356 current_input_column += flex_yyleng ();
3351 quote_is_transpose = false; 3357 quote_is_transpose = false;
3352 convert_spaces_to_comma = true; 3358 convert_spaces_to_comma = true;
3353 looking_for_object_index = true; 3359 looking_for_object_index = true;
3354 3360
3355 return FCN_HANDLE; 3361 return FCN_HANDLE;
3361 3367
3362 if (kw_token) 3368 if (kw_token)
3363 { 3369 {
3364 if (kw_token >= 0) 3370 if (kw_token >= 0)
3365 { 3371 {
3366 current_input_column += yyleng; 3372 current_input_column += flex_yyleng ();
3367 quote_is_transpose = false; 3373 quote_is_transpose = false;
3368 convert_spaces_to_comma = true; 3374 convert_spaces_to_comma = true;
3369 looking_for_object_index = false; 3375 looking_for_object_index = false;
3370 } 3376 }
3371 3377
3440 do_comma_insert_check (); 3446 do_comma_insert_check ();
3441 3447
3442 maybe_unput_comma (spc_gobbled); 3448 maybe_unput_comma (spc_gobbled);
3443 } 3449 }
3444 3450
3445 current_input_column += yyleng; 3451 current_input_column += flex_yyleng ();
3446 3452
3447 if (tok != "__end__") 3453 if (tok != "__end__")
3448 looking_for_object_index = true; 3454 looking_for_object_index = true;
3449 3455
3450 return NAME; 3456 return NAME;