[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: multiline comments
From: |
David Bateman |
Subject: |
Re: multiline comments |
Date: |
Fri, 15 Apr 2005 17:38:23 +0200 |
User-agent: |
Mozilla Thunderbird 0.8 (X11/20040923) |
John W. Eaton wrote:
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)
Running the function
function nest ()
%{
disp("1");
%{
disp("2");
%}
disp("3");
%}
end
on matlab v7sp2 displays nothing, so the first case is the way matlab
implements it, and this makes more sense, as you can comment a large
part of already commented code.
* 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
-------------------------------------------------------------
--
David Bateman address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax)
91193 Gif-Sur-Yvette FRANCE
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
-------------------------------------------------------------
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
-------------------------------------------------------------