caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Hendrik Tews <tews@tcs.inf.tu-dresden.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] LL(n) stream parsers?
Date: Wed, 07 Dec 2005 09:28:38 +0100	[thread overview]
Message-ID: <rllkyx5n0p.fsf@ithif59.inf.tu-dresden.de> (raw)
In-Reply-To: <hd9mpk7a.fsf@mail.ru>

Dmitry Bely <dbely@mail.ru> writes:

   It looks like camlp4 can only generate LL(1) parsers. How difficult it
   would be to extend it to build LL(n) parsers?
   
Camlp4 does some left factorization in the parsing rules. This
gives some LL(n) effect:

          Objective Caml version 3.09.0

  # #load "camlp4o.cma";;
          Camlp4 Parsing version 3.09.0

  # #load "pa_extend.cmo";;
  # let gram = Grammar.gcreate (Plexer.gmake ());;
  val gram : Grammar.g = <abstr>
  # let test = Grammar.Entry.create gram "test";;
  val test : '_a Grammar.Entry.e = <abstr>
  # EXTEND
    test:
      [ [ "a"; "b"; "c"; "d" -> print_endline "abcd"
        | "a"; "b"; "c"; "e" -> print_endline "abce"
      ] ];
  END;;
            - : unit = ()
  # Grammar.Entry.parse test (Stream.of_string "a b c d");;
  abcd
  - : unit = ()
  # Grammar.Entry.parse test (Stream.of_string "a b c e");;
  abce
  - : unit = ()

Bye,

Hendrik


      reply	other threads:[~2005-12-07  8:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-06 10:56 Dmitry Bely
2005-12-07  8:28 ` Hendrik Tews [this message]

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=rllkyx5n0p.fsf@ithif59.inf.tu-dresden.de \
    --to=tews@tcs.inf.tu-dresden.de \
    --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;
as well as URLs for NNTP newsgroup(s).