From b29d1ea51fa40ed0bdd8341c518b8b82e2fd3283 Mon Sep 17 00:00:00 2001 From: Attila Mihaly <60483498+AttilaMihaly@users.noreply.github.com> Date: Tue, 28 Apr 2020 15:54:34 -0400 Subject: [PATCH] Report parse error location (#71) * Added missing module declarations. #37 * Process only those modules that are reachable from exposed ones. Remove package path from module names. #21 * Renaming concepts based on review feedback. #41 * Moved Advanced module up a level. #43 * Removed unused unindent function. * Moved name to SDK. * Added missing module to SDK. * Partial implementation of value mapping. * Ignore all generated JS. * Change extra arg position and naming. #46, #25 * Change extra arg position and naming. #46, #25 * Removed remaining references to extra. #5 * Change extra arg position. #46, #25, #5 * Added more coverage. #46, #25, #5 * Changes suggested in the PR. #46, #25, #5 * Use more explicit names. * All patterns supported. * Pattern-match supported. * Added support for SDK operators. #52 * Fix compile errors. * Prepare Elm module publishing. #2 * Fix repo name. #2 * Support for let expressions. #54 * Simple join implementations. #64 * Refactoring to make the code more organized. * Refactoring to make the code more organized. * Prepare value mapping utils. #53 * More descriptive naming. * More descriptive naming. * Removed unused function * Better naming * Added utility function and removed unused one. * Added variable resolution. * Hooked up variable resolution and updated tests. #53 * Completed reference resolution. #53 * Added missing docs and refactored. #68 * Document and refactor driven by the goal to process Morphir using Morphir. #68 * Various fixes. #68 * Report parse errors. --- src/Morphir/Elm/Frontend.elm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Morphir/Elm/Frontend.elm b/src/Morphir/Elm/Frontend.elm index 4ffaae826..a09beca04 100644 --- a/src/Morphir/Elm/Frontend.elm +++ b/src/Morphir/Elm/Frontend.elm @@ -43,7 +43,7 @@ import Morphir.IR.Value as Value exposing (Value) import Morphir.JsonExtra as JsonExtra import Morphir.ListOfResults as ListOfResults import Morphir.Rewrite as Rewrite -import Parser +import Parser exposing (DeadEnd) import Set exposing (Set) @@ -148,11 +148,22 @@ type Error | VariableShadowing Name SourceLocation SourceLocation +encodeDeadEnd : DeadEnd -> Encode.Value +encodeDeadEnd deadEnd = + Encode.list identity + [ Encode.int deadEnd.row + , Encode.int deadEnd.col + ] + + encodeError : Error -> Encode.Value encodeError error = case error of - ParseError _ _ -> - JsonExtra.encodeConstructor "ParseError" [] + ParseError sourcePath deadEnds -> + JsonExtra.encodeConstructor "ParseError" + [ Encode.string sourcePath + , Encode.list encodeDeadEnd deadEnds + ] CyclicModules _ -> JsonExtra.encodeConstructor "CyclicModules" []