From 048ee552d82c1864697e07f55f5882cc46a1c9ed Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Sun, 13 Sep 2015 15:32:16 +0200 Subject: [PATCH] Take care of comments --- Data/GraphQL/Parser.hs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Data/GraphQL/Parser.hs b/Data/GraphQL/Parser.hs index db6091b..013dd9b 100644 --- a/Data/GraphQL/Parser.hs +++ b/Data/GraphQL/Parser.hs @@ -5,18 +5,20 @@ import Prelude hiding (takeWhile) import Control.Applicative (Alternative, (<|>), empty, many) import Data.Char -import Data.Attoparsec.Text.Lazy +import Data.Attoparsec.Text ( Parser , () , anyChar , decimal , double + , endOfLine , isEndOfLine , many1 , manyTill , satisfy , sepBy , sepBy1 + , skipMany , skipSpace , skipWhile , signed @@ -289,10 +291,16 @@ space' :: Parser Char space' = satisfy isSpace' s :: Parser () -s = skipWhile isSpace' +s = comments <|> skipWhile isSpace' s1 :: Parser () -s1 = space' *> s +s1 = comments <|> space' *> s isSpace' :: Char -> Bool isSpace' c = isSpace c || ',' == c || isEndOfLine c + +comments :: Parser () +comments = skipMany comment + +comment :: Parser () +comment = () <$ "#" <* manyTill anyChar endOfLine