Fri 23 Aug 2013 08:55:44 PM UTC, comment #14:
I checked in the following change:
http://hg.savannah.gnu.org/hgweb/octave/rev/4c1ae06111c9
|
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.
|
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.
|
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.
|
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:
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:
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. :-)
|
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:
It seems like these two situations should both produce a syntax error.
|
Mon 19 Aug 2013 07:45:04 PM UTC, comment #8:
Attached patch fixes this bug.
(file #28878)
|
Mon 27 Aug 2012 04:54:40 AM UTC, comment #7:
Max.
Yes i thought i can tell octave to interpret an empty semicolon as a null statement.
|
Sun 26 Aug 2012 05:36:11 AM UTC, comment #6:
Vivek,
It looks to me like you are dealing with an empty statement.
|
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.
|
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.
|
Thu 23 Aug 2012 02:03:37 PM UTC, comment #3:
Vivek,
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.
|
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)
|
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:
I'm not handy with the parser code so someone else will need to fix this.
|
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;');
octave:18>
Under Matlab R2012A, ';' works as expected:
>> clear b;
>> eval('sin(b)',';')
>>
|