Skip to content

Commit

Permalink
feat(Token): added proper graphic character handling
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mie6 committed Jan 16, 2024
1 parent f43aee8 commit f892e8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions gigaparsec.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ library
Text.Gigaparsec.Token.Numeric,
Text.Gigaparsec.Token.Patterns,
Text.Gigaparsec.Token.Symbol,
Text.Gigaparsec.Token.Text,
Text.Gigaparsec.Registers,

-- Internals
Expand Down
12 changes: 9 additions & 3 deletions src/Text/Gigaparsec/Token/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ module Text.Gigaparsec.Token.Numeric (module Text.Gigaparsec.Token.Numeric) wher

import Text.Gigaparsec (Parsec, void, (<|>), empty, filterS)
import Text.Gigaparsec.Char (char, digit, hexDigit, octDigit, bit, satisfy)
import Text.Gigaparsec.Token.Descriptions (TextDesc(..), EscapeDesc(..), NumericEscape)
import Text.Gigaparsec.Token.Descriptions (TextDesc(..), EscapeDesc(..), NumericEscape, CharPredicate)
import Text.Gigaparsec.Token.Generic (GenericNumeric(zeroAllowedDecimal, zeroAllowedHexadecimal, zeroAllowedOctal, zeroAllowedBinary))
import Data.Char (isSpace)

type TextParsers :: * -> *
data TextParsers t = TextParsers { unicode :: Parsec t
Expand All @@ -30,8 +31,13 @@ mkCharacterParsers TextDesc{..} escape = TextParsers {..}
lit c = quote *> c <* quote
uncheckedUniLetter = escapeChar escape <|> graphic

-- FIXME: nope!
graphic = maybe empty satisfy graphicCharacter
graphic = maybe empty satisfy (letter characterLiteralEnd False graphicCharacter)

letter :: Char -> Bool -> CharPredicate -> CharPredicate
letter !terminalLead !allowsAllSpace (Just g)
| allowsAllSpace = Just $ \c -> c /= terminalLead && (g c || isSpace c)
| otherwise = Just $ \c -> c /= terminalLead && g c
letter _ _ Nothing = Nothing

type Escape :: *
data Escape = Escape { escapeCode :: !(Parsec Char)
Expand Down

0 comments on commit f892e8a

Please sign in to comment.