mirror of
https://github.com/github/semantic.git
synced 2024-12-20 13:21:59 +03:00
🔥 Empty.
This commit is contained in:
parent
ffe79d34c8
commit
10e81996fa
@ -117,7 +117,6 @@ data AssignmentF ast grammar a where
|
|||||||
Choose :: HasCallStack => IntMap.IntMap a -> AssignmentF ast grammar a
|
Choose :: HasCallStack => IntMap.IntMap a -> AssignmentF ast grammar a
|
||||||
Many :: HasCallStack => Assignment ast grammar a -> AssignmentF ast grammar [a]
|
Many :: HasCallStack => Assignment ast grammar a -> AssignmentF ast grammar [a]
|
||||||
Alt :: HasCallStack => a -> a -> AssignmentF ast grammar a
|
Alt :: HasCallStack => a -> a -> AssignmentF ast grammar a
|
||||||
Empty :: HasCallStack => AssignmentF ast grammar a
|
|
||||||
Throw :: HasCallStack => Error grammar -> AssignmentF ast grammar a
|
Throw :: HasCallStack => Error grammar -> AssignmentF ast grammar a
|
||||||
Catch :: HasCallStack => a -> (Error grammar -> a) -> AssignmentF ast grammar a
|
Catch :: HasCallStack => a -> (Error grammar -> a) -> AssignmentF ast grammar a
|
||||||
|
|
||||||
@ -296,14 +295,13 @@ makeState = AssignmentState 0 (Info.Pos 1 1)
|
|||||||
|
|
||||||
instance Enum grammar => Alternative (Assignment ast grammar) where
|
instance Enum grammar => Alternative (Assignment ast grammar) where
|
||||||
empty :: HasCallStack => Assignment ast grammar a
|
empty :: HasCallStack => Assignment ast grammar a
|
||||||
empty = Empty `Then` return
|
empty = Choose mempty `Then` return
|
||||||
(<|>) :: HasCallStack => Assignment ast grammar a -> Assignment ast grammar a -> Assignment ast grammar a
|
(<|>) :: HasCallStack => Assignment ast grammar a -> Assignment ast grammar a -> Assignment ast grammar a
|
||||||
Return a <|> _ = Return a
|
Return a <|> _ = Return a
|
||||||
a <|> b | Just c <- (liftA2 (<>) `on` choices) a b = Choose c `Then` identity
|
a <|> b | Just c <- (liftA2 (<>) `on` choices) a b = Choose c `Then` identity
|
||||||
| otherwise = wrap $ Alt a b
|
| otherwise = wrap $ Alt a b
|
||||||
where choices :: Assignment ast grammar a -> Maybe (IntMap (Assignment ast grammar a))
|
where choices :: Assignment ast grammar a -> Maybe (IntMap (Assignment ast grammar a))
|
||||||
choices (Choose choices `Then` continue) = Just (continue <$> choices)
|
choices (Choose choices `Then` continue) = Just (continue <$> choices)
|
||||||
choices (Empty `Then` _) = Just mempty
|
|
||||||
choices (Many rule `Then` continue) = fmap (const (Many rule `Then` continue)) <$> choices rule
|
choices (Many rule `Then` continue) = fmap (const (Many rule `Then` continue)) <$> choices rule
|
||||||
choices _ = Nothing
|
choices _ = Nothing
|
||||||
many :: HasCallStack => Assignment ast grammar a -> Assignment ast grammar [a]
|
many :: HasCallStack => Assignment ast grammar a -> Assignment ast grammar [a]
|
||||||
@ -318,7 +316,6 @@ instance Show grammar => Show1 (AssignmentF ast grammar) where
|
|||||||
Choose choices -> showsUnaryWith (liftShowsPrec (liftShowsPrec sp sl) (liftShowList sp sl)) "Choose" d (IntMap.toList choices)
|
Choose choices -> showsUnaryWith (liftShowsPrec (liftShowsPrec sp sl) (liftShowList sp sl)) "Choose" d (IntMap.toList choices)
|
||||||
Many a -> showsUnaryWith (liftShowsPrec (\ d a -> sp d [a]) (sl . pure)) "Many" d a
|
Many a -> showsUnaryWith (liftShowsPrec (\ d a -> sp d [a]) (sl . pure)) "Many" d a
|
||||||
Alt a b -> showsBinaryWith sp sp "Alt" d a b
|
Alt a b -> showsBinaryWith sp sp "Alt" d a b
|
||||||
Empty -> showString "Empty"
|
|
||||||
Throw e -> showsUnaryWith showsPrec "Throw" d e
|
Throw e -> showsUnaryWith showsPrec "Throw" d e
|
||||||
Catch during handler -> showsBinaryWith sp (const (const (showChar '_'))) "Catch" d during handler
|
Catch during handler -> showsBinaryWith sp (const (const (showChar '_'))) "Catch" d during handler
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user