From da33ae15ea56ae672afdd8226691cdaad6dbc83f Mon Sep 17 00:00:00 2001 From: Calvin Beck Date: Thu, 20 Aug 2015 15:36:43 -0600 Subject: [PATCH] Added a basic option for changing whitespace. --- Text/Parsec/Token.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Text/Parsec/Token.hs b/Text/Parsec/Token.hs index 27c13033..5d07e042 100644 --- a/Text/Parsec/Token.hs +++ b/Text/Parsec/Token.hs @@ -22,6 +22,7 @@ module Text.Parsec.Token , TokenParser , GenTokenParser (..) , makeTokenParser + , makeTokenParser' ) where import Data.Char ( isAlpha, toLower, toUpper, isSpace, digitToInt ) @@ -343,7 +344,17 @@ data GenTokenParser s u m makeTokenParser :: (Stream s m Char) => GenLanguageDef s u m -> GenTokenParser s u m -makeTokenParser languageDef +makeTokenParser = makeTokenParser' isSpace + + +-- | Same as @makeTokenParser@, but a function which determines whether or +-- not a character should count as whitespace is provided. This is +-- useful for parsing languages like Python, which depend upon +-- indentation and newlines for syntax. + +makeTokenParser' :: (Stream s m Char) + => (Char -> Bool) -> GenLanguageDef s u m -> GenTokenParser s u m +makeTokenParser' isSpace languageDef = TokenParser{ identifier = identifier , reserved = reserved , operator = operator