hayleigh-dot-dev / nibble

A string parsing library heavily inspired by elm/parser.
MIT License
55 stars 10 forks source link

Case-insensitive #5

Open manuel-rubio opened 1 year ago

manuel-rubio commented 1 year ago

Is it possible to indicate tokens to be case-sensitive or case-insensitive? I'm needing for a SQL-like parser to have case-insensitive tokens.

manuel-rubio commented 1 year ago

what about this?

pub fn itoken(str: String, value: a) -> Matcher(a, mode) {
  use mode, lexeme, _ <- Matcher

  case string.lowercase(lexeme) == string.lowercase(str) {
    True -> Keep(value, mode)
    False -> NoMatch
  }
}