def parse()

in src/latex2sympy2_extended/latex2sympy2.py [0:0]


    def parse(self, latex_str: str):
        """Main entry point to parse latex string"""
        # setup listener
        parser = self.create_parser(latex_str)

        # process the input
        math = parser.math()

        # if set relation
        if math.set_relation():
            return self.convert_set_relation(math.set_relation())
        
        if math.set_elements():
            # The issue with 333,333 or 3,333 is that it makess sets and numbers with commas ambigous
            # is that 333333 or {333,333}?
            # What we therefore do is that default to numbers with commas
            # We make the regex match directly on latex_str, because otherwise don't know if there is space
            # between the comma and the number, in this case it should be a set
            if comma_number_regex.match(latex_str):
                return convert_number(latex_str)
            return self.convert_set_elements(math.set_elements())
        
        if math.set_elements_relation():
            return self.convert_set_elements_relation(math.set_elements_relation())

        raise Exception('Nothing matched')