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

Fix for the inconsistent internal parser state bug #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/Elm/Kernel/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ var _Parser_consumeBase16 = F2(function(offset, string)

var _Parser_findSubString = F5(function(smallString, offset, row, col, bigString)
{
var newOffset = bigString.indexOf(smallString, offset);
var target = newOffset < 0 ? bigString.length : newOffset + smallString.length;
var index = bigString.indexOf(smallString, offset);
var target = index < 0 ? bigString.length : index + smallString.length;

while (offset < target)
{
Expand All @@ -130,5 +130,5 @@ var _Parser_findSubString = F5(function(smallString, offset, row, col, bigString
: ( col++, (code & 0xF800) === 0xD800 && offset++ )
}

return __Utils_Tuple3(newOffset, row, col);
return __Utils_Tuple3(index < 0 ? -1 : target, row, col);
});
4 changes: 2 additions & 2 deletions src/Parser/Advanced.elm
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ chompUntilEndOr str =
Parser <| \s ->
let
(newOffset, newRow, newCol) =
Elm.Kernel.Parser.findSubString str s.offset s.row s.col s.src
findSubString str s.offset s.row s.col s.src

adjustedOffset =
if newOffset < 0 then String.length s.src else newOffset
Expand Down Expand Up @@ -1125,7 +1125,7 @@ isAsciiCode =
findSubString "42" offset row col "Is 42 the answer?"
--==> (newOffset, newRow, newCol)

If `offset = 0` we would get `(3, 1, 4)`
If `offset = 0` we would get `(5, 1, 6)`
If `offset = 7` we would get `(-1, 1, 18)`
-}
findSubString : String -> Int -> Int -> Int -> String -> (Int, Int, Int)
Expand Down