For Programmers: Free Programming Magazines  


Home > Archive > Prolog > September 2006 > Newbie Question: Reading older grammar rule code...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Newbie Question: Reading older grammar rule code...
Charles Turner

2006-09-17, 9:59 pm

Hi all-

Hope this isn't too much of an RTFM question: I'm pretty new to Prolog
and Grammar Rules, trying to get a piece of code from the mid-80s to
run with GNU-Prolog. The excerpts below come from Louis Odette's
"Compiling Prolog to Forth" published in JFAR, 4/4.

Also, the xerox I have of his paper is not the best, so my ability to
distinguish square "[" from curly "{" braces is quite compromised.

GNU-Prolog gives a compliation error, for example, here at the
asterisked line:

args(Vars, Old, New, Num0, Num1) -->
simple_term(Vars, Old, N1),
* ([','], [Num is Num0+1], args(Vars, N1, New, Num, Num1) |
[New = N1, Num1 is Num0+1]).

which seems fair, considering GNU-Prolog doesn't support "|" as the
disjunction operator. But later on in the code, Odette wrote this:

variable(Vars, Old, ['VAR', Num |Old]) -->
[Var], [char(1, Var, L), ascii(L, M),
(ascii('_', M) ;
ascii('A', _a), ascii('Z', _z), _a =< M, M =< _z),
memberchkN(Var, Vars, 0, Num)], !.

where a ";" is used explicitly: the only instance.

I suppose this could be some sort of typo, but I'm hoping someone might
clarify the use of these operators. Perhaps "|" meant something other
than disjunction for some Prolog(s) in the mid-80s?

Many thanks! Charles Turner

Jan Wielemaker

2006-09-18, 4:00 am

On 2006-09-17, Charles Turner <vze26m98@optonline.net> wrote:
> Hi all-
>
> Hope this isn't too much of an RTFM question: I'm pretty new to Prolog
> and Grammar Rules, trying to get a piece of code from the mid-80s to
> run with GNU-Prolog. The excerpts below come from Louis Odette's
> "Compiling Prolog to Forth" published in JFAR, 4/4.
>
> Also, the xerox I have of his paper is not the best, so my ability to
> distinguish square "[" from curly "{" braces is quite compromised.
>
> GNU-Prolog gives a compliation error, for example, here at the
> asterisked line:
>
> args(Vars, Old, New, Num0, Num1) -->
> simple_term(Vars, Old, N1),
> * ([','], [Num is Num0+1], args(Vars, N1, New, Num, Num1) |
> [New = N1, Num1 is Num0+1]).
>
> which seems fair, considering GNU-Prolog doesn't support "|" as the
> disjunction operator. But later on in the code, Odette wrote this:
>
> variable(Vars, Old, ['VAR', Num |Old]) -->
> [Var], [char(1, Var, L), ascii(L, M),
> (ascii('_', M) ;
> ascii('A', _a), ascii('Z', _z), _a =< M, M =< _z),
> memberchkN(Var, Vars, 0, Num)], !.
>
> where a ";" is used explicitly: the only instance.
>
> I suppose this could be some sort of typo, but I'm hoping someone might
> clarify the use of these operators. Perhaps "|" meant something other
> than disjunction for some Prolog(s) in the mid-80s?


In old systems, | and ; where the same. Actually quite a few today
systems still support |.

--- Jan
Charles Turner

2006-09-18, 7:59 am

Jan Wielemaker wrote:

> In old systems, | and ; where the same. Actually quite a few today
> systems still support |.


Hi Jan-

Thanks for the history lesson/clarification. It seems as though Quintus
at the very least still supports "|" for disjunction.

Still puzzled why Odette would also use ";" in a couple places in the
code, but I guess stranger things have happened in publication!

Best, Charles

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com