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. Votre vie privée l'est-elle vraiment ? Internet Explorer 8 vous protège gratuitement ! _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
Hi Adrien
2010/6/1 Adrien BARREAU <[hidden email]>: > 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 _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
In reply to this post by Adrien BARREAU
> - 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 _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
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 <[hidden email]> 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 [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
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 <[hidden email]> 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 > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users _______________________________________________ Pharo-users mailing list [hidden email] 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 <[hidden email]> 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 >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users > > > _______________________________________________ > Pharo-users mailing list > [hidden email] > 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." _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
In reply to this post by Stéphane Ducasse
> From: [hidden email]
> Date: Tue, 1 Jun 2010 23:09:47 +0200 > To: [hidden email] > 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. Vous voulez protéger votre numéro de CB ? Utilisez Internet Explorer 8 _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
> 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 [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
Thanks a lot Lukas :)
Adrien. > From: [hidden email] > Date: Wed, 2 Jun 2010 11:36:03 +0200 > To: [hidden email] > 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 > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users Envie de plus d'originalité dans vos conversations ? Téléchargez gratuitement les Emoch'ticones ! _______________________________________________ Pharo-users mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users |
Free forum by Nabble | Edit this page |