Skip to content
Permalink
Browse files

Proposed fix for issue elm#9

  • Loading branch information...
Brendan Lawlor
Brendan Lawlor committed Dec 31, 2018
1 parent 2bf6e09 commit 3efe129adb056a91480d1ed6f6f5e0112ba655c4
Showing with 66 additions and 1 deletion.
  1. +66 −1 src/Parser.elm
@@ -154,6 +154,9 @@ type Problem
| BadRepeat





{-| Turn all the `DeadEnd` data into a string that is easier for people to
read.
@@ -168,7 +171,67 @@ _thinks_ is happening can be really helpful!
-}
deadEndsToString : List DeadEnd -> String
deadEndsToString deadEnds =
"TODO deadEndsToString"
String.join "\n" (List.map deadEndToString deadEnds)


deadEndToString : DeadEnd -> String
deadEndToString deadEnd =
problemToString deadEnd.problem
++ " at "
++ deadEndToRowColString deadEnd

problemToString : Problem -> String
problemToString prob =
case prob of
Expecting s ->
"Expecting " ++ s

ExpectingInt ->
"Expecting Int"

ExpectingHex ->
"Expecting Hex"

ExpectingOctal ->
"Expecting Octal"

ExpectingBinary ->
"Expecting Binary"

ExpectingFloat ->
"Expecting Float"

ExpectingNumber ->
"Expecting Number"

ExpectingVariable ->
"Expecting Variable"

ExpectingSymbol s ->
"Expecting Symbol " ++ s

ExpectingKeyword s ->
"Expecting Keyword " ++ s

ExpectingEnd ->
"Expecting End"

UnexpectedChar ->
"Unexpected Char"

Problem s ->
"Problem: " ++ s

BadRepeat ->
"Bad Repeat"




deadEndToRowColString : DeadEnd -> String
deadEndToRowColString deadEnd =
"row " ++ String.fromInt deadEnd.row ++ ", " ++ "col " ++ String.fromInt deadEnd.col




@@ -1256,3 +1319,5 @@ toAdvancedNestable nestable =
case nestable of
NotNestable -> A.NotNestable
Nestable -> A.Nestable


0 comments on commit 3efe129

Please sign in to comment.
You can’t perform that action at this time.