def parse_common(source, info):
 initial_group_count = info.group_count
 branches = [parse_sequence(source, info)]
 final_group_count = info.group_count
 while source.match('|'):
  info.group_count = initial_group_count
  branches.append(parse_sequence(source, info))
  final_group_count = max(final_group_count, info.group_count)
 info.group_count = final_group_count
 source.expect(')')
 if (len(branches) == 1):
  return branches[0]
 return Branch(branches)

def parse_common ( source , info ) : initial_group_count = info . group_count branches = [ parse_sequence ( source , info ) ] final_group_count = info . group_count while source . match ( '|' ) : info . group_count = initial_group_count branches . append ( parse_sequence ( source , info ) ) final_group_count = max ( final_group_count , info . group_count ) info . group_count = final_group_count source . expect ( ')' ) if ( len ( branches ) == 1 ) : return branches [ 0 ] return Branch ( branches )
parses a common groups branch .