[DGD] Question...
Noah Gibbs
angelbob at monkeyspeak.com
Thu Feb 28 01:57:43 CET 2002
> > But for bugs after parsing has occurred, I just have a lot of error
> > checking code so if there's a bug I know what entry it's in -- I make sure
> > my error message tells me. And when doing the DTD structured parsing
> > after the parse_string pass I actually keep a separate parser_error stack
> > of error messages so I can find out exactly what the problem is, and in
> > what entry. It's a lot of error check code, but I wrote it once and now I
> > use it almost everywhere.
>
>
> I don't really understand this paragraph at all, I'm afraid. :)
The code's in my unq_dtd.c program in Phantasmal :-)
My parse_string grammar returns me a structured tree of labelled UNQ
expressions. For instance:
({ "room", ({ "location", "37" }),
({ "bdesc", "a room" }),
({ "gdesc", "a test room" }),
({ "exit", "nw 107 234" }),
({ "number", "bob" })
})
Note this isn't enough for a valid Phantasmal room ;-)
Anyway, that's what you get if it parses as UNQ. Then the UNQ DTD
parser, which does *not* use parse_string, examines structure like the
above and parses it into a better structure. That section doesn't use
parse_string, so I can do better error checking. For instance if your DTD
says that the "number" field of "room" should be an integer, the word
"bob" as an argument to "number" above is going to cause an error. In
particular, the stack returned will look something like:
- "bob" is not a valid integer
- Error parsing field "number"
- Error parsing entry "room"
Since it tells you what field it's parsing, and what the expected type
is, and the string it's unable to deal with, the error is easy to track
down.
Basically, since it doesn't use parse_string it can do a lot of error
checking. I happen to like returning "stacks" of errors like the above so
that I can easily pinpoint the problem.
---
angelbob at monkeyspeak.com
See my page of DGD documentation at
"http://www.angelbob.com/projects/DGD_Page.html"
If you post to the DGD list, you may see yourself there!
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list