2023-06-07 11:04:00 +02:00
|
|
|
module Lexer where
|
|
|
|
|
|
|
|
import Text.Parsec.Char (alphaNum, letter, oneOf)
|
|
|
|
import Text.Parsec.Language (emptyDef)
|
|
|
|
import Text.Parsec.String (Parser)
|
2023-06-07 17:36:14 +02:00
|
|
|
import qualified Text.Parsec.Token as Tok
|
2023-06-07 11:04:00 +02:00
|
|
|
|
|
|
|
lexer :: Tok.TokenParser ()
|
|
|
|
lexer = Tok.makeTokenParser style
|
|
|
|
where
|
|
|
|
ops = ["/\\", "\\/", "->", "!"]
|
|
|
|
names = ["forall", "exists"]
|
|
|
|
style =
|
|
|
|
emptyDef
|
|
|
|
{ Tok.commentLine = ""
|
|
|
|
, Tok.reservedOpNames = ops
|
|
|
|
, Tok.reservedNames = names
|
|
|
|
, Tok.opStart = oneOf "\\/-"
|
|
|
|
, Tok.opLetter = oneOf "\\/>"
|
|
|
|
, Tok.identStart = letter
|
|
|
|
, Tok.identLetter = alphaNum
|
|
|
|
}
|
|
|
|
|
|
|
|
parens :: Parser a -> Parser a
|
|
|
|
parens = Tok.parens lexer
|
|
|
|
|
|
|
|
dot :: Parser String
|
|
|
|
dot = Tok.dot lexer
|
|
|
|
|
|
|
|
comma :: Parser String
|
|
|
|
comma = Tok.comma lexer
|
|
|
|
|
|
|
|
semi :: Parser String
|
|
|
|
semi = Tok.semi lexer
|
|
|
|
|
|
|
|
identifier :: Parser String
|
|
|
|
identifier = Tok.identifier lexer
|
|
|
|
|
|
|
|
reserved :: String -> Parser ()
|
|
|
|
reserved = Tok.reserved lexer
|
|
|
|
|
|
|
|
reservedOp :: String -> Parser ()
|
|
|
|
reservedOp = Tok.reservedOp lexer
|
|
|
|
|
|
|
|
whiteSpace :: Parser ()
|
|
|
|
whiteSpace = Tok.whiteSpace lexer
|