octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Parsing Peculiarity


From: John W. Eaton
Subject: Parsing Peculiarity
Date: Mon, 19 Jan 2009 21:04:26 -0500

On 19-Jan-2009, Daniel J Sebald wrote:

| On a fairly recent HG build, something like this gives strange results:
| 
| a = 1
| %b = 2
| b = 3
| %b = 4
| b = 5
| c = length(b)
| 
| It's as though b gets lost because of the comment character.

Try the following patch.

jwe

# HG changeset patch
# User John W. Eaton <address@hidden>
# Date 1232414505 18000
# Node ID 17ef48c699a508ff443e95de5b66389a6aaf6f7b
# Parent  de1b944d5306c53bc425db5709c8247f849068af
lex.l (grab_comment_block): if not reading from a file, bail at first newline 
inside a comment:

diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,7 @@
 2009-01-19  John W. Eaton  <address@hidden>
+
+       * lex.l (grab_comment_block): If not reading input from a file,
+       bail out at first newline inside a comment.
 
        * lex.l (lexer_debug_flag): New static variable.
        (F__lexer_debug_flag__): New function.
diff --git a/src/lex.l b/src/lex.l
--- a/src/lex.l
+++ b/src/lex.l
@@ -1667,6 +1667,20 @@
              at_bol = true;
              current_input_column = 0;
              in_comment = false;
+
+             // FIXME -- bailing out here prevents things like
+             //
+             //    octave> # comment
+             //    octave> x = 1
+             //
+             // from failing at the command line, while still
+             // allowing blocks of comments to be grabbed properly
+             // for function doc strings.  But only the first line of
+             // a mult-line doc string will be picked up for
+             // functions defined on the command line.  We need a
+             // better way of collecting these comments...
+             if (! (reading_fcn_file || reading_script_file))
+               goto done;
            }
        }
       else

reply via email to

[Prev in Thread] Current Thread [Next in Thread]