diff --git "a/24.12/demo/\350\257\255\346\263\225\345\210\206\346\236\220.md" "b/24.12/\350\257\255\346\263\225\345\210\206\346\236\220.md" similarity index 99% rename from "24.12/demo/\350\257\255\346\263\225\345\210\206\346\236\220.md" rename to "24.12/\350\257\255\346\263\225\345\210\206\346\236\220.md" index 8d924599..104666c7 100644 --- "a/24.12/demo/\350\257\255\346\263\225\345\210\206\346\236\220.md" +++ "b/24.12/\350\257\255\346\263\225\345\210\206\346\236\220.md" @@ -402,7 +402,7 @@ function parseExpression(tokens, start, end, precedence, currentIndex = {index: var numNode = new NumberAstNode(tokens[start].value); var result = numNode; - while (currentIndex.index < end) { + while (currentIndex.index < end - 1) { var opNode = new InfixOperatorAstNode(tokens[currentIndex.index + 1]); if (opNode.precedence <= precedence) { currentIndex.index = start; // currentIndex是用对象类型,记录的上下文在所有的dfs中是一个单例 @@ -415,4 +415,5 @@ function parseExpression(tokens, start, end, precedence, currentIndex = {index: } return result; } -``` \ No newline at end of file +``` +这个代码行数不多,但是因为有循环和递归,所以比较难理解。 \ No newline at end of file