> And this is the part that I object to. I have quite a number of keywords and > I > don't want to have a bunch of if statements or have a hash table mapping > lowercase to camel case. This would mean having to track the parser (camel > case) > version in two places: the lexer and the parser.
Ahhh ok, I (finally) got it! I believe there is a (partially acceptable) solution, if you are willing to accept having all your keywords in lower-case in the grammar (not in the lexer), ie you match against "buyorsell", "sellshort" etc. Then you can change the functions match_keyword and keyword_conversion as follows: let keyword_conversion tok is_kwd = match tok with SYMBOL s | IDENT s when is_kwd (String.lowercase s) -> KEYWORD s | _ -> tok This will pass lower-cased identifiers to "is_kwd", so "BuyOrSell" becomes a valid keyword. let match_keyword kwd = function KEYWORD kwd' when kwd = String.lowercase kwd' -> true | _ -> false Here kwd is the keyword from the grammar ("buyorsell") and kwd' is the content of the keyword produced by the lexer ("BuyOrSell"), and they match. Cheers, Matthieu _______________________________________________ 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