Beispiel #1
0
 def print_error(self):
     """
     If the corresponding rule didn't match,
     prints the relevant error so the user is aware of what the lexing
     problem was.
     """
     if self._matched is None:
         raise ValueError(
             "Tried to print an error for rule '" + self.__class__.__name__ + \
             "' before it was applied."
         )
     if self._matched:
         raise ValueError(
             "Tried to print an error for rule '" + self.__class__.__name__ + \
             "' when no error occurred."
         )
     if self.error_msg is None:
         raise ValueError(
             "No error to print for rule '" + self.__class__.__name__ + \
             "'."
         )
     InputFileManager.get_or_create() \
         .syntax_error(self.error_msg, self._furthest_matched_index + 1)
Beispiel #2
0
    def __init__(self, master_file_path):
        if (master_file_path is not None
                and not isinstance(master_file_path, string_types)):
            raise ValueError(
                "Since v1.4.0, the parser takes as an argument " + \
                "the path of the master file directly, rather " + \
                "than the file itself as before.")
        self._master_filepath = master_file_path

        self.input_file_manager = \
            InputFileManager.get_or_create(master_file_path)
        self.lexer = Lexer()
        self.ast = AST.get_or_create()

        self._declaration_line_allowed = True
        self._last_indentation = None

        self._current_unit_declaration = None
        self._current_variation_name = None
Beispiel #3
0
 def reset_system(cls, *args, **kwargs):
     Stats.reset_instance()
     Deprecations.reset_instance()
     AST.reset_instance()
     InputFileManager.reset_instance(None)
     return cls.reset_instance(*args, **kwargs)
Beispiel #4
0
 def __init__(self):
     self._file_manager = InputFileManager.get_or_create()