示例#1
0
    def __init__(self, fh=-1):
        self.fh = fh
        if fh != -1:
            self.file_name = fh.name
            self.line_n = get_current_line_info_number(fh)
        else:
            self.file_name = "no file handle"
            self.line_n = -1

        self.space_db = {}  # Maps: space width --> character_set
        self.grid_db = {}  # Maps: grid width  --> character_set
        self.bad_character_set = LocalizedParameter("bad", NumberSet())
        self.newline_state_machine = LocalizedParameter("newline", None)
        self.newline_suppressor_state_machine = LocalizedParameter(
            "suppressor", None)

        self.__containing_mode_name = ""
示例#2
0
    def specify_grid(self, PatternStr, CharSet, Count, FH=-1):
        self.__check("grid", self.grid_db, CharSet, FH, Key=Count)

        if Count == 0:
            error_msg(
                "A grid count of 0 is nonsense. May be define a space count of 0.",
                FH)
        if Count == 1:
            error_msg("Indentation grid counts of '1' are equivalent of to a space\n" + \
                      "count of '1'. The latter is faster to compute.",
                      FH, DontExitF=True)

        self.grid_db[Count] = LocalizedParameter("grid", CharSet, FH)
        self.grid_db[Count].set_pattern_string(PatternStr)
示例#3
0
 def specify_suppressor(self, PatternStr, SM, FH=-1):
     self.__check("suppressor", self.newline_suppressor_state_machine, SM,
                  FH)
     self.newline_suppressor_state_machine = LocalizedParameter(
         "suppressor", SM, FH)
     self.newline_suppressor_state_machine.set_pattern_string(PatternStr)
示例#4
0
 def specify_bad(self, PatternStr, CharSet, FH=-1):
     self.__check("bad", self.bad_character_set, CharSet, FH)
     self.bad_character_set = LocalizedParameter("bad", CharSet, FH)
     self.bad_character_set.set_pattern_string(PatternStr)
示例#5
0
    def specify_space(self, PatternStr, CharSet, Count, FH=-1):
        self.__check("space", self.space_db, CharSet, FH, Key=Count)

        # Note, a space count of '0' is theoretically possible
        self.space_db[Count] = LocalizedParameter("space", CharSet, FH)
        self.space_db[Count].set_pattern_string(PatternStr)