summaryrefslogtreecommitdiff
path: root/source/Felix/Parse.hs
diff options
context:
space:
mode:
Diffstat (limited to 'source/Felix/Parse.hs')
-rw-r--r--source/Felix/Parse.hs147
1 files changed, 113 insertions, 34 deletions
diff --git a/source/Felix/Parse.hs b/source/Felix/Parse.hs
index b9d5c57..751f09c 100644
--- a/source/Felix/Parse.hs
+++ b/source/Felix/Parse.hs
@@ -8,6 +8,7 @@ module Felix.Parse
( ParseException(..)
, ParseWorkspaceError(..)
, renderParseWorkspaceError
+ , renderSyntaxMaterializationError
, ParseExecutionError(..)
, ParsedArtifactIntegrityError(..)
, SyntaxDeclarationError(..)
@@ -89,7 +90,9 @@ module Felix.Parse
, parseMeasurementTargetInspectionCount
, parseSourceWorkspaceMeasured
, parseSourceWorkspaceMeasuredWithSyntaxInputs
+ , parseSourceWorkspaceMeasuredWithSyntaxInputsAndGraphValidation
, parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputs
+ , parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndGraphValidation
, parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndCallback
, parseSourceWorkspaceWith
, parseResolvedSourceGraph
@@ -1149,10 +1152,28 @@ parseSourceWorkspaceMeasuredWithSyntaxInputs
(ParsedSourceWorkspace, ParseMeasurements))
-- Implicit syntax inputs must be self-contained module interfaces.
parseSourceWorkspaceMeasuredWithSyntaxInputs mounts request syntaxInputs =
- parseSourceWorkspaceMeasuredWithSyntaxInputsAndCallback
+ parseSourceWorkspaceMeasuredWithSyntaxInputsAndGraphValidation
mounts
request
syntaxInputs
+ (const (Right ()))
+
+parseSourceWorkspaceMeasuredWithSyntaxInputsAndGraphValidation
+ :: SourceMounts
+ -> RootRequest
+ -> (ResolvedSource -> [ModuleSyntaxInterface])
+ -> (ResolvedSourceGraph -> Either SourceError ())
+ -> IO
+ (Either
+ ParseWorkspaceError
+ (ParsedSourceWorkspace, ParseMeasurements))
+parseSourceWorkspaceMeasuredWithSyntaxInputsAndGraphValidation
+ mounts request syntaxInputs validateGraph =
+ parseSourceWorkspaceMeasuredWithSyntaxInputsAndGraphValidationAndCallback
+ mounts
+ request
+ syntaxInputs
+ validateGraph
(\_source _block -> pure ())
parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputs
@@ -1166,8 +1187,24 @@ parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputs
(ParsedSourceWorkspace, ParseMeasurements))
parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputs
store mounts request syntaxInputs =
- parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndCallback
- store mounts request syntaxInputs (\_source _block -> pure ())
+ parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndGraphValidation
+ store mounts request syntaxInputs (const (Right ()))
+
+parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndGraphValidation
+ :: Store.Store
+ -> SourceMounts
+ -> RootRequest
+ -> (ResolvedSource -> [ModuleSyntaxInterface])
+ -> (ResolvedSourceGraph -> Either SourceError ())
+ -> IO
+ (Either
+ ParseExecutionError
+ (ParsedSourceWorkspace, ParseMeasurements))
+parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndGraphValidation
+ store mounts request syntaxInputs validateGraph =
+ parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndGraphValidationAndCallback
+ store mounts request syntaxInputs validateGraph
+ (\_source _block -> pure ())
parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndCallback
:: Store.Store
@@ -1181,6 +1218,22 @@ parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndCallback
(ParsedSourceWorkspace, ParseMeasurements))
parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndCallback
store mounts request syntaxInputs emitBlock = do
+ parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndGraphValidationAndCallback
+ store mounts request syntaxInputs (const (Right ())) emitBlock
+
+parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndGraphValidationAndCallback
+ :: Store.Store
+ -> SourceMounts
+ -> RootRequest
+ -> (ResolvedSource -> [ModuleSyntaxInterface])
+ -> (ResolvedSourceGraph -> Either SourceError ())
+ -> (ResolvedSource -> Raw.Block -> IO ())
+ -> IO
+ (Either
+ ParseExecutionError
+ (ParsedSourceWorkspace, ParseMeasurements))
+parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndGraphValidationAndCallback
+ store mounts request syntaxInputs validateGraph emitBlock = do
resolutionStart <- getMonotonicTimeNSec
graphResult <- buildResolvedSourceGraphMeasured mounts request
resolutionEnd <- getMonotonicTimeNSec
@@ -1191,20 +1244,27 @@ parseSourceWorkspaceMeasuredWithStoreAndSyntaxInputsAndCallback
(ParseExecutionWorkspaceError
(SourceWorkspaceError err)))
Right (graph, selectionMeasurements) ->
- fmap
- (fmap
- (\(workspace, measurements) ->
- ( workspace
- , withResolutionMeasurements
- measurements
- (resolutionEnd - resolutionStart)
- selectionMeasurements
- )))
- (parseResolvedSourceGraphMeasuredWithArtifacts
- (PersistentParsedArtifacts store)
- graph
- syntaxInputs
- emitBlock)
+ case validateGraph graph of
+ Left err ->
+ pure
+ (Left
+ (ParseExecutionWorkspaceError
+ (SourceWorkspaceError err)))
+ Right () ->
+ fmap
+ (fmap
+ (\(workspace, measurements) ->
+ ( workspace
+ , withResolutionMeasurements
+ measurements
+ (resolutionEnd - resolutionStart)
+ selectionMeasurements
+ )))
+ (parseResolvedSourceGraphMeasuredWithArtifacts
+ (PersistentParsedArtifacts store)
+ graph
+ syntaxInputs
+ emitBlock)
-- | Resolve, strictly load, and parse one source closure with a block
-- callback.
@@ -1250,6 +1310,21 @@ parseSourceWorkspaceMeasuredWithSyntaxInputsAndCallback
(ParsedSourceWorkspace, ParseMeasurements))
parseSourceWorkspaceMeasuredWithSyntaxInputsAndCallback
mounts request syntaxInputs emitBlock = do
+ parseSourceWorkspaceMeasuredWithSyntaxInputsAndGraphValidationAndCallback
+ mounts request syntaxInputs (const (Right ())) emitBlock
+
+parseSourceWorkspaceMeasuredWithSyntaxInputsAndGraphValidationAndCallback
+ :: SourceMounts
+ -> RootRequest
+ -> (ResolvedSource -> [ModuleSyntaxInterface])
+ -> (ResolvedSourceGraph -> Either SourceError ())
+ -> (ResolvedSource -> Raw.Block -> IO ())
+ -> IO
+ (Either
+ ParseWorkspaceError
+ (ParsedSourceWorkspace, ParseMeasurements))
+parseSourceWorkspaceMeasuredWithSyntaxInputsAndGraphValidationAndCallback
+ mounts request syntaxInputs validateGraph emitBlock = do
resolutionStart <- getMonotonicTimeNSec
graphResult <- buildResolvedSourceGraphMeasured mounts request
resolutionEnd <- getMonotonicTimeNSec
@@ -1257,23 +1332,27 @@ parseSourceWorkspaceMeasuredWithSyntaxInputsAndCallback
Left err ->
pure (Left (SourceWorkspaceError err))
Right (graph, selectionMeasurements) ->
- fmap
- (fmap
- (\(workspace, measurements) ->
- let
- -- Resolution includes source loading and import
- -- scanning for graph construction.
- measured =
- withResolutionMeasurements
- measurements
- (resolutionEnd - resolutionStart)
- selectionMeasurements
- in
- (workspace, measured)))
- (parseResolvedSourceGraphMeasuredWith
- graph
- syntaxInputs
- emitBlock)
+ case validateGraph graph of
+ Left err ->
+ pure (Left (SourceWorkspaceError err))
+ Right () ->
+ fmap
+ (fmap
+ (\(workspace, measurements) ->
+ let
+ -- Resolution includes source loading and
+ -- import scanning for graph construction.
+ measured =
+ withResolutionMeasurements
+ measurements
+ (resolutionEnd - resolutionStart)
+ selectionMeasurements
+ in
+ (workspace, measured)))
+ (parseResolvedSourceGraphMeasuredWith
+ graph
+ syntaxInputs
+ emitBlock)
parseResolvedSourceGraph
:: ResolvedSourceGraph