🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1263

Re: Query - DCGs and parse error handling

#1263
From: Peter G Ludemann
Date: Thu, 18 Oct 1990 01:25
16 lines
1188 bytes
> 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
Technical Details
Message-ID: <34969@cup.portal.com>
Path: arc1-ca.pugleaf.net!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
References: <6691@castle.ed.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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