bugGNU Octave - Bugs: bug #37099, Parser does not accept bare ';' as...


bug #37099: Parser does not accept bare ';' as valid input

Submitted by:  Randy <littlemanrkc>
Submitted on:  Wed 15 Aug 2012 12:43:49 AM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Randy Open/Closed:  Closed
Release:  3.4.3 Operating System:  GNU/Linux

Add a New Comment (Rich Markup)

You are not logged in

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


( Jump to the original submission)

Fri 23 Aug 2013 08:55:44 PM UTC, comment #14: 
John W. Eaton <jwe>
Project Administrator
Thu 22 Aug 2013 04:31:18 PM UTC, comment #13: 

Inside [], I think Matlab accepts multiple semicolons to separate new lines but it does not allow mulitple consecutive commas.  We have no way of knowing whether that was intentional or an accident of the implementation, but whatever, people seem to think this is needed somehow.

The separators in matrix and cell array lists are a completely separate issue from statement separators.

Yes, it would be great if someone other than me really understood the parser.  I think it should be easier now.  The recent rewrite really did simplify a lot of things.  But it is still not trivial, and you need some understanding of bison/yacc parser generators and grammar specifications generally.  In any case, I'm self taught in this area, so it is certainly possible to learn.  It's also possible that my implementation could be better.

In any case, I have a couple of other things I want to do with the parser so I'll try to take a look at the multiple separator issue soon.

John W. Eaton <jwe>
Project Administrator
Thu 22 Aug 2013 04:22:02 PM UTC, comment #12: 

Yes, Matlab ignores the addtional ';' like octave does. So the result for both is [1;2].

Well, the second resource besides jwe is mgoffioul.

Stefan Mahr <dac922>
Thu 22 Aug 2013 04:14:43 PM UTC, comment #11: 

I couldn't quite tell from your answer, does Matlab accept


Or does it error out as it does for the situation with commas?

I haven't taken the time to understand the parser either, but it would be nice if there was a second resource besides jwe who could modify it.  Right now I think he is the only one who fully groks it.

Rik <rik5>
Project Administrator
Thu 22 Aug 2013 09:30:17 AM UTC, comment #10: 

My patch doesn't change this behaviour. Also, MATLAB seems to do the same:

??? [1,,2]
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

Surprisingly my patch also doesn't introduce new parser conflicts. (I learned from jwe, that I should check oct-parse.output before submitting a parser patch.)

However, jwe said he don't want to add an additional 'input2' statement. My first try was to modify the 'input' statement as follows:

input           : opt_sep_no_nl input1
                    parser.stmt_list = $2;

but this doesn't work for some reason. It produces many parser conflicts and you always have to write ';' or ',' in front of the first statement. Maybe someone could explain what's the difference between my patch and the lines above...

I just should keep my hands off the parser. :-)

Stefan Mahr <dac922>
Thu 22 Aug 2013 05:17:34 AM UTC, comment #9: 

Stefan, I didn't push your changeset yet because I'm wondering about the behavior of the following:

ans =



parse error:

  syntax error

>>> [1,,,2]

It seems like these two situations should both produce a syntax error.

Rik <rik5>
Project Administrator
Mon 19 Aug 2013 07:45:04 PM UTC, comment #8: 

Attached patch fixes this bug.

(file #28878)

Stefan Mahr <dac922>
Mon 27 Aug 2012 04:54:40 AM UTC, comment #7: 

Yes i thought i can tell octave to interpret an empty semicolon as a null statement.

Vivek <vivek91m>
Sun 26 Aug 2012 05:36:11 AM UTC, comment #6: 


It looks to me like you are dealing with an empty statement.

Max Brister <fisheater>
Thu 23 Aug 2012 06:26:46 PM UTC, comment #5: 

Thanks Rik for your reply. I will keep in mind all the things you mentioned. Yes, i was also a little worried about making ';' an expression.
Just few days back only i got comfortable with Lexers and Parsers.

Anyone could you please explain the problem specifically, that would be really helpful. I will try to implement the same.

Vivek <vivek91m>
Thu 23 Aug 2012 04:45:54 PM UTC, comment #4: 

I'm going to re-title this issue on the bug tracker to be clearer.

Rik <rik5>
Project Administrator
Thu 23 Aug 2012 02:03:37 PM UTC, comment #3: 


Thanks for submitting a patch.  I'm not applying it because there are some problems with the change you are proposing.

First, I don't think it makes sense to allow ';' to literally be an expression.  A semicolon is a separator between expressions, not an expression itself.  With the change you made, things like ;++ are accepted as valid syntax but cause an immediate segfault.  Even if you avoid the crash, that syntax doesn't make sense to me.

Further, with your patch applied, make doesn't complete properly for me.  It fails when trying to build figures for the documentation.  If I skip that part of the build and run "make check" in the test subdirectory, there are some new test failures.  You should get in the habit of running "make check" after making any change so that you can be sure you haven't introduced any unexpected problems.

Also, a few minor points about submitting changes:

  • Please don't use tabs for indenting in Octave source files.
John W. Eaton <jwe>
Project Administrator
Thu 23 Aug 2012 09:58:30 AM UTC, comment #2: 

I have fixed this bug by adding NULL EXPRESSION to the grammar of Octave, i am attaching the patch for the same.

(file #26420)

Vivek <vivek91m>
Wed 15 Aug 2012 04:13:09 AM UTC, comment #1: 

This bug is actually in the parser, not in eval.  A bare ';' is not interpreted as NULL_INPUT ';' so it produces an error.  Even simpler test code is just to type a semicolon at the octave prompt.

Example code:

octave:1> ;
parse error:

  syntax error

>>> ;

I'm not handy with the parser code so someone else will need to fix this.

Rik <rik5>
Project Administrator
Wed 15 Aug 2012 12:43:49 AM UTC, original submission:  

Under octave, passing ';' as the second parameter to eval() when an exception is thrown causes a parse error. To replicate, if 'b' is not defined:

octave:15> clear b;
octave:16> eval('sin(b)',';');
parse error:

  syntax error

>>> ;


Passing any other statement before the semicolon works ok.
octave:17> eval('sin(b)','a=3;');

Under Matlab R2012A, ';' works as expected:

>> clear b;
>> eval('sin(b)',';')

Randy <littlemanrkc>


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

Attach Files:

Attached Files
file #26420:  bug37099.diff added by vivek91m (1KiB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by dac922 (Updated the item)
  • -email is unavailable- added by fisheater (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by vivek91m (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by littlemanrkc (Submitted the item)

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

    Only project members can vote.




    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-08-23 jwe StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2013-08-19 dac922 Attached File- => Added allow_line_starting_with_seperator.diff, #28878
    2012-08-23 rik5 Summaryeval() with \';\' as second parameter causes parse error => Parser does not accept bare ';' as valid input
    2012-08-23 vivek91m Attached File- => Added bug37099.diff, #26420
    2012-08-15 rik5 Item GroupIncorrect Result => Matlab Compatibility
        StatusNone => Confirmed

    Back to the top

    Powered by Savane 3.5