bugGNU Octave - Bugs: bug #37132, Parse error with cell arrays

 
 

bug #37132: Parse error with cell arrays

Submitter:  Guillaume <gyom>
Submitted:  Fri 17 Aug 2012 03:00:35 PM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 14 Mar 2013 07:17:58 PM UTC, comment #4: 

jwe has overhauled the parser and the issue seems to be fixed.  Try a Mercurial changeset >= 16303:085976d9ef08.

Rik <rik5>
Group administrator
Tue 16 Oct 2012 03:20:36 PM UTC, comment #3: 

The most likely file is the Bison parser in libinterp/parse-tree/oct-parse.yy.  You might also need to check the lexer which feeds the parser.  The lexer is in the same directory in file lex.ll.

Rik <rik5>
Group administrator
Tue 16 Oct 2012 11:03:52 AM UTC, comment #2: 

Thanks for the confirmation, Rik.

I agree that the ";" workaround is enough to rank this as a minor issue.

Which file in the Octave codebase is dealing with this?

Guillaume <gyom>
Fri 12 Oct 2012 03:27:50 PM UTC, comment #1: 

Confirmed on a recent development tip (10/12/2012).

The syntax you are using is correct.  There is a bug in the parser.  It should treat the newline ("\n") as the equivalent of ";" when deciding whether to place the next element in either the following column or in a new row.

I'm lowering the severity level since there is a current workaround of always using the ";" to indicate that a new row is desired.

Perhaps this is related, but it only happens with cell arrays.  The following code which uses matrices for the inner element, works.


 a = {
> [
> 1
> 2
> ]
> [
> 3
> 4
> ]
> }



Rik <rik5>
Group administrator
Fri 17 Aug 2012 03:00:35 PM UTC, original submission:  

With MATLAB:

>> a={
{
1
2
}
{
2
3
}
}

a =
    {2x1 cell}
    {2x1 cell}


With Octave:

octave> {
> {
> 1
> 2
> }
> {
> 2
> 3
parse error:

  syntax error

>>> 3
    ^


Arguably, the correct syntax might be:

octave:86> a={
> {
> 1;
> 2
> }
> {
> 2;
> 3
> }
> }
a =
{
  [1,1] =
  {
    [1,1] =  1
    [2,1] =  2
  }
  [2,1] =
  {
    [1,1] =  2
    [2,1] =  3
  }
}


or

octave:91> {
> {
> 1
> 2
> };
> {
> 2
> 3
> }
> }
ans =
{
  [1,1] =
  {
    [1,1] =  1
    [2,1] =  2
  }
  [2,1] =
  {
    [1,1] =  2
    [2,1] =  3
  }
}


but I'm still unsure whether the difference in behaviour is due to MATLAB accepting an invalid syntax or a bug in the Octave parser.

Guillaume <gyom>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by gyom (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-03-14 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2012-10-12 rik5 Severity3 - Normal 2 - Minor
        Item GroupMatlab Compatibility Incorrect Result
        StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code