Hello, Nicolas Pouillard wrote: > On 4/8/07, Martin Jambon <[EMAIL PROTECTED]> wrote: >> On Sat, 7 Apr 2007, Nicolas Pouillard wrote: >> >>> On 4/5/07, Martin Jambon <[EMAIL PROTECTED]> wrote: >>>> On Thu, 5 Apr 2007, Hugo Ferreira wrote: >>>> > > [...] > >>>> You shouldn't try to do this because the parser looks only one token ahead >>>> to make its decision. If you add a rule that starts from "let" (it has >>>> to), the token which enables the parser to select this rule is in position >>>> 3, so it comes too late. Camlp4 will not warn you about the conflict but >>>> fail during preprocessing because it will choose either the predefined >>>> "let" rule or yours without knowing if it's the right one. >>> In fact it's wrong camlp4 can takes more than one token of look ahead. >>> It will try to match the input with all the firsts terminals of a rule. >> I am not sure I understand, but this is a crucial matter that should be >> thoroughly documented. > > In fact that's not so simple, the implementation is the only reference > and extracting the algorithm is an hard task. > > One can say that camlp4 use all terminals on the beginning of the rule > to choose if it choose to follow this rule. >
Just a comment: my greatest difficulty with camlp4 is twofold: - knowing how the AST maps to the actual Ocaml syntax. - knowing when/where the camlp4 parser does its transformations so that I may alter these transformations (match and replace expressions). Describing this, as Nicolas said, is tantamount to "extracting the algorithm" which is difficult. I think the use of filters is the way to go. For all intents and purposes as a camlp4 user I need *not* know: - what rules (if any) are used - what AST constructs should be matched on - what AST constructs should be generated In effect I write Ocaml "expression" which is automatically matched and I only need write an Ocaml expression to introduce the changes I want. All this using simply using the quotation system. The rules and the AST structure itself should, in my humble opinion, be avoided. This will also allow the underlying camlp4 system to change without unduly affecting user's code. Once again, this is a just a comment. Regards, Hugo F. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ocaml-developer" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/ocaml-developer?hl=en For other OCaml forums, see http://caml.inria.fr/resources/forums.en.html -~----------~----~----~----~------~----~------~--~---
