* General overview of Recursive Descent Parsing https://www.engr.mun.ca/~theo/Misc/exp_parsing.htm Operator Predence planner during parse phase: when we parse and build our node-sub-node structures we need to plan the precedence rules, we use a recursion tree to build this http://dev.mysql.c
(depth int)
| 319 | |
| 320 | // expr: |
| 321 | func (t *tree) O(depth int) Node { |
| 322 | debugf(depth, "O pre: %v", t.Cur()) |
| 323 | n := t.A(depth) |
| 324 | debugf(depth, "O post: n:%v cur:%v ", n, t.Cur()) |
| 325 | for { |
| 326 | tok := t.Cur() |
| 327 | switch tok.T { |
| 328 | case lex.TokenLogicOr, lex.TokenOr: |
| 329 | t.Next() |
| 330 | n = NewBinaryNode(tok, n, t.A(depth+1)) |
| 331 | case lex.TokenCommentSingleLine: |
| 332 | t.Next() // consume -- |
| 333 | t.Next() // consume comment after -- |
| 334 | case lex.TokenEOF, lex.TokenEOS, lex.TokenFrom, lex.TokenComma, lex.TokenIf, |
| 335 | lex.TokenAs, lex.TokenSelect, lex.TokenLimit: |
| 336 | // these are indicators of End of Current Clause, so we can return |
| 337 | return n |
| 338 | default: |
| 339 | return n |
| 340 | } |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | func (t *tree) A(depth int) Node { |
| 345 | debugf(depth, "A pre: %v", t.Cur()) |