simpleparse.common.numbers
index
/usr/src/tmp/python3-module-simpleparse-buildroot/usr/lib/python3/site-packages/simpleparse/common/numbers.py

Samples showing the parsing of common programming-language constructs
 
numbers
    integers
        int
        int_unsigned
        
    hexidecimal integers
        hex
        
    floats (including exponents, requring a '.' in the literal)
        float
            floats, with optional integer-only exponents
        float_floatexp
            floats, with optional integer or float exponents
 
    imaginary_number
        (float/int),[jJ]
 
    number
        hex/float/int
    number_full
        binary_number/imaginary_number/hex/float/int
 
    binary_number
        signed binary number
            1001001b or 1001001B bit-field format,
            optional sign
            can be used with number as (binary_number/number)
 
Interpreters:
 
    IntInterpreter
        int, int_unsigned
    HexInterpreter
        hex
    FloatInterpreter
        float
    FloatFloatExpInterpreter
        float_floatexp
    BinaryInterpreter
        binary_number
    ImaginaryInterpreter
        imaginary_number

 
Modules
       
simpleparse.common.chartypes
simpleparse.common
simpleparse.objectgenerator
string
sys

 
Classes
       
DispatchProcessor(Processor)
BinaryInterpreter
FloatFloatExpInterpreter
FloatInterpreter
HexInterpreter
ImaginaryInterpreter
IntInterpreter

 
class BinaryInterpreter(DispatchProcessor)
    
Method resolution order:
BinaryInterpreter
DispatchProcessor
Processor
MethodSource
object

Methods defined here:
__call__(self, match, buffer)
Interpret a bitfield set as an integer

Methods inherited from Processor:
__repr__(self)
Return a representation of the class

Data descriptors inherited from MethodSource:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class FloatFloatExpInterpreter(DispatchProcessor)
    Interpret a float string as an integer value
Note: we're allowing float exponentiation, which
gives you a nice way to write 2e.5
 
 
Method resolution order:
FloatFloatExpInterpreter
DispatchProcessor
Processor
MethodSource
object

Methods defined here:
__call__(self, match, buffer)

Methods inherited from Processor:
__repr__(self)
Return a representation of the class

Data descriptors inherited from MethodSource:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class FloatInterpreter(DispatchProcessor)
    Interpret a standard float value as a float
 
 
Method resolution order:
FloatInterpreter
DispatchProcessor
Processor
MethodSource
object

Methods defined here:
__call__(self, match, buffer)

Methods inherited from Processor:
__repr__(self)
Return a representation of the class

Data descriptors inherited from MethodSource:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class HexInterpreter(DispatchProcessor)
    Interpret a hexidecimal integer string as an integer value
 
 
Method resolution order:
HexInterpreter
DispatchProcessor
Processor
MethodSource
object

Methods defined here:
__call__(self, match, buffer)

Methods inherited from Processor:
__repr__(self)
Return a representation of the class

Data descriptors inherited from MethodSource:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class ImaginaryInterpreter(DispatchProcessor)
    
Method resolution order:
ImaginaryInterpreter
DispatchProcessor
Processor
MethodSource
object

Methods defined here:
__call__(self, match, buffer)
Interpret a literal imaginary number

Data and other attributes defined here:
map = {'float': <FloatInterpreter object @ 4144430732>, 'int': <IntInterpreter object @ 4144429612>}

Methods inherited from Processor:
__repr__(self)
Return a representation of the class

Data descriptors inherited from MethodSource:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class IntInterpreter(DispatchProcessor)
    Interpret an integer (or unsigned integer) string as an integer
 
 
Method resolution order:
IntInterpreter
DispatchProcessor
Processor
MethodSource
object

Methods defined here:
__call__(self, match, buffer)

Methods inherited from Processor:
__repr__(self)
Return a representation of the class

Data descriptors inherited from MethodSource:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
_toInt(s, base)
_toLong(s, base)

 
Data
        __file__ = '/usr/src/tmp/python3-module-simpleparse-buildroo...thon3/site-packages/simpleparse/common/numbers.py'
__name__ = 'simpleparse.common.numbers'
__package__ = 'simpleparse.common'
_p = <simpleparse.parser.Parser object>
c = {'binary_number': LibraryElement(value='binary_number',report=True...,repeating=False,expanded=False,lookahead=False ), 'float': LibraryElement(value='float',report=True,negativ...,repeating=False,expanded=False,lookahead=False ), 'float_floatexp': LibraryElement(value='float_floatexp',report=Tru...,repeating=False,expanded=False,lookahead=False ), 'hex': LibraryElement(value='hex',report=True,negative=...,repeating=False,expanded=False,lookahead=False ), 'imaginary_number': LibraryElement(value='imaginary_number',report=T...,repeating=False,expanded=False,lookahead=False ), 'int': LibraryElement(value='int',report=True,negative=...,repeating=False,expanded=False,lookahead=False ), 'int_unsigned': LibraryElement(value='int_unsigned',report=True,...,repeating=False,expanded=False,lookahead=False ), 'number': LibraryElement(value='number',report=True,negati...,repeating=False,expanded=False,lookahead=False ), 'number_full': LibraryElement(value='number_full',report=True,n...,repeating=False,expanded=False,lookahead=False )}
declaration = '\n# sample for parsing integer and float numbers\n... := binary_number/imaginary_number/hex/float/int\n'
name = 'number_full'