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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 8D0C6BC0A for ; Tue, 27 Feb 2007 16:29:29 +0100 (CET) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.184]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1RFTTIJ020470 for ; Tue, 27 Feb 2007 16:29:29 +0100 Received: by nf-out-0910.google.com with SMTP id m19so198700nfc for ; Tue, 27 Feb 2007 07:29:28 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer; b=ICYckGnyffsEb52Q/WfMQp438kEtddSB5ybQrepcz0fkzJ4G8zjUS2VBCnah/sjkiiZjAW63YNPM0lTpzKlxo6tPEoS9hLtoMjJNvLDJC1TQP9yiwAKpIn3K4q4/dilnTP5/O8DDT23oXJ8PVzSgjQPEM1potRQODiR9OL88+o8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer; b=X3HpqiEJW9p2rDG0NuAgNj4QU4YDl7MMH1hvuq0XSSOxYH4GpKYmU3w1DxnHADVD2c7n1zNYe7ENUS+nS0KnZyosbKgaRcyENRMGXBmxFZbMJUuvaxXEghGD8MN9keghizgchXZA19gl1bnP3FQgjeUafvj7zbUp5VDFs+GRFhU= Received: by 10.49.93.4 with SMTP id v4mr1292675nfl.1172590168284; Tue, 27 Feb 2007 07:29:28 -0800 (PST) Received: from ?192.168.1.33? ( [83.53.109.173]) by mx.google.com with ESMTP id i1sm2223184nfe.2007.02.27.07.29.26; Tue, 27 Feb 2007 07:29:27 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v752.3) Content-Transfer-Encoding: 7bit Message-Id: <7175FEA6-5CA0-4379-9BBC-CF43504CE733@gmail.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: caml-list@inria.fr From: Joel Reymont Subject: Testing lexers and parsers Date: Tue, 27 Feb 2007 15:29:24 +0000 X-Mailer: Apple Mail (2.752.3) X-j-chkmail-Score: MSGID : 45E44E59.000 on concorde : j-chkmail score : XXX : 5/20 1 0.000 -> 3 X-Miltered: at concorde with ID 45E44E59.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lexers:01 parsers:01 chunks:01 structurally:01 parsing:01 ocaml:01 lexers:01 parsers:01 functions:01 modules:02 ast:02 ast:02 match:02 dependent:04 comparison:04 Folks, I'm trying to incrementally develop a translator using a test-driven approach. I figure I can write a bunch of tests for small chunks of functionality to structurally test expected AST against produced. Once I get to testing the parsing of whole files I think I can print the AST I produce into a file and test this against a target file with the correct printed AST. I can probably run 'cmp' to make sure my files match. This would not be a structural comparison, though, and would be highly dependent on white space which does not strike me as ideal. Is there a better way to accomplish this while still using structural comparison of ASTs? Should I try to read my target AST into OCaml, for example? Should I create a bunch of "target AST" modules with functions that return my target AST? How does everyone else approach testing of lexers and parsers? Thanks, Joel -- http://wagerlabs.com/