Re: Dynamic Operators in Prolog (R. Nigel Horspool)
26 Apr 89 15:30:49 GMT

          From comp.compilers

Related articles
Dynamic Operators in Prolog (1989-04-20)
Re: Dynamic Operators in Prolog harvard!!pase (1989-04-26)
Re: Dynamic Operators in Prolog (1989-04-26)
| List of all articles for this month |

From: (R. Nigel Horspool)
Newsgroups: comp.compilers
Date: 26 Apr 89 15:30:49 GMT
References: <>
Organization: University of Victoria, Victoria B.C. Canada

I have managed to implement a parser for Prolog and its
dynamically-defined operators using lex & yacc, but it is
extremely messy. Since all the shift-reduce conflicts are
resolved at parser-creation time, there are only two possible

1. Construct a grammar where all possible precedence levels for the
        operators are pre-defined. (But typical Prologs allow 255 or more
          precedence levels.)

2. Have semantic actions attached to production rules that
        look up the operator precedences and associativities.
        The semantic actions then select a shift action or a reduce
        action by telling the lexer to insert extra symbols into the input.
        The extra symbols subsequently cause the parse to follow either a
        shift path or a reduce path.

I implemented #2, but this simple idea has a lot of complications.
I will happily e-mail a short paper giving the full details to
anyone who requests it.

R. Nigel Horspool, nigelh@uvunix.bitnet

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.