
Hi, What is the idiomatic way of parsing keywords, in a case agnostic fashion, for a ‘mini-language’? For example I’m creating some structured text… project{ env{ } setup{ } run{ } } that has ‘project’, ‘env’, ‘setup’ and ‘run’ as keywords and I want to parse in such a way that ‘PROJECT’, ‘ProJect’ etc are all recognised as the keyword ‘project’ similarly for ‘env’ etc. I’m using monadic rather than applicative parsing. Many Thanks Mike

On Sat, Oct 03, 2015 at 10:12:20AM +0100, Mike Houghton wrote:
Hi,
What is the idiomatic way of parsing keywords, in a case agnostic fashion, for a ‘mini-language’?
I lifted this from `Text.ParserCombinators.Parsec.Rfc2234` and used it in a project of mine (lentil). ciString s = mapM ciChar s > "case insensitive string" where ciChar :: Char -> ParIssue Char ciChar c = char (C.toLower c) <|> char (C.toUpper c) This assumes you are using Parsec parsing library.

Thanks. I’ll try that. Mike
On 3 Oct 2015, at 10:21, Francesco Ariis
wrote: On Sat, Oct 03, 2015 at 10:12:20AM +0100, Mike Houghton wrote:
Hi,
What is the idiomatic way of parsing keywords, in a case agnostic fashion, for a ‘mini-language’?
I lifted this from `Text.ParserCombinators.Parsec.Rfc2234` and used it in a project of mine (lentil).
ciString s = mapM ciChar s > "case insensitive string" where ciChar :: Char -> ParIssue Char ciChar c = char (C.toLower c) <|> char (C.toUpper c)
This assumes you are using Parsec parsing library. _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (2)
-
Francesco Ariis
-
Mike Houghton