Mercurial > hg > octave-lyh
diff 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 |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -235,7 +235,7 @@ curr_lexer->looking_for_object_index = false; curr_lexer->at_beginning_of_statement = false; - return curr_lexer->push_token (tok, SQ_STRING); + return curr_lexer->handle_token (tok, SQ_STRING); } %{ @@ -3633,16 +3633,21 @@ } int -octave_lexer::push_token (const std::string& name, int tok) +octave_lexer::handle_token (const std::string& name, int tok) { - push_token (new token (name, input_line_number, current_input_column)); - - return handle_token (tok); + token *tok_val = new token (name, input_line_number, current_input_column); + + return handle_token (tok, tok_val); } int -octave_lexer::handle_token (int tok) +octave_lexer::handle_token (int tok, token *tok_val) { + if (! tok_val) + tok_val = new token (input_line_number, current_input_column); + + push_token (tok_val); + current_input_column += flex_yyleng (); quote_is_transpose = false; convert_spaces_to_comma = true;