HasLocation

HasLocation
This commit is contained in:
crumbtoo
2024-02-16 17:22:24 -07:00
parent da81a5a98e
commit 910cf66468
4 changed files with 77 additions and 42 deletions

View File

@@ -17,7 +17,7 @@ module Rlp.Parse.Types
, RlpToken(..), AlexInput(..), Position(..), spanFromPos, LexerAction
, Located(..), PsName
-- ** Lenses
, aiPrevChar, aiSource, aiBytes, aiPos, posLine, posColumn
, _TokenLitInt, aiPrevChar, aiSource, aiBytes, aiPos, posLine, posColumn
-- * Error handling
, MsgEnvelope(..), RlpcError(..), RlpParseError(..)
@@ -53,7 +53,7 @@ data RlpcPs
type instance NameP RlpcPs = PsName
type PsName = Text
type PsName = Located Text
--------------------------------------------------------------------------------
@@ -125,6 +125,11 @@ data RlpToken
| TokenEOF
deriving (Show)
_TokenLitInt :: Prism' RlpToken Int
_TokenLitInt = prism TokenLitInt $ \case
TokenLitInt n -> Right n
x -> Left x
newtype P a = P {
runP :: ParseState
-> (ParseState, [MsgEnvelope RlpParseError], Maybe a)