diff 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
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll	Wed Mar 13 02:46:56 2013 -0400
+++ b/libinterp/parse-tree/lex.ll	Wed Mar 13 03:19:35 2013 -0400
@@ -1129,7 +1129,11 @@
 
     int c = curr_lexer->text_yyinput ();
 
-    if (c != EOF)
+    if (c == 1)
+      return -1;
+    else if (c == EOF)
+      return curr_lexer->handle_end_of_input ();
+    else
       {
         curr_lexer->current_input_column++;
 
@@ -1139,8 +1143,6 @@
 
         return LEXICAL_ERROR;
       }
-    else
-      return curr_lexer->handle_end_of_input ();
   }
 
 %%
@@ -3012,3 +3014,24 @@
 
   return status;
 }
+
+int
+octave_push_lexer::fill_flex_buffer (char *buf, unsigned max_size)
+{
+  int status = 0;
+
+  if (input_buf.empty () && ! input_buf.at_eof ())
+    input_buf.fill (std::string (1, static_cast<char> (1)), false);
+ 
+  if (! input_buf.empty ())
+    status = input_buf.copy_chunk (buf, max_size);
+  else
+    {
+      status = YY_NULL;
+
+      if (! input_buf.at_eof ())
+        fatal_error ("octave_base_lexer::fill_flex_buffer failed");
+    }
+
+  return status;
+}