[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Syntax extension of infix languages



Tim Hickey <tim@cs.brandeis.edu> writes:

> On 15 Dec 2001, Eric Kidd wrote:
> > I'm stuck in a terrible bind. :-/
> >
> > I'm designing an infix language, and I want to support syntax
> > extension.  There are some interesting papers in the literature, but
> > most of them seem to have rough edges.
> >
> 
> Prolog uses an extensible infix grammar based on an extension of
> operator grammars. A program can introduce new infix operators with
> specified associativity, precedence, and fixity (infix, prefix, postfix).
> The parser always translates the expressions into operator syntax
> trees in a fairly simple manner.

As far as i know:

- it's quite simple for infix/prefix/postfix operators

- using the same operator for infix/prefix/postfix is simple too 
  (eg: unary and binary minus
    or things like ".." in [1..] [1..2] [..2])

-> this fits quite well in a LR-like parsing.

- things like "if then else" are harder (any standard names? i call them
  multi-ops).
  I've had some problems with them, and would be interested with good
  solutions for this (mine is quite costly, but for now i don't care much :)