From 66d3c75031e501995d27ca91fd69ad8f57aaf1a1 Mon Sep 17 00:00:00 2001 From: aarne Date: Mon, 28 Aug 2006 19:36:41 +0000 Subject: [PATCH] the EOF error changed to more informative lexer error msg --- src/GF/Source/LexGF.hs | 2 +- src/GF/Source/ParGF.hs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/GF/Source/LexGF.hs b/src/GF/Source/LexGF.hs index 9aa802910..326f738ed 100644 --- a/src/GF/Source/LexGF.hs +++ b/src/GF/Source/LexGF.hs @@ -121,7 +121,7 @@ tokens str = go (alexStartPos, '\n', str) go inp@(pos, _, str) = case alexScan inp 0 of AlexEOF -> [] - AlexError (pos, _, _) -> fail $ show pos ++ ": lexical error" + AlexError (pos, _, _) -> [Err pos] AlexSkip inp' len -> go inp' AlexToken inp' len act -> act pos (take len str) : (go inp') diff --git a/src/GF/Source/ParGF.hs b/src/GF/Source/ParGF.hs index ebb017d90..d106d81a3 100644 --- a/src/GF/Source/ParGF.hs +++ b/src/GF/Source/ParGF.hs @@ -3133,7 +3133,11 @@ thenM = (>>=) happyError :: [Token] -> Err a 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 {-# LINE 1 "GenericTemplate.hs" #-}