Copyright | (C) CSIRO 2017-2018 |
---|---|
License | BSD3 |
Maintainer | Isaac Elliott <isaace71295@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Numerical literal values in Python
Synopsis
- data IntLiteral a
- = IntLiteralDec {
- _intLiteralAnn :: a
- _unsafeIntLiteralDecValue :: NonEmpty DecDigit
- | IntLiteralBin {
- _intLiteralAnn :: a
- _unsafeIntLiteralBinUppercase :: Bool
- _unsafeIntLiteralBinValue :: NonEmpty BinDigit
- | IntLiteralOct {
- _intLiteralAnn :: a
- _unsafeIntLiteralOctUppercase :: Bool
- _unsafeIntLiteralOctValue :: NonEmpty OctDigit
- | IntLiteralHex {
- _intLiteralAnn :: a
- _unsafeIntLiteralHexUppercase :: Bool
- _unsafeIntLiteralHexValue :: NonEmpty HeXDigit
- = IntLiteralDec {
- data Sign
- data E
- data FloatExponent = FloatExponent E (Maybe Sign) (NonEmpty DecDigit)
- data FloatLiteral a
- = FloatLiteralFull {
- _floatLiteralAnn :: a
- _floatLiteralFullLeft :: NonEmpty DecDigit
- _floatLiteralFullRight :: Maybe (These (NonEmpty DecDigit) FloatExponent)
- | FloatLiteralPoint {
- _floatLiteralAnn :: a
- _floatLiteralPointRight :: NonEmpty DecDigit
- _floatLiteralPointExponent :: Maybe FloatExponent
- | FloatLiteralWhole {
- _floatLiteralAnn :: a
- _floatLiteralWholeRight :: NonEmpty DecDigit
- _floatLiteralWholeExponent :: FloatExponent
- = FloatLiteralFull {
- data ImagLiteral a
- = ImagLiteralInt {
- _imagLiteralAnn :: a
- _unsafeImagLiteralIntValue :: NonEmpty DecDigit
- _imagLiteralUppercase :: Bool
- | ImagLiteralFloat { }
- = ImagLiteralInt {
- showIntLiteral :: IntLiteral a -> Text
- showFloatLiteral :: FloatLiteral a -> Text
- showFloatExponent :: FloatExponent -> Text
- showImagLiteral :: ImagLiteral a -> Text
Datatypes
data IntLiteral a Source #
An integer literal value.
5
is an integer literal.
6.2
is a literal but is not an integer
x
might be an integer, but is not a literal
See https://docs.python.org/3.5/reference/lexical_analysis.html#integer-literals
IntLiteralDec | Decimal 1234 |
| |
IntLiteralBin | Binary 0b10110 |
| |
IntLiteralOct | Octal 0o1367 |
| |
IntLiteralHex | Mixed-case hexadecimal 0x18B4f |
|
Instances
When a floating point literal is in scientific notation, it includes the character
e
, which can be lower or upper case.
data FloatExponent Source #
The exponent of a floating point literal.
An e
, followed by an optional Sign
, followed by at least one digit.
FloatExponent E (Maybe Sign) (NonEmpty DecDigit) |
Instances
Eq FloatExponent Source # | |
Defined in Language.Python.Syntax.Numbers (==) :: FloatExponent -> FloatExponent -> Bool # (/=) :: FloatExponent -> FloatExponent -> Bool # | |
Ord FloatExponent Source # | |
Defined in Language.Python.Syntax.Numbers compare :: FloatExponent -> FloatExponent -> Ordering # (<) :: FloatExponent -> FloatExponent -> Bool # (<=) :: FloatExponent -> FloatExponent -> Bool # (>) :: FloatExponent -> FloatExponent -> Bool # (>=) :: FloatExponent -> FloatExponent -> Bool # max :: FloatExponent -> FloatExponent -> FloatExponent # min :: FloatExponent -> FloatExponent -> FloatExponent # | |
Show FloatExponent Source # | |
Defined in Language.Python.Syntax.Numbers showsPrec :: Int -> FloatExponent -> ShowS # show :: FloatExponent -> String # showList :: [FloatExponent] -> ShowS # |
data FloatLiteral a Source #
A literal floating point value.
Eg. 7.63
See https://docs.python.org/3.5/reference/lexical_analysis.html#floating-point-literals
FloatLiteralFull | 'Complete' floats 12. 12.34 12.e34 12.34e56 |
| |
FloatLiteralPoint | Floats that begin with a decimal point .12 .12e34 |
| |
FloatLiteralWhole | Floats with no decimal points 12e34 |
|
Instances
data ImagLiteral a Source #
Imaginary number literals
See https://docs.python.org/3.5/reference/lexical_analysis.html#imaginary-literals
ImagLiteralInt | A decimal integer followed by a 'j' 12j |
| |
ImagLiteralFloat | A float followed by a 'j' 12.j 12.3j .3j |
Instances
Rendering
The output of these functions is guaranteed to be valid Python code
showIntLiteral :: IntLiteral a -> Text Source #
showFloatLiteral :: FloatLiteral a -> Text Source #
showImagLiteral :: ImagLiteral a -> Text Source #