Skip to content

Option to change whitespace in token parsing. #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Text/Parsec/Token.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module Text.Parsec.Token
, TokenParser
, GenTokenParser (..)
, makeTokenParser
, makeTokenParser'
) where

import Data.Char ( isAlpha, toLower, toUpper, isSpace, digitToInt )
Expand Down Expand Up @@ -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
Expand Down