Related articles |
---|
Dynamic Operators in Prolog jamesbk@saturn.ucsc.edu (1989-04-20) |
Re: Dynamic Operators in Prolog harvard!ogccse.ogc.edu!pase (1989-04-26) |
Re: Dynamic Operators in Prolog nigelh@uvicctr.UVic.ca.UUCP (1989-04-26) |
From: | nigelh@uvicctr.UVic.ca.UUCP (R. Nigel Horspool) |
Newsgroups: | comp.compilers |
Date: | 26 Apr 89 15:30:49 GMT |
References: | <3780@ima.ima.isc.com> |
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
approaches.
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@csr.uvic.ca, nigelh@uvunix.bitnet
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.