Next / Previous / Contents / Shipman's homepage

44. Scan.fixed(): Parse a float constant

logscan.py
# - - -   S c a n . f i x e d

    def fixed(self):
        '''Parse a fixed-point constant.
        '''

For the regular expression used in this logic, see Section 9.6, “FLOAT_PATTERN.

logscan.py
        #-- 1 --
        # [ if the line in self starts with a string that matches
        #   FLOAT_PATTERN ->
        #       self  :=  self advanced past the match
        #       m  :=  a MatchObject representing the match
        #   else ->
        #       rawFloat  :=  None ]
        m = self.tabReMatch(FLOAT_PATTERN)

        #-- 2 --
        if m is None:
            return None
        else:
            return float(m.group())