Re: Compiler tool question

Norman Ramsey <>
18 Jun 1998 11:05:51 -0400

          From comp.compilers

Related articles
Compiler tool question (1998-06-09)
Re: Compiler tool question (1998-06-11)
Re: Compiler tool question (Norman Ramsey) (1998-06-18)
| List of all articles for this month |

From: Norman Ramsey <>
Newsgroups: comp.compilers
Date: 18 Jun 1998 11:05:51 -0400
Organization: University of Virginia Computer Science
References: 98-06-042
Keywords: parse, design

Eric O'Dell <> wrote:
>For new operators, the user will be able to choose characters from a
>special operator character set (the usual C operator characters, plus
>some extras) or alternatively give them names that follow the same
>rules as any other variable or function identifier.

I suggest you follow the Standard ML trick of letting the user declare
any binary function to be infix with specified precedence and
associativity. Your parser should just suck in a list of tokens and
then you run a little operator-precedecnce parser in the semantic
analysis phase. For an example of such a parser that also support
prefix and postfix operators, see the appendix to (which will appear in
SP&E). For a complete translator using this approach, see

>I'd also like to
>be able to define operators that consist of more than one token, like
>the trinary "? :" operator in C, so that ... would be legal

You'd be amazed at how much haacking you can do with just binary infix
operators. For an example of defining

    mumble <== foo <quux> bar


Post a followup to this message

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