summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Grammar/Lexer.x
diff options
context:
space:
mode:
authorInari Listenmaa <inari.listenmaa@gmail.com>2023-09-13 08:24:07 +0200
committerGitHub <noreply@github.com>2023-09-13 08:24:07 +0200
commit318b710a14e3bcbfb8386e4e357d4ed64b1a0ae1 (patch)
tree9a3a2710a18225713c89ba27eab2384d47995d8b /src/compiler/GF/Grammar/Lexer.x
parent096b36c21d9657d1dee93638b436dc7bb35af439 (diff)
parentb90666455efd3b83345ad4b77eac4b64373e4c83 (diff)
Merge pull request #160 from anka-213/prettier-syntax-errors
Improve syntax error messages
Diffstat (limited to 'src/compiler/GF/Grammar/Lexer.x')
-rw-r--r--src/compiler/GF/Grammar/Lexer.x11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/compiler/GF/Grammar/Lexer.x b/src/compiler/GF/Grammar/Lexer.x
index 365388726..b3d271ddd 100644
--- a/src/compiler/GF/Grammar/Lexer.x
+++ b/src/compiler/GF/Grammar/Lexer.x
@@ -4,7 +4,7 @@
module GF.Grammar.Lexer
( Token(..), Posn(..)
, P, runP, runPartial, token, lexer, getPosn, failLoc
- , isReservedWord
+ , isReservedWord, invMap
) where
import Control.Applicative
@@ -134,7 +134,7 @@ data Token
| T_Double Double -- double precision float literals
| T_Ident Ident
| T_EOF
--- deriving Show -- debug
+ deriving (Eq, Ord, Show) -- debug
res = eitherResIdent
eitherResIdent :: (Ident -> Token) -> Ident -> Token
@@ -224,6 +224,13 @@ resWords = Map.fromList
]
where b s t = (identS s, t)
+invMap :: Map.Map Token String
+invMap = res
+ where
+ lst = Map.toList resWords
+ flp = map (\(k,v) -> (v,showIdent k)) lst
+ res = Map.fromList flp
+
unescapeInitTail :: String -> String
unescapeInitTail = unesc . tail where
unesc s = case s of