Parsing Peculiarity

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Parsing Peculiarity

Daniel Sebald
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.

Dan
Reply | Threaded
Open this post in threaded view
|

Parsing Peculiarity

John W. Eaton
Administrator
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 <[hidden email]>
# 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  <[hidden email]>
+
+ * 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 | Threaded
Open this post in threaded view
|

Re: Parsing Peculiarity

Daniel Sebald
John W. Eaton wrote:

> 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.

> +      if (! (reading_fcn_file || reading_script_file))
> + goto done;

Not the cleanest solution, but it works.

Thanks,

Dan