anchor.diff:  dc(Str) -> string:to_lower(Str).
   
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  +%% Parsing real pages
  +wget(Url) ->
  +  inets:start(),
  +  {ok, {_Rc, _Hdrs, Body}} = http:request(get, {Url, []}, [], []),
  +  Body.
  +
  +wget_parse(Url) ->
  +  sax(wget(Url),fun(T,A)-> A++[T] end, []).
  +
  +wget_print(Url) ->
  +  io:fwrite("~s~n",[wget(Url)]).
  +
  +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %% ad-hoc unit test
  +unit(N) when is_integer(N) ->
  +  validate([lists:nth(N,tests())]).
  +
   unit() ->
  -  validate(
  -    [{"<!DOCTYPE bla><P a=b c=d>",
  -      [{exclamation,"doctype bla"},
  -       {tag,"p",[{"a","b"},{"c","d"}]},
  -       {end_tag,"p"}]},
  -     {"<head><B>< p><p ></z></ b></x>",
  -      [{tag,"head",[]},
  -       {tag,"b",[]},
  -       {tag,"p",[]},
  -       {tag,"p",[]}, 
  -       {end_tag,"p"},
  -       {end_tag,"p"},
  -       {end_tag,"b"},
  -       {end_tag,"head"}]},
  -     {"<tag catt xatt=\"\" batt>",
  -      [{tag,"tag",[{"catt",""},{"xatt",""},{"batt",""}]},
  -       {end_tag,"tag"}]},
  -     {"<a>...<...</a>",
  -      [{tag,"a",[]},
  -       {text,"...&lt;..."},
  -       {end_tag,"a"}]},
  -     {"<P a=b c=d>hej<!-- tobbe --><b>svejsan</b>foo</p>grump<x x=y />",
  -      [{tag,"p",[{"a","b"},{"c","d"}]},
  -       {text,"hej"},
  -       {comment," tobbe "},
  -       {tag,"b",[]},
  -       {text,"svejsan"},
  -       {end_tag,"b"},
  -       {text,"foo"},
  -       {end_tag,"p"},
  -       {text,"grump"},
  -       {tag,"x",[{"x","y"}]},
  -       {end_tag,"x"}]}
  -    ]).
  +  validate(tests()).
   
   validate([]) -> [];
   validate([{Str,Toks}|Vs]) -> 
  
positive.code: parse(Str,Fun,Acc) ->
    parse({Fun,Acc,[]},tokenize(Str)).
  
  parse(State,[Token1,Token2,T]) ->
    parse(maybe_emit(Token2,maybe_emit(Token1,State)),T);
  parse(State,[Token,T]) ->
    parse(maybe_emit(Token,State),T);
  parse({Fun,Acc,Stack}=State,{Token,T}) -> 
    case Token of
      eof -> eof(unroll(Stack,{Fun,Acc,[]}));
      _   -> parse(maybe_emit(Token,State),tokenize(T))
    end.
  
  eof({_Fun,Acc,_Stack}) -> Acc.
  
  
negative.code: -module('trane').
  -author('mats cronqvist').
  -export([sax/3
           , unit/0,unit/1
           , wget_parse/1,wget_print/1]).
  
  -define(ok(X),$a=<X,X=<$z;$A=<X,X=<$Z;$0=<X,X=<$9;X==$_;X==$-;X==$:).
  