Extract flag parser

This commit is contained in:
Joscha 2019-11-20 18:19:25 +00:00
parent 602e8b5b14
commit 42d52055d1
2 changed files with 5 additions and 4 deletions

View file

@ -6,6 +6,7 @@ module Mima.Parse.Common
-- * Basic parsers
, whitespace
, labelName
, flag
-- ** Number literals
, binDigit
, decDigit
@ -58,6 +59,9 @@ labelName = label "label" $ do
ts <- takeWhileP Nothing (\c -> isAlphaNum c || isConnecting c)
pure $ T.singleton t <> ts
flag :: Parser (Set.Set Char)
flag = label "alphanumeric character" $ Set.singleton <$> satisfy isAlphaNum
binDigit :: (Num a) => Parser a
binDigit = label "binary digit" $ token helper Set.empty
where

View file

@ -21,11 +21,8 @@ import Mima.Word
lAddress :: Parser MimaAddress
lAddress = lexeme fixedWidthHexAddress
lFlag :: Parser (Set.Set Char)
lFlag = lexeme $ label "alphanumeric character" $ Set.singleton <$> satisfy isAlphaNum
lFlags :: Parser (Set.Set Char)
lFlags = Set.unions <$> some lFlag
lFlags = Set.unions <$> some (lexeme flag)
lAddressRange :: Parser AddressRange
lAddressRange = do