From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA30332; Sat, 1 Nov 2003 01:30:18 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 BAA30450 for ; Sat, 1 Nov 2003 01:30:17 +0100 (MET) Received: from chase3000.com (mercury.chase3000.com [12.36.212.25]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hA10UG127883 for ; Sat, 1 Nov 2003 01:30:16 +0100 (MET) Received: from skeeter.chase3000.com ([172.16.11.212]) by chase3000.com ([12.36.212.25]) with SMTP (MDaemon.PRO.v6.7.6.R) for ; Fri, 31 Oct 2003 17:29:06 -0700 Message-Id: <5.2.0.9.0.20031031173948.00b07ff0@127.0.0.1> X-Sender: mail.chase3000.com:sketerpot@127.0.0.1 X-Mailer: QUALCOMM Windows Eudora Version 5.2.0.9 Date: Fri, 31 Oct 2003 17:49:28 -0700 To: caml-list@pauillac.inria.fr From: Peter Scott Subject: [Caml-list] Camlp4 parser question Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-MDRemoteIP: 172.16.11.212 X-Return-Path: sketerpot@chase3000.com X-MDaemon-Deliver-To: caml-list@pauillac.inria.fr X-Loop: caml-list@inria.fr X-Spam: no; 0.00; camlp:01 int:01 syntax:02 syntax:02 match:02 parser:02 parser:02 tree:02 interpreter:03 variable:03 abstract:03 let:04 let:04 parse:04 structure:06 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I'm making an interpreter for my own language. I have it to the point where it can parse the syntax of my language, make an abstract syntax tree, and evaluate it. The problem is that the program is structured as a list of lines, and I have no way of denoting block structure for these lines. The consequence: I can't have control flow in my language. I'm trying to get block structure in my internal representation. Here is what I'm trying to do, boiled down to a simple example: type section = Num of int | Block of section list;; let testStream = [< '"1"; '"2"; '"3"; '"beginblock"; '"4"; '"5"; '"6"; '"endblock"; '"7"; '"8"; '"9" >];; let whatIWant = [Num 1; Num 2; Num 3; Block [Num 4; Num 5; Num 6]; Num 7; Num 8; Num 9];; I want (in my example) to change the "beginblock"..."endblock" into Block [...]. How would you do this with a parser? I don't know if a parser can match a variable number of elements until it reaches some delimiter telling it to stop, but that's what I want to do. Thank you, -Peter ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners