zxCoder
V2EX  ›  问与答

手写 sql parser 的话怎么处理 where 子句中的 and 和 or 或者是+号 *号的优先级呢

  •  
  •   zxCoder · Jan 6, 2021 · 724 views
    This topic created in 1959 days ago, the information mentioned may be changed or developed.
    Supplement 1  ·  Jan 7, 2021

    我目前想的是先不管优先级的问题,直接按二元表达式的文法把where子句都解析出来,比如 a=5 and b=6*2 or c=10 这样子,然后再按照学栈的时候计算表达式的那种方法,用两个栈,定义一些优先级来进行处理

    这样子的处理方式和课本里那种算符优先文法的处理方式是等价的吗,那种算法优先文法看是能看懂,但不知道应该怎么写

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5071 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 09:20 · PVG 17:20 · LAX 02:20 · JFK 05:20
    ♥ Do have faith in what you're doing.