'Advance and return the symbol if the next symbol matches the regex.
Args:
regex: the compiled regular expression to attempt acceptance on.
Returns:
The first group in the expression to allow for convenient access
to simple matches. Requires () around some objects in the regex.
None if no match is found.'

def __AcceptRegex(self, regex):

    if (self.__next_symbol < len(self.__symbols)):
        match_symbol = self.__symbols[self.__next_symbol]
        logging.log(LOG_LEVEL, ' DCTB accept    %s    on    symbol    %s', regex, match_symbol)
        match = regex.match(match_symbol)
        if match:
            self.__next_symbol += 1
            if match.groups():
                matched_string = match.group(1)
            logging.log(LOG_LEVEL, ' DCTB accepted    %s', matched_string)
            return matched_string
    return None
