1
1
mirror of https://github.com/anoma/juvix.git synced 2024-11-30 14:13:27 +03:00

Fix #2924. Use MegaParsec scanner for Markdown files (#2925)

This PR addresses a bug/missing case present since v0.6.2, introduced
specifically by

- PR #2779, 

That PR involves detecting imports in Juvix files before type checking,
and that's the issue.
Detecting/scanning imports is done by running a flat parser (which
ignores the Juvix Markdown structure) and when it fails, it runs a
Megaparser parse. So, for simplicity,
we could just continue using the same Megaparser as before for Juvix
Markdown files.

---------

Co-authored-by: Jan Mas Rovira <janmasrovira@gmail.com>
This commit is contained in:
Jonathan Cubides 2024-07-30 16:51:55 -05:00 committed by GitHub
parent 2524606757
commit 2416f78a3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View File

@ -12,7 +12,10 @@ import Juvix.Prelude.FlatParse qualified as FP
import Juvix.Prelude.FlatParse.Lexer qualified as L
scanBSImports :: Path Abs File -> ByteString -> Maybe ScanResult
scanBSImports fp = fromResult . scanner fp
scanBSImports fp
-- FlatParse only supports .juvix files
| isJuvixFile fp = fromResult . scanner fp
| otherwise = const Nothing
where
fromResult :: Result () ok -> Maybe ok
fromResult = \case

View File

@ -1,5 +1,7 @@
# Example
What is important is seldom urgent.
A Juvix Markdown file name ends with `.juvix.md`. This kind of file must contain
a module declaration at the top, as shown below ---in the first code block.

View File

@ -1,5 +1,7 @@
# Example
What is important is seldom urgent.
A Juvix Markdown file name ends with `.juvix.md`. This kind of file must contain
a module declaration at the top, as shown below ---in the first code block.