@@ -620,31 +620,72 @@ toParseErrorReport source modul =
620 error "TODO FreshLineAfterDocComment" row col
620 error "TODO FreshLineAfterDocComment" row col
622 ImportStart row col ->
622 ImportStart row col ->
623− error "TODO ImportStart" row col
623+ toImportReport source row col
625 ImportName row col ->
625 ImportName row col ->
626− error "TODO ImportName" row col
626+ let
627+ region = toRegion row col
629+ Report.Report "EXPECTING IMPORT NAME" region [] $
630+ Code.toSnippet source region Nothing
633+ "I was parsing an `import` until I got stuck here:"
637+ "I was expecting to see a module name next, like in these examples:"
638+ , D.indent 4 $ D.vcat $
639+ [ D.fillSep [D.blue "import","Dict"]
640+ , D.fillSep [D.blue "import","Maybe"]
641+ , D.fillSep [D.blue "import","Html.Attributes"]
642+ , D.fillSep [D.blue "import","Json.Decode"]
645+ "Notice that the module names all start with capital letters. That is required!"
628 ImportAs row col ->
649 ImportAs row col ->
629− error "TODO ImportAs" row col
650+ toImportReport source row col
631 ImportAlias row col ->
652 ImportAlias row col ->
632− error "TODO ImportAlias" row col
653+ let
654+ region = toRegion row col
656+ Report.Report "EXECTING IMPORT ALIAS" region [] $
657+ Code.toSnippet source region Nothing
660+ "I was parsing an `import` until I got stuck here:"
664+ "I was expecting to see an alias next, like in these examples:"
665+ , D.indent 4 $ D.vcat $
666+ [ D.fillSep [D.blue "import","Html.Attributes",D.blue "as","Attr"]
667+ , D.fillSep [D.blue "import","WebGL.Texture",D.blue "as","Texture"]
668+ , D.fillSep [D.blue "import","Json.Decode",D.blue "as","D"]
671+ "Notice that the alias always starts with a capital letter. That is required!"
634 ImportExposing row col ->
675 ImportExposing row col ->
635− error "TODO ImportExposing" row col
676+ toImportReport source row col
637 ImportExposingList exposing row col ->
678 ImportExposingList exposing row col ->
638 error "TODO ImportExposingList" exposing row col
679 error "TODO ImportExposingList" exposing row col
640 ImportEnd row col ->
681 ImportEnd row col ->
641− error "TODO ImportEnd" row col
682+ toImportReport source row col
643 ImportIndentName row col ->
684 ImportIndentName row col ->
644− error "TODO ImportIndentName" row col
685+ toImportReport source row col
646 ImportIndentAlias row col ->
687 ImportIndentAlias row col ->
647− error "TODO ImportIndentAlias" row col
688+ toImportReport source row col
649 ImportIndentExposingList row col ->
690 ImportIndentExposingList row col ->
@@ -661,8 +702,8 @@ toParseErrorReport source modul =
661 "I was expecting to see the list of exposed values next. For example, here\
702 "I was expecting to see the list of exposed values next. For example, here\
662 \ are two ways to expose values from the `Html` module:"
703 \ are two ways to expose values from the `Html` module:"
663 , D.indent 4 $ D.vcat $
704 , D.indent 4 $ D.vcat $
664− [ D.fillSep [D.blue "import","Html",D.blue "exposing",D.green "(..)"]
705+ [ D.fillSep [D.blue "import","Html",D.blue "exposing","(..)"]
665− , D.fillSep [D.blue "import","Html",D.blue "exposing",D.green "(Html, div, text)"]
706+ , D.fillSep [D.blue "import","Html",D.blue "exposing","(Html, div, text)"]
667 , D.reflow $
708 , D.reflow $
668 "I generally recommend the second style. It is more explicit, making it\
709 "I generally recommend the second style. It is more explicit, making it\
@@ -689,6 +730,40 @@ toParseErrorReport source modul =
689 toDeclarationsReport source decl
730 toDeclarationsReport source decl
737+toImportReport :: Code.Source -> Row -> Col -> Report.Report
738+toImportReport source row col =
740+ region = toRegion row col
742+ Report.Report "UNFINISHED IMPORT" region [] $
743+ Code.toSnippet source region Nothing
746+ "I am partway through parsing an import, but I got stuck here:"
750+ "Here are some examples of valid `import` declarations:"
751+ , D.indent 4 $ D.vcat $
752+ [ D.fillSep [D.blue "import","Html"]
753+ , D.fillSep [D.blue "import","Html",D.blue "as","H"]
754+ , D.fillSep [D.blue "import","Html",D.blue "exposing","(Html, div, text)"]
755+ , D.fillSep [D.blue "import","Html",D.blue "as","H",D.blue "exposing","(..)"]
758+ "You are probably trying to import a different module, but try to make it look like one of these examples!"
692toSpaceReport :: Code.Source -> Space -> Row -> Col -> Report.Report
767toSpaceReport :: Code.Source -> Space -> Row -> Col -> Report.Report
693toSpaceReport source space row col =
768toSpaceReport source space row col =
694 case space of
769 case space of
@@ -726,6 +801,10 @@ toSpaceReport source space row col =
729toRegion :: Row -> Col -> A.Region
808toRegion :: Row -> Col -> A.Region
730toRegion row col =
809toRegion row col =
@@ -1621,7 +1700,7 @@ toRecordReport source context record startRow startCol =
1621 region = toRegion row col
1700 region = toRegion row col
1623 case Code.whatIsNext source row col of
1702 case Code.whatIsNext source row col of
1624− Keyword keyword ->
1703+ Code.Keyword keyword ->
1625 Report.Report "RESERVED WORD" region [] $
1704 Report.Report "RESERVED WORD" region [] $
1626 Code.toSnippet source surroundings (Just region)
1705 Code.toSnippet source surroundings (Just region)