def parse_atom(tokens, options):
 token = tokens.current()
 result = []
 if (token in '(['):
  tokens.move()
  (matching, pattern) = {'(': [')', Required], '[': [']', Optional]}[token]
  result = pattern(*parse_expr(tokens, options))
  if (tokens.move() != matching):
   raise tokens.error(("unmatched '%s'" % token))
  return [result]
 elif (token == 'options'):
  tokens.move()
  return [OptionsShortcut()]
 elif (token.startswith('--') and (token != '--')):
  return parse_long(tokens, options)
 elif (token.startswith('-') and (token not in ('-', '--'))):
  return parse_shorts(tokens, options)
 elif ((token.startswith('<') and token.endswith('>')) or token.isupper()):
  return [Argument(tokens.move())]
 else:
  return [Command(tokens.move())]

def parse_atom ( tokens , options ) : token = tokens . current ( ) result = [ ] if ( token in '([' ) : tokens . move ( ) ( matching , pattern ) = { '(' : [ ')' , Required ] , '[' : [ ']' , Optional ] } [ token ] result = pattern ( * parse_expr ( tokens , options ) ) if ( tokens . move ( ) != matching ) : raise tokens . error ( ( "unmatched '%s'" % token ) ) return [ result ] elif ( token == 'options' ) : tokens . move ( ) return [ OptionsShortcut ( ) ] elif ( token . startswith ( '--' ) and ( token != '--' ) ) : return parse_long ( tokens , options ) elif ( token . startswith ( '-' ) and ( token not in ( '-' , '--' ) ) ) : return parse_shorts ( tokens , options ) elif ( ( token . startswith ( '<' ) and token . endswith ( '>' ) ) or token . isupper ( ) ) : return [ Argument ( tokens . move ( ) ) ] else : return [ Command ( tokens . move ( ) ) ]
atom ::= | [ expr ] | options | long | shorts | argument | command ; .