on master help sign in
properly parse UUIDs
commit78a1cdb27b0b9904002924aef04ebeb8912cba4e authorAgentM <agentm@themactionfaction.com> dateWed 7 Sep 2016, 18:58 (10 years ago) parent40fdd7f
1 file changed+11−2
src/bin/TutorialD/Interpreter/Base.hs+11−2
src/bin/TutorialD/Interpreter/Base.hs+11−2
@@ -5,7 +5,7 @@ import Text.Megaparsec.Text
55import qualified Text.Megaparsec.Lexer as Lex
66import ProjectM36.Base
77import ProjectM36.AtomType
8−import Data.Text
8+import Data.Text hiding (count)
99import qualified Data.Text as T
1010import qualified Data.List as L
1111import qualified Data.Vector as V
@@ -127,7 +127,16 @@ quotedString = try tripleQuotedString <|> normalQuotedString
127127
128128uuidP :: Parser U.UUID
129129uuidP = do
130− uuidStr <- count' 28 (28 + 4) (hexDigitChar <|> char '-') -- min 28 with no dashes, maximum 4 dashes
130+ uuidStart <- count 8 hexDigitChar
131+ _ <- char '-' -- min 28 with no dashes, maximum 4 dashes
132+ uuidMid1 <- count 4 hexDigitChar
133+ _ <- char '-'
134+ uuidMid2 <- count 4 hexDigitChar
135+ _ <- char '-'
136+ uuidMid3 <- count 4 hexDigitChar
137+ _ <- char '-'
138+ uuidEnd <- count 12 hexDigitChar
139+ let uuidStr = L.intercalate "-" [uuidStart, uuidMid1, uuidMid2, uuidMid3, uuidEnd]
131140 case U.fromString uuidStr of
132141 Nothing -> fail "Invalid uuid string"
133142 Just uuid -> return uuid