Change FC end column to be one past the end
This commit is contained in:
@@ -20,7 +20,7 @@ for fn in tests/*.newt ; do
|
||||
echo "Compile failure mismatch for $fn"
|
||||
diff ${fn}.fail tmp/${bn}.compile
|
||||
failed=$((failed + 1))
|
||||
if [ $1 = "--fix" ]; then
|
||||
if [ x$1 = "x--fix" ]; then
|
||||
cp tmp/${bn}.compile ${fn}.fail
|
||||
fi
|
||||
continue
|
||||
@@ -44,7 +44,7 @@ for fn in tests/*.newt ; do
|
||||
echo "Output mismatch for $fn"
|
||||
diff ${fn}.golden tmp/${bn}.out
|
||||
failed=$((failed + 1))
|
||||
if [ $1 = "--fix" ]; then
|
||||
if [ x$1 = "x--fix" ]; then
|
||||
cp tmp/${bn}.out ${fn}.golden
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -98,7 +98,7 @@ makeEdits fc@(MkFC uri (MkBounds sr sc er ec)) names inPlace = do
|
||||
let (Just line) = getAt' sr lines | _ => pure Nil
|
||||
let cs = unpack line
|
||||
let head = take (cast sc) cs
|
||||
let tail = drop (S $ cast ec) cs
|
||||
let tail = drop (S $ cast (ec - 1)) cs
|
||||
let (isEq, before, after) = splitEquals Lin tail
|
||||
let np = needParens (Lin <>< head) tail
|
||||
let cons = map (addParens np) cons
|
||||
|
||||
@@ -88,7 +88,7 @@ fcToRange (MkFC uri (MkBounds sr sc er ec)) =
|
||||
if sc == 0 && ec == 0
|
||||
-- For the insert position in edits
|
||||
then JsonObj $ ("start", mkPosition sr sc) :: ("end", mkPosition er (ec)) :: Nil
|
||||
else JsonObj $ ("start", mkPosition sr sc) :: ("end", mkPosition er (ec + 1)) :: Nil
|
||||
else JsonObj $ ("start", mkPosition sr sc) :: ("end", mkPosition er (ec)) :: Nil
|
||||
where
|
||||
mkPosition : Int → Int → Json
|
||||
mkPosition l c = JsonObj $ ("line", JsonInt l) :: ("character", JsonInt c) :: Nil
|
||||
|
||||
@@ -164,8 +164,7 @@ data Error
|
||||
| Postpone FC QName String
|
||||
|
||||
instance Show FC where
|
||||
-- We add one to the end column so it points after the end, which seems to be what Idris does
|
||||
show (MkFC file (MkBounds l c el ec)) = "\{file}:\{show $ l + 1}:\{show $ c + 1}--\{show $ el + 1}:\{show $ ec + 2}"
|
||||
show (MkFC file (MkBounds l c el ec)) = "\{file}:\{show $ l + 1}:\{show $ c + 1}--\{show $ el + 1}:\{show $ ec + 1}"
|
||||
|
||||
showError : String -> Error -> String
|
||||
showError src (E fc msg) = "ERROR at \{show fc}: \{msg}\n" ++ go 0 (lines src)
|
||||
@@ -174,7 +173,7 @@ showError src (E fc msg) = "ERROR at \{show fc}: \{msg}\n" ++ go 0 (lines src)
|
||||
go l Nil = ""
|
||||
go l (x :: xs) =
|
||||
if l == fcLine fc then
|
||||
let width = fc.bnds.endCol - fc.bnds.startCol + 1 in
|
||||
let width = fc.bnds.endCol - fc.bnds.startCol in
|
||||
" \{x}\n \{replicate (cast $ fcCol fc) ' '}\{replicate (cast width) '^'}\n"
|
||||
else if fcLine fc - 3 < l then " " ++ x ++ "\n" ++ go (l + 1) xs
|
||||
else go (l + 1) xs
|
||||
|
||||
@@ -63,7 +63,7 @@ quoteTokenise ts@(TS el ec toks chars) startl startc acc = case chars of
|
||||
|
||||
where
|
||||
stok : BTok
|
||||
stok = MkBounded (Tok StringKind (pack $ acc <>> Nil)) (MkBounds startl startc el ec)
|
||||
stok = MkBounded (Tok StringKind (pack $ acc <>> Nil)) (MkBounds startl startc el (ec + 1))
|
||||
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ rawTokenise ts@(TS sl sc toks chars) = case chars of
|
||||
Right (TS sl sc toks chars) => case chars of
|
||||
'"' :: cs => let tok = mktok False sl (sc + 1) EndQuote "\"" in
|
||||
rawTokenise (TS sl (sc + 1) (toks :< tok) cs)
|
||||
cs => Left $ E (MkFC "" (MkBounds sl sc sl sc)) "Expected '\"'"
|
||||
cs => Left $ E (MkFC "" (MkBounds sl sc sl (sc + 1))) "Expected '\"'"
|
||||
|
||||
'{' :: '{' :: cs =>
|
||||
let tok = mktok False sl (sc + 2) Keyword "{{" in
|
||||
@@ -88,7 +88,7 @@ rawTokenise ts@(TS sl sc toks chars) = case chars of
|
||||
Right (TS sl sc toks chars) => case chars of
|
||||
'}' :: '}' :: cs => let tok = mktok False sl (sc + 2) Keyword "}}" in
|
||||
rawTokenise (TS sl (sc + 2) (toks :< tok) cs)
|
||||
cs => Left $ E (MkFC "" (MkBounds sl sc sl sc)) "Expected '}}'"
|
||||
cs => Left $ E (MkFC "" (MkBounds sl sc sl (sc + 1))) "Expected '}}'"
|
||||
|
||||
'}' :: cs => Right ts
|
||||
'{' :: cs =>
|
||||
@@ -98,7 +98,7 @@ rawTokenise ts@(TS sl sc toks chars) = case chars of
|
||||
Right (TS sl sc toks chars) => case chars of
|
||||
'}' :: cs => let tok = mktok False sl (sc + 1) Symbol "}" in
|
||||
rawTokenise (TS sl (sc + 1) (toks :< tok) cs)
|
||||
cs => Left $ E (MkFC "" (MkBounds sl sc sl sc)) "Expected '}'"
|
||||
cs => Left $ E (MkFC "" (MkBounds sl sc sl (sc + 1))) "Expected '}'"
|
||||
|
||||
',' :: cs => rawTokenise (TS sl (sc + 1) (toks :< mktok False sl (sc + 1) Ident ",") cs)
|
||||
'_' :: ',' :: '_' :: cs => rawTokenise (TS sl (sc + 3) (toks :< mktok False sl (sc + 3) MixFix "_,_") cs)
|
||||
@@ -131,7 +131,7 @@ rawTokenise ts@(TS sl sc toks chars) = case chars of
|
||||
doBacktick : TState -> SnocList Char -> Either Error TState
|
||||
doBacktick (TS l c toks Nil) acc = Left $ E (MkFC "" (MkBounds l c l c)) "EOF in backtick string"
|
||||
doBacktick (TS el ec toks ('`' :: cs)) acc =
|
||||
let tok = MkBounded (Tok JSLit (pack $ acc <>> Nil)) (MkBounds sl sc el ec) in
|
||||
let tok = MkBounded (Tok JSLit (pack $ acc <>> Nil)) (MkBounds sl sc el (ec + 1)) in
|
||||
rawTokenise (TS el (ec + 1) (toks :< tok) cs)
|
||||
doBacktick (TS l c toks ('\n' :: cs)) acc = doBacktick (TS (l + 1) 0 toks cs) (acc :< '\n')
|
||||
doBacktick (TS l c toks (ch :: cs)) acc = doBacktick (TS l (c + 1) toks cs) (acc :< ch)
|
||||
@@ -140,7 +140,7 @@ rawTokenise ts@(TS sl sc toks chars) = case chars of
|
||||
-- temporary use same token as before
|
||||
mktok : Bool -> Int -> Int -> Kind -> String -> BTok
|
||||
mktok checkkw el ec kind text = let kind = if checkkw && elem text keywords then Keyword else kind in
|
||||
MkBounded (Tok kind text) (MkBounds sl sc el ec)
|
||||
MkBounded (Tok kind text) (MkBounds sl sc el (ec + 1))
|
||||
|
||||
lineComment : TState -> Either Error TState
|
||||
lineComment (TS line col toks Nil) = rawTokenise (TS line col toks Nil)
|
||||
@@ -171,7 +171,7 @@ rawTokenise ts@(TS sl sc toks chars) = case chars of
|
||||
tokenise : String -> String -> Either Error (List BTok)
|
||||
tokenise fn text = case rawTokenise (TS 0 0 Lin (unpack text)) of
|
||||
Right (TS trow tcol acc Nil) => Right $ acc <>> Nil
|
||||
Right (TS trow tcol acc chars) => Left $ E (MkFC fn (MkBounds trow tcol trow tcol)) "Extra toks"
|
||||
Right (TS trow tcol acc chars) => Left $ E (MkFC fn (MkBounds trow tcol trow (tcol + 1))) "Extra toks"
|
||||
Left (E (MkFC file start) str) => Left $ E (MkFC fn start) str
|
||||
Left err => Left err
|
||||
|
||||
|
||||
@@ -7,4 +7,4 @@ ERROR at tests/BadAlt.newt:6:6--6:13: Prelude._:<_ not a constructor for (Prelud
|
||||
foo (xs :< x) = x
|
||||
^^^^^^^
|
||||
|
||||
ERROR at tests/BadAlt.newt:1:1--1:2: Compile failed
|
||||
ERROR at tests/BadAlt.newt:1:1--1:1: Compile failed
|
||||
|
||||
@@ -6,4 +6,4 @@ ERROR at tests/Duplicate.newt:5:1--5:5: Duplicate.Left is already defined at tes
|
||||
data Either : U -> U -> U where
|
||||
^^^^
|
||||
|
||||
ERROR at tests/Duplicate.newt:1:1--1:2: Compile failed
|
||||
ERROR at tests/Duplicate.newt:1:1--1:1: Compile failed
|
||||
|
||||
@@ -7,4 +7,4 @@ ERROR at tests/ErrMsg2.newt:6:13--6:15: Expected '=>' at Keyword:->
|
||||
foo x = \ x -> x
|
||||
^^
|
||||
|
||||
ERROR at tests/ErrMsg2.newt:1:1--1:2: Compile failed
|
||||
ERROR at tests/ErrMsg2.newt:1:1--1:1: Compile failed
|
||||
|
||||
@@ -18,4 +18,4 @@ ERROR at tests/ErrorDup.newt:5:6--5:9: Nat already declared
|
||||
data Nat = Z | S Nat
|
||||
^^^
|
||||
|
||||
ERROR at tests/ErrorDup.newt:1:1--1:2: Compile failed
|
||||
ERROR at tests/ErrorDup.newt:1:1--1:1: Compile failed
|
||||
|
||||
@@ -6,4 +6,4 @@ ERROR at tests/LitConCase.newt:7:5--7:11: expected Prim.Int
|
||||
foo MkUnit = MkUnit
|
||||
^^^^^^
|
||||
|
||||
ERROR at tests/LitConCase.newt:1:1--1:2: Compile failed
|
||||
ERROR at tests/LitConCase.newt:1:1--1:1: Compile failed
|
||||
|
||||
@@ -7,4 +7,4 @@ ERROR at tests/Possible.newt:6:5--6:8: possible constructors: [Prelude.Z, Prelud
|
||||
foo ()
|
||||
^^^
|
||||
|
||||
ERROR at tests/Possible.newt:1:1--1:2: Compile failed
|
||||
ERROR at tests/Possible.newt:1:1--1:1: Compile failed
|
||||
|
||||
@@ -7,4 +7,4 @@ ERROR at tests/Quantity.newt:11:15--11:16: used erased value x$0 (FIXME FC may b
|
||||
bar {x} = foo x
|
||||
^
|
||||
|
||||
ERROR at tests/Quantity.newt:1:1--1:2: Compile failed
|
||||
ERROR at tests/Quantity.newt:1:1--1:1: Compile failed
|
||||
|
||||
Reference in New Issue
Block a user