Extract flag parser
This commit is contained in:
parent
602e8b5b14
commit
42d52055d1
2 changed files with 5 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue