Skip to content

Commit

Permalink
⬆️ UPDATE 语法分析(未完成)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunwu51 committed Dec 17, 2024
1 parent 7f8b63b commit 964511e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions 24.12/demo/语法分析.md → 24.12/语法分析.md
Original file line number Diff line number Diff line change
Expand Up @@ -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中是一个单例
Expand All @@ -415,4 +415,5 @@ function parseExpression(tokens, start, end, precedence, currentIndex = {index:
}
return result;
}
```
```
这个代码行数不多,但是因为有循环和递归,所以比较难理解。

0 comments on commit 964511e

Please sign in to comment.