From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA00705; Tue, 24 Aug 2004 16:55:27 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA02665 for ; Tue, 24 Aug 2004 16:55:26 +0200 (MET DST) Received: from mwinf0406.wanadoo.fr (smtp4.wanadoo.fr [193.252.22.27]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i7OEtPmL018033 for ; Tue, 24 Aug 2004 16:55:25 +0200 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf0406.wanadoo.fr (SMTP Server) with SMTP id A70871800077 for ; Tue, 24 Aug 2004 16:55:25 +0200 (CEST) Received: from [127.0.0.1] (AGrenoble-152-1-26-31.w82-122.abo.wanadoo.fr [82.122.144.31]) by mwinf0406.wanadoo.fr (SMTP Server) with ESMTP id 3DA4A180010C for ; Tue, 24 Aug 2004 16:55:25 +0200 (CEST) Message-ID: <412B5711.9060604@libertysurf.fr> Date: Tue, 24 Aug 2004 16:56:17 +0200 From: Nicolas Rougnon-Glasson User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list Subject: Re: [Caml-list] (Release) ocamllex tutorial (ver 0.1) References: <007d01c489b1$843acfc0$1501a8c0@hama> <1093339280.15255.495.camel@pelican.wigram> In-Reply-To: <1093339280.15255.495.camel@pelican.wigram> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 412B56DD.004 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 passing:01 recursively:01 ocaml:01 ocaml:01 nicolas:01 nicolas:01 token:01 cope:02 parser:02 literals:02 nested:02 identifier:03 string:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk another interesting example is the use of several lexer functions (like in the ocaml lexer itself...), to analyse properly string literals and nested comments. skaller wrote: >On Tue, 2004-08-24 at 18:07, SooHyoung Oh wrote: > > > >>Any comment will be appreciated. >> >> > >It looks very good! > > > >>This tutorial is work-in-progress. The latest version can be found at >>http://pllab.kaist.ac.kr/~shoh/ocaml/ocamllex_ocamlyacc/ocamllex-tutorial/index.html. >> >> > >First -- you haven't explained how to use the new argument >feature. A good example would be to take the non-reentrant >line counting example and show how to make it re-entrant >by passing an object containing the counters. > >To justify not using a global variable, you can extend >the example to allow for recursively counting #include >files (or something similar :) > >The second thing I'd like to see here is an example >showing the common technique of lexing an identifier >and then using a lookup table to see if it is keyword: >this is done because (a) it is possible and (b) it >simplifies the lexer which otherwise needs a huge >number of states. > >The third thing I'd like to see is a more functional example >where the lexer isn't just executing code for side effects. >All your examples have the lexer tail calling itself: but >most real lexing applications do not do this, instead >you call the lexer repeatedly from a driver loop. > >In particular Ocamlyacc calls Ocamllex to lex one >token at a time. > >Finally -- since your tutorial is Ocaml specific, >I'd like to see some information on lexbufs. >Are they functional? Can I write a backtracking >functional parser that just 'goes backwards' >in the input stream using a lexbuf to allow >re-lexing some input? > >How do i cope with the fact >that lexbufs think they're reading named >files with lines in them .. what if this isn't so? > >This is actually a design fault which is unfortunately >propagated to Ocamlyacc. > > > ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners