Safe Haskell | Safe |
---|---|
Language | Haskell98 |
- data Located a = Located !SourcePos !a
- columnOfLocated :: Located a -> Int
- data Token n
- = KErrorJunk String
- | KErrorUnterm String
- | KM !TokenMeta
- | KA !TokenAtom
- | KN !(TokenNamed n)
- data TokenMeta
- data TokenAtom
- data TokenNamed n
- data Keyword
- data Symbol
- = SRoundBra
- | SRoundKet
- | SSquareBra
- | SSquareKet
- | SBraceBra
- | SBraceKet
- | SSquareColonBra
- | SSquareColonKet
- | SBraceColonBra
- | SBraceColonKet
- | SBigLambdaSlash
- | SArrowTilde
- | SArrowDashRight
- | SArrowDashLeft
- | SArrowEquals
- | SAt
- | SHat
- | SDot
- | SBar
- | SComma
- | SEquals
- | SLambda
- | SSemiColon
- | SBackSlash
- | SBigLambda
- | SUnderscore
- data Builtin
- data Literal
- describeToken :: Pretty n => Token n -> String
- describeTokenMeta :: TokenMeta -> String
- describeTokenAtom :: TokenAtom -> String
- describeTokenNamed :: Pretty n => TokenNamed n -> String
- sayKeyword :: Keyword -> String
- saySymbol :: Symbol -> String
- sayBuiltin :: Builtin -> String
- renameToken :: Ord n2 => (n1 -> Maybe n2) -> Token n1 -> Maybe (Token n2)
- isVarName :: String -> Bool
- isVarStart :: Char -> Bool
- isVarBody :: Char -> Bool
- isConName :: String -> Bool
- isConStart :: Char -> Bool
- isConBody :: Char -> Bool
- isLitName :: String -> Bool
- isLitStart :: Char -> Bool
- isLitBody :: Char -> Bool
- readLitInteger :: String -> Maybe Integer
- readLitNat :: String -> Maybe Integer
- readLitInt :: String -> Maybe Integer
- readLitSize :: String -> Maybe Integer
- readLitWordOfBits :: String -> Maybe (Integer, Int)
- readLitFloatOfBits :: String -> Maybe (Double, Int)
- readBinary :: Num a => String -> a
- readHex :: (Enum a, Num a) => String -> a
Documentation
A located thing.
columnOfLocated :: Located a -> Int Source #
Yield the column number of a located thing.
Tokens
Tokens accepted by the core language parser.
KErrorJunk String | Some junk symbol that isn't part of the language. |
KErrorUnterm String | The first part of an unterminated string. |
KM !TokenMeta | Meta tokens contain out-of-band information that is eliminated before parsing proper. |
KA !TokenAtom | Atomic tokens are keywords, punctuation and baked-in constructor names. |
KN !(TokenNamed n) | A named token that is specific to the language fragment (maybe it's a primop), or a user defined name. |
Meta tokens contain out-of-band information that is eliminated before parsing proper.
KNewLine | |
KComment String | Comment string. |
KCommentUnterminated | This is injected by |
KOffsideClosingBrace | This is injected by |
Atomic tokens are keywords, punctuation and baked-in constructor names. They don't contain user-defined names or primops specific to the language fragment.
data TokenNamed n Source #
A token with a user-defined name.
Eq n => Eq (TokenNamed n) Source # | |
Show n => Show (TokenNamed n) Source # | |
Keyword tokens.
Symbol tokens.
SRoundBra | Like '(' |
SRoundKet | Like ')' |
SSquareBra | Like '[' |
SSquareKet | Like ']' |
SBraceBra | Like '{' |
SBraceKet | Like '}' |
SSquareColonBra | Like '[:' |
SSquareColonKet | Like ':]' |
SBraceColonBra | Like '{:' |
SBraceColonKet | Like ':}' |
SBigLambdaSlash | Like |
SArrowTilde | Like |
SArrowDashRight | Like '->' |
SArrowDashLeft | Like '<-' |
SArrowEquals | Like '=>' |
SAt | Like '@' |
SHat | Like |
SDot | Like |
SBar | Like '|' |
SComma | Like ',' |
SEquals | Like '=' |
SLambda | Like 'λ' |
SSemiColon | Like ';' |
SBackSlash | Like |
SBigLambda | Like 'Λ' |
SUnderscore | Like '_' |
Builtin name tokens.
Types of literal values known to the compiler.
Note that literals are embedded in the name type of each fragment rather than in the expression itself so that fragments can choose which types of literals they support.
Description
describeTokenMeta :: TokenMeta -> String Source #
Describe a TokMeta, for lexer error messages.
describeTokenAtom :: TokenAtom -> String Source #
Describe a TokAtom
, for parser error messages.
describeTokenNamed :: Pretty n => TokenNamed n -> String Source #
Describe a TokNamed
, for parser error messages.
sayKeyword :: Keyword -> String Source #
Yield the string name of a keyword.
sayBuiltin :: Builtin -> String Source #
Yield the string name of a Builtin.
Renaming
renameToken :: Ord n2 => (n1 -> Maybe n2) -> Token n1 -> Maybe (Token n2) Source #
Apply a function to all the names in a Tok
.
Predicates
isVarStart :: Char -> Bool Source #
Charater can start a variable name.
isConStart :: Char -> Bool Source #
Character can start a constructor name.
isLitStart :: Char -> Bool Source #
Character can start a literal.
Literal Reading
readLitNat :: String -> Maybe Integer Source #
Read an integer with an explicit format specifier like 1234i
.
readLitInt :: String -> Maybe Integer Source #
Read an integer literal with an explicit format specifier like 1234i
.
readLitSize :: String -> Maybe Integer Source #
Read an size literal with an explicit format specifier like 1234s
.
readLitWordOfBits :: String -> Maybe (Integer, Int) Source #
Read a word with an explicit format speficier.
readLitFloatOfBits :: String -> Maybe (Double, Int) Source #
Read a float literal with an explicit format specifier like 123.00f32#
.
readBinary :: Num a => String -> a Source #
Read a binary string as a number.