Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move noFile to common code #2661

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/Juvix/Compiler/Asm/Translation/FromSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Juvix.Compiler.Asm.Language
import Juvix.Compiler.Asm.Translation.FromSource.Lexer
import Juvix.Compiler.Tree.Translation.FromSource.Base
import Juvix.Compiler.Tree.Translation.FromSource.Sig qualified as S
import Juvix.Extra.Paths
import Juvix.Parser.Error
import Text.Megaparsec qualified as P

Expand All @@ -31,9 +32,6 @@ parseAsmSig =
_parserSigEmptyExtra = mempty
}

noFile :: Path Abs File
noFile = $(mkAbsFile "/<text>")

parseText :: Text -> Either MegaparsecError InfoTable
parseText = runParser noFile

Expand Down
3 changes: 2 additions & 1 deletion src/Juvix/Compiler/Casm/Translation/FromSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import Juvix.Compiler.Casm.Data.LabelInfo
import Juvix.Compiler.Casm.Data.LabelInfoBuilder
import Juvix.Compiler.Casm.Language
import Juvix.Compiler.Casm.Translation.FromSource.Lexer
import Juvix.Extra.Paths
import Juvix.Parser.Error
import Text.Megaparsec qualified as P

parseText :: Text -> Either MegaparsecError (LabelInfo, [Instruction])
parseText = runParser $(mkAbsFile "/<text>")
parseText = runParser noFile

runParser :: Path Abs File -> Text -> Either MegaparsecError (LabelInfo, [Instruction])
runParser fileName input_ =
Expand Down
4 changes: 1 addition & 3 deletions src/Juvix/Compiler/Nockma/Translation/FromSource/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Data.HashMap.Internal.Strict qualified as HashMap
import Data.List.NonEmpty qualified as NonEmpty
import Data.Text qualified as Text
import Juvix.Compiler.Nockma.Language
import Juvix.Extra.Paths
import Juvix.Extra.Strings qualified as Str
import Juvix.Parser.Error
import Juvix.Parser.Lexer (onlyInterval, withLoc)
Expand Down Expand Up @@ -34,9 +35,6 @@ parseProgramFile fp = do
parseReplStatement :: Text -> Either MegaparsecError (ReplStatement Natural)
parseReplStatement = runParserFor replStatement noFile

noFile :: Prelude.Path Abs File
noFile = $(mkAbsFile "/<text>")

runParserProgram :: Prelude.Path Abs File -> Text -> Either MegaparsecError (Program Natural)
runParserProgram = runParserFor program

Expand Down
4 changes: 1 addition & 3 deletions src/Juvix/Compiler/Reg/Translation/FromSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Juvix.Compiler.Reg.Language
import Juvix.Compiler.Reg.Translation.FromSource.Lexer
import Juvix.Compiler.Tree.Translation.FromSource.Base
import Juvix.Compiler.Tree.Translation.FromSource.Sig qualified as S
import Juvix.Extra.Paths
import Juvix.Parser.Error
import Text.Megaparsec qualified as P

Expand All @@ -30,9 +31,6 @@ parseRegSig =
_parserSigEmptyExtra = ()
}

noFile :: Path Abs File
noFile = $(mkAbsFile "/<text>")

parseText :: Text -> Either MegaparsecError InfoTable
parseText = runParser noFile

Expand Down
4 changes: 1 addition & 3 deletions src/Juvix/Compiler/Tree/Translation/FromSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Juvix.Compiler.Tree.Language
import Juvix.Compiler.Tree.Translation.FromSource.Base
import Juvix.Compiler.Tree.Translation.FromSource.Lexer
import Juvix.Compiler.Tree.Translation.FromSource.Sig qualified as S
import Juvix.Extra.Paths
import Juvix.Parser.Error
import Text.Megaparsec qualified as P

Expand All @@ -31,9 +32,6 @@ parseTreeSig =
_parserSigEmptyExtra = ()
}

noFile :: Path Abs File
noFile = $(mkAbsFile "/<text")

parseText :: Text -> Either MegaparsecError InfoTable
parseText = runParser noFile

Expand Down
3 changes: 3 additions & 0 deletions src/Juvix/Extra/Paths.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ formatStdinPath = $(mkAbsFile "/format-stdin")

gebReplPath :: Path Abs File
gebReplPath = $(mkAbsFile ("/repl" <> juvixGebFileExt))

noFile :: Path Abs File
noFile = $(mkAbsFile "/<text>")
Loading