(context string)
| 630 | } |
| 631 | |
| 632 | func (t *Template) assignmentOrExpression(context string) (operand Expression) { |
| 633 | t.peekNonSpace() |
| 634 | line := t.lex.lineNumber() |
| 635 | var right, left []Expression |
| 636 | |
| 637 | var isSet bool |
| 638 | var isLet bool |
| 639 | var returned item |
| 640 | operand, returned = t.parseExpression(context) |
| 641 | pos := operand.Position() |
| 642 | if returned.typ == itemComma || returned.typ == itemAssign { |
| 643 | isSet = true |
| 644 | } else { |
| 645 | if operand == nil { |
| 646 | t.unexpected(returned, context, "operand") |
| 647 | } |
| 648 | t.backup() |
| 649 | return operand |
| 650 | } |
| 651 | |
| 652 | if isSet { |
| 653 | leftloop: |
| 654 | for { |
| 655 | switch operand.Type() { |
| 656 | case NodeField, NodeChain, NodeIdentifier, NodeUnderscore: |
| 657 | left = append(left, operand) |
| 658 | default: |
| 659 | t.errorf("unexpected node in assign") |
| 660 | } |
| 661 | |
| 662 | switch returned.typ { |
| 663 | case itemComma: |
| 664 | operand, returned = t.parseExpression(context) |
| 665 | case itemAssign: |
| 666 | isLet = returned.val == ":=" |
| 667 | break leftloop |
| 668 | default: |
| 669 | t.unexpected(returned, "assignment", "comma or assignment") |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | if isLet { |
| 674 | for _, operand := range left { |
| 675 | if operand.Type() != NodeIdentifier && operand.Type() != NodeUnderscore { |
| 676 | t.errorf("unexpected node type %s in variable declaration", operand) |
| 677 | } |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | for { |
| 682 | operand, returned = t.parseExpression("assignment") |
| 683 | right = append(right, operand) |
| 684 | if returned.typ != itemComma { |
| 685 | t.backup() |
| 686 | break |
| 687 | } |
| 688 | } |
| 689 |
no test coverage detected