parser/parsing/parseSubExpression.py
def parse_expression(exp = None):
	"""
    Main parsing function to parse sub expressions of expression

    :param exp: protobuf Expression object
    :return: protobuf Expression object
    """
	# exp = parser.parse(r"\b[A-Z]{1}\b")
	tokens = exp.tokens
	index = 0
	while index < len(tokens):
		if tokens[index].token == "(" or tokens[index].token == "[" or tokens[index].token == "<"\
			or tokens[index].token == "/":
			length, sub_expression = find_closing(tokens[index + 1:], tokens[index].token)
			append_sub_expression(exp, sub_expression, tokens[index: index + length])
			index += length
		elif tokens[index].type == root.TokenType.QuantifierModifier and\
			tokens[index].groupref != root.QuantifierModifierType.AlternationPipe:
			if len(exp.expressions) == 0:
				raise ValueError('Wrong expression.')
			exp.expressions[-1].raw += tokens[index].token
			exp.expressions[-1].tokens.append(tokens[index])
			index += 1
		else:
			append_sub_expression(exp, tokens[index].token, [tokens[index]])
			index += 1

	json_obj = MessageToJson(exp)
	# print(json_obj)
	return exp

    Main parsing function to parse sub expressions of expression

    :param exp: protobuf Expression object
    :return: protobuf Expression object
    
Main parsing function to parse sub expressions of expression
Main parsing function to parse sub expressions of expression
def parse_expression(exp = None):
	tokens = exp.tokens
	index = 0
	while index < len(tokens):
		if tokens[index].token == "(" or tokens[index].token == "[" or tokens[index].token == "<"\
			or tokens[index].token == "/":
			length, sub_expression = find_closing(tokens[index + 1:], tokens[index].token)
			append_sub_expression(exp, sub_expression, tokens[index: index + length])
			index += length
		elif tokens[index].type == root.TokenType.QuantifierModifier and\
			tokens[index].groupref != root.QuantifierModifierType.AlternationPipe:
			if len(exp.expressions) == 0:
				raise ValueError('Wrong expression.')
			exp.expressions[-1].raw += tokens[index].token
			exp.expressions[-1].tokens.append(tokens[index])
			index += 1
		else:
			append_sub_expression(exp, tokens[index].token, [tokens[index]])
			index += 1
	json_obj = MessageToJson(exp)
	return exp
def parse_expression ( exp = None ) : tokens = exp . tokens index = 0 while index < len ( tokens ) : if tokens [ index ] . token == "(" or tokens [ index ] . token == "[" or tokens [ index ] . token == "<" or tokens [ index ] . token == "/" : length , sub_expression = find_closing ( tokens [ index + 1 : ] , tokens [ index ] . token ) append_sub_expression ( exp , sub_expression , tokens [ index : index + length ] ) index += length elif tokens [ index ] . type == root . TokenType . QuantifierModifier and tokens [ index ] . groupref != root . QuantifierModifierType . AlternationPipe : if len ( exp . expressions ) == 0 : raise ValueError ( 'Wrong expression.' ) exp . expressions [ - 1 ] . raw += tokens [ index ] . token exp . expressions [ - 1 ] . tokens . append ( tokens [ index ] ) index += 1 else : append_sub_expression ( exp , tokens [ index ] . token , [ tokens [ index ] ] ) index += 1 json_obj = MessageToJson ( exp ) return exp
Main parsing function to parse sub expressions of expression
Main parsing function to parse sub expressions of expression
"""
    Main parsing function to parse sub expressions of expression

    :param exp: protobuf Expression object
    :return: protobuf Expression object
    """ # exp = parser.parse(r"\b[A-Z]{1}\b") # print(json_obj)
protobuf Expression object
protobuf Expression object
exp
protobuf Expression object
protobuf Expression object