I would like to know how is the best way to create the syntax tree.
The standard Stack Overflow resource for learning to write compilers and interpreters is Learning to write a compiler