<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/1fdaa5e902b0c73415d567249ed998ad"
  from="Nicolas FRANCOIS &lt;nicolas.francois@f...&gt;"
  author="Nicolas FRANCOIS"
  date="2002-07-12T02:33:12"
  subject="[Caml-list] What&apos;s wrong with my parser ?"
  prev="2002/07/0da4aa869a6e04848c53aefa92f12971"
  next="2002/07/1cbfb9354e107fc23bcc20c58328417a"
  next-in-thread="2002/07/7185ceed122bb848370dcb84ee239d6e"
  prev-thread="2002/07/4e07fd5ea13c7b76f164f1ee5265fa6c"
  next-thread="2002/07/b0c7298c9c0bead77bcf8ed319d71bf4"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] What&apos;s wrong with my parser ?">
<msg 
  url="2002/07/1fdaa5e902b0c73415d567249ed998ad"
  from="Nicolas FRANCOIS &lt;nicolas.francois@f...&gt;"
  author="Nicolas FRANCOIS"
  date="2002-07-12T02:33:12"
  subject="[Caml-list] What&apos;s wrong with my parser ?">
<msg 
  url="2002/07/7185ceed122bb848370dcb84ee239d6e"
  from="John Prevost &lt;j.prevost@c...&gt;"
  author="John Prevost"
  date="2002-07-12T02:42:17"
  subject="Re: [Caml-list] What&apos;s wrong with my parser ?">
</msg>
<msg 
  url="2002/07/895c189fc1924ba0778af55006e0dbc8"
  from="John Prevost &lt;j.prevost@c...&gt;"
  author="John Prevost"
  date="2002-07-12T02:52:48"
  subject="Re: [Caml-list] What&apos;s wrong with my parser ?">
<msg 
  url="2002/07/4646ea3840468a1a992752add8269c3d"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-07-12T07:14:24"
  subject="Re: [Caml-list] What&apos;s wrong with my parser ?">
</msg>
</msg>
<msg 
  url="2002/07/2883b78ed3d95e9729ba61b17cb910fc"
  from="Nicolas FRANCOIS &lt;nicolas.francois@f...&gt;"
  author="Nicolas FRANCOIS"
  date="2002-07-13T11:19:24"
  subject="Re: [Caml-list] What&apos;s wrong with my parser ?">
</msg>
</msg>
</thread>

<contents>
I define a polynom parser like this :

  let rec parse =
    let parse_puissance = parser
      | [&lt; ''^'; e = parse_int &gt;] -&gt; e
      | [&lt; &gt;] -&gt; 1
    in
    let parse_x = parser
      | [&lt; ''X'; e = parse_puissance &gt;] -&gt; e
      | [&lt; &gt;] -&gt; 0
    in
    let parse_coeff = parser
      | [&lt; n = R.parse &gt;] -&gt; n
      | [&lt; &gt;] -&gt; R.one
    in
    let parse_monome = parser
      | [&lt; n = R.parse; e = parse_x &gt;] -&gt;
	  monome n e
      | [&lt; e = parse_x &gt;] -&gt;
	  monome R.one e
    in
      parser
	| [&lt; ''+'; m = parse_monome; p = parse &gt;] -&gt;
	    m ++ p
	| [&lt; ''-'; m = parse_monome; p = parse &gt;] -&gt;
	    (opp m) ++ p
	| [&lt; m = parse_monome; p = parse &gt;] -&gt;
	    m ++ p
	| [&lt; &gt;] -&gt; zero

parse_int and the R.parse functions work OK, and I'll add all the
"_=parse_space" after. But :

# let p1 = P.parse (Stream.of_string "1+X");;
Stack overflow during evaluation (looping recursion?).

What's the problem ?

\bye

-- 

                   Nicolas FRANCOIS
            http://nicolas.francois.free.fr
 A TRUE Klingon programmer does NOT comment his code
-------------------
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

</contents>

</message>

