caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Peter Scott <sketerpot@chase3000.com>
To: caml-list@pauillac.inria.fr
Subject: [Caml-list] Camlp4 parser question
Date: Fri, 31 Oct 2003 17:49:28 -0700	[thread overview]
Message-ID: <5.2.0.9.0.20031031173948.00b07ff0@127.0.0.1> (raw)

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


                 reply	other threads:[~2003-11-01  0:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5.2.0.9.0.20031031173948.00b07ff0@127.0.0.1 \
    --to=sketerpot@chase3000.com \
    --cc=caml-list@pauillac.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).