Joel Reymont wrote:
> I would like my expression rule to parse "1 + 2 points" as "Plus (1,
> Points 2)".
> 
> I currently have the following, with Points right-associative and at the
> bottom, but it doesn't work. Is this something that Camlp4 can handle?
> 
>     Thanks, Joel
> 
> expr:
>   [ ...
>   | LEFTA
>     [ e1 = expr; "Or"; e2 = expr -> Or (e1, e2)
>     | e1 = expr; "And"; e2 = expr -> And (e1, e2)
>     | e1 = expr; "Mod"; e2 = expr -> Mod (e1, e2)
>     | e1 = expr; "*"; e2 = expr -> Mul (e1, e2)
>     | e1 = expr; "/"; e2 = expr -> Div (e1, e2)
>     | "Not"; e = expr -> Not e
>     ]
>   | RIGHTA
>     [ e = expr; [ "Points"; "Point" ]; i = OPT instr -> Points (e, i) ]
>   ];

I'm sure you mean:

[ "Points" | "Point" ]



Martin

-- 
http://mjambon.com/

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to