comparison libinterp/parse-tree/lex.ll @ 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 c40a8873c2e7
comparison
equal deleted inserted replaced
16293:57e87ddfee14 16294:0925d1f6875e
1127 1127
1128 curr_lexer->xunput (yytext[0]); 1128 curr_lexer->xunput (yytext[0]);
1129 1129
1130 int c = curr_lexer->text_yyinput (); 1130 int c = curr_lexer->text_yyinput ();
1131 1131
1132 if (c != EOF) 1132 if (c == 1)
1133 return -1;
1134 else if (c == EOF)
1135 return curr_lexer->handle_end_of_input ();
1136 else
1133 { 1137 {
1134 curr_lexer->current_input_column++; 1138 curr_lexer->current_input_column++;
1135 1139
1136 error ("invalid character '%s' (ASCII %d) near line %d, column %d", 1140 error ("invalid character '%s' (ASCII %d) near line %d, column %d",
1137 undo_string_escape (static_cast<char> (c)), c, 1141 undo_string_escape (static_cast<char> (c)), c,
1138 curr_lexer->input_line_number, curr_lexer->current_input_column); 1142 curr_lexer->input_line_number, curr_lexer->current_input_column);
1139 1143
1140 return LEXICAL_ERROR; 1144 return LEXICAL_ERROR;
1141 } 1145 }
1142 else
1143 return curr_lexer->handle_end_of_input ();
1144 } 1146 }
1145 1147
1146 %% 1148 %%
1147 1149
1148 static void 1150 static void
3010 fatal_error ("octave_base_lexer::fill_flex_buffer failed"); 3012 fatal_error ("octave_base_lexer::fill_flex_buffer failed");
3011 } 3013 }
3012 3014
3013 return status; 3015 return status;
3014 } 3016 }
3017
3018 int
3019 octave_push_lexer::fill_flex_buffer (char *buf, unsigned max_size)
3020 {
3021 int status = 0;
3022
3023 if (input_buf.empty () && ! input_buf.at_eof ())
3024 input_buf.fill (std::string (1, static_cast<char> (1)), false);
3025
3026 if (! input_buf.empty ())
3027 status = input_buf.copy_chunk (buf, max_size);
3028 else
3029 {
3030 status = YY_NULL;
3031
3032 if (! input_buf.at_eof ())
3033 fatal_error ("octave_base_lexer::fill_flex_buffer failed");
3034 }
3035
3036 return status;
3037 }