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

Dead ends to string #16

Open
wants to merge 4 commits 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
27 changes: 25 additions & 2 deletions src/Parser.elm
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,31 @@ _thinks_ is happening can be really helpful!
-}
deadEndsToString : List DeadEnd -> String
deadEndsToString deadEnds =
"TODO deadEndsToString"

String.concat (List.intersperse "; " (List.map deadEndToString deadEnds))


deadEndToString : DeadEnd -> String
deadEndToString deadend =
problemToString deadend.problem ++ " at row " ++ String.fromInt deadend.row ++ ", col " ++ String.fromInt deadend.col


problemToString : Problem -> String
problemToString p =
case p 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"


-- PIPELINES
Expand Down