I'm creating a programming language in C ++. I made a simple lexer, which works perfectly fine for now.
out 5 + 7 * 3
My lexer turns this into:
kw: out
num: 5
op: +
num: 7
op: *
num: 3
nl
Now I need to create an AST (abstract syntax tree), which makes the example into this:
kw out
|
op +
/ \
num 5 op *
/ \
num 7 num 2
But how do you do a tree algorithm?
Note Please do not post a code, that takes away all grace. Instead, tell me the logic of the algorithm.