test(Words) :-
        initial(Node),
        recognize(Node,Words).

recognize(Node,[]) :-
        final(Node).
recognize(FromNode,String) :-
        arc(FromNode,Label,ToNode),
        traverse(Label,String,NewString),
        recognize(ToNode,NewString).

traverse(Label,[Label|RestString],RestString) :-
	not(special(Label)).
traverse(Abbrev,[Label|RestString],RestString) :-
	macro(Abbrev,Label).
traverse('#',String,String).

special('#').
special(X) :-
        macro(X,_).

not(X) :- 
	\+(X).
