caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] Genlex (question and problem)
  2001-11-07  9:42 [Caml-list] Genlex (question and problem) Jeremy Fincher
@ 2001-11-07  9:19 ` Daniel de Rauglaudre
  2001-11-07 13:59   ` Jeremy Fincher
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel de Rauglaudre @ 2001-11-07  9:19 UTC (permalink / raw)
  To: caml-list

Hi,

> First, however, is the question: What's to happen to Genlex once
> camlp4 is integrated into the standard compiler distribution?  Will
> it be deprecated, will it require me to preprocess my files with
> camlp4; how will I have to change my Genlex-using source when I
> upgrade to 3.03?

You have just to preprocess your files using parser with camlp4o.
The module Genlex remains in the OCaml standard library. It is
not obsolete nor deprecated.

> I get "This pattern matches values of type Genlex.token option but
> is here used to match values of type Genlex.token Stream.t option",
> which I *cannot* figure out.

At which location of your source?

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Caml-list] Genlex (question and problem)
@ 2001-11-07  9:42 Jeremy Fincher
  2001-11-07  9:19 ` Daniel de Rauglaudre
  0 siblings, 1 reply; 4+ messages in thread
From: Jeremy Fincher @ 2001-11-07  9:42 UTC (permalink / raw)
  To: caml-list

I've just started using the Genlex module for some simple configuration file parsing, and I've run into a problem.

First, however, is the question: What's to happen to Genlex once camlp4 is integrated into the standard compiler distribution?  Will it be deprecated, will it require me to preprocess my files with camlp4; how will I have to change my Genlex-using source when I upgrade to 3.03?

As far as the probem goes, I can't do much better than include the source that's giving me the type error I can't figure out, so here goes:

----------
let record_lexer = make_lexer ["{"; "}"; "="; ";"] (* this is the lexer I use *)
type channel_user_stats =
    {
      msgs : int;
      chars : int;
      words : int;
      actions : int;
      kicks : int;
      modes : int;
      topics : int;
      joins : int;
    }

let default_channel_user_stats =
  {
    msgs = 0;
    chars = 0;
    words = 0;
    actions = 0;
    kicks = 0;
    modes = 0;
    topics = 0;
    joins = 0;
  }

type channel_user =
    {
      seen : float;
      flags : string;
      karma : int;
      stats : channel_user_stats;
    }

let default_channel_user =
  {
    seen = 0.;
    flags = "";
    karma = 0;
    stats = default_channel_user_stats;
  }

let parse_channel_user =
  let parse_stats =
    let rec parse_inside stats = parser
      | [< 'Ident "msgs"; 'Kwd "="; 'Int i; 'Kwd ";"; rest >] ->
	  parse_inside { stats with msgs = i } rest
      | [< 'Ident "chars"; 'Kwd "="; 'Int i; 'Kwd ";"; rest >] ->
	  parse_inside { stats with chars = i } rest
      | [< 'Ident "words"; 'Kwd "="; 'Int i; 'Kwd ";"; rest >] ->
	  parse_inside { stats with words = i } rest
      | [< 'Ident "actions"; 'Kwd "="; 'Int i; 'Kwd ";"; rest >] ->
	  parse_inside { stats with actions = i } rest
      | [< 'Ident "kicks"; 'Kwd "="; 'Int i; 'Kwd ";"; rest >] ->
	  parse_inside { stats with kicks = i } rest
      | [< 'Ident "modes"; 'Kwd "="; 'Int i; 'Kwd ";"; rest >] ->
	  parse_inside { stats with modes = i } rest
      | [< 'Ident "topics"; 'Kwd "="; 'Int i; 'Kwd ";"; rest >] ->
	  parse_inside { stats with topics = i } rest
      | [< 'Ident "joins"; 'Kwd "="; 'Int i; 'Kwd ";"; rest >] ->
	  parse_inside { stats with joins = i } rest
      | [< >] -> stats
    in
      parser
	| [< 'Kwd "{"; stats = parse_inside default_channel_user_stats;
	     'Kwd "}" >] -> stats
  in
  let rec parse_inside cu = parser
    | [< 'Ident "seen"; 'Kwd "="; 'Int i; 'Kwd ";"; rest >] ->
	parse_inside { cu with seen = (float_of_int i) } rest
    | [< 'Ident "flags"; 'Kwd "="; 'String flags; 'Kwd ";"; rest >] ->
	parse_inside { cu with flags = flags } rest
    | [< 'Ident "stats"; 'Kwd "="; stats = parse_stats; Kwd ";"; rest >] ->
	parse_inside { cu with stats = stats } rest
    | [< 'Ident "karma"; 'Kwd "="; 'Int i; 'Kwd ";"; rest >] ->
	parse_inside { cu with karma = i } rest
    | [< >] -> cu
  in
    parser
      | [< 'Kwd "{"; cu = parse_inside default_channel_user; 'Kwd "}" >] -> cu
----------

I get "This pattern matches values of type Genlex.token option but is here used to match values of type Genlex.token Stream.t option", which I *cannot* figure out.

Thanks,
Jeremy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Genlex (question and problem)
  2001-11-07  9:19 ` Daniel de Rauglaudre
@ 2001-11-07 13:59   ` Jeremy Fincher
  2001-11-07 14:31     ` Jeremy Fincher
  0 siblings, 1 reply; 4+ messages in thread
From: Jeremy Fincher @ 2001-11-07 13:59 UTC (permalink / raw)
  To: Daniel de Rauglaudre; +Cc: caml-list

> > I get "This pattern matches values of type Genlex.token option but
> > is here used to match values of type Genlex.token Stream.t option",
> > which I *cannot* figure out.
> 
> At which location of your source?

Did I really forget that?  Sheesh!  It was late here :)

I get the error on the parse_inside function *after* the parse_stats function (the second one :))  If I comment out this line:

| [< 'Ident "stats"; 'Kwd "="; stats = parse_stats; Kwd ";"; rest >] ->
      parse_inside2 { cu with stats = stats } rest

Then it works.  But I can't see what's wrong with that line.

Thanks,
Jeremy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Genlex (question and problem)
  2001-11-07 13:59   ` Jeremy Fincher
@ 2001-11-07 14:31     ` Jeremy Fincher
  0 siblings, 0 replies; 4+ messages in thread
From: Jeremy Fincher @ 2001-11-07 14:31 UTC (permalink / raw)
  To: caml-list

> I get the error on the parse_inside function *after* the parse_stats function (the second one :))  If I comment out this line:
> 
> | [< 'Ident "stats"; 'Kwd "="; stats = parse_stats; Kwd ";"; rest >] ->
>       parse_inside2 { cu with stats = stats } rest

Looks like I forgot the single quote before the second Kwd.  Sorry to trouble everyone :)

Jeremy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-11-07 13:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-07  9:42 [Caml-list] Genlex (question and problem) Jeremy Fincher
2001-11-07  9:19 ` Daniel de Rauglaudre
2001-11-07 13:59   ` Jeremy Fincher
2001-11-07 14:31     ` Jeremy Fincher

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).