unparsing (continued)

Our unparse rules have a minor problem: they output superflous parentheses.
for expression (1 + 1) * (1 + 1)
they output ((1 + 1) * (1 + 1))

We can solve this by making full use of pattern matching power, adding the following unparse rules:


Times( e1 = Plus(*, *), e2 ) -> [: "(" e1 ") * " e2 ]; Times( e1, e2 = Plus(*, *)) -> [: e1 " * (" e2 ")" ]; Times( e1 = Plus(*, *), e2 = Plus(*, *)) -> [: "(" e1 ") * (" e2 ")" ];

next back overview up


Last updated at 03 February '98 by kimwitu@cs.utwente.nl