Skip to content

Commit

Permalink
Fix #2924. Use MegaParsec scanner for Markdown files (#2925)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jonaprieto and janmasrovira authored Jul 30, 2024
1 parent 2524606 commit 2416f78
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/positive/Markdown/Test.juvix.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 2 additions & 0 deletions tests/positive/Markdown/markdown/Test.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down

0 comments on commit 2416f78

Please sign in to comment.