... | ... | @@ -237,10 +237,13 @@ Make the corresponding changes as for Section 3. |
|
|
|
|
|
The following is an example implementation of fixity resolution for
|
|
|
Haskell expressions. The function \@resolve@ takes a list consisting
|
|
|
of alternating expressions and operators (an instance of the
|
|
|
\@infixexp@ non-terminal in the context-free grammar), and returns
|
|
|
of alternating expressions and operators; i.e. an instance of the
|
|
|
\@infixexp@ non-terminal in the context-free grammar, and returns
|
|
|
either \@Just e@ where \@e@ is the resolved expression, or \@Nothing@ if
|
|
|
the input does not represent a valid expression.
|
|
|
the input does not represent a valid expression. In a compiler, of
|
|
|
course, it would be better to return more information about the
|
|
|
operators involved for the purposes of producing a useful error message,
|
|
|
but the \@Maybe@ type will suffice to illustrate the algorithm here.
|
|
|
|
|
|
```wiki
|
|
|
data Op = Op String Prec Fixity deriving Eq
|
... | ... | |