[climacs-devel] prolog syntax

Robert Strandh strandh at labri.fr
Mon Mar 28 05:15:26 UTC 2005


Hello, 

I am going to keep this short since my computer is currently
vulnerable to crackers (I am running Knoppix, because my RedHat was
cracked the other day, and I have not gotten around to reinstalling
RedHat yet). 

Christophe Rhodes writes:
 > 
 > I've added the beginnings of a syntax for ISO Prolog.  The commit
 > message lists a number of problems I currently have, but I think I
 > should probably air them here.
 > 
 > The biggest, I think, is in dealing with comments, though in fact it's
 > not clear that the problem is restricted to that.  I believe that
 > there is an assumption in the display code that lexemes contain no
 > whitespace, and in particular contain no #\Newline characters.  

I am not sure that is an assumption, but it is certainly the case for
the existing syntaxes.  However, one can definitely declare that to be
the case.  It is a matter of mapping lexemes to tokens in the
programming language. 

 > This
 > is not really true in Prolog's case; the obvious case is the bracketed
 > /* */ comment, but quoted tokens likewise can contain whitespace.
 > (These cases are analogous, I think, to Common Lisp's #| |# comment
 > and |Symbol With Spaces| -- one might argue over whether the comment
 > is one lexeme or several -- or none -- but I think it's clear that
 > |Symbol With Spaces| is exactly one token).

The obvious solution to this problem is to have grammar rules that
make language tokens (that may contain whitespace) out of lexemes
(that may not). 

 > The incremental lexer that I, erm, cut'n'pasted from html-syntax.lisp
 > doesn't cut it for Prolog, for related reasons: the damaged region
 > from deleting a quoting character is extensive.  I think I can fix
 > this -- it's similar to a problem I've already dealt with in my
 > Tabcode parser.

That is a problem only if one sees a literal character string as a
token.  A better view would be to see the quote character as a lexeme
and the character string as a token produced by grammar rules. 

 > For a variety of reasons, I think, the incremental redisplay stuff
 > doesn't work.  I'm not convinced I understand why. :-/ I encourage
 > interested parties to have a play with Set Syntax SPC Prolog, and see
 > if they can characterize bugs, problems.

Are you talking about McCLIM here?  There are known problems in McCLIM
incremental redisplay.  For one thing, it displays each output record
twice, once with a clipping region and once without. 

 > (There are a number of incompletenesses in the Prolog parser itself
 > that I'm aware of: floating point numbers, escaped quotes in quoted
 > tokens, underscores in tokens, [A,B] list syntax (embarrassingly), and
 > the like.  It is relatively capable, though: see
 > <http://www-jcsu.jesus.cam.ac.uk/~csr21/prolog-climacs.png>,
 > <http://www-jcsu.jesus.cam.ac.uk/~csr21/pretty-prolog.png> and
 > <http://www-jcsu.jesus.cam.ac.uk/~csr21/prolog-comments.png> for eye
 > candy...)

Nice!
-- 
Robert Strandh

---------------------------------------------------------------------
Greenspun's Tenth Rule of Programming: any sufficiently complicated C
or Fortran program contains an ad hoc informally-specified bug-ridden
slow implementation of half of Common Lisp.
---------------------------------------------------------------------



More information about the climacs-devel mailing list