[climacs-devel] prolog syntax

Robert Strandh strandh at labri.fr
Tue Mar 29 07:02:02 UTC 2005


Christophe Rhodes writes:
 > 
 > Possibly.  I'm slightly reluctant to go down this route for a number
 > of reasons, most importantly that of maintainability: at the moment,
 > my Prolog grammar and lexer are more-or-less direct transcriptions of
 > the grammar and token syntax in the Prolog standard (modulo the fact
 > that I've been lazy in the lexer with respect to some of the details).

As I said before, I can understand why you are reluctant to modifying
the grammar with respect to that of the Prolog standard.  However, it
was never a goal for the syntax modules of Climacs to be able to
import grammars from standards documents without modification, and I
am not sure it will be possible in general.  The best one can hope for
is some minor tweaking of the grammar; in your case, it would be to
write a grammar rule for a token which would normally be a lexeme. 

I think what it boils down to is whether you want to write an
extremely complicated lexer that stops reading at the end of the
window, or whether you want to add a rule to your grammar.  In
addition, the complicated lexer will likely be slow compared to the
extra grammar rule.  

 > As you know, this Prolog work doesn't exist in a vacuum; I am hoping
 > to hook this work into an adaptation of Peter Norvig's Prolog
 > implementation from _Paradigms of Artificial Intelligence
 > Programming_.  This means that the lexer and parser can't be simply
 > motivated by getting glyphs on the screen: and in particular I think
 > that keeping whitespace characters of language tokens separate will
 > cause more problems in terms of the multiple uses of this parser than
 > it will solve; consider the difficulty of a line comment (Prolog's
 > introduced by #\%, Common Lisp's by #\;), if whitespace is ignored by
 > the lexer: how will the grammar be able to tell when a line-oriented
 > comment ends?

Again, it was never an objective of the syntax modules to be able to
serve as compiler front-ends.  Some minor adaptations are to be
expected for that to be possible. 

 > In any case, if it is the case that there is no absolutely hardwired
 > assumption that whitespace cannot be part of tokens, I shall attempt
 > to see what temporary problems can be fixed.

I think the only assumption that is hardwired at the moment is that a
lexeme does not straddle the top and bot marks of the window.

Take care, 
-- 
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