On Thu, Nov 3, 2011 at 10:16 AM, Jérémie Dimino <[email protected]> wrote: > Hi, > > On Thu, Nov 03, 2011 at 04:12:29PM +0900, Jun Furuse wrote: >> I want to have pcre regexp literals in the same syntax as Perl i.e. >> /hello\sworld\\n/. Currently what we do in OCaml is Pcre.regexp >> "hello\\sworld\\\\n", where the backslash char must be escaped in a >> OCaml string literal. This is lousy for scripting in OCaml.
As said earlier Camlp4's lexer is not extensible. One can change the meaning of the token stream using the token filters but this won't work in your case. The third option is to use quotations this is really the adapted feature for this task. Of course the syntax won't be as concise as /bla/... Regarding OCaml lexing you may be interested in camllexer [1] which is not intended to be extensible but is very small and selfcontained. If you really want to hack your own lexical syntax I suggest you to fork camllexer and change it for your purpose. [1]: https://github.com/np/camllexer Best regards, -- Nicolas Pouillard http://nicolaspouillard.fr -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
