On Tue, 2006-07-18 at 18:17 +1000, skaller wrote:
> On Tue, 2006-07-18 at 17:05 +1000, skaller wrote:
> > On Mon, 2006-07-17 at 17:22 -0700, Erick Tryzelaar wrote:
> > > Here's another: for-else, while-else and break statements
> 
> One more comment on user defined syntax.
> 
> At present, if there is an error ANYWHERE in the
> user code using your extensions, you will just get
> a message like:

[]

> This means the parser tried all the 'whilst' statements,
> and couldn't find one that matched.
> 
> Executable RD parsing is very bad at errors.

> We can do better by left factoring and inserting cuts after
> unique heads.

Ok, I think this now works better: there is a cut when
there is a single alternative so that you can get this:


[EMAIL PROTECTED]:/work/felix/flx$ flx --test ab

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
; always print i ; if i + stride <= last do print "," ; done ; ++ count
done
Syntax Error before token 114 in ab.flx, line 44 col 7
if count > 5 do print " ... " ; break ; done ; i += stride ; finally
print "}" ; otherwise
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
CLIENT ERROR
User Syntax Parse Error parsing statementsx
In ab.flx: line 37, cols 3 to 9
36:   var count = 0;
37:   whilstx i <= last do
      *******
38:     initially

See also ab.flx: line 44, cols 7 to 8
43:       ++count done
44:       if count > 5 do
          **
45:          print " ... ";

In this example there is only one production for 
the statement 'whilstx' (not shown). Whilst parsing
that, the normal Ocaml parser finds an error --
there is a missing semicolon after '++count'
and before 'done'.

The tokeniser error diagnostic shows point the error was found,
and the error is reported at the top level as a client error
with two locations:

(a) the start of the statement being parsed by the RD parser
(b) the point where the parse failed irrevocably

Note that if the statement was changed to 'whilst'
you would not get this detail because there is already
a 'whilst' statement in the library .. there's no way
to tell which one was intended until one of them
is parsed successfully.

It's crude .. but better than before I hope:
it should help making user defined syntax more
useful. The problem is that the main use at the
moment is high level control structures which tend
to be nested, and errors deep in the recursion can end
up failing the top level .. giving you no idea where
the error actually is.

----------------------------------------

I will note there is another problem with errors many
of you will have encountered .. if you mess up
a print statement .. the diagnostic shows you a location
in the macro definition, which isn't very helpful:
you may like to have that, but the point of call is
more useful, assuming the macro is correctly defined.

------------------------------------------

Felix is generally capable of MUCH better diagnostics than
many other languages, because of the heavy emphasis
in the compiler on tracking errors. However, the mechanism
requires manual effort deciding for each error where
to report the problem is .. and sometimes I got lazy
and sometimes I just picked the wrong location.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to