def _MatchDirective(token):
 if token.startswith('.'):
  token = token[1:]
 else:
  return (None, None)
 if (token == 'alternates with'):
  return (ALTERNATES_TOKEN, token)
 if token.startswith('or'):
  if (token.strip() == 'or'):
   return (OR_TOKEN, None)
  else:
   pred_str = token[2:].strip()
   return (OR_TOKEN, pred_str)
 if (token == 'end'):
  return (END_TOKEN, None)
 match = _SECTION_RE.match(token)
 if match:
  (repeated, section_name) = match.groups()
  if repeated:
   return (REPEATED_SECTION_TOKEN, section_name)
  else:
   return (SECTION_TOKEN, section_name)
 if token.startswith('if '):
  return (PREDICATE_TOKEN, token[3:].strip())
 if token.endswith('?'):
  return (PREDICATE_TOKEN, token)
 return (None, None)

def _MatchDirective ( token ) : if token . startswith ( '.' ) : token = token [ 1 : ] else : return ( None , None ) if ( token == 'alternates with' ) : return ( ALTERNATES_TOKEN , token ) if token . startswith ( 'or' ) : if ( token . strip ( ) == 'or' ) : return ( OR_TOKEN , None ) else : pred_str = token [ 2 : ] . strip ( ) return ( OR_TOKEN , pred_str ) if ( token == 'end' ) : return ( END_TOKEN , None ) match = _SECTION_RE . match ( token ) if match : ( repeated , section_name ) = match . groups ( ) if repeated : return ( REPEATED_SECTION_TOKEN , section_name ) else : return ( SECTION_TOKEN , section_name ) if token . startswith ( 'if ' ) : return ( PREDICATE_TOKEN , token [ 3 : ] . strip ( ) ) if token . endswith ( '?' ) : return ( PREDICATE_TOKEN , token ) return ( None , None )
helper function for matching certain directives .