Related articles |
---|
User defined precedence for user defined operators. gah@ugcs.caltech.edu (glen herrmannsfeldt) (2006-08-14) |
Re: User defined precedence for user defined operators. tommy.thorn@gmail.com (Tommy Thorn) (2006-08-15) |
Re: User defined precedence for user defined operators. DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-08-15) |
Re: User defined precedence for user defined operators. marcov@stack.nl (Marco van de Voort) (2006-08-15) |
Re: User defined precedence for user defined operators. tmk@netvision.net.il (Michael Tiomkin) (2006-08-15) |
User defined precedence for user defined operators. derek@knosof.co.uk (Derek M Jones) (2006-08-15) |
Re: User defined precedence for user defined operators. torbenm@app-5.diku.dk (2006-08-18) |
From: | "Tommy Thorn" <tommy.thorn@gmail.com> |
Newsgroups: | comp.lang.fortran,comp.compilers |
Date: | 15 Aug 2006 18:51:52 -0400 |
Organization: | Compilers Central |
References: | <1155280055.803334.85200@h48g2000cwc.googlegroups.com> <1155424619.168792.202040@h48g2000cwc.googlegroups.com> <ebpn6e$qbt$1@vilya.larc.nasa.gov> <1hk1yfv.zyn74w12uw4xsN%nospam@see.signature> <44E0B3FF.4040401@cits1.stanford.edu> 06-08-081 |
Keywords: | Fortran, design |
Posted-Date: | 15 Aug 2006 18:51:52 EDT |
glen herrmannsfeldt wrote:
> For new readers to this discussion, the question relates to being
> able to specify the precedence for user defined operators (operator
> overloading), and the possible ambiguities that can cause.
It's a horrid idea, but it can be done. Fx. you could do it by
completely ignoring operator precedence and reorder the tree at some
point after parsing using the type information (this implies you'd
have to keep parenthesis in the parse tree). Doing it on the fly is
probably only possible with a hand-crafted parser.
Notice, this is slightly similar to the problem with parsing C where
(a) - (b) is ambigous and requires knowing if a is a type or a
variable.
Haskell allows you to define brand new operators with a user specified
precedence (though any given operator always has the same preceedence
and associativity regardless of types). The above trick is sometimes
used there.
Tommy
Return to the
comp.compilers page.
Search the
comp.compilers archives again.