From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 56696D176 for ; Mon, 1 Aug 2005 03:45:50 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j711jnUB032068 for ; Mon, 1 Aug 2005 03:45:49 +0200 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 DAA26795 for ; Mon, 1 Aug 2005 03:45:47 +0200 (MET DST) Received: from mail.rsise.anu.edu.au (mail.rsise.anu.edu.au [150.203.208.4]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j711jicV023389 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Mon, 1 Aug 2005 03:45:47 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id 142841E933 for ; Mon, 1 Aug 2005 11:45:42 +1000 (EST) Received: from mail.rsise.anu.edu.au ([150.203.208.4]) by localhost (mail [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 04892-05 for ; Mon, 1 Aug 2005 11:45:42 +1000 (EST) Received: from pulp.rsise.anu.edu.au (pulp.rsise.anu.edu.au [150.203.208.49]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id 035841C06A for ; Mon, 1 Aug 2005 11:45:41 +1000 (EST) Received: by pulp.rsise.anu.edu.au (Postfix, from userid 1560) id E9771296336; Mon, 1 Aug 2005 11:45:38 +1000 (EST) Date: Mon, 1 Aug 2005 11:45:38 +1000 From: Pietro Abate To: ocaml ml Subject: Re: [Caml-list] buidlExpressionParser Message-ID: <20050801014538.GA16537@pulp.anu.edu.au> Mail-Followup-To: Pietro Abate , ocaml ml References: <20050731132119.GA368@pulp.anu.edu.au> <1122853171.6779.134.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1122853171.6779.134.camel@localhost.localdomain> X-Operating-System: GNU/Linux X-Organization: Research School of Information Science and Engineering (Australian National University) User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mail.rsise.anu.edu.au X-Miltered: at nez-perce with ID 42ED7ECD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 42ED7EC8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; anu:01 caml-list:01 parser:01 runtime:01 ocamlfind:01 lexer:01 hmmm:01 regexps:01 nfa:01 token:01 token:01 lexer:01 func:01 parser:01 func:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Mon, Aug 01, 2005 at 09:39:31AM +1000, skaller wrote: > > Is there a better way of doing this ? > Do I understand right: you're leveraging the camlp4 library > code to build a general purpose LL(1) parser which will support > runtime extension? yep, I tought it was a kinda of creative way of using it... now I've to convince ocamlfind to compile it properly :) I'm not sure that this can be a general solution, but for my small calculator-like example works well. > > Does anybody have an example on how to write a simple lexer that I can > > use instead ? > Hmmm ... don't know about 'simple lexer' but I have a library > function that can translate a representation of a labelled sequence > of regexps into a tokeniser. I'll be happy to have a look at this function... > You may want an NFA based interpreter instead though. I was thinking of using the Token interface in the Camlp4 library that is, if f = Token.lexer_func_of_parser maybe your function can be used here ... then the glexer would be something like: { Token.tok_func = f; Token.tok_using = (fun _ -> ()); Token.tok_removing = (fun _ -> ()); Token.tok_match = Token.default_match; Token.tok_text = Token.lexer_text } :) p -- ++ Blog: http://blog.rsise.anu.edu.au/?q=pietro ++ ++ "All great truths begin as blasphemies." -George Bernard Shaw ++ Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html