From e6cb5693568615f4958dd317052392c0cceec48f Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Thu, 13 Sep 2018 13:08:34 -0600 Subject: [PATCH 1/4] initial implementation of deadEndsToString --- src/Parser.elm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Parser.elm b/src/Parser.elm index 5a8b03a..d42f5f9 100644 --- a/src/Parser.elm +++ b/src/Parser.elm @@ -168,7 +168,30 @@ _thinks_ is happening can be really helpful! -} deadEndsToString : List DeadEnd -> String deadEndsToString deadEnds = - "TODO deadEndsToString" + String.concat (List.intersperse "\n" (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 -> "ExpectingInt" + ExpectingHex -> "ExpectingOctal" + ExpectingOctal -> "ExpectingOctal" + ExpectingBinary -> "ExpectingBinary" + ExpectingFloat -> "ExpectingNumber" + ExpectingNumber -> "ExpectingVariable" + ExpectingVariable -> "ExpectingVariable" + ExpectingSymbol s -> "ExpectingSymbol " ++ s + ExpectingKeyword s -> "ExpectingKeyword " ++ s + ExpectingEnd -> "ExpectingEnd" + UnexpectedChar -> "UnexpectedChar" + Problem s -> "Problem " ++ s + BadRepeat -> "BadRepeat" From 7949067c4b3e639a86d379a5b81b0d00b742f618 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Thu, 13 Sep 2018 13:41:46 -0600 Subject: [PATCH 2/4] lowercase; --- src/Parser.elm | 52 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/src/Parser.elm b/src/Parser.elm index d42f5f9..c0929aa 100644 --- a/src/Parser.elm +++ b/src/Parser.elm @@ -9,6 +9,7 @@ module Parser exposing , DeadEnd, Problem(..), deadEndsToString , withIndent, getIndent , getPosition, getRow, getCol, getOffset, getSource + , endTests ) @@ -42,7 +43,7 @@ module Parser exposing @docs withIndent, getIndent # Positions -@docs getPosition, getRow, getCol, getOffset, getSource +@docs getPosition, getRow, getCol, getOffset, getSource, endTests -} @@ -168,7 +169,7 @@ _thinks_ is happening can be really helpful! -} deadEndsToString : List DeadEnd -> String deadEndsToString deadEnds = - String.concat (List.intersperse "\n" (List.map deadEndToString deadEnds)) + String.concat (List.intersperse "; " (List.map deadEndToString deadEnds)) deadEndToString : DeadEnd -> String deadEndToString deadend = @@ -178,21 +179,38 @@ deadEndToString deadend = problemToString : Problem -> String problemToString p = case p of - Expecting s -> "Expecting " ++ s - ExpectingInt -> "ExpectingInt" - ExpectingHex -> "ExpectingOctal" - ExpectingOctal -> "ExpectingOctal" - ExpectingBinary -> "ExpectingBinary" - ExpectingFloat -> "ExpectingNumber" - ExpectingNumber -> "ExpectingVariable" - ExpectingVariable -> "ExpectingVariable" - ExpectingSymbol s -> "ExpectingSymbol " ++ s - ExpectingKeyword s -> "ExpectingKeyword " ++ s - ExpectingEnd -> "ExpectingEnd" - UnexpectedChar -> "UnexpectedChar" - Problem s -> "Problem " ++ s - BadRepeat -> "BadRepeat" - + Expecting s -> "expecting '" ++ s ++ "'" + ExpectingInt -> "expecting int" + ExpectingHex -> "expecting octal" + ExpectingOctal -> "expecting octal" + ExpectingBinary -> "expecting binary" + ExpectingFloat -> "expecting number" + ExpectingNumber -> "expecting variable" + 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" + + +endTests = + List.map (\p -> { row = 0, col = 0, problem = p }) + [ Expecting "blah" + , ExpectingInt + , ExpectingHex + , ExpectingOctal + , ExpectingBinary + , ExpectingFloat + , ExpectingNumber + , ExpectingVariable + , ExpectingSymbol "symbol" + , ExpectingKeyword "keyword" + , ExpectingEnd + , UnexpectedChar + , Problem "problem" + , BadRepeat ] -- PIPELINES From 18e57b458a0d94d1f1ed7ea25fc5a6494c230b38 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Thu, 13 Sep 2018 13:42:17 -0600 Subject: [PATCH 3/4] remove test stuff --- src/Parser.elm | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/Parser.elm b/src/Parser.elm index c0929aa..8a830e7 100644 --- a/src/Parser.elm +++ b/src/Parser.elm @@ -9,7 +9,6 @@ module Parser exposing , DeadEnd, Problem(..), deadEndsToString , withIndent, getIndent , getPosition, getRow, getCol, getOffset, getSource - , endTests ) @@ -43,7 +42,7 @@ module Parser exposing @docs withIndent, getIndent # Positions -@docs getPosition, getRow, getCol, getOffset, getSource, endTests +@docs getPosition, getRow, getCol, getOffset, getSource -} @@ -195,24 +194,6 @@ problemToString p = BadRepeat -> "bad repeat" -endTests = - List.map (\p -> { row = 0, col = 0, problem = p }) - [ Expecting "blah" - , ExpectingInt - , ExpectingHex - , ExpectingOctal - , ExpectingBinary - , ExpectingFloat - , ExpectingNumber - , ExpectingVariable - , ExpectingSymbol "symbol" - , ExpectingKeyword "keyword" - , ExpectingEnd - , UnexpectedChar - , Problem "problem" - , BadRepeat ] - - -- PIPELINES From 33c98fc8159fe4fd7d726b25036c8a3dad793e8a Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Thu, 13 Sep 2018 22:19:30 -0600 Subject: [PATCH 4/4] wups, fix these messages! --- src/Parser.elm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Parser.elm b/src/Parser.elm index 8a830e7..fd797f7 100644 --- a/src/Parser.elm +++ b/src/Parser.elm @@ -170,6 +170,7 @@ deadEndsToString : List DeadEnd -> String deadEndsToString deadEnds = 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 @@ -180,11 +181,11 @@ problemToString p = case p of Expecting s -> "expecting '" ++ s ++ "'" ExpectingInt -> "expecting int" - ExpectingHex -> "expecting octal" + ExpectingHex -> "expecting hex" ExpectingOctal -> "expecting octal" ExpectingBinary -> "expecting binary" - ExpectingFloat -> "expecting number" - ExpectingNumber -> "expecting variable" + ExpectingFloat -> "expecting float" + ExpectingNumber -> "expecting number" ExpectingVariable -> "expecting variable" ExpectingSymbol s -> "expecting symbol '" ++ s ++ "'" ExpectingKeyword s -> "expecting keyword '" ++ s ++ "'"