anchor.diff:       {[Opt#option{value = Value}|Acc], Rest}
    end.
   
  +-spec add_option(state(), #option{}) -> state().
   add_option(State, Option) ->
     State#state{options=[Option|options(State)]}.
   
  +-spec option(string()) -> #option{}.
   option(ShortName) ->
     #option{short = ShortName, argcount = 0, long = undefined, value = false}.
   
  +-spec get_value_shorts(char(), string(), state()) -> {string(), state()}.
   get_value_shorts(H, [], State) ->
     case current(State) of
       []      -> throw({H, "requires an argument"});
  
positive.code:                 },
    parse_args_tokens(State).
  
  parse_args_tokens(#state{tokens=[]}) -> [];
  parse_args_tokens(State0) ->
    case current(State0) of
  
negative.code:     _   -> throw("Unmatched '('")
    end.
  
  -spec is_arg(string()) -> boolean().
  is_arg(S) ->
    (hd(S) == $< andalso lists:last(S) == $>) orelse string:to_upper(S) == S.
  
  -spec match(pattern(), patterns()) -> {boolean(), patterns(), patterns()}.
  match(Pat, Rest) ->
    {Bool, R, A} = match(Pat, Rest, []),
    {Bool, R, lists:reverse(A)}.
  
  -spec match(pattern(), patterns(), patterns()) ->
                 {boolean(), patterns(), patterns()}.
  match(#optional{}    = Pat, Rest, Acc) -> match_optional(Pat, Rest, Acc);
  match(#required{}    = Pat, Rest, Acc) -> match_required(Pat, Rest, Acc);
  match(#either{}      = Pat, Rest, Acc) -> match_either(Pat, Rest, Acc);
  match(#one_or_more{} = Pat, Rest, Acc) -> match_one_or_more(Pat, Rest, Acc);
  match(                 Pat, Rest, Acc) -> match_child_pattern(Pat, Rest, Acc).
  
  -spec match_optional(#optional{}, patterns(), patterns()) ->
                          {boolean(), patterns(), patterns()}.
  match_optional(#optional{children=Children}, Rest0, Acc0) ->
    lists:foldl(fun(Pat, {true, R, A}) ->
                    {_, Rest, Acc} = match(Pat, R, A),
                    {true, Rest, Acc}
                end, {true, Rest0, Acc0}, Children).
  
  -spec match_required(#required{}, patterns(), patterns()) ->
                          {boolean(), patterns(), patterns()}.
  match_required(#required{children=Children}, Rest0, Acc0) ->
    lists:foldl(fun(Pat, {true, R, A}) ->
                    case match(Pat, R, A) of
  