Skip to content

Commit

Permalink
take deadEndsToString implementation from PR, fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
brandly committed Apr 18, 2020
1 parent dd7b234 commit 5b313e0
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ update options msg model =
)

Err e ->
( model, Native.Log.line <| E.string ("failed to parse: " ++ Parser.deadEndsToString e) )
( model, Native.Log.line <| E.string ("failed to parse: " ++ deadEndsToString e) )

( Crawling state, FileError (Ok { code, message, path }) ) ->
if code == "ENOENT" then
Expand Down Expand Up @@ -203,3 +203,61 @@ subscriptions model =

_ ->
Sub.none


deadEndsToString : List Parser.DeadEnd -> String
deadEndsToString deadEnds =
-- Parser.deadEndsToString is broken/neglected. Here's a patch from this PR:
-- https://github.com/elm/parser/pull/38
let
deadEndToString : Parser.DeadEnd -> String
deadEndToString deadEnd =
let
position : String
position =
"row:" ++ String.fromInt deadEnd.row ++ " col:" ++ String.fromInt deadEnd.col ++ "\n"
in
case deadEnd.problem of
Parser.Expecting str ->
"Expecting " ++ str ++ "at " ++ position

Parser.ExpectingInt ->
"ExpectingInt at " ++ position

Parser.ExpectingHex ->
"ExpectingHex at " ++ position

Parser.ExpectingOctal ->
"ExpectingOctal at " ++ position

Parser.ExpectingBinary ->
"ExpectingBinary at " ++ position

Parser.ExpectingFloat ->
"ExpectingFloat at " ++ position

Parser.ExpectingNumber ->
"ExpectingNumber at " ++ position

Parser.ExpectingVariable ->
"ExpectingVariable at " ++ position

Parser.ExpectingSymbol str ->
"ExpectingSymbol " ++ str ++ " at " ++ position

Parser.ExpectingKeyword str ->
"ExpectingKeyword " ++ str ++ "at " ++ position

Parser.ExpectingEnd ->
"ExpectingEnd at " ++ position

Parser.UnexpectedChar ->
"UnexpectedChar at " ++ position

Parser.Problem str ->
"ProblemString " ++ str ++ " at " ++ position

Parser.BadRepeat ->
"BadRepeat at " ++ position
in
List.foldl (++) "" (List.map deadEndToString deadEnds)

0 comments on commit 5b313e0

Please sign in to comment.