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