# Path: fmodpy/parsing/util.py
# def pop_group(list_str, open_with="(", close_with=")"):
#     group = []
#     # Get the first element of the string (open the group, if matched).
#     if ((len(list_str) > 0) and (list_str[0] == open_with)):
#         list_str.pop(0)
#         num_open = 1
#     else: num_open = 0
#     # Search until the started group is closed.
#     while (num_open > 0):
#         # TOOD: Might need to raise parsing error when this happens.
#         if (len(list_str) == 0): raise(NotImplementedError)
#         next_value = list_str.pop(0)
#         if   (next_value == open_with):  num_open += 1
#         elif (next_value == close_with): num_open -= 1
#         if (num_open != 0): group.append(next_value)
#     # Return the captured portion and the remaining.
#     return group, list_str


from . import pop_group
        import re # <- use regular expressions to capture SIZE(...) syntax.
                import warnings
            self.kind = " ".join(group)
        # The rest can come in any order, so loop over possibilities.
        while (len(line) > 0):
            # Skip commas.
            if (line[0] == ","):
                line.pop(0)
                continue
            # The following happen if the ":: names" has not been stripped.
            if (line[0] == ":"): raise(NotImplementedError)
            # Read ALLOCATABLE
            if (line[0] == "ALLOCATABLE"):
                line.pop(0)
                self.allocatable = True
            # Read DIMENSION
            elif (line[0] == "DIMENSION"):
                group, line = pop_group(line[1:])
                if (len(group) == 0): raise(NotImplementedError)
                # Break up dimensions by commas, allow nested parentheses.
                self.dimension = [""]
                num_open = 0
                while (len(group) > 0):
                    next_value = group.pop(0)
                    if (next_value == ",") and (num_open == 0):
                        self.dimension.append("")
                    else: self.dimension[-1] += next_value
                    if (next_value == "("): num_open += 1
                    if (next_value == ")"): num_open -= 1
                # Done processing dimension.
            # Read INTENT
            elif (line[0] == "INTENT"):

# Path: fmodpy/parsing/util.py
# def pop_group(list_str, open_with="(", close_with=")"):
#     group = []
#     # Get the first element of the string (open the group, if matched).
#     if ((len(list_str) > 0) and (list_str[0] == open_with)):
#         list_str.pop(0)
#         num_open = 1
#     else: num_open = 0
#     # Search until the started group is closed.
#     while (num_open > 0):
#         # TOOD: Might need to raise parsing error when this happens.
#         if (len(list_str) == 0): raise(NotImplementedError)
#         next_value = list_str.pop(0)
#         if   (next_value == open_with):  num_open += 1
#         elif (next_value == close_with): num_open -= 1
#         if (num_open != 0): group.append(next_value)
#     # Return the captured portion and the remaining.
#     return group, list_str


# Path: fmodpy/parsing/argument.py
from . import pop_group
        import re # <- use regular expressions to capture SIZE(...) syntax.
                import warnings

            self.kind = " ".join(group)
        # The rest can come in any order, so loop over possibilities.
        while (len(line) > 0):
            # Skip commas.
            if (line[0] == ","):
                line.pop(0)
                continue
            # The following happen if the ":: names" has not been stripped.
            if (line[0] == ":"): raise(NotImplementedError)
            # Read ALLOCATABLE
            if (line[0] == "ALLOCATABLE"):
                line.pop(0)
                self.allocatable = True
            # Read DIMENSION
            elif (line[0] == "DIMENSION"):
                group, line = pop_group(line[1:])
                if (len(group) == 0): raise(NotImplementedError)
                # Break up dimensions by commas, allow nested parentheses.
                self.dimension = [""]
                num_open = 0
                while (len(group) > 0):
                    next_value = group.pop(0)
                    if (next_value == ",") and (num_open == 0):
                        self.dimension.append("")
                    else: self.dimension[-1] += next_value
                    if (next_value == "("): num_open += 1
                    if (next_value == ")"): num_open -= 1
                # Done processing dimension.
            # Read INTENT
            elif (line[0] == "INTENT"):

                group, line = pop_group(line[1:])