Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!usc!apple!portal!cup.portal.com!pgl From: pgl@cup.portal.com (Peter G Ludemann) Newsgroups: comp.lang.prolog Subject: Re: Query - DCGs and parse error handling Message-ID: <34969@cup.portal.com> Date: 18 Oct 90 01:25:39 GMT References: <6691@castle.ed.ac.uk> Organization: The Portal System (TM) Lines: 16 > I have recently started to use Prolog DCGs (Definite Clause Grammars) > to implement a command parser, but have found it very hard to give > effective error messages besides the uninformative 'Parse Error'. For parsing computer languages, I've managed to produce reasonable error messages by adding error productions. There's a fair amount of literature on how to do this -- a readily available text is Wirth's "Programs = Data Structures + Algorithms" which contains an LL(1) [top-down] parser and which uses a simple look-ahead to see if things make sense. If your system supports XGs or similar, you can do lookahead: lookahead(X), [X] --> [X] . which checks for the token X but doesn't consume it. - peter ludemann ludemann@mlpvm1.iinus1.ibm.com