Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: Looking for a nail
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Hendrik Tews <tews@i...>
Subject: Re: Looking for a nail
Hi,

   From: Ian T Zimmerman <itz@transbay.net>
   Date: Tue, 26 Jan 1999 11:20:47 -0800
   Subject: Re: Looking for a nail
   
    [concerning an oo interface to ocamllex]
   
   No.  Sorry, but I don't want to be forced to use classes.  I want to

Hold on! This was only a suggestion to somebody looking for a
nail! I agree that the possibility of choosing between (or even
mixing) the functional and the oo paradigm is one of the great
advantages of ocaml. Therefore there should always be a
functional version of the standard libray. But, by the same
argument it would be nice, to have an oo version.

   >  - adding start conditions a la flex to ocamllex
   
   I haven't thought of this really hard, but I bet there is already a
   way to do that.  If there isn't, I would think hard again to find a
   cleaner, more functional (less stateful) way to do it.  If the current
   condition is kept in a global as in flex, that just drops again the
   reentrancy that Christian has been working so hard to achieve.

Yes, indeed, you can do the following:

	{
	   type lexer_state_type = A | B
	   let lexer_state = ref A
	}

	rule token = parse
	   ""                           { match !lexer_state with
					    A -> atoken lexbuf
					  | B -> btoken lexbuf
					}

	and atoken = parse ...

But it would be nice to have an intuitive syntax for that.

Bye,

Hendrik