And of course thanks for all the other replies and versions.<br>This mailing list is *really* active!<br><br><div class="gmail_quote">2009/10/28 Ozgur Akgun <span dir="ltr"><<a href="mailto:ozgurakgun@gmail.com">ozgurakgun@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Even though it was nice to see how it can be implemented, I'll be using the "PS" version :)<br>
I was really close in implementing it myself.<br><br>Anyway thanks for the quick reply.<br><br><div class="gmail_quote">
2009/10/28 S. Doaitse Swierstra <span dir="ltr"><<a href="mailto:doaitse@cs.uu.nl" target="_blank">doaitse@cs.uu.nl</a>></span><div><div></div><div class="h5"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
pToken [] = pSucceed []<br>
pToken (x:xs) = (:) <$> pSym x <*> pToken xs<br>
<br>
pKeyword_Float = pToken "Float"<br>
etc<br><font color="#888888">
<br>
Doaitse<br>
</font><br>
PS: this function has been defined in the module Text.ParserCombinators.UU.Derived<div><div></div><div><br>
<br>
<br>
<br>
On 28 okt 2009, at 17:39, Ozgur wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi everybody,<br>
<br>
I am using the uu-parsinglib to parse a structured language and map<br>
the results to some proper data structures. Thanks to Prof Doaitse<br>
Swierstra (and other authors if any), it is fun to write a parser<br>
using this library.<br>
<br>
I've been sending private mails to Doaitse about my questions, who<br>
kindly gives nice replies everytime. But this time I thought I can ask<br>
my question to the community, and give everyone the chance to benefit<br>
from the answers.<br>
<br>
[After the intro, here comes my real question]<br>
<br>
I am trying to capture the following pattern.<br>
<br>
pKeyword_Int = ( \ _ _ _ -> "int" ) <$> pSym 'i' <*> pSym 'n' <*> pSym<br>
't'<br>
pKeyword_Float = ( \ _ _ _ _ _ -> "float" ) <$> pSym 'f' <*> pSym 'l'<br>
<*> pSym 'o' <*> pSym 'a' <*> pSym 't'<br>
<br>
As you can see there is an obvious pattern if you try to capture a<br>
"keyword". If there were a function called pKeyword taking a string as<br>
an argument and producing the necessary parser, things would be<br>
easier.<br>
<br>
What I mean is,<br>
<br>
pKeyword_Int = pKeyword "int"<br>
pKeyword_Float = pKeyword "float"<br>
<br>
I tried to create this pKeyword function myself but I couldn't manage<br>
to do it.<br>
<br>
I can feel that, one can simply add a "<* pReturn []" to the ends of<br>
every parser and write a recursion with this base condition.<br>
<br>
Any suggestions?<br>
<br>
PS: Actually I'm a little bit uncomfortable since there may be such a<br>
function in the library already :)<br>
</blockquote>
<br>
</div></div></blockquote></div></div></div><br><br clear="all"><br>-- <br><font color="#888888">Ozgur Akgun<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Ozgur Akgun<br>