cryptol-2.2.6: Cryptol: The Language of Cryptography

Safe Haskell | Trustworthy
Language | Haskell98

Cryptol.Parser.Lexer

Synopsis

- primLexer :: Config -> String -> ([Located Token], Position)
- lexer :: Config -> String -> ([Located Token], Position)
- data Layout
  - = Layout
  - | NoLayout
- data Token = Token {
  - tokenType :: TokenT
  - tokenText :: String
  }
- data TokenT
  - = Num Integer Int Int
  - | ChrLit Char
  - | Ident String
  - | StrLit String
  - | KW TokenKW
  - | Op TokenOp
  - | Sym TokenSym
  - | Virt TokenV
  - | White TokenW
  - | Err TokenErr
  - | EOF
- data TokenV
  - = VCurlyL
  - | VCurlyR
  - | VSemi
- data TokenKW
  - = KW_Arith
  - | KW_Bit
  - | KW_Cmp
  - | KW_False
  - | KW_True
  - | KW_else
  - | KW_Eq
  - | KW_error
  - | KW_extern
  - | KW_fin
  - | KW_if
  - | KW_private
  - | KW_include
  - | KW_inf
  - | KW_join
  - | KW_lg2
  - | KW_lengthFromThen
  - | KW_lengthFromThenTo
  - | KW_max
  - | KW_min
  - | KW_module
  - | KW_newtype
  - | KW_pragma
  - | KW_pmult
  - | KW_pdiv
  - | KW_pmod
  - | KW_property
  - | KW_random
  - | KW_reverse
  - | KW_split
  - | KW_splitAt
  - | KW_then
  - | KW_transpose
  - | KW_type
  - | KW_where
  - | KW_let
  - | KW_x
  - | KW_zero
  - | KW_import
  - | KW_as
  - | KW_hiding
- data TokenErr
  - = UnterminatedComment
  - | UnterminatedString
  - | UnterminatedChar
  - | InvalidString
  - | InvalidChar
  - | LexicalError
- data TokenOp
  - = Plus
  - | Minus
  - | Mul
  - | Div
  - | Exp
  - | Mod
  - | NotEqual
  - | Equal
  - | LessThan
  - | GreaterThan
  - | LEQ
  - | GEQ
  - | EqualFun
  - | NotEqualFun
  - | ShiftL
  - | ShiftR
  - | RotL
  - | RotR
  - | Conj
  - | Disj
  - | Xor
  - | Complement
  - | Bang
  - | BangBang
  - | At
  - | AtAt
  - | Hash
- data TokenSym
  - = Bar
  - | ArrL
  - | ArrR
  - | FatArrR
  - | Lambda
  - | EqDef
  - | Comma
  - | Semi
  - | Dot
  - | DotDot
  - | DotDotDot
  - | Colon
  - | ColonColon
  - | BackTick
  - | ParenL
  - | ParenR
  - | BracketL
  - | BracketR
  - | CurlyL
  - | CurlyR
  - | TriL
  - | TriR
  - | Underscore
- data TokenW
  - = BlockComment
  - | LineComment
  - | Space
- data Located a = Located {
  - srcRange :: !Range
  - thing :: a
  }
- data Config = Config {
  - cfgSource :: !FilePath
  - cfgLayout :: !Layout
  - cfgPreProc :: PreProc
  - cfgAutoInclude :: [FilePath]
  - cfgModuleScope :: Bool
  }
- defaultConfig :: Config

# Documentation

primLexer :: Config -> String -> ([Located Token], Position) Source

Returns the tokens and the last position of the input that we processed. The tokens include whte space tokens.

lexer :: Config -> String -> ([Located Token], Position) Source

Returns the tokens in the last position of the input that we processed. White space is removed, and layout processing is done as requested. This stream is fed to the parser.

data Layout Source

Constructors

Layout |
NoLayout |

data Token Source

Constructors

Token |

Fields

tokenType :: TokenT
tokenText :: String

Instances

Show Token Source |
PP Token Source |

data TokenT Source

Constructors

Num Integer Int Int | value, base, number of digits
ChrLit Char | character literal
Ident String | identifier
StrLit String | string literal
KW TokenKW | keyword
Op TokenOp | operator
Sym TokenSym | symbol
Virt TokenV | virtual token (for layout)
White TokenW | white space token
Err TokenErr | error token
EOF |

Instances

Eq TokenT Source |
Show TokenT Source |

data TokenV Source

Virtual tokens, inserted by layout processing.

Constructors

VCurlyL |
VCurlyR |
VSemi |

Instances

Eq TokenV Source |
Show TokenV Source |

data TokenKW Source

Constructors

KW_Arith |
KW_Bit |
KW_Cmp |
KW_False |
KW_True |
KW_else |
KW_Eq |
KW_error |
KW_extern |
KW_fin |
KW_if |
KW_private |
KW_include |
KW_inf |
KW_join |
KW_lg2 |
KW_lengthFromThen |
KW_lengthFromThenTo |
KW_max |
KW_min |
KW_module |
KW_newtype |
KW_pragma |
KW_pmult |
KW_pdiv |
KW_pmod |
KW_property |
KW_random |
KW_reverse |
KW_split |
KW_splitAt |
KW_then |
KW_transpose |
KW_type |
KW_where |
KW_let |
KW_x |
KW_zero |
KW_import |
KW_as |
KW_hiding |

Instances

Eq TokenKW Source |
Show TokenKW Source |

data TokenErr Source

Constructors

UnterminatedComment |
UnterminatedString |
UnterminatedChar |
InvalidString |
InvalidChar |
LexicalError |

Instances

Eq TokenErr Source |
Show TokenErr Source |

data TokenOp Source

Constructors

Plus |
Minus |
Mul |
Div |
Exp |
Mod |
NotEqual |
Equal |
LessThan |
GreaterThan |
LEQ |
GEQ |
EqualFun |
NotEqualFun |
ShiftL |
ShiftR |
RotL |
RotR |
Conj |
Disj |
Xor |
Complement |
Bang |
BangBang |
At |
AtAt |
Hash |

Instances

Eq TokenOp Source |
Show TokenOp Source |

data TokenSym Source

Constructors

Bar |
ArrL |
ArrR |
FatArrR |
Lambda |
EqDef |
Comma |
Semi |
Dot |
DotDot |
DotDotDot |
Colon |
ColonColon |
BackTick |
ParenL |
ParenR |
BracketL |
BracketR |
CurlyL |
CurlyR |
TriL |
TriR |
Underscore |

Instances

Eq TokenSym Source |
Show TokenSym Source |

data TokenW Source

Constructors

BlockComment |
LineComment |
Space |

Instances

Eq TokenW Source |
Show TokenW Source |

data Located a Source

Constructors

Located |

Fields

srcRange :: !Range
thing :: a

Instances

Functor Located Source |
Eq a => Eq (Located a) Source |
Show a => Show (Located a) Source |
PP a => PP (Located a) Source |
AddLoc (Located a) Source |
HasLoc (Located a) Source |
NoPos (Located t) Source |
Rename a => Rename (Located a) Source |

data Config Source

Constructors

Config |

Fields

cfgSource :: !FilePath

  File that we are working on

cfgLayout :: !Layout

  Settings for layout processing

cfgPreProc :: PreProc

  Preprocessor settings

cfgAutoInclude :: [FilePath]

  Implicit includes

cfgModuleScope :: Bool

  When we do layout processing should we add a vCurly (i.e., are we parsing a list of things).

defaultConfig :: Config Source