create tree of input string from bnf rules