forked from GitHub/gf-core
the EOF error changed to more informative lexer error msg
This commit is contained in:
@@ -121,7 +121,7 @@ tokens str = go (alexStartPos, '\n', str)
|
|||||||
go inp@(pos, _, str) =
|
go inp@(pos, _, str) =
|
||||||
case alexScan inp 0 of
|
case alexScan inp 0 of
|
||||||
AlexEOF -> []
|
AlexEOF -> []
|
||||||
AlexError (pos, _, _) -> fail $ show pos ++ ": lexical error"
|
AlexError (pos, _, _) -> [Err pos]
|
||||||
AlexSkip inp' len -> go inp'
|
AlexSkip inp' len -> go inp'
|
||||||
AlexToken inp' len act -> act pos (take len str) : (go inp')
|
AlexToken inp' len act -> act pos (take len str) : (go inp')
|
||||||
|
|
||||||
|
|||||||
@@ -3133,7 +3133,11 @@ thenM = (>>=)
|
|||||||
|
|
||||||
happyError :: [Token] -> Err a
|
happyError :: [Token] -> Err a
|
||||||
happyError ts =
|
happyError ts =
|
||||||
Bad $ "syntax error at " ++ tokenPos ts ++ if null ts then [] else (" before " ++ unwords (map prToken (take 4 ts)))
|
Bad $ "syntax error at " ++ tokenPos ts ++
|
||||||
|
case ts of
|
||||||
|
[] -> []
|
||||||
|
[Err _] -> " due to lexer error"
|
||||||
|
_ -> (" before " ++ unwords (map prToken (take 4 ts)))
|
||||||
|
|
||||||
myLexer = tokens
|
myLexer = tokens
|
||||||
{-# LINE 1 "GenericTemplate.hs" #-}
|
{-# LINE 1 "GenericTemplate.hs" #-}
|
||||||
|
|||||||
Reference in New Issue
Block a user