comparison libinterp/parse-tree/lex.ll @ 16231:2b15ae55c721

put all tokens in the token cache * lex.h, lex.ll (octave_lexer::handle_token (int, token *)): New arg, tok_val, with default value 0. If tok_val is 0, create token object. Put token object in the token cache. (octave_lexer::handle_token (const std::string&, int)): Rename from push_token. Change all uses. Create token and pass to octave_lexer::handle_token (int, tok_val *).
author John W. Eaton <jwe@octave.org>
date Sat, 09 Mar 2013 02:02:22 -0500
parents 4bf907906134
children d8c0f46efaf0 a89cf57ba3a5
comparison
equal deleted inserted replaced
16230:4bf907906134 16231:2b15ae55c721
233 std::string tok = strip_trailing_whitespace (yytext); 233 std::string tok = strip_trailing_whitespace (yytext);
234 234
235 curr_lexer->looking_for_object_index = false; 235 curr_lexer->looking_for_object_index = false;
236 curr_lexer->at_beginning_of_statement = false; 236 curr_lexer->at_beginning_of_statement = false;
237 237
238 return curr_lexer->push_token (tok, SQ_STRING); 238 return curr_lexer->handle_token (tok, SQ_STRING);
239 } 239 }
240 240
241 %{ 241 %{
242 // For this and the next two rules, we're looking at ']', and we 242 // For this and the next two rules, we're looking at ']', and we
243 // need to know if the next token is '=' or '=='. 243 // need to know if the next token is '=' or '=='.
3631 3631
3632 return count_token (tok); 3632 return count_token (tok);
3633 } 3633 }
3634 3634
3635 int 3635 int
3636 octave_lexer::push_token (const std::string& name, int tok) 3636 octave_lexer::handle_token (const std::string& name, int tok)
3637 { 3637 {
3638 push_token (new token (name, input_line_number, current_input_column)); 3638 token *tok_val = new token (name, input_line_number, current_input_column);
3639 3639
3640 return handle_token (tok); 3640 return handle_token (tok, tok_val);
3641 } 3641 }
3642 3642
3643 int 3643 int
3644 octave_lexer::handle_token (int tok) 3644 octave_lexer::handle_token (int tok, token *tok_val)
3645 { 3645 {
3646 if (! tok_val)
3647 tok_val = new token (input_line_number, current_input_column);
3648
3649 push_token (tok_val);
3650
3646 current_input_column += flex_yyleng (); 3651 current_input_column += flex_yyleng ();
3647 quote_is_transpose = false; 3652 quote_is_transpose = false;
3648 convert_spaces_to_comma = true; 3653 convert_spaces_to_comma = true;
3649 3654
3650 return count_token (tok); 3655 return count_token (tok);