Skip to content
Advertisement

Tag: parse-tree

Generate syntax tree for simple math operations

I am trying to generate a syntax tree, for a given string with simple math operators (+, -, *, /, and parenthesis). Given the string “1 + 2 * 3”: It should return an array like this: I made a function to transform “1 + 2 * 3″ in [1,”+”,2,”*”,3]. The problem is: I have no idea to give priority

Advertisement