| 342 | } |
| 343 | |
| 344 | func (t *tree) A(depth int) Node { |
| 345 | debugf(depth, "A pre: %v", t.Cur()) |
| 346 | n := t.C(depth) |
| 347 | for { |
| 348 | debugf(depth, "A post: cur=%v peek=%v", t.Cur(), t.Peek()) |
| 349 | switch tok := t.Cur(); tok.T { |
| 350 | case lex.TokenLogicAnd, lex.TokenAnd: |
| 351 | p := t.Peek() |
| 352 | if p.T == lex.TokenLeftParenthesis && t.boolean { |
| 353 | // This is a Boolean Expression Not Binary |
| 354 | return n |
| 355 | } |
| 356 | t.Next() |
| 357 | debugf(depth, "AND pre-binary n=%s", n) |
| 358 | n = NewBinaryNode(tok, n, t.C(depth+1)) |
| 359 | debugf(depth, "and post %s", n) |
| 360 | default: |
| 361 | return n |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | func (t *tree) C(depth int) Node { |
| 367 | debugf(depth, "C pre: %v", t.Cur()) |