Parser combinator problem

From: Steffen Mazanek <steffen.mazanek_at_unibw.de>
Date: Fri, 08 Feb 2008 11:31:25 +0100

Hello,

I have a question regarding the <*> operator (successive
application) known from parser combinator libraries,

Normally, I would define it as follows:

(<*>)::Parser (res1->res2)->Parser res1->Parser res2
(p1 <*> p2) g = (pv qv, g'')
   where
   (pv, g') = p1 g
   (qv, g'') = p2 g'

However, applied to real input this results in stack overflow
in the Münster Curry Compiler and non- or really late
termination in PACKS.

If I use this formulation, no problems occur:

(p1 <*> p2) g | p1 g =:= (pv,g') & p2 g' =:= (qv, g'') = (pv qv, g'')
   where g',g'',pv,qv free

However, I think, that the latter one is not as intuitive as the
first one, so I wonder why it performs so much better.

Any hints are greatly appreciated!

Regards,
Steffen Mazanek

_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Fr Feb 08 2008 - 14:19:47 CET

This archive was generated by hypermail 2.3.0 : Do Jun 20 2024 - 07:15:09 CEST