octave-maintainers
[Top][All Lists]
Advanced

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

Re: Changes to lexer invalidate documentation


From: John W. Eaton
Subject: Re: Changes to lexer invalidate documentation
Date: Sun, 12 Apr 2009 19:34:34 -0500

On 12-Apr-2009, Rik wrote:

| The semicolon is used to indicate an end of line (and please don't print
| the results of the previous command) or as a new row indicator in a
| matrix.  The original example is,
| 
| functon y = f (x) y = x^2; endfunction
| 
| which I would think would parse as 
|  A ; B
| where A = 'functon y = f (x) y = x^2'
| and B = 'endfunction'.
| 
| If I follow your lead and type line 'A' individually I get a nice
| clean error message, but when I follow it with 'endfunction' I get
| the generic parse error.  Should the parser really have a forward
| dependency on what lies beyond the semicolon in this case?

The error message comes from the part of Octave that interprets the
syntax tree generated by the parser.  There is no syntax error in A,
so the parser has no reason to complain about that.  But there is a
syntax error in B, and parse errors happen before run-time erorrs, so
you see the parse error instead of the run-time error even though the
parse error occurs after the code that will generate the run-time
error.  This happens because A line like

  A ; B

is parsed into a list of commands and then the list is evaluated, so
that's why you see the parse error for B before the interpreter has a
chance to try to evaluate A.

I don't see how we can change that behavior.  Imagine typing

  missing_function (); x+++

and having your typing interrupted by an error message about the
missing function as you started to type "x+++", or typing

  y = rand (10), x = 1

and getting output (the display of Y) before you finished typing "x = 1".

jwe


reply via email to

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