mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 02:25:39 +03:00
Add parens to annotation of lexed symboly segments
This commit is contained in:
parent
6a6b7b8643
commit
b00acbe182
@ -19,6 +19,15 @@ x y =
|
||||
x + y
|
||||
-- Should keep comments after
|
||||
|
||||
-- symbolyDefinition
|
||||
(<|>) : Nat -> Nat -> (Nat, Nat)
|
||||
(<|>) a b = (a, b)
|
||||
|
||||
symbolyEndOfBlock =
|
||||
use List +:
|
||||
(+:)
|
||||
|
||||
|
||||
-- Test for a previous regression that added extra brackets.
|
||||
oneLiner = {{ one liner }}
|
||||
-- After
|
||||
|
@ -15,6 +15,15 @@ x y =
|
||||
x + y
|
||||
-- Should keep comments after
|
||||
|
||||
-- symbolyDefinition
|
||||
(<|>) : Nat -> Nat -> (Nat, Nat)
|
||||
(<|>) a b = (a, b)
|
||||
|
||||
f x y =
|
||||
use List +:
|
||||
(+:)
|
||||
|
||||
|
||||
-- Test for a previous regression that added extra brackets.
|
||||
oneLiner = {{ one liner }}
|
||||
-- After
|
||||
@ -94,6 +103,13 @@ x y =
|
||||
x + y
|
||||
-- Should keep comments after
|
||||
|
||||
-- symbolyDefinition
|
||||
(<|>) : Nat -> Nat -> (Nat, Nat)
|
||||
a <|> b = (a, b)
|
||||
|
||||
f x y = (+:)
|
||||
|
||||
|
||||
-- Test for a previous regression that added extra brackets.
|
||||
oneLiner = {{ one liner }}
|
||||
-- After
|
||||
|
@ -338,8 +338,16 @@ symbolyDefinitionName = queryToken $ \case
|
||||
L.SymbolyId n -> Just $ Name.toVar (HQ'.toName n)
|
||||
_ -> Nothing
|
||||
|
||||
parenthesize :: (Ord v) => P v m a -> P v m a
|
||||
parenthesize p = P.try (openBlockWith "(" *> p) <* closeBlock
|
||||
-- | Expect parentheses around a token, includes the parentheses within the start/end
|
||||
-- annotations of the resulting token.
|
||||
parenthesize :: (Ord v) => P v m (L.Token a) -> P v m (L.Token a)
|
||||
parenthesize p = do
|
||||
(start, a) <- P.try do
|
||||
start <- L.start <$> openBlockWith "("
|
||||
a <- p
|
||||
pure (start, a)
|
||||
end <- L.end <$> closeBlock
|
||||
pure (L.Token {payload = L.payload a, start, end})
|
||||
|
||||
hqPrefixId, hqInfixId :: (Ord v) => P v m (L.Token (HQ.HashQualified Name))
|
||||
hqPrefixId = hqWordyId_ <|> parenthesize hqSymbolyId_
|
||||
|
Loading…
Reference in New Issue
Block a user