Hello
All
Not sure whether
this is the right forum for this question - please excuse and point me in the
right direction if I'm wrong.
I have been
playing with Moose 4.8, downloaded last October, mainly because I am interested
in PetitParser. I have been constructing fairly trivial parsers to get to
understand the system. I took as an example a typical HTML tag, i.e. any
text enclosed in angle brackets <>. My first attempt
was:
($< asParser,
$> asParser not star, $> asParser).
This seemed to send
the parser into a loop, except in the case where there was no text between the
brackets. Floundering around, I tried:
($<
asParser, (PPPredicateObjectParser anyExceptAnyOf: '>') star, $>
asParser).
This worked as
expected, but I was not happy with the apparent clumsiness of the middle term.
So I tried:
($<
asParser, (PPPredicateObjectParser char: $>) not star, $>
asParser).
This again sent the
parser into a loop.
It looks as though I
have some fundamental misunderstanding of the function of 'not' in a parser, or
else it is not working as specified. Could someone kindly explain to an
inquisitive idiot what is going wrong?
Many thanks in
advance
Peter
Kenny |
Hi, For Moose related questions, there exists a dedicated mailing list: Related to your problem, "not" does consume the input. You want to use "negate", which is implemented as: PPParser>>negate "Answer a new parser consumes any input token but the receiver."
^ self not , #any asParser ==> #second Keep the questions flowing :) Cheers, Doru On Sat, Feb 22, 2014 at 5:25 PM, PBK Research <[hidden email]> wrote:
"Every thing has its own flow"
|
Doru
Many thanks. I knew it must be something simple. I was
nearly there, because I had tried 'negated' as an alternative to
'not'.
You may regret the invitation in your last line. The
documentation is rather sparse, so there may well be more questions. I
shall always try to solve it myself first, of course.
Thanks also for the speedy answer - on a Saturday afternoon
too!
Peter From: Pharo-users [mailto:[hidden email]] On Behalf Of Tudor Girba Sent: 22 February 2014 16:38 To: Any question about pharo is welcome Subject: Re: [Pharo-users] Moose: Problem in Petit Parser Hi,
For Moose related questions, there exists a dedicated mailing list:
Related to your problem, "not" does consume the input. You want to use
"negate", which is implemented as:
PPParser>>negate
"Answer a new parser consumes any
input token but the receiver."
^ self not , #any asParser ==>
#second Keep the questions flowing :)
Cheers,
Doru On Sat, Feb 22, 2014 at 5:25 PM, PBK Research <[hidden email]> wrote:
"Every thing has its own flow" |
In reply to this post by Tudor Girba-2
On Sat, Feb 22, 2014 at 6:00 PM, PBK Research <[hidden email]> wrote:
> The documentation is rather sparse did you read the dedicated book chapter of Deep into Pharo? http://deepintopharo.com/ -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill |
Damien
No, I haven't yet looked at that book. My main sources on PetitParser have been: a. Chapter 14 in the Moose Book; b. Two lengthy blog posts by Lukas Renggli referenced in the Moose documentation; c. The chapter in Lukas Renggli's PhD thesis. It may be unfair to call this 'sparse'; the problem is perhaps my inability to understand it. If you think 'Deep into Pharo' will give me more than these sources, I may well get hold of it. Thanks for your help Peter Kenny -----Original Message----- From: Pharo-users [mailto:[hidden email]] On Behalf Of Damien Cassou Sent: 24 February 2014 09:33 To: Any question about pharo is welcome Subject: Re: [Pharo-users] Moose: Problem in Petit Parser On Sat, Feb 22, 2014 at 6:00 PM, PBK Research <[hidden email]> wrote: > The documentation is rather sparse did you read the dedicated book chapter of Deep into Pharo? http://deepintopharo.com/ -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill |
In reply to this post by Damien Cassou
On Mon, Feb 24, 2014 at 12:09 PM, PBK Research <[hidden email]> wrote:
> c. The chapter in Lukas Renggli's PhD thesis. > It may be unfair to call this 'sparse'; the problem is perhaps my inability > to understand it. If you think 'Deep into Pharo' will give me more than > these sources, I may well get hold of it. please have a look at this chapter and please send us feedback (or better send us a patch for the chapter, I can give you access to the book sources). -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill |
Damien
I have downloaded and skimmed through the chapter on PetitParser. It looks fine to me, it is a clear explanation of what PP does, but it does not go beyond what I have already found in the sources I mentioned. I recognised all the worked examples (expression parser, JSON parser etc.) as things I had come across before. I am not sure I had seen the section on testing before; that may mean I had skipped it because I am generally rather lazy about programming tests. What is clear to me, however, is that I was very unfair to say the documentation is sparse. As soon as I looked again at the Moose Book chapter, I saw an example which explained exactly the issue that tripped me up on 'not' vs. 'negate'. In other words, the only problem with the documentation is that I had not read it properly. I shall press on with my experiments, but I shall take good care to read everything I can find before raising queries. Thanks again Peter Kenny -----Original Message----- From: Pharo-users [mailto:[hidden email]] On Behalf Of Damien Cassou Sent: 24 February 2014 12:13 To: Any question about pharo is welcome Subject: Re: [Pharo-users] Moose: Problem in Petit Parser On Mon, Feb 24, 2014 at 12:09 PM, PBK Research <[hidden email]> wrote: > c. The chapter in Lukas Renggli's PhD thesis. > It may be unfair to call this 'sparse'; the problem is perhaps my > inability to understand it. If you think 'Deep into Pharo' will give > me more than these sources, I may well get hold of it. please have a look at this chapter and please send us feedback (or better send us a patch for the chapter, I can give you access to the book sources). -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill |
In reply to this post by Damien Cassou
On Mon, Feb 24, 2014 at 6:01 PM, PBK Research <[hidden email]> wrote:
> but I shall take good care to read everything I can find before > raising queries. asking question is not a problem, please continue, even if you believe the answer is somewhere already. Don't hesitate to use stackoverflow (tag #pharo) for your questions instead of the mailing list. -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill |
Free forum by Nabble | Edit this page |