Mercurial > hg > octave-nkf
changeset 16167:22bb3aa9f025
make push parser interface partially work
* oct-parse.yy: Use USE_OCTAVE_PUSH_PARSER, not USE_PUSH_PARSER.
(octave_parser::~octave_parser): Cast parser state to yypstate*.
(octave_parser::run): Simplify. If USE_OCTAVE_PUSH_PARSER, use push
parser interface, but still require that the lexer is in charge of
gathering input.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 01 Mar 2013 07:18:18 -0500 |
parents | cb80b1d062b1 |
children | 8650eec57e9f |
files | libinterp/parse-tree/oct-parse.yy |
diffstat | 1 files changed, 14 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.yy +++ b/libinterp/parse-tree/oct-parse.yy @@ -1482,15 +1482,15 @@ octave_parser::~octave_parser (void) { -#if defined (USE_PUSH_PARSER) - yypstate_delete (parser_state); +#if defined (OCTAVE_USE_PUSH_PARSER) + yypstate_delete (static_cast<yypstate *> (parser_state)); #endif delete curr_lexer; } void octave_parser::init (void) { -#if defined (USE_PUSH_PARSER) +#if defined (OCTAVE_USE_PUSH_PARSER) parser_state = yypstate_new (); #endif @@ -1502,36 +1502,19 @@ { int status = 0; -#if defined (USE_PUSH_PARSER) - - for (;;) +#if defined (OCTAVE_USE_PUSH_PARSER) + + do { - unwind_protect frame; - - frame.protect_var (current_input_line); - - bool eof = false; - - get_user_input (eof); - - do - { - octave_char = eof ? END_OF_INPUT : octave_lex (); - - if (octave_char == 0) - { - // Attempt to get more input. - status = -1; - break; - } - - status = octave_push_parse (pstate); - } - while (status == YYPUSH_MORE); - - if (status >= 0) - break; + YYSTYPE lval; + + int token = octave_lex (&lval, scanner); + + yypstate *pstate = static_cast<yypstate *> (parser_state); + + status = octave_push_parse (pstate, token, &lval, this); } + while (status == YYPUSH_MORE); #else