Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Parsing keywords (Mike Houghton)
   2. Re:  Parsing keywords (Francesco Ariis)


----------------------------------------------------------------------

Message: 1
Date: Sat, 3 Oct 2015 10:12:20 +0100
From: Mike Houghton <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Parsing keywords
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

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



------------------------------

Message: 2
Date: Sat, 3 Oct 2015 11:21:38 +0200
From: Francesco Ariis <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Parsing keywords
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

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.


------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 88, Issue 2
****************************************

Reply via email to