From: Fermin Reig <reig@acm.org>
To: ocaml <caml-list@inria.fr>
Cc: Markus Mottl <markus.mottl@gmail.com>
Subject: Re: [Caml-list] Partial parsing
Date: Thu, 27 Jul 2006 23:57:57 +0100 [thread overview]
Message-ID: <44C944F5.6050006@acm.org> (raw)
In-Reply-To: <f8560b80607271537r29bf2ae1j850277cd4e1edafe@mail.gmail.com>
Markus Mottl wrote:
> Hi,
>
> one feature that I'd love to see with our lexing/parsing tools for
> OCaml would be the possibility to perform partial lexing / parsing.
>
> For example, imagine that you read a message from a socket into a
> string buffer, but it is not yet complete. You may not be able to
> know that in advance, because that would require parsing it.
>
> What I'd like to be able to do is to e.g. call a lexer or parser
> function on this buffer, and it will recognize as much as possible
> with the option to continue parsing in another buffer. For this we
> could e.g. define a type "parse_result":
>
> type parse_result =
> | Done of result * int
> | Cont of parse_fun
> and parse_fun = pos : int -> len : int -> string -> parse_result
>
> If a full parse was detected, it would return e.g. "Done (result,
> next_pos)", where "result" is the result of the successful parse, and
> "next_pos" is the position in the buffer that contains the character
> following the successfully parsed text.
> [...]
This sounds like a parsing problem suitable for the parser combinator
approach. There, the result of a parse is a pair where one of the two
components is the remaining of the input string.
Many of the papers and implementations are from the Haskell folk, but I
think there are some in Ocaml as well.
HTH,
Fermin
next prev parent reply other threads:[~2006-07-27 22:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-27 22:37 Markus Mottl
2006-07-27 22:57 ` Fermin Reig [this message]
2006-07-28 13:39 ` [Caml-list] " Sebastien Ferre
2006-07-28 9:58 ` Jean-Marie Gaillourdet
2006-07-28 14:01 ` Markus Mottl
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=44C944F5.6050006@acm.org \
--to=reig@acm.org \
--cc=caml-list@inria.fr \
--cc=markus.mottl@gmail.com \
/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).