simpleparse.common.numbers
index
s:\sp\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
            
simpleparse.dispatchprocessor.DispatchProcessor(simpleparse.processor.Processor)
BinaryInterpreter
FloatFloatExpInterpreter
FloatInterpreter
HexInterpreter
ImaginaryInterpreter
IntInterpreter
 
class BinaryInterpreter(simpleparse.dispatchprocessor.DispatchProcessor)
       
  
Method resolution order:
BinaryInterpreter
simpleparse.dispatchprocessor.DispatchProcessor
simpleparse.processor.Processor
simpleparse.processor.MethodSource

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

Data and non-method functions defined here:
__doc__ = None
__module__ = 'simpleparse.common.numbers'
str(object) -> string
 
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.

Methods inherited from simpleparse.processor.Processor:
__repr__(self)
Return a representation of the class
 
class FloatFloatExpInterpreter(simpleparse.dispatchprocessor.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
simpleparse.dispatchprocessor.DispatchProcessor
simpleparse.processor.Processor
simpleparse.processor.MethodSource

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

Data and non-method functions defined here:
__doc__ = 'Interpret a float string as an integer value\n\tNo...tion, which\n\tgives you a nice way to write 2e.5\n\t'
str(object) -> string
 
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
__module__ = 'simpleparse.common.numbers'
str(object) -> string
 
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.

Methods inherited from simpleparse.processor.Processor:
__repr__(self)
Return a representation of the class
 
class FloatInterpreter(simpleparse.dispatchprocessor.DispatchProcessor)
      Interpret a standard float value as a float
 
  
Method resolution order:
FloatInterpreter
simpleparse.dispatchprocessor.DispatchProcessor
simpleparse.processor.Processor
simpleparse.processor.MethodSource

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

Data and non-method functions defined here:
__doc__ = 'Interpret a standard float value as a float'
str(object) -> string
 
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
__module__ = 'simpleparse.common.numbers'
str(object) -> string
 
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.

Methods inherited from simpleparse.processor.Processor:
__repr__(self)
Return a representation of the class
 
class HexInterpreter(simpleparse.dispatchprocessor.DispatchProcessor)
      Interpret a hexidecimal integer string as an integer value
 
  
Method resolution order:
HexInterpreter
simpleparse.dispatchprocessor.DispatchProcessor
simpleparse.processor.Processor
simpleparse.processor.MethodSource

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

Data and non-method functions defined here:
__doc__ = 'Interpret a hexidecimal integer string as an integer value'
str(object) -> string
 
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
__module__ = 'simpleparse.common.numbers'
str(object) -> string
 
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.

Methods inherited from simpleparse.processor.Processor:
__repr__(self)
Return a representation of the class
 
class ImaginaryInterpreter(simpleparse.dispatchprocessor.DispatchProcessor)
       
  
Method resolution order:
ImaginaryInterpreter
simpleparse.dispatchprocessor.DispatchProcessor
simpleparse.processor.Processor
simpleparse.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 non-method functions defined here:
__doc__ = None
__module__ = 'simpleparse.common.numbers'
str(object) -> string
 
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
map = {'float': <FloatInterpreter object @ 8339248>, 'int': <IntInterpreter object @ 8339768>}
dict() -> new empty dictionary.
dict(mapping) -> new dictionary initialized from a mapping object's
    (key, value) pairs.
dict(seq) -> new dictionary initialized as if via:
    d = {}
    for k, v in seq:
        d[k] = v

Methods inherited from simpleparse.processor.Processor:
__repr__(self)
Return a representation of the class
 
class IntInterpreter(simpleparse.dispatchprocessor.DispatchProcessor)
      Interpret an integer (or unsigned integer) string as an integer
 
  
Method resolution order:
IntInterpreter
simpleparse.dispatchprocessor.DispatchProcessor
simpleparse.processor.Processor
simpleparse.processor.MethodSource

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

Data and non-method functions defined here:
__doc__ = 'Interpret an integer (or unsigned integer) string as an integer'
str(object) -> string
 
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
__module__ = 'simpleparse.common.numbers'
str(object) -> string
 
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.

Methods inherited from simpleparse.processor.Processor:
__repr__(self)
Return a representation of the class
 
Functions
            
_toInt(s, base)
_toLong(s, base)
 
Data
             __file__ = r'S:\sp\simpleparse\common\numbers.pyc'
__name__ = 'simpleparse.common.numbers'
_p = <simpleparse.parser.Parser instance at 0x007B37F0>
c = {'binary_number': LibraryElement( production = 'binary_number'...se.generator.Generator instance at 0x007B25B0>, ), 'float': LibraryElement( production = 'float', ge...se.generator.Generator instance at 0x007B25B0>, ), 'float_floatexp': LibraryElement( production = 'float_floatexp...se.generator.Generator instance at 0x007B25B0>, ), 'hex': LibraryElement( production = 'hex', gene...se.generator.Generator instance at 0x007B25B0>, ), 'imaginary_number': LibraryElement( production = 'imaginary_numb...se.generator.Generator instance at 0x007B25B0>, ), 'int': LibraryElement( production = 'int', gene...se.generator.Generator instance at 0x007B25B0>, ), 'int_unsigned': LibraryElement( production = 'int_unsigned',...se.generator.Generator instance at 0x007B25B0>, ), 'number': LibraryElement( production = 'number', g...se.generator.Generator instance at 0x007B25B0>, ), 'number_full': LibraryElement( production = 'number_full', ...se.generator.Generator instance at 0x007B25B0>, )}
declaration = '\n# sample for parsing integer and float numbers\n... := binary_number/imaginary_number/hex/float/int\n'
name = 'number_full'