bugGNU Octave - Bugs: bug #44616, Parser report Syntax Error...

 
 

bug #44616: Parser report Syntax Error dependent on Whitespace

Submitted by:  Thomas Foesel <thofoe>
Submitted on:  Tue 24 Mar 2015 10:13:07 AM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: InvalidAssigned to: None
Originator Name: Open/Closed: Closed
Release: 3.8.2Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 24 Mar 2015 01:31:17 PM UTC, comment #3:

Well, it would be easy if commas and semicolons were required as separators between elements, but that's not the choice that the MathWorks made for Matlab and we aim to be compatible, so we are stuck with this behavior.

John W. Eaton <jwe>
Project Administrator
Tue 24 Mar 2015 12:05:12 PM UTC, comment #2:

This is expected behavior. Within a matrix ([...]) or cell ({...}) you cannot have a space between a function identifier and it's arguments. Otherwise it would be difficult to parse something like: { foo (1+2) bar } in a deterministic way.

Michael Goffioul <goffioul>
Project Member
Tue 24 Mar 2015 11:56:10 AM UTC, comment #1:

I did a quick check to make sure and this behavior is the same as Matlab (checked R2010b, R2013a)

John Donoghue <lostbard>
Project Member
Tue 24 Mar 2015 10:13:07 AM UTC, original submission:

The following code should create a cell array with one element, the string "foo" (my original problem was more complex, of course, but I downsized it to that one).

===========
function txt=foo()
txt = 'bar' ;
end

{ foo () }
===========

Executing this yields

===========
syntax error

>>> { foo () }

^
===========

Obviously, the parser dislikes the space character after "foo"; it assumes something similar to "[1 2;3 4]" and does not recognize that in fact this should be a function call. If that character is deleted, the code works. Is such a behavior intended?

Even more strange, it is also OK if the function "foo" is called before outside of the cell array initialization.

Thomas Foesel <thofoe>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by goffioul (Posted a comment)
  • -unavailable- added by lostbard (Posted a comment)
  • -unavailable- added by thofoe (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 24 Mar 2015 01:31:17 PM UTCjweItem GroupSegfault, Bus Error, etc.=>None
      StatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1