| Copyright | (c) roki 2019 |
|---|---|
| License | MIT |
| Maintainer | falgon53@yahoo.co.jp |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Htcc.Tokenizer.Token
Description
Types used in lexical analysis and their utility functions
Synopsis
- data TokenLCNums i = TokenLCNums {}
- type TokenLC i = (TokenLCNums i, Token i)
- data Token i
- length :: Show i => Token i -> Int
- emptyToken :: Num i => TokenLC i
- isTKNum :: Token i -> Bool
- isTKType :: Token i -> Bool
- isTKStruct :: Token i -> Bool
- isTKEnum :: Token i -> Bool
- isTKIdent :: Token i -> Bool
- isTKReserved :: Token i -> Bool
- isTKMacro :: Token i -> Bool
- isTKString :: Token i -> Bool
- spanStrLiteral :: Text -> Maybe (Text, Text)
- spanCharLiteral :: Text -> Maybe (Text, Text)
- spanIntLit :: (Eq i, Num i, Read i) => Text -> Maybe (Natural, Token i, Text)
- lookupKeyword :: forall i. Show i => Text -> Maybe (Token i)
- altEmptyToken :: Num i => [TokenLC i] -> TokenLC i
Token data types
data TokenLCNums i Source #
TokenLCNums is data structure for storing the line number and character number of each token
Constructors
| TokenLCNums | The constructor of |
Instances
type TokenLC i = (TokenLCNums i, Token i) Source #
Token and its TokenLCNums.
Token type
Constructors
| TKReserved Text | The reserved token |
| TKNum !i | The number data |
| TKIdent Text | The identifier |
| TKReturn | The |
| TKIf | The |
| TKSwitch | The |
| TKCase | The |
| TKDefault | The |
| TKElse | The |
| TKWhile | The |
| TKFor | The |
| TKBreak | The |
| TKContinue | The |
| TKEnum | The |
| TKSizeof | The |
| TKAlignof | The |
| TKStruct | The |
| TKGoto | THe |
| TKType (StorageClass i) | Types |
| TKTypedef | The |
| TKString ByteString | The string literal |
| TKMacro Macros Text | The C macro |
| TKEmpty | The empty token (This is not used by |
Instances
Utilities for accessing to token data
emptyToken :: Num i => TokenLC i Source #
emptyToken is used when it cannot be referenced
isTKStruct :: Token i -> Bool Source #
isTKReserved :: Token i -> Bool Source #
Utility for TKReserved. When the argument is TKReserved, it returns True, otherwise False.
isTKString :: Token i -> Bool Source #
spanStrLiteral :: Text -> Maybe (Text, Text) Source #
spanStrLiteral separate the string literal part and the non-string literal part from the input text
spanCharLiteral :: Text -> Maybe (Text, Text) Source #
spanCharLiteral separate the string literal part and the non-string literal part from the input text
spanIntLit :: (Eq i, Num i, Read i) => Text -> Maybe (Natural, Token i, Text) Source #
Take the integer literal from given text.
lookupKeyword :: forall i. Show i => Text -> Maybe (Token i) Source #
Lookup keyword from Text. If the specified Text is not keyword as C language, lookupKeyword returns Nothing.
altEmptyToken :: Num i => [TokenLC i] -> TokenLC i Source #
altEmptyToken returns emptyToken if the first token is empty. Otherwise, returns the first token in the token sequence.