octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #38758] Parser oddity with 'if' statements and


From: Rik
Subject: [Octave-bug-tracker] [bug #38758] Parser oddity with 'if' statements and spurious display with nargin
Date: Wed, 19 Jun 2013 22:46:18 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0

Update of bug #38758 (project octave):

                 Summary: Spurious display with nargin => Parser oddity with
'if' statements and spurious display with nargin

    _______________________________________________________

Follow-up Comment #2:

I think the problem is also related to the path the parser is taking through
if statements.  For example, using a pair of parentheses around the condition
of the if statement also fixes the problem.


if (nargin >=3), disp('test'); end


Ordinarily code of the form

STATEMENT1, STATEMENT2

is equivalent to

STATEMENT1
STATEMENT2

as the comma just tells the parser that a new statement has begun.  This seems
to be the case here for whatever reason.


if nargin >=3, disp('test'); end
seems to be parsed as
">=3", disp('test');
ans = >=3
test


In fact, I would guess that the problem is that the if conditional is not
being greedy enough and stops after accepting nargin.  Thus, the parsing
results in


if nargin
   ">=3",
   "disp('test');
end



    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?38758>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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