Skip to content

Commit

Permalink
update loc
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Dec 27, 2024
1 parent 1b4ae69 commit b50a271
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
16 changes: 6 additions & 10 deletions src/Juvix/Compiler/Concrete/Translation/ImportScanner/FlatParse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,22 @@ bareIdentifier = do
t <- many (satisfy L.validTailChar)
return (pack (h : t))

dottedIdentifier :: Parser e (NonEmpty Text)
dottedIdentifier = lexeme (nonEmpty' <$> sepBy1 bareIdentifier dot)
bareDottedIdentifier :: Parser e (NonEmpty Text)
bareDottedIdentifier = nonEmpty' <$> sepBy1 bareIdentifier dot
where
dot :: Parser e ()
dot = $(char '.')

pImport :: Parser e ImportScanParsed
pImport = do
withSpan helper $ \names _importScanLoc ->
pImport = lexeme $ do
iden <- lexeme bareIdentifier
guard (iden == Str.import_)
withSpan bareDottedIdentifier $ \names _importScanLoc ->
return
ImportScan
{ _importScanLoc,
_importScanKey = nonEmptyToTopModulePathKey names
}
where
helper :: Parser e (NonEmpty Text)
helper = do
iden <- lexeme bareIdentifier
guard (iden == Str.import_)
dottedIdentifier

pToken :: Parser e Token
pToken =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ parserStateToScanResult st =
fromImport :: Import 'Parsed -> ImportScan
fromImport i =
ImportScan
{ _importScanLoc = getLoc i,
{ _importScanLoc = getLoc (i ^. importModulePath),
_importScanKey = topModulePathKey (i ^. importModulePath)
}
2 changes: 2 additions & 0 deletions src/Juvix/Data/ImportScan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import Juvix.Prelude.Base

data ImportScan' a = ImportScan
{ _importScanKey :: TopModulePathKey,
-- The loc corresponds only to the module name. So it does not include the
-- import keyword
_importScanLoc :: a
}
deriving stock (Show, Eq, Generic)
Expand Down

0 comments on commit b50a271

Please sign in to comment.