simpleparse.common.numbers
index
/home/mcfletch/pylive/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

Methods defined here:
__call__(self, (tag, left, right, children), buffer)
Interpret a bitfield set as an integer

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

 
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

Methods defined here:
__call__(self, (tag, left, right, children), buffer)

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

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

Methods defined here:
__call__(self, (tag, left, right, children), buffer)

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

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

Methods defined here:
__call__(self, (tag, left, right, children), buffer)

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

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

Methods defined here:
__call__(self, (tag, left, right, children), buffer)
Interpret a bitfield set as an integer, not sure this algo
is correct, will see I suppose

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

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

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

Methods defined here:
__call__(self, (tag, left, right, children), buffer)

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

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

 
Data
        _p = <simpleparse.parser.Parser instance>
c = {'binary_number': LibraryElement( production = 'binary_number'...enerator.Generator instance at 0x2aaaad5f69e0>, ), 'float': LibraryElement( production = 'float', ge...enerator.Generator instance at 0x2aaaad5f69e0>, ), 'float_floatexp': LibraryElement( production = 'float_floatexp...enerator.Generator instance at 0x2aaaad5f69e0>, ), 'hex': LibraryElement( production = 'hex', gene...enerator.Generator instance at 0x2aaaad5f69e0>, ), 'imaginary_number': LibraryElement( production = 'imaginary_numb...enerator.Generator instance at 0x2aaaad5f69e0>, ), 'int': LibraryElement( production = 'int', gene...enerator.Generator instance at 0x2aaaad5f69e0>, ), 'int_unsigned': LibraryElement( production = 'int_unsigned',...enerator.Generator instance at 0x2aaaad5f69e0>, ), 'number': LibraryElement( production = 'number', g...enerator.Generator instance at 0x2aaaad5f69e0>, ), 'number_full': LibraryElement( production = 'number_full', ...enerator.Generator instance at 0x2aaaad5f69e0>, )}
declaration = '\n# sample for parsing integer and float numbers\n... := binary_number/imaginary_number/hex/float/int\n'
name = 'number_full'