mpe85 / grampa

A PEG parser library for Kotlin/JVM
https://mpe85.github.io/grampa/
MIT License
13 stars 1 forks source link

case insensitive string/char matches? #49

Open jottinger opened 2 months ago

jottinger commented 2 months ago

Is there a way to match such that "ThIS" and "this" both match string("this")?

mpe85 commented 2 months ago

Hi @jottinger, there are ignoreCase(String), ignoreCase(Char) and ignoreCase(int) that ignore the case of the provided string/char/codepoint.

jottinger commented 2 months ago

Yeah, I found those. IMO, having an analog to string() be ignoreCase is insufficient naming; I'd think the two methods would be string("foo") and stringIgnoreCase("foo"). I'd found the variant by the time you'd commented, by accident, purely from crawling through AbstractGrammar's source code. (This happened for another issue, too, issue #50).

mpe85 commented 2 months ago

Some history: when I initially started work on grampa I have taken over the naming mainly from parboiled1. Just have a look at this: https://www.javadoc.io/doc/org.parboiled/parboiled-java/latest/org/parboiled/BaseParser.html :-)

I can change the names of these rule functions to be more precise, probably in the next major release (since this would be a breaking change).

jottinger commented 2 months ago

You could - or you could alias them over, which is what I'd do, personally. It clouds the API a little bit (because methods are duplicated, even though they'd defer to a central spot) but... honestly? Method slots are CHEAP.

On Wed, Sep 11, 2024 at 5:20 PM Marco Perazzo @.***> wrote:

Some history: when I initially started work on grampa I have taken over the naming mainly from parboiled1. Just have a look at this: https://www.javadoc.io/doc/org.parboiled/parboiled-java/latest/org/parboiled/BaseParser.html :-)

I can change the names of these rule functions to be more precise, probably in the next major release (since this would be a breaking change).

— Reply to this email directly, view it on GitHub https://github.com/mpe85/grampa/issues/49#issuecomment-2344721454, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADSNGTWLWUMPSCPXHE2FTDZWCXYFAVCNFSM6AAAAABN5IU4EKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBUG4ZDCNBVGQ . You are receiving this because you were mentioned.Message ID: @.***>

-- Joseph B. Ottinger http://www.enigmastation.com http://enigmastation.com To the beautiful and the wise,

mpe85 commented 2 months ago

Yeah, introduce stringIgnoreCase() and deprecate ignoreCase() would be the way to go I think.