caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
To: caml-list@inria.fr
Subject: Re : [Caml-list] Re: camlp4 stream parser syntax
Date: Sun, 8 Mar 2009 11:27:24 +0100	[thread overview]
Message-ID: <20090308102724.GC5433@yquem.inria.fr> (raw)
In-Reply-To: <046C7516-62FF-4F46-B2D9-CEA1045132CD@gmail.com>

Hi,

On Sun, Mar 08, 2009 at 09:51:26AM +0000, Joel Reymont wrote:

> I would prefer to use the #2 approach but I'm using a custom lexer  
> built by ocamllex.

Mmm... I am not eventually sure that what I said was correct... I should
test it myself, what I generally do before asserting things... :-)

But I was not clear: I said that you had to program *both* items. It
was not an "or" but an "and"...

But... it was false...

Bsakjfvouveoussasj.... I said nothing... I restart...

A change in the lexer should be sufficient.

If you cannot (or if you don't want):

Only changing the "tok_match" record field (2nd point) would not work
for keywords (defined by "just a string" in Camlp* grammars), because
the lexer *must* recognize all combinations of the identifier as
keywords, implying a change, anyway, in the lexer.

On the other hand, if you can accept that these identifiers are not
keywords (i.e. not reserved names), and if there a token for identifiers,
like "LIDENT" of "UIDENT" in Camlp* proposed lexer (module Plexer in
Camlp5), you can put them in your grammar as (for example):
     LIDENT "delay"
instead of:
     "delay"

In this case, a change of the "tok_match" record field should work.
Define the function:

let my_tok_match =
  function
    (p_con, "") ->
       begin function (con, prm) ->
         if con = p_con then prm else raise Stream.Failure
       end
  | (p_con, p_prm) ->
       begin function (con, prm) ->
         if String.lowercase con = p_con && prm = p_prm then prm
         else raise Stream.Failure
       end
;;

Then look for an identifier named "tok_match" in your code, which
should be a record field, and define that "tok_match" record field as
"my_tok_match".

If you don't find it, perhaps it is implicitely used by another Camlp*
library function. In this case, well, more work may have been done.

-- 
Daniel de Rauglaudre
http://pauillac.inria.fr/~ddr/


  reply	other threads:[~2009-03-08 10:27 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-07 22:38 Joel Reymont
2009-03-07 22:52 ` Joel Reymont
2009-03-07 23:21   ` Re : [Caml-list] " Matthieu Wipliez
2009-03-07 23:42     ` Joel Reymont
2009-03-08  0:40     ` Joel Reymont
2009-03-08  1:08       ` Re : " Matthieu Wipliez
2009-03-08  8:25         ` Joel Reymont
2009-03-08  9:37           ` Daniel de Rauglaudre
2009-03-08  9:51             ` Joel Reymont
2009-03-08 10:27               ` Daniel de Rauglaudre [this message]
2009-03-08 10:35                 ` Joel Reymont
2009-03-08 11:07                   ` Joel Reymont
2009-03-08 11:28                     ` Daniel de Rauglaudre
2009-03-08 11:45           ` Re : Re : " Matthieu Wipliez
2009-03-08 11:52             ` Joel Reymont
2009-03-08 13:33               ` Re : " Matthieu Wipliez
2009-03-08 13:59                 ` Joel Reymont
2009-03-08 14:09                   ` Re : " Matthieu Wipliez
2009-03-08 14:30                     ` Joel Reymont
2009-03-08 15:07                       ` Re : " Matthieu Wipliez
2009-03-08 15:24                         ` Joel Reymont
2009-03-08 15:32                           ` Re : " Matthieu Wipliez
2009-03-08 15:39                             ` Joel Reymont
2009-03-08 15:46                             ` Joel Reymont
2009-03-08 15:55                               ` Re : " Matthieu Wipliez
2009-03-08 16:58                                 ` Joel Reymont
2009-03-08 17:04                                   ` Re : " Matthieu Wipliez
2009-03-08 17:15                                     ` Joel Reymont
2009-03-08  9:34         ` Joel Reymont
2009-03-07 23:52 ` [Caml-list] " Jon Harrop
2009-03-07 23:53   ` Joel Reymont
2009-03-08  0:12     ` Jon Harrop
2009-03-08  0:20       ` Re : " Matthieu Wipliez
2009-03-08  0:29         ` Jon Harrop
2009-03-08  0:30         ` Re : " Joel Reymont
2009-03-08  0:37           ` Re : " Matthieu Wipliez

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=20090308102724.GC5433@yquem.inria.fr \
    --to=daniel.de_rauglaudre@inria.fr \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).