Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed fix for issue #9 #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 66 additions & 1 deletion src/Parser.elm
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ type Problem
| BadRepeat





{-| Turn all the `DeadEnd` data into a string that is easier for people to
read.

Expand All @@ -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




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