-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MarkdownInfo entry in Module Concrete Decl and proper errors (#2515)
Remove TODO added by @janmasrovira in - #2513
- Loading branch information
1 parent
90200ab
commit 8616370
Showing
16 changed files
with
227 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module Juvix.Compiler.Backend.Markdown.Error where | ||
|
||
import Juvix.Compiler.Concrete.Language | ||
import Juvix.Compiler.Concrete.Translation.FromParsed.Analysis.Scoping.Error.Pretty | ||
import Juvix.Prelude | ||
|
||
data MarkdownBackendError | ||
= ErrInternalNoMarkdownInfo NoMarkdownInfoError | ||
| ErrNoJuvixCodeBlocks NoJuvixCodeBlocksError | ||
deriving stock (Show) | ||
|
||
instance ToGenericError MarkdownBackendError where | ||
genericError = \case | ||
ErrInternalNoMarkdownInfo e -> genericError e | ||
ErrNoJuvixCodeBlocks e -> genericError e | ||
|
||
newtype NoMarkdownInfoError = NoMarkdownInfoError | ||
{ _noMarkdownInfoFilepath :: Path Abs File | ||
} | ||
deriving stock (Show) | ||
|
||
instance ToGenericError NoMarkdownInfoError where | ||
genericError NoMarkdownInfoError {..} = do | ||
let msg = "The markdown file is empty:\n" <+> pretty _noMarkdownInfoFilepath | ||
return | ||
GenericError | ||
{ _genericErrorLoc = i, | ||
_genericErrorMessage = prettyError msg, | ||
_genericErrorIntervals = [i] | ||
} | ||
where | ||
i :: Interval | ||
i = singletonInterval . mkInitialLoc $ _noMarkdownInfoFilepath | ||
|
||
newtype NoJuvixCodeBlocksError = NoJuvixCodeBlocksError | ||
{ _noJuvixCodeBlocksErrorFilepath :: Path Abs File | ||
} | ||
deriving stock (Show) | ||
|
||
instance ToGenericError NoJuvixCodeBlocksError where | ||
genericError NoJuvixCodeBlocksError {..} = do | ||
let msg = "The markdown file contain no Juvix code blocks:\n" <+> pretty _noJuvixCodeBlocksErrorFilepath | ||
return | ||
GenericError | ||
{ _genericErrorLoc = i, | ||
_genericErrorMessage = prettyError msg, | ||
_genericErrorIntervals = [i] | ||
} | ||
where | ||
i :: Interval | ||
i = singletonInterval . mkInitialLoc $ _noJuvixCodeBlocksErrorFilepath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module BackendMarkdown | ||
( allTests, | ||
) | ||
where | ||
|
||
import BackendMarkdown.Negative qualified as N | ||
import BackendMarkdown.Positive qualified as P | ||
import Base | ||
|
||
allTests :: TestTree | ||
allTests = testGroup "BackendMarkdown tests" [P.allTests, N.allTests] |
Oops, something went wrong.