Next / Previous / Contents / Shipman's homepage

11. Truths._lineCheck(): Check one input line

# - - -   T r u t h s . _ l i n e C h e c k

    def _lineCheck(self, rawLine):
        '''Parse and store one line of input.

          [ rawLine is a string ->
              if rawLine is a valid input line ->
                self._condList  +:=  a string containing the
                      uppercased truth values from line
                else -> raise ValueError ]

We use the regular expression defined in Section 6.5, “LINE_PAT to check the overall syntax of the line. The resulting re.MatchObject contains two groups, but we care only about the first one, whose group name TRUTH_GROUP is given in Section 6.5, “LINE_PAT. The “+” suffix in the definition of this group requires that there be at least one truth code.

        #-- 1
        # [ if rawLine matches LINE_PAT ->
        #     rawTruth  :=  the TRUTH_GROUP group from that match,
        #                   uppercased
        #   else -> raise ValueError ]
        m = LINE_PAT.match(rawLine)
        if m is None:
            raise ValueError("Invalid line syntax.")
            rawTruth =

        #-- 2