Simple but Powerful Pratt Parsing › Pratt 解析,一般“形状” Pratt parsing, the general shape [#266]

仅使用循环不足以解析中缀表达式。相反,Pratt 解析同时使用循环和递归:
Using just loops won’t be enough for parsing infix expressions. Instead, Pratt parsing uses both loops and recursion:

fn parse_expr() {
    ...
    loop {
        ...
        parse_expr()
        ...
    }
}

它不仅会让你陷入 摩比乌斯 ( Möbeus ) 形状的仓鼠轮中,而且还能处理结合性和优先级问题!
Not only does it send your mind into Möbeus-shaped hamster wheel, it also handles associativity and precedence!