From: Nicolas Pouillard <nicolas.pouillard@gmail.com>
To: Jun Furuse <jun.furuse@gmail.com>, caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Is it possible to extend OCaml lexer rules via Camlp4?
Date: Sat, 5 Nov 2011 22:19:05 +0100 [thread overview]
Message-ID: <CALNLti+Y9rqiYhVsJS0BOn8ewqsMRqqkR=kDWzyzZrgs+UTtdA@mail.gmail.com> (raw)
In-Reply-To: <20111103091646.GA24501@solaria.dimino.org>
On Thu, Nov 3, 2011 at 10:16 AM, Jérémie Dimino <jeremie@dimino.org> 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
next prev parent reply other threads:[~2011-11-05 21:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-02 20:34 Jun Furuse
2011-11-02 22:52 ` Gabriel Scherer
2011-11-03 7:12 ` Jun Furuse
2011-11-03 9:16 ` Jérémie Dimino
2011-11-05 21:19 ` Nicolas Pouillard [this message]
2011-11-06 0:58 ` Jun Furuse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALNLti+Y9rqiYhVsJS0BOn8ewqsMRqqkR=kDWzyzZrgs+UTtdA@mail.gmail.com' \
--to=nicolas.pouillard@gmail.com \
--cc=caml-list@inria.fr \
--cc=jun.furuse@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox