Skip to content

Commit

Permalink
syntax fixity
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed Oct 28, 2024
1 parent 89d0335 commit 7bc65e7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Backend/Html/Translation/FromTyped.hs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ goStatement = \case

goFixity :: forall r. (Members '[Reader HtmlOptions] r) => FixitySyntaxDef 'Scoped -> Sem r Html
goFixity def = do
sig' <- ppHelper (ppFixityDefHeaderNew def)
sig' <- ppHelper (ppFixityDefHeader def)
header' <- defHeader (def ^. fixitySymbol) sig' (def ^. fixityDoc)
prec' <- mkPrec
ari' <- ari
Expand Down
10 changes: 5 additions & 5 deletions src/Juvix/Compiler/Concrete/Print/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,8 @@ instance PrettyPrint Precedence where
PrecApp -> noLoc (pretty ("ω" :: Text))
PrecUpdate -> noLoc (pretty ("ω₁" :: Text))

ppFixityDefHeaderNew :: (SingI s) => PrettyPrinting (FixitySyntaxDef s)
ppFixityDefHeaderNew FixitySyntaxDef {..} = do
ppFixityDefHeader :: (SingI s) => PrettyPrinting (FixitySyntaxDef s)
ppFixityDefHeader FixitySyntaxDef {..} = do
let sym' = annotated (AnnKind KNameFixity) (ppSymbolType _fixitySymbol)
ppCode _fixitySyntaxKw <+> ppCode _fixityKw <+> sym'

Expand Down Expand Up @@ -914,14 +914,14 @@ instance (SingI s) => PrettyPrint (ParsedFixityInfo s) where
belowItem = do
a <- _fixityFieldsPrecBelow
return (ppCode Kw.kwBelow <+> ppCode Kw.kwAssign <+> ppSymbolList a)
items = hsepSemicolon (catMaybes [assocItem, sameItem, aboveItem, belowItem])
items = ppBlockOrList' (catMaybes [assocItem, sameItem, aboveItem, belowItem])
(l, r) = _fixityFieldsBraces ^. unIrrelevant
return (ppCode l <> items <> ppCode r)
return (grouped (ppCode l <> items <> ppCode r))
ppCode _fixityParsedArity <+?> rhs

instance (SingI s) => PrettyPrint (FixitySyntaxDef s) where
ppCode f@FixitySyntaxDef {..} = do
let header' = ppFixityDefHeaderNew f
let header' = ppFixityDefHeader f
body' = ppCode _fixityInfo
header' <+> ppCode _fixityAssignKw <+> body'

Expand Down
4 changes: 3 additions & 1 deletion src/Juvix/Compiler/Concrete/Translation/FromSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ parsedFixityFields = do
bel <- toPermutationWithDefault Nothing (Just <$> belowAbove kwBelow)
abov <- toPermutationWithDefault Nothing (Just <$> belowAbove kwAbove)
sam <- toPermutationWithDefault Nothing (Just <$> same)
-- This is a hack to allow an optional semicolon at the end
toPermutationWithDefault Nothing (return (Just ()))
pure (as, bel, abov, sam)
r <- kw delimBraceR
let _fixityFieldsBraces = Irrelevant (l, r)
Expand Down Expand Up @@ -769,9 +771,9 @@ parsedIteratorInfo = do
(_parsedIteratorInfoInitNum, _parsedIteratorInfoRangeNum) <- intercalateEffect semicolon $ do
ini <- toPermutationWithDefault Nothing (Just <$> pinit)
ran <- toPermutationWithDefault Nothing (Just <$> prangeNum)
-- This is a hack to allow an optional semicolon at the end
toPermutationWithDefault Nothing (return (Just ()))
pure (ini, ran)
optional semicolon
r <- kw delimBraceR
let _parsedIteratorInfoBraces = Irrelevant (l, r)
return ParsedIteratorInfo {..}
Expand Down

0 comments on commit 7bc65e7

Please sign in to comment.