caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: luc.maranget@inria.fr (Luc Maranget)
To: "lehalle@miriad" <charles.lehalle@miriadtech.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] ocamllex parametrized parse regexp
Date: Mon, 6 Sep 2004 19:34:40 +0200	[thread overview]
Message-ID: <20040906173440.GB17368@yquem.inria.fr> (raw)
In-Reply-To: <opsdwxscak1j4mhy@tahiti2.miriad.fr>

> Hi,
> 
> I try to use ocamllex like this (I want to have one of the parsing regexp  
> to be read from an external file) :
> 
> 
> {
>   open Printf;;
> 
> }
> let digit = ['0'-'9']
> 
> let mark = ...read in a file...
> 
> rule oaddress outcan = parse
>   | mark as bemark
>       {
>         printf "MARK(%s)" bemark;
>         oaddress outcan lexbuf
>       }
>   | _ as d
>       { printf "Unk[%c]\n" d;
>         oaddress outcan lexbuf
>       }
>   | eof
>       {
>         fprintf outcan "END";
>       }
> 
> Is it possible or useless to try somethink like that ?


ocamllex is a standard compiler, it compiles its input base.mll file into
a base.ml file that implements the lexer.

The language understood by ocamllex remains quite basic. As a consequence
there is no built-in support for what you want.
(Basically the 'let name = regexp' feature can be seen as simple macros).

However, nothing prevents you from generating the appropriate source
(.mll) files before you feed them into ocamllex.

-- Luc

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2004-09-06 17:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-06 15:50 [Caml-list] mod_caml makes Apache segfault Alan Schmitt
2004-09-06 16:02 ` Benjamin Geer
2004-09-06 16:03 ` Richard Jones
2004-09-07  6:50   ` Alan Schmitt
2004-09-07  8:34     ` Richard Jones
2004-11-09 18:02   ` Paul Argentoff
2004-11-10  3:52     ` N. Owen Gunden
2004-11-10  9:35       ` Richard Jones
2004-11-10 15:27         ` Paul Argentoff
2004-11-10 15:25       ` Paul Argentoff
2004-09-06 16:08 ` [Caml-list] ocamllex parametrized parse regexp lehalle@miriad
2004-09-06 17:34   ` Luc Maranget [this message]
2004-09-06 17:49   ` skaller

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=20040906173440.GB17368@yquem.inria.fr \
    --to=luc.maranget@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=charles.lehalle@miriadtech.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;
as well as URLs for NNTP newsgroup(s).