Simplify the final evaluation by not having it return a context

This commit is contained in:
Jeroen Engels 2019-06-15 21:13:40 +02:00
parent e979393ef8
commit 68a4c9ab01
3 changed files with 13 additions and 17 deletions

View File

@ -22,7 +22,7 @@ createExitAndEnterWithChildren toVisitor node children =
moduleVisitor : Visitor context
moduleVisitor rule context =
finalEvaluation rule context
( finalEvaluation rule context, context )
moduleDefinitionVisitor : Node Module -> Visitor context

View File

@ -95,7 +95,7 @@ type Implementation context
, importVisitor : context -> Node Import -> ( List Error, context )
, expressionVisitor : context -> Direction -> Node Expression -> ( List Error, context )
, declarationVisitor : context -> Direction -> Node Declaration -> ( List Error, context )
, finalEvaluationFn : context -> ( List Error, context )
, finalEvaluationFn : context -> List Error
}
@ -111,7 +111,7 @@ create initContext =
, importVisitor = \ctx node -> ( [], ctx )
, expressionVisitor = \ctx direction node -> ( [], ctx )
, declarationVisitor = \ctx direction node -> ( [], ctx )
, finalEvaluationFn = \ctx -> ( [], ctx )
, finalEvaluationFn = \ctx -> []
}
@ -135,7 +135,7 @@ withDeclarationVisitor visitor (Implementation impl) =
Implementation { impl | declarationVisitor = visitor }
withFinalEvaluation : (context -> ( List Error, context )) -> Implementation context -> Implementation context
withFinalEvaluation : (context -> List Error) -> Implementation context -> Implementation context
withFinalEvaluation visitor (Implementation impl) =
Implementation { impl | finalEvaluationFn = visitor }
@ -165,7 +165,7 @@ evaluateDeclaration (Implementation impl) =
impl.declarationVisitor
finalEvaluation : Implementation context -> context -> ( List Error, context )
finalEvaluation : Implementation context -> context -> List Error
finalEvaluation (Implementation impl) =
impl.finalEvaluationFn

View File

@ -315,20 +315,16 @@ declarationVisitor ctx direction node =
( [], ctx )
finalEvaluation : Context -> ( List Error, Context )
finalEvaluation : Context -> List Error
finalEvaluation ctx =
let
errors =
if ctx.exposesEverything then
[]
if ctx.exposesEverything then
[]
else
ctx.scopes
|> Nonempty.head
|> makeReport
|> Tuple.first
in
( errors, ctx )
else
ctx.scopes
|> Nonempty.head
|> makeReport
|> Tuple.first
registerFunction : Function -> Context -> Context