From 025b21c9546af634f9c279092632a0e922eb6102 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sun, 3 Feb 2019 22:46:46 -0800 Subject: [PATCH] Require that the parser parses the whole string. --- src/Main.elm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Main.elm b/src/Main.elm index d5d92f6..2551e1f 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -4,7 +4,7 @@ import Html.Events exposing (onInput) import Browser exposing (element) import Canvas exposing (Shape) import Dict exposing (Dict) -import Parser exposing (Parser, Problem(..), DeadEnd, (|.), (|=), variable, succeed, symbol, int, spaces, map, oneOf, lazy, sequence, Trailing(..), keyword, run, backtrackable) +import Parser exposing (Parser, Problem(..), DeadEnd, (|.), (|=), variable, succeed, symbol, int, spaces, map, oneOf, lazy, sequence, Trailing(..), keyword, run, backtrackable, end) import Color import Canvas exposing (Point, path, lineTo, circle, shapes, stroke, lineWidth, fill, rect) import Set @@ -357,9 +357,9 @@ init fs = view : Model -> Html Msg view m = let + parseResult = Result.mapError humanParseError (run (parseProg |. end) m.programText) evalResult = Result.map (\(_, s) -> s) - <| Result.andThen (\prg -> evaluateAll prg initialState) - <| Result.mapError humanParseError (run parseProg m.programText) + <| Result.andThen (\prg -> evaluateAll prg initialState) parseResult toRender = Result.withDefault initialState evalResult error = case evalResult of Err e -> [ p [ classList [ ("centered", True), ("error", True), ("shadow", True) ] ] [ text e ] ]