Mercurial > hg > octave-nkf
comparison libinterp/parse-tree/oct-parse.in.yy @ 16294:0925d1f6875e
push parser/lexer interface
* lex.h, lex.ll (octave_push_lexer): New class.
(octave_base_lexer:is_push_lexer, octave_base_lexer::at_end_of_file,
octave_base_lexer::at_end_of_buffer): New functions.
(.): Handle special character (ASCII 0x01) that
octave_push_lexer::fill_flex_buffer returns for an end-of-buffer
condition.
* parse.h, oct-parse.in.yy (octave_push_parser): New class.
(octave_base_parser::parser_state): Move to octave_push_parser class.
(octave_base_parser::~octave_base_parser, octave_base_parser::init):
Delete special case for push parser.
* configure.ac (--enable-push-parser): Delete option handling. Both
push and pull parser interfaces will always be defined.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 13 Mar 2013 03:19:35 -0400 |
parents | 57e87ddfee14 |
children | a4af67e0d22c |
comparison
equal
deleted
inserted
replaced
16293:57e87ddfee14 | 16294:0925d1f6875e |
---|---|
1448 parser.bison_error (s); | 1448 parser.bison_error (s); |
1449 } | 1449 } |
1450 | 1450 |
1451 octave_base_parser::~octave_base_parser (void) | 1451 octave_base_parser::~octave_base_parser (void) |
1452 { | 1452 { |
1453 #if defined (OCTAVE_USE_PUSH_PARSER) | |
1454 yypstate_delete (static_cast<yypstate *> (parser_state)); | |
1455 #endif | |
1456 | |
1457 delete stmt_list; | 1453 delete stmt_list; |
1458 | 1454 |
1459 delete &lexer; | 1455 delete &lexer; |
1460 } | 1456 } |
1461 | 1457 |
1462 void octave_base_parser::init (void) | 1458 void octave_base_parser::init (void) |
1463 { | 1459 { |
1464 #if defined (OCTAVE_USE_PUSH_PARSER) | |
1465 parser_state = yypstate_new (); | |
1466 #endif | |
1467 | |
1468 LEXER = &lexer; | 1460 LEXER = &lexer; |
1469 } | 1461 } |
1470 | 1462 |
1471 void | 1463 void |
1472 octave_base_parser::reset (void) | 1464 octave_base_parser::reset (void) |
3158 | 3150 |
3159 int | 3151 int |
3160 octave_parser::run (void) | 3152 octave_parser::run (void) |
3161 { | 3153 { |
3162 return octave_parse (*this); | 3154 return octave_parse (*this); |
3155 } | |
3156 | |
3157 octave_push_parser::~octave_push_parser (void) | |
3158 { | |
3159 yypstate_delete (static_cast<yypstate *> (parser_state)); | |
3160 } | |
3161 | |
3162 void | |
3163 octave_push_parser::init (void) | |
3164 { | |
3165 parser_state = yypstate_new (); | |
3166 | |
3167 octave_base_parser::init (); | |
3168 } | |
3169 | |
3170 // Parse input from INPUT. Pass TRUE for EOF if the end of INPUT should | |
3171 // finish the parse. | |
3172 | |
3173 int | |
3174 octave_push_parser::run (const std::string& input, bool eof) | |
3175 { | |
3176 int status = -1; | |
3177 | |
3178 dynamic_cast<octave_push_lexer&> (lexer).append_input (input, eof); | |
3179 | |
3180 do | |
3181 { | |
3182 YYSTYPE lval; | |
3183 | |
3184 int token = octave_lex (&lval, scanner); | |
3185 | |
3186 if (token < 0) | |
3187 { | |
3188 if (! eof && lexer.at_end_of_buffer ()) | |
3189 { | |
3190 status = -1; | |
3191 break; | |
3192 } | |
3193 } | |
3194 | |
3195 yypstate *pstate = static_cast<yypstate *> (parser_state); | |
3196 | |
3197 status = octave_push_parse (pstate, token, &lval, *this); | |
3198 } | |
3199 while (status == YYPUSH_MORE); | |
3200 | |
3201 return status; | |
3163 } | 3202 } |
3164 | 3203 |
3165 static void | 3204 static void |
3166 safe_fclose (FILE *f) | 3205 safe_fclose (FILE *f) |
3167 { | 3206 { |