Fix LSP crash and tokenizer issue
This commit is contained in:
@@ -165,7 +165,8 @@ rawTokenise ts@(TS sl sc toks chars) = case chars of
|
|||||||
doChar : Char -> List Char -> Either Error TState
|
doChar : Char -> List Char -> Either Error TState
|
||||||
doChar c cs = if elem c standalone
|
doChar c cs = if elem c standalone
|
||||||
then rawTokenise (TS sl (sc + 1) (toks :< mktok True sl (sc + 1) Symbol (pack $ c :: Nil)) cs)
|
then rawTokenise (TS sl (sc + 1) (toks :< mktok True sl (sc + 1) Symbol (pack $ c :: Nil)) cs)
|
||||||
else let kind = if isDigit c then Number else if isUpper c then UIdent else Ident in
|
else if isDigit c then doRest (TS sl sc toks (c :: cs)) Number isDigit Lin
|
||||||
|
else let kind = if isUpper c then UIdent else Ident in
|
||||||
doRest (TS sl sc toks (c :: cs)) kind isIdent Lin
|
doRest (TS sl sc toks (c :: cs)) kind isIdent Lin
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -456,8 +456,7 @@ debugLog a = putStrLn (debugStr a)
|
|||||||
|
|
||||||
pfunc stringToInt : String → Int := `(s) => {
|
pfunc stringToInt : String → Int := `(s) => {
|
||||||
let rval = Number(s)
|
let rval = Number(s)
|
||||||
if (isNaN(rval)) throw new Error(s + " is NaN")
|
return isNaN(rval) ? 0 : rval
|
||||||
return rval
|
|
||||||
}`
|
}`
|
||||||
|
|
||||||
class Foldable (m : U → U) where
|
class Foldable (m : U → U) where
|
||||||
|
|||||||
9
tests/Number.newt
Normal file
9
tests/Number.newt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
module Number
|
||||||
|
|
||||||
|
import Prelude
|
||||||
|
|
||||||
|
add : Int → Int → Int
|
||||||
|
add a b = a + b
|
||||||
|
|
||||||
|
main : IO Unit
|
||||||
|
main = printLn $ add 2$ 40
|
||||||
1
tests/Number.newt.golden
Normal file
1
tests/Number.newt.golden
Normal file
@@ -0,0 +1 @@
|
|||||||
|
42
|
||||||
Reference in New Issue
Block a user