From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA28188 for caml-redist; Thu, 4 May 2000 18:49:13 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA24224 for ; Thu, 4 May 2000 16:49:50 +0200 (MET DST) Received: from firewall.f5.com (firewall.f5.com [207.17.117.200]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id QAA23781 for ; Thu, 4 May 2000 16:49:36 +0200 (MET DST) From: knotwell@f5.com Received: by firewall.f5.com; id HAA00354; Thu, 4 May 2000 07:24:30 GMT Received: from klar.f5.com(192.50.100.9) by firewall.f5.com via smap (4.1) id xma000333; Thu, 4 May 00 07:24:06 GMT Received: by klar.f5.com; (8.8.7/1.1.8.2/18Jul96-1139AM) id HAA22067; Thu, 4 May 2000 07:49:07 -0700 Date: Thu, 4 May 2000 07:49:07 -0700 Message-Id: <200005041449.HAA22067@klar.f5.com> To: caml-list@inria.fr Subject: a parsing question Sender: weis Hello all-- I've been writing a configuration file parser using ocaml's lex and yacc. So far, I've run into two things (actually they both grow out of the same problem) that seem like there should be a better way (NOTE: since I'm new the example will seem pretty contrived): Let's say I have the following data: 40 and I want to parse out the 40 and stuff it into a data structure usable *outside* of parser (assume lexer.mll, parser.mly, and config_test.ml). What I've currently done is the following: (* parser.mly *) (* NOTE: I tried creating a yoyo_time object, but ocamlyacc apparently doesn't like the yoyo_time#set_time syntax *) %{ let yoyo_time = ref 10;; let set_yoyo_time newtime = yoyo_time := (int_of_string newtime);; %} %token YOYO_TIME_BEGIN YOYO_TIME_END INT %start main %type INT %% main: YOYO_TIME_BEGIN INT YOYO_TIME_END { set_yoyo_time $2; $2 } %% ============================= Unfortunately, I don't know how to "export" yoyo_time to parser.mli. My Makefile currently does the following: echo "val yoyo_time: int ref" >> parser.mli While this works fine, I'd like to avoid using Make as a post-processor. I wondered about defining numerous entry points, but I presumed this would force me to be extremely careful about the ordering in my config file. Put another way, am I incorrect in assuming the lexer discards previously unmatched data? Since this is so long, I'll skip the second question--macros. Thanks. --Brad