|Anyone help a newbie at parsing/syntax error reporting? firstname.lastname@example.org (paul.dunn4) (2001-02-01)|
|Date:||1 Feb 2001 17:49:47 -0500|
|Organization:||ntlworld News Service|
|Posted-Date:||01 Feb 2001 17:49:47 EST|
Hi all, having "lurked" for a while in this group, I thought I might
post a message. I'm posting normally through MS Outlook Express, so if
that's the wrong thing to do, then I apologise.
Anyway, I'm currently writing a Sinclair BASIC interpreter. I've
written interpreters before, but as I was the only person expected to
code in them, the error and syntax checking was a little down the list
of priorities. Now however, I am trying to parse a line of basic
code. I have tried a few methods - reducing using rules (# + # becomes
#) but the best one by far that I have tried is BNF - using a parse
tree. It's only simple, but I've come up against a small problem. I
can tell when and why the parser drops out with a syntax error, but I
want to be able to report more than "Expected X, but found Y" errors,
such as "The keyword TO cannot be used to subscript a numeric
However, due to the recursive nature of my BNF checker, I only find
which rule failed, not why. Does anybody have experience of this sort
of thing, and can point me in the right direction?
Return to the
Search the comp.compilers archives again.