Require that the parser parses the whole string.

This commit is contained in:
Danila Fedorin 2019-02-03 22:46:46 -08:00
parent d4303606df
commit 025b21c954
1 changed files with 3 additions and 3 deletions

View File

@ -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 ] ]