From: Jeremy Fincher <fincher.8@osu.edu>
To: caml-list@pauillac.inria.fr
Subject: [Caml-list] Genlex (question and problem)
Date: Wed, 7 Nov 2001 04:42:23 -0500 [thread overview]
Message-ID: <20011107044223.A35732@functor.resnet.ohio-state.edu> (raw)
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
next reply other threads:[~2001-11-07 8:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-07 9:42 Jeremy Fincher [this message]
2001-11-07 9:19 ` Daniel de Rauglaudre
2001-11-07 13:59 ` Jeremy Fincher
2001-11-07 14:31 ` Jeremy Fincher
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=20011107044223.A35732@functor.resnet.ohio-state.edu \
--to=fincher.8@osu.edu \
--cc=caml-list@pauillac.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