Example #1
0
    def __validate(self, declaration, macro_text):
        declaration_arguments = match_alphanumerical_in_brackets.findall(declaration)
        macro_text_arguments = match_alphanumerical_in_brackets.findall(macro_text)

        for argument in declaration_arguments:
            assert argument in macro_text_arguments, \
                "Macro argument mismatch. Declaration arguments were: %s, whereas macro_text arguments were: %s" \
                % (str(declaration_arguments), str(macro_text_arguments))
Example #2
0
    def __init__(self, declaration, macro_text):
        regex_declaration_builder = RegexDeclarationBuilder()
        macro_function_builder = MacroFunctionBuilder()

        self.__validate(declaration, macro_text)

        self.__declaration = declaration
        self.__declaration_regex = regex_declaration_builder.build(declaration)
        self.__arg_count = len(match_alphanumerical_in_brackets.findall(declaration))
        self.__arguments = match_alphanumerical_in_brackets.findall(declaration)

        macro_text = self.__preprocess_macro_text(macro_text)

        self.__macro_text = macro_text
        self.__macro_function = macro_function_builder.build(macro_text)
 def get_bracket_parts(self, declaration):
     return match_alphanumerical_in_brackets.findall(declaration)