From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id D8C6ABC69 for ; Tue, 1 May 2007 14:44:32 +0200 (CEST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.174]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l41CiWLc018176 for ; Tue, 1 May 2007 14:44:32 +0200 Received: by ug-out-1314.google.com with SMTP id k3so37993ugf for ; Tue, 01 May 2007 05:44:32 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:resent-message-id:mime-version:content-type:resent-date:message-id:content-transfer-encoding:resent-to:from:subject:resent-from:date:to:x-mailer; b=sEDEmTBNvNjD/A9Lw3CIbbJsoi7oTLG0QbQWndoQGXRUsAmgckH9HIqBAbKgV3SVZp8LNKQaHz/sg2bMVoQM7KjxwYJHOlscBPL0E230hikBARk8YfHUnnJhqGbCM0eloXK1RNCASGwjccxwBdvMdl5Fq1eq1B6Ci9HXdh4l5dU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:resent-message-id:mime-version:content-type:resent-date:message-id:content-transfer-encoding:resent-to:from:subject:resent-from:date:to:x-mailer; b=RuDoUQII0lcr9A+dndMoQSzJCLOot5RrnIzcrCXiZLADl6B9b2hrM50fxykeilxSXHlZ2IlqOZdWNioKHufB5m1eBtBLYLSIasB+6L6/d33j3XYcv2Pz4d1+f160+TGEkIapfzMckwKVtTyNv5XPMWH1+58DgevSidM2eS1VyNQ= Received: by 10.66.244.11 with SMTP id r11mr318265ugh.1178023472291; Tue, 01 May 2007 05:44:32 -0700 (PDT) Received: from ?192.168.1.34? ( [83.52.237.136]) by mx.google.com with ESMTP id 53sm752434ugn.2007.05.01.05.44.29; Tue, 01 May 2007 05:44:30 -0700 (PDT) Resent-Message-Id: <25FB169C-08E5-4B9D-ADA3-E58524759752@gmail.com> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Resent-Date: Tue, 1 May 2007 13:44:28 +0100 Message-Id: <6E3B0D38-E618-49F6-A69A-28524EA6C495@gmail.com> Content-Transfer-Encoding: 7bit Resent-To: Caml List From: Joel Reymont Subject: Functors and sharing a symbol table between a Menhir parser and ocamllex lexer Resent-From: Joel Reymont Date: Tue, 1 May 2007 11:34:48 +0100 To: Francois.Pottier@inria.fr X-Mailer: Apple Mail (2.752.3) X-j-chkmail-Score: MSGID : 46373630.001 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 46373630.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; functors:01 parser:01 ocamllex:01 lexer:01 parser:01 parsers:01 ocamllex:01 lexer:01 struct:01 symtab:01 lexbuf:01 lexing:01 symtab:01 lexbuf:01 curried:01 I want to pass a symbol table to my Menhir parser since I want to run several parsers in parallel and don't want any shared state. I have this in the header of my ocamllex lexer: module P = EasyParser.Make ( struct type t = EasySymtab.symtab_t let putsym = EasySymtab.putsym let infer_type = EasyCheck.infer_type let symtype = EasyCheck.symtype end ) rule token tab = parse ... Above are functions that take a symbol table as their first argument and the lexer (token) takes the symbol table as well. In my parser test harness I have: let parse str = let lexbuf = Lexing.from_string str in let ast = EasyLexer.P.program (EasyLexer.token (symtab ())) lexbuf in List.map EasyLocStrip.strip_stmt ast How do I ensure that the lexer and the parser use the same symbol table? I thought I could parameterize the parser on curried functions like "putsym tab" but then how do I make sure that all functions in Make above take the same tab? If that works than I need to ensure that EasyLexer.token in my parse function takes the same tab that was used by EasyParser.Make. Any suggestions? Thanks, Joel -- http://wagerlabs.com/