From: "Jeffrey Loren Shaw" <shawjef3@msu.edu>
To: caml-list@inria.fr
Subject: lazy evaluation of combinator parsers
Date: Fri, 23 Mar 2007 21:28:16 -0400 [thread overview]
Message-ID: <E1HUv3J-0002P1-Bt@sys29.mail.msu.edu> (raw)
Hello fellow Camlers,
I'm trying to write a combinator parser in ocaml that uses lazy evaluation.
My goal is that it won't get stuck on infinite loops. So for instance I want
to be able to parse something like (in regex syntax)
a*
let alt p1 p2 xs = append (p1 xs) (p2 xs)
(* regex ? *)
let opt a = alt a epsilon
let rec recseq a =
seq
a
(recseq a)
(* regex * *)
let rec star a =
recseq (opt a)
However, "star (symbol 'a')" causes a stack overflow. I'm not sure why,
since my seq and alt functions are lazy. seq depends on fold_right, map and
append, and alt depends on append. fold_right, map and append are all lazy.
The definitions of alt and seq contain no Lazy.forces.
sources:
http://www.msu.edu/~shawjef3/combparslazy3.ml
http://www.msu.edu/~shawjef3/lazylist3.ml
I would greatly appreciate any help!
Jeff
next reply other threads:[~2007-03-24 1:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-24 1:28 Jeffrey Loren Shaw [this message]
2007-03-24 6:48 ` [Caml-list] " skaller
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=E1HUv3J-0002P1-Bt@sys29.mail.msu.edu \
--to=shawjef3@msu.edu \
--cc=caml-list@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