module Agda.Syntax.Parser.Tokens
( Token(..)
, Keyword(..)
, layoutKeywords
, Symbol(..)
) where
import Agda.Syntax.Literal (Literal)
import Agda.Syntax.Position
data Keyword
= KwLet | KwIn | KwWhere | KwData | KwCoData | KwDo
| KwPostulate | KwMutual | KwAbstract | KwPrivate | KwInstance
| KwOverlap
| KwOpen | KwImport | KwModule | KwPrimitive | KwMacro
| KwInfix | KwInfixL | KwInfixR | KwWith | KwRewrite
| KwSet | KwProp | KwForall | KwRecord | KwConstructor | KwField
| KwInductive | KwCoInductive
| KwEta | KwNoEta
| KwHiding | KwUsing | KwRenaming | KwTo | KwPublic
| KwOPTIONS | KwBUILTIN | KwLINE
| KwFOREIGN | KwCOMPILE
| KwIMPOSSIBLE | KwSTATIC | KwINJECTIVE | KwINLINE | KwNOINLINE
| KwETA
| KwNO_TERMINATION_CHECK | KwTERMINATING | KwNON_TERMINATING
| KwNON_COVERING
| KwWARNING_ON_USAGE | KwWARNING_ON_IMPORT
| KwMEASURE | KwDISPLAY
| KwREWRITE
| KwQuote | KwQuoteTerm
| KwUnquote | KwUnquoteDecl | KwUnquoteDef
| KwSyntax
| KwPatternSyn | KwTactic | KwCATCHALL
| KwVariable
| KwNO_POSITIVITY_CHECK | KwPOLARITY
| KwNO_UNIVERSE_CHECK
deriving (Keyword -> Keyword -> Bool
(Keyword -> Keyword -> Bool)
-> (Keyword -> Keyword -> Bool) -> Eq Keyword
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Keyword -> Keyword -> Bool
$c/= :: Keyword -> Keyword -> Bool
== :: Keyword -> Keyword -> Bool
$c== :: Keyword -> Keyword -> Bool
Eq, Int -> Keyword -> ShowS
[Keyword] -> ShowS
Keyword -> String
(Int -> Keyword -> ShowS)
-> (Keyword -> String) -> ([Keyword] -> ShowS) -> Show Keyword
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Keyword] -> ShowS
$cshowList :: [Keyword] -> ShowS
show :: Keyword -> String
$cshow :: Keyword -> String
showsPrec :: Int -> Keyword -> ShowS
$cshowsPrec :: Int -> Keyword -> ShowS
Show)
layoutKeywords :: [Keyword]
layoutKeywords :: [Keyword]
layoutKeywords =
[ Keyword
KwLet, Keyword
KwWhere, Keyword
KwDo, Keyword
KwPostulate, Keyword
KwMutual, Keyword
KwAbstract, Keyword
KwPrivate, Keyword
KwInstance, Keyword
KwMacro, Keyword
KwPrimitive, Keyword
KwField, Keyword
KwVariable ]
data Symbol
= SymDot | SymSemi | SymVirtualSemi | SymBar
| SymColon | SymArrow | SymEqual | SymLambda
| SymUnderscore | SymQuestionMark | SymAs
| SymOpenParen | SymCloseParen
| SymOpenIdiomBracket | SymCloseIdiomBracket | SymEmptyIdiomBracket
| SymDoubleOpenBrace | SymDoubleCloseBrace
| SymOpenBrace | SymCloseBrace
| SymOpenVirtualBrace | SymCloseVirtualBrace
| SymOpenPragma | SymClosePragma | SymEllipsis | SymDotDot
|
deriving (Symbol -> Symbol -> Bool
(Symbol -> Symbol -> Bool)
-> (Symbol -> Symbol -> Bool) -> Eq Symbol
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Symbol -> Symbol -> Bool
$c/= :: Symbol -> Symbol -> Bool
== :: Symbol -> Symbol -> Bool
$c== :: Symbol -> Symbol -> Bool
Eq, Int -> Symbol -> ShowS
[Symbol] -> ShowS
Symbol -> String
(Int -> Symbol -> ShowS)
-> (Symbol -> String) -> ([Symbol] -> ShowS) -> Show Symbol
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Symbol] -> ShowS
$cshowList :: [Symbol] -> ShowS
show :: Symbol -> String
$cshow :: Symbol -> String
showsPrec :: Int -> Symbol -> ShowS
$cshowsPrec :: Int -> Symbol -> ShowS
Show)
data Token
= TokKeyword Keyword Interval
| TokId (Interval, String)
| TokQId [(Interval, String)]
| TokLiteral Literal
| TokSymbol Symbol Interval
| TokString (Interval, String)
| TokSetN (Interval, Integer)
| TokPropN (Interval, Integer)
| TokTeX (Interval, String)
| TokMarkup (Interval, String)
| (Interval, String)
| TokDummy
| TokEOF Interval
deriving (Token -> Token -> Bool
(Token -> Token -> Bool) -> (Token -> Token -> Bool) -> Eq Token
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Token -> Token -> Bool
$c/= :: Token -> Token -> Bool
== :: Token -> Token -> Bool
$c== :: Token -> Token -> Bool
Eq, Int -> Token -> ShowS
[Token] -> ShowS
Token -> String
(Int -> Token -> ShowS)
-> (Token -> String) -> ([Token] -> ShowS) -> Show Token
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Token] -> ShowS
$cshowList :: [Token] -> ShowS
show :: Token -> String
$cshow :: Token -> String
showsPrec :: Int -> Token -> ShowS
$cshowsPrec :: Int -> Token -> ShowS
Show)
instance HasRange Token where
getRange :: Token -> Range
getRange (TokKeyword Keyword
_ Interval
i) = Interval -> Range
forall t. HasRange t => t -> Range
getRange Interval
i
getRange (TokId (Interval
i, String
_)) = Interval -> Range
forall t. HasRange t => t -> Range
getRange Interval
i
getRange (TokQId [(Interval, String)]
iss) = [Interval] -> Range
forall t. HasRange t => t -> Range
getRange (((Interval, String) -> Interval)
-> [(Interval, String)] -> [Interval]
forall a b. (a -> b) -> [a] -> [b]
map (Interval, String) -> Interval
forall a b. (a, b) -> a
fst [(Interval, String)]
iss)
getRange (TokLiteral Literal
lit) = Literal -> Range
forall t. HasRange t => t -> Range
getRange Literal
lit
getRange (TokSymbol Symbol
_ Interval
i) = Interval -> Range
forall t. HasRange t => t -> Range
getRange Interval
i
getRange (TokString (Interval
i, String
_)) = Interval -> Range
forall t. HasRange t => t -> Range
getRange Interval
i
getRange (TokSetN (Interval
i, Integer
_)) = Interval -> Range
forall t. HasRange t => t -> Range
getRange Interval
i
getRange (TokPropN (Interval
i, Integer
_)) = Interval -> Range
forall t. HasRange t => t -> Range
getRange Interval
i
getRange (TokTeX (Interval
i, String
_)) = Interval -> Range
forall t. HasRange t => t -> Range
getRange Interval
i
getRange (TokMarkup (Interval
i, String
_)) = Interval -> Range
forall t. HasRange t => t -> Range
getRange Interval
i
getRange (TokComment (Interval
i, String
_)) = Interval -> Range
forall t. HasRange t => t -> Range
getRange Interval
i
getRange Token
TokDummy = Range
forall a. Range' a
noRange
getRange (TokEOF Interval
i) = Interval -> Range
forall t. HasRange t => t -> Range
getRange Interval
i