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 OAA00755; Wed, 30 Apr 2003 14:32:25 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 OAA00568 for ; Wed, 30 Apr 2003 14:32:24 +0200 (MET DST) Received: from mail3.tpgi.com.au (mail.tpgi.com.au [203.12.160.59]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h3UCWMH27812 for ; Wed, 30 Apr 2003 14:32:23 +0200 (MET DST) Received: from ozemail.com.au ([203.219.225.209]) (authenticated (0 bits)) by mail3.tpgi.com.au (8.11.6/8.11.6) with ESMTP id h3UCVZr08196; Wed, 30 Apr 2003 22:31:36 +1000 Message-ID: <3EAFC226.7010002@ozemail.com.au> Date: Wed, 30 Apr 2003 22:31:34 +1000 From: John Max Skaller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901 X-Accept-Language: en-us MIME-Version: 1.0 To: Michal Moskal CC: Alan Schmitt , caml-list@inria.fr Subject: Re: [Caml-list] a few lexing questions References: <20030428181348.GM9337@alan-schm1p> <20030428213053.GA23545@roke.freak> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ozemail:01 caml-list:01 michal:01 moskal:01 0400,:01 srcref:01 toxteth:01 glebe:01 2037,:01 9660:01 0850:01 closure:01 nsw:01 snail:02 bytes:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Michal Moskal wrote: > On Mon, Apr 28, 2003 at 02:13:48PM -0400, Alan Schmitt wrote: > >>A second question is about integration this code with other lexing code >>or streams. An iCalendar file cannot have a line that is longer than 75 >>bytes, excluding line break. A line may be broken anywhere as long as >>there is a space at the beginning of the next line, as in: >> >>this is a very lo >> ng line >> >>represents "this is a very long line". As this break may occur anywhere >>(even inside keywords), I assume when writing the lexer these kind of >>lines have been already merged together. I know how to implement the >>merging using a temp file, but I'm looking for a nicer solution (like >>using a stream, or using one lexer to feed the current lexer). Any >>suggestion ? >> > > Maybe Lexing.from_function ? Yes, I do this. In the lexer: .... | "(" { fun state -> state#inbody; [LPAR (state#get_srcref lexbuf)] } .... Notice each executable section is a function accepting the state object. You can form a closure of a method of a lexer state class and pass that to Lexing.from_function, and you call the lexer function with an extra arguemnt like: lex_my_stuff lexbuf state In that way you can (a) pre-process the input (b) maintain state such as the original line number -- John Max Skaller, mailto:skaller@ozemail.com.au snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia. voice:61-2-9660-0850 ------------------- 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