From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 563EFBC48 for ; Tue, 5 Apr 2005 18:23:41 +0200 (CEST) Received: from first.in-berlin.de (dialin-145-254-065-220.arcor-ip.net [145.254.65.220]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j35GNeLU029690 for ; Tue, 5 Apr 2005 18:23:40 +0200 Received: by first.in-berlin.de (Postfix, from userid 501) id 0B88ACEDB9; Tue, 5 Apr 2005 18:06:12 +0200 (CEST) Date: Tue, 5 Apr 2005 18:06:12 +0200 From: Oliver Bandel To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] some comments on ocaml{lex,yacc} from a novice's POV Message-ID: <20050405160612.GA605@first.in-berlin.de> References: <49464.202.164.198.46.1112355123.squirrel@www.ivorykite.com> <424DA923.7020106@tfb.com> <50130.202.164.198.46.1112418604.squirrel@www.ivorykite.com> <20050402.163851.88994843.garrigue@math.nagoya-u.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050402.163851.88994843.garrigue@math.nagoya-u.ac.jp> User-Agent: Mutt/1.5.6i X-Miltered: at concorde with ID 4252BB8C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; oliver:01 bandel:01 oliver:01 in-berlin:01 caml-list:01 ocaml:01 tokens:01 corresponds:01 ocaml:01 parsers:01 parsers:01 parser:01 combinators:01 lacks:01 ...:98 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.2 X-Spam-Level: On Sat, Apr 02, 2005 at 04:38:51PM +0900, Jacques Garrigue wrote: > From: "Jack Andrews" [...] > > # calclex.py > > import lex > > tokens = ( 'NUMBER', 'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'LPAREN', 'RPAREN',) > > t_PLUS = r'\+' # in python, the r prefix to a string literal > > t_MINUS = r'-' # means as-is. r'\' in python is "\\" in c > > [snip] > > Interestingly, your example corresponds exactly to the one in the > ocaml tutorial, where it is solved using stream parsers. > Stream parsers are a bit more involved than just writing yacc rules, > but they give you more control on how to combine rules (you can write > parser combinators.) And they are completely integrated in the > language using camlp4. ...which lacks adequate documentation... :( Btw: Is the campl4-tutorial-project growing? Ciao, Oliver