summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Grammar/Lexer.x
diff options
context:
space:
mode:
authorkrangelov <kr.angelov@gmail.com>2020-10-02 19:55:24 +0200
committerkrangelov <kr.angelov@gmail.com>2020-10-02 19:55:24 +0200
commitf3a8658cc1ed5b2721ee9d3f670f6b9a49f0f049 (patch)
tree8a311ec3c3a454088fa3c74b4464f974fe5aee21 /src/compiler/GF/Grammar/Lexer.x
parentbfb94d1e48fded159bbf63a992564cb24e987772 (diff)
parentf56fbcf86e472262d07c6bd713f6955cfbcfee8a (diff)
Merge branch 'master' of https://github.com/GrammaticalFramework/gf-core
Diffstat (limited to 'src/compiler/GF/Grammar/Lexer.x')
-rw-r--r--src/compiler/GF/Grammar/Lexer.x6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/compiler/GF/Grammar/Lexer.x b/src/compiler/GF/Grammar/Lexer.x
index d1550dd09..fe455c58a 100644
--- a/src/compiler/GF/Grammar/Lexer.x
+++ b/src/compiler/GF/Grammar/Lexer.x
@@ -1,5 +1,6 @@
-- -*- haskell -*-
{
+{-# LANGUAGE CPP #-}
module GF.Grammar.Lexer
( Token(..), Posn(..)
, P, runP, runPartial, token, lexer, getPosn, failLoc
@@ -18,6 +19,7 @@ import qualified Data.Map as Map
import Data.Word(Word8)
import Data.Char(readLitChar)
--import Debug.Trace(trace)
+import qualified Control.Monad.Fail as Fail
}
@@ -282,8 +284,12 @@ instance Monad P where
(P m) >>= k = P $ \ s -> case m s of
POk s a -> unP (k a) s
PFailed posn err -> PFailed posn err
+
+
+instance Fail.MonadFail P where
fail msg = P $ \(_,AI posn _ _) -> PFailed posn msg
+
runP :: P a -> BS.ByteString -> Either (Posn,String) a
runP p bs = snd <$> runP' p (Pn 1 0,bs)