mirror of
https://github.com/github/semantic.git
synced 2024-12-22 14:21:31 +03:00
Add a leaf combinator.
This commit is contained in:
parent
c2df871607
commit
129d962041
@ -105,6 +105,9 @@ literal = term <*> (Literal.true <$ symbol Language.Ruby.Syntax.True <* source
|
||||
term :: InUnion Syntax' f => Assignment (Node grammar) (f (Term Syntax Location) -> Term Syntax Location)
|
||||
term = (\ a f -> cofree $ a :< inj f) <$> location
|
||||
|
||||
leaf :: (Enum symbol, Eq symbol, InUnion Syntax' f) => (ByteString -> f (Term Syntax Location)) -> symbol -> Assignment (Node symbol) (Term Syntax Location)
|
||||
leaf f s = symbol s *> pure (\ a -> cofree . (a :<) . inj . f) <*> location <*> source
|
||||
|
||||
optional :: Assignment (Node Grammar) (Term Syntax Location) -> Assignment (Node Grammar) (Term Syntax Location)
|
||||
optional a = a <|> term <*> pure Syntax.Empty
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user