caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* LL(n) stream parsers?
@ 2005-12-06 10:56 Dmitry Bely
  2005-12-07  8:28 ` [Caml-list] " Hendrik Tews
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Bely @ 2005-12-06 10:56 UTC (permalink / raw)
  To: caml-list

It looks like camlp4 can only generate LL(1) parsers. How difficult it
would be to extend it to build LL(n) parsers?

- Dmitry Bely


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] LL(n) stream parsers?
  2005-12-06 10:56 LL(n) stream parsers? Dmitry Bely
@ 2005-12-07  8:28 ` Hendrik Tews
  0 siblings, 0 replies; 2+ messages in thread
From: Hendrik Tews @ 2005-12-07  8:28 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-12-07  8:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-06 10:56 LL(n) stream parsers? Dmitry Bely
2005-12-07  8:28 ` [Caml-list] " Hendrik Tews

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).