parsing - Parse function, python (binary search tree) -
I am trying to implement a parsed function. "From an infix stream of tokens, and in the current index token stream, as a collection of nodes, the tree is built and returned, which represents the expression" It is that I have come so far:
Pars (lst, i + 1) correct, i = parse (lst, i + 1) if token.isdigit (): return mkLiteralNode (token) alifed token. Identifier (): Return mkVariableNode (token) Other: Left, I = parse (lst, i + 1) true, i = parse (lst, i + 1) returns true
In general, The error is correct in the previous row: You are tokens.advertisement means that this command must return an integer, which is
mkLiteralNode , and
token. The identifier must return the variable, or
mkVariableNode . I get an error when testing this function and the error occurs:
token = lst [i] TypeError: 'int' object is not subscriptable < P> How can I fix this?
lst = 0 < / Code>
lst an
int and then you are trying to access it as a list that is causing the error You may be looking at
token = lst [i] :
token = token [i]
Comments
Post a Comment