Hello, I need some help with petitparser. I encountered 2 problems. Here they are: - I don't find to way in petitparser to: parse every string except a list of strings. For example, I want to parse all string except 'string' and 'STRING'. - I don't find a way to parse a string without taking care of its case. For example, I want to parse 'string', 'STRING', 'String', 'stRINg', etc ... I hope you'll can help me :) Adrien. _________________________________________________________________ La boîte mail NOW Génération vous permet de réunir toutes vos boîtes mail dans Hotmail ! http://www.windowslive.fr/hotmail/nowgeneration/
Hi Adrien 2010/6/1 Adrien BARREAU <abarreau.dev@live.fr>:
Hello,
I need some help with petitparser. I encountered 2 problems. Here they are:
- I don't find to way in petitparser to: parse every string except a list of strings. For example, I want to parse all string except 'string' and 'STRING'.
Something like... ( 'string' asParser / 'STRING' asParser ) negate matches: 'STRING' ( 'string' asParser / 'STRING' asParser ) negate matches: 'STING'
- I don't find a way to parse a string without taking care of its case. For example, I want to parse 'string', 'STRING', 'String', 'stRINg', etc ...
you may lowercase your input String with #asLowercase? Hope it helps. Hernán
- I don't find to way in petitparser to: parse every string except a list of strings. For example, I want to parse all string except 'string' and 'STRING'.
The logical #not parser helps you here: ('string' asParser / 'STRING' asParser) not , #letter star plus
- I don't find a way to parse a string without taking care of its case. For example, I want to parse 'string', 'STRING', 'String', 'stRINg', etc ...
This is currently not supported out of the box. You could add it by subclassing PRLiteralCollectionParser and compare the strings with #sameAs: instead of #=. If this turns out to be generally useful we should maybe add it to the core framework? Lukas -- Lukas Renggli www.lukas-renggli.ch
I've added case-insensitive matching to the latest version of PetitParser-lr.173. I am not entirely happy with the implementation itself, but the API is ok and will be stable. By default all matches are case-sensitive, but you can tell character and string parsers to match case insensitive: " matches 'a' and 'A' " $a asParser caseInsensitive " matches 'abc', 'AbC', 'Abc', ... " 'abc' asParser caseInsensitive Hope this helps. Lukas On 1 June 2010 17:29, Lukas Renggli <renggli@gmail.com> wrote:
- I don't find to way in petitparser to: parse every string except a list of strings. For example, I want to parse all string except 'string' and 'STRING'.
The logical #not parser helps you here:
  ('string' asParser / 'STRING' asParser) not , #letter star plus
- I don't find a way to parse a string without taking care of its case. For example, I want to parse 'string', 'STRING', 'String', 'stRINg', etc ...
This is currently not supported out of the box. You could add it by subclassing PRLiteralCollectionParser and compare the strings with #sameAs: instead of #=. If this turns out to be generally useful we should maybe add it to the core framework?
Lukas
-- Lukas Renggli www.lukas-renggli.ch
-- Lukas Renggli www.lukas-renggli.ch
Cool. Adrien did a full bibtext parser :) Stef On Jun 1, 2010, at 10:35 PM, Lukas Renggli wrote:
I've added case-insensitive matching to the latest version of PetitParser-lr.173. I am not entirely happy with the implementation itself, but the API is ok and will be stable.
By default all matches are case-sensitive, but you can tell character and string parsers to match case insensitive:
" matches 'a' and 'A' " $a asParser caseInsensitive
" matches 'abc', 'AbC', 'Abc', ... " 'abc' asParser caseInsensitive
Hope this helps.
Lukas
On 1 June 2010 17:29, Lukas Renggli <renggli@gmail.com> wrote:
- I don't find to way in petitparser to: parse every string except a list of strings. For example, I want to parse all string except 'string' and 'STRING'.
The logical #not parser helps you here:
('string' asParser / 'STRING' asParser) not , #letter star plus
- I don't find a way to parse a string without taking care of its case. For example, I want to parse 'string', 'STRING', 'String', 'stRINg', etc ...
This is currently not supported out of the box. You could add it by subclassing PRLiteralCollectionParser and compare the strings with #sameAs: instead of #=. If this turns out to be generally useful we should maybe add it to the core framework?
Lukas
-- Lukas Renggli www.lukas-renggli.ch
-- Lukas Renggli www.lukas-renggli.ch
_______________________________________________ Pharo-users mailing list Pharo-users@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Wow, that sounds really cool! Just out of curiosity: How does it compare in speed with the one from Citezen? Doru On 1 Jun 2010, at 23:09, Stéphane Ducasse wrote:
Cool. Adrien did a full bibtext parser :)
Stef
On Jun 1, 2010, at 10:35 PM, Lukas Renggli wrote:
I've added case-insensitive matching to the latest version of PetitParser-lr.173. I am not entirely happy with the implementation itself, but the API is ok and will be stable.
By default all matches are case-sensitive, but you can tell character and string parsers to match case insensitive:
" matches 'a' and 'A' " $a asParser caseInsensitive
" matches 'abc', 'AbC', 'Abc', ... " 'abc' asParser caseInsensitive
Hope this helps.
Lukas
On 1 June 2010 17:29, Lukas Renggli <renggli@gmail.com> wrote:
- I don't find to way in petitparser to: parse every string except a list of strings. For example, I want to parse all string except 'string' and 'STRING'.
The logical #not parser helps you here:
('string' asParser / 'STRING' asParser) not , #letter star plus
- I don't find a way to parse a string without taking care of its case. For example, I want to parse 'string', 'STRING', 'String', 'stRINg', etc ...
This is currently not supported out of the box. You could add it by subclassing PRLiteralCollectionParser and compare the strings with #sameAs: instead of #=. If this turns out to be generally useful we should maybe add it to the core framework?
Lukas
-- Lukas Renggli www.lukas-renggli.ch
-- Lukas Renggli www.lukas-renggli.ch
_______________________________________________ Pharo-users mailing list Pharo-users@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
_______________________________________________ Pharo-users mailing list Pharo-users@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
-- www.tudorgirba.com "Not knowing how to do something is not an argument for how it cannot be done."
From: stephane.ducasse@inria.fr Date: Tue, 1 Jun 2010 23:09:47 +0200 To: pharo-users@lists.gforge.inria.fr Subject: Re: [Pharo-users] Help with petitparser
Cool. Adrien did a full bibtext parser :)
Stef
I'm currently doing it. I'll probably finish it today. Again a little question about petitparser: In bibtex I have to parse: "{ here is a string }". I wrote that: $} asParser negate star. But, in the string between { and } can contain the $} character, like that: { Mart{\'\i}n }. I don't know how I write that... Hope you can answer that :) Adrien. _________________________________________________________________ Hotmail : Simple et Efficace qui vous facilite la vie⦠Découvrez la NOW génération ! http://www.windowslive.fr/hotmail/nowgeneration/
Again a little question about petitparser:
In bibtex I have to parse: "{ here is a string }". I wrote that: $} asParser negate star. But, in the string between { and } can contain the $} character, like that: { Mart{\'\i}n }. I don't know how I write that...
${ asParser , ((${ asParser , $} asParser negate star , $} asParser) / $} asParser negate) star , $} asParser Lukas -- Lukas Renggli www.lukas-renggli.ch
Thanks a lot Lukas :) Adrien.
From: renggli@gmail.com Date: Wed, 2 Jun 2010 11:36:03 +0200 To: pharo-users@lists.gforge.inria.fr Subject: Re: [Pharo-users] Help with petitparser
Again a little question about petitparser:
In bibtex I have to parse: "{ here is a string }". I wrote that: $} asParser negate star. But, in the string between { and } can contain the $} character, like that: { Mart{\'\i}n }. I don't know how I write that...
${ asParser , ((${ asParser , $} asParser negate star , $} asParser) / $} asParser negate) star , $} asParser
Lukas
-- Lukas Renggli www.lukas-renggli.ch
_______________________________________________ Pharo-users mailing list Pharo-users@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
_________________________________________________________________ Vous voulez regarder la TV directement depuis votre PC ? C'est très simple avec Windows 7 http://clk.atdmt.com/FRM/go/229960614/direct/01/
participants (5)
-
Adrien BARREAU -
Hernán Morales Durand -
Lukas Renggli -
Stéphane Ducasse -
Tudor Girba