From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id B3931BB81 for ; Wed, 7 Dec 2005 09:28:40 +0100 (CET) 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 jB78SecX011566 for ; Wed, 7 Dec 2005 09:28:40 +0100 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 JAA24109 for ; Wed, 7 Dec 2005 09:28:39 +0100 (MET) Received: from mail.tcs.inf.tu-dresden.de (tcs01.inf.tu-dresden.de [141.76.75.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jB78SdJO011563 for ; Wed, 7 Dec 2005 09:28:39 +0100 Received: from localhost (localhost [127.0.0.1]) by mail.tcs.inf.tu-dresden.de (Sun Java System Messaging Server 6.1 HotFix 0.06 (built Nov 11 2004)) with ESMTP id <0IR400I50CVRAY00@mail.tcs.inf.tu-dresden.de> for caml-list@inria.fr; Wed, 07 Dec 2005 09:28:39 +0100 (MET) Received: from tcs01.inf.tu-dresden.de ([127.0.0.1]) by localhost (mail.tcs.inf.tu-dresden.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 00965-09 for ; Wed, 07 Dec 2005 09:28:38 +0100 (MET) Received: from ithif59.inf.tu-dresden.de (ithif59.inf.tu-dresden.de [141.76.75.59]) by mail.tcs.inf.tu-dresden.de (Sun Java System Messaging Server 6.1 HotFix 0.06 (built Nov 11 2004)) with ESMTPS id <0IR400IHZCVQ6R00@mail.tcs.inf.tu-dresden.de> for caml-list@inria.fr; Wed, 07 Dec 2005 09:28:38 +0100 (MET) Received: from tews by ithif59.inf.tu-dresden.de with local (Exim 4.50) id 1EjufG-00077O-Qc for caml-list@inria.fr; Wed, 07 Dec 2005 09:28:38 +0100 Date: Wed, 07 Dec 2005 09:28:38 +0100 From: Hendrik Tews Subject: Re: [Caml-list] LL(n) stream parsers? In-reply-to: To: caml-list@inria.fr Message-id: MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT X-Virus-Scanned: amavisd-new at tcs.inf.tu-dresden.de References: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 X-Miltered: at nez-perce with ID 43969D38.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43969D37.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; hendrik:01 tews:01 tews:01 caml-list:01 parsers:01 camlp:01 parsers:01 camlp:01 parsing:01 3.09.0:01 parsing:01 3.09.0:01 cmo:01 grammar:01 plexer: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 Dmitry Bely writes: It looks like camlp4 can only generate LL(1) parsers. How difficult it would be to extend it to build LL(n) parsers? Camlp4 does some left factorization in the parsing rules. This gives some LL(n) effect: Objective Caml version 3.09.0 # #load "camlp4o.cma";; Camlp4 Parsing version 3.09.0 # #load "pa_extend.cmo";; # let gram = Grammar.gcreate (Plexer.gmake ());; val gram : Grammar.g = # let test = Grammar.Entry.create gram "test";; val test : '_a Grammar.Entry.e = # EXTEND test: [ [ "a"; "b"; "c"; "d" -> print_endline "abcd" | "a"; "b"; "c"; "e" -> print_endline "abce" ] ]; END;; - : unit = () # Grammar.Entry.parse test (Stream.of_string "a b c d");; abcd - : unit = () # Grammar.Entry.parse test (Stream.of_string "a b c e");; abce - : unit = () Bye, Hendrik