module Lvm.Core.Parsing.Token
( Token, Lexeme(..), Pos, incpos, newpos
) where
import Text.PrettyPrint.Leijen (Pretty(..))
type Pos = (Int,Int)
type Token = (Pos,Lexeme)
data Lexeme = LexUnknown Char
| LexError String
| LexChar Char
| LexString String
| LexInt Integer
| LexFloat Double
| LexId String
| LexQualId String String
| LexOp String
| LexCon String
| LexQualCon String String
| LexConOp String
| LexCOMMA
| LexQUOTE
| LexSEMI
| LexBSLASH
| LexASG
| LexCOLON
| LexCOLCOL
| LexDOT
| LexDOTDOT
| LexBAR
| LexLARROW
| LexRARROW
| LexTILDE
| LexARROW
| LexAT
| LexEXCL
| LexDASH
| LexLPAREN
| LexRPAREN
| LexLBRACKET
| LexRBRACKET
| LexLBRACE
| LexRBRACE
| LexLET
| LexIN
| LexDO
| LexWHERE
| LexCASE
| LexOF
| LexIF
| LexTHEN
| LexELSE
| LexDATA
| LexTYPE
| LexMODULE
| LexIMPORT
| LexEOF
| LexLETSTRICT
| LexMATCH
| LexWITH
| LexPRIVATE
| LexPUBLIC
| LexDEFAULT
| LexCON
| LexABSTRACT
| LexINSTR
| LexEXTERN
| LexNOTHING
| LexCUSTOM
| LexSTATIC | LexDYNAMIC | LexRUNTIME
| LexCCALL | LexSTDCALL | LexINSTRCALL
| LexDECORATE | LexORDINAL
deriving (Eq,Show)
instance Pretty Lexeme where
pretty = pretty . show
incpos :: Pos -> Int -> Pos
incpos (line,col) i = (line,col+i)
newpos :: Pos -> Char -> Pos
newpos (line,_) '\n' = (line + 1,1)
newpos (line,col) '\t' = (line, ((((col1) `div` 8)+1)*8)+1)
newpos (line,col) _ = (line, col+1)