Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
lex: including regex definitions from a separate file
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Oliver Bandel <oliver@f...>
Subject: Re: [Caml-list] lex: including regex definitions from a separate file
Zitat von Sam Steingold <>:

> Hash: SHA1
> I have several lexers in the same directory and I want them to share the
> regexp definitions.
> is there a way to put the regexp definitions in foo.mll and include them
>  in bar.mll?

You can't share the definitions, only the generated scanner-functions
and tables/tokens (but I never looked at these thingas in detail,
I normally only used the scanner functions).

It is possible to have more than one lexer definition
in a ocamllex-file. So, if you not necessarily need
all those seperated files, you can use one *.mll file
and throw in all scanner-definitions.

But be aware on possibly name-problems then,
if some scanner-definitions might have the same name.
As you then have all things in one compilation unit, you can't distinguish
function "token" from another function "token", so you may have to
rename your functions in the scanner.