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
|
-- * Basic parsers
|
||||||
, whitespace
|
, whitespace
|
||||||
, labelName
|
, labelName
|
||||||
|
, flag
|
||||||
-- ** Number literals
|
-- ** Number literals
|
||||||
, binDigit
|
, binDigit
|
||||||
, decDigit
|
, decDigit
|
||||||
|
|
@ -58,6 +59,9 @@ labelName = label "label" $ do
|
||||||
ts <- takeWhileP Nothing (\c -> isAlphaNum c || isConnecting c)
|
ts <- takeWhileP Nothing (\c -> isAlphaNum c || isConnecting c)
|
||||||
pure $ T.singleton t <> ts
|
pure $ T.singleton t <> ts
|
||||||
|
|
||||||
|
flag :: Parser (Set.Set Char)
|
||||||
|
flag = label "alphanumeric character" $ Set.singleton <$> satisfy isAlphaNum
|
||||||
|
|
||||||
binDigit :: (Num a) => Parser a
|
binDigit :: (Num a) => Parser a
|
||||||
binDigit = label "binary digit" $ token helper Set.empty
|
binDigit = label "binary digit" $ token helper Set.empty
|
||||||
where
|
where
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,8 @@ import Mima.Word
|
||||||
lAddress :: Parser MimaAddress
|
lAddress :: Parser MimaAddress
|
||||||
lAddress = lexeme fixedWidthHexAddress
|
lAddress = lexeme fixedWidthHexAddress
|
||||||
|
|
||||||
lFlag :: Parser (Set.Set Char)
|
|
||||||
lFlag = lexeme $ label "alphanumeric character" $ Set.singleton <$> satisfy isAlphaNum
|
|
||||||
|
|
||||||
lFlags :: Parser (Set.Set Char)
|
lFlags :: Parser (Set.Set Char)
|
||||||
lFlags = Set.unions <$> some lFlag
|
lFlags = Set.unions <$> some (lexeme flag)
|
||||||
|
|
||||||
lAddressRange :: Parser AddressRange
|
lAddressRange :: Parser AddressRange
|
||||||
lAddressRange = do
|
lAddressRange = do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue