help-octave
[Top][All Lists]
Advanced

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

Re: multiline comments


From: John W. Eaton
Subject: Re: multiline comments
Date: Fri, 15 Apr 2005 11:24:17 -0400

On 15-Apr-2005, Quentin Spencer <address@hidden> wrote:

| I'm not sure if this is what was meant in the original question, but 
| Matlab 7 now supports block comments of the form
| %{
|    commented stuff here
| %}
| 
| As far as I know this has not yet been implemented in octave.

Right.  Well, it is a relatively new addition.

| It may be 
| implemented eventually, but I think it's a low priority for those most 
| actively involved in octave development. I'm sure John would welcome a 
| patch to support this.

Sure, it should not be too hard.  Most of the changes would be in
src/lex.l.  Some possible complications are

  * Do these comments nest?  Do you get this behavior:

      %{ 1
      %{ 2
      %} matches 2
      %} matches 1

   or

      %{ 1
      %{ 2
      %} matches 1
      %} error, warning, or just ignored (it is a valid comment)

  * You must save the text of these comments as you read them, so that
    they can be printed by the parse tree printing code, and you must
    modify the printing code to properly emit the saved comments.

  * You must maintain the line and column number information recorded
    by the lexer when you read the comments.

| Unfortunately I'm not familiar enough with  
| octave's parser to attempt this. In the mean time, as Geordie suggests, 
| there are other workaraounds (my preferred one is if(0) ... end).

Yes, if(0) endif is the more common way of faking block comments.  The
disadvantage is that the text inside the if(0) endif block must be
valid code.  In a block comment, you could have anything except "%}"
at the beginning of a line.

jwe



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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