getConditionalExpression - Return ast.ConditionExpression created from tokens and validate the syntax
(leftSide token.Token, isAnonymitifier bool)
| 806 | |
| 807 | // getConditionalExpression - Return ast.ConditionExpression created from tokens and validate the syntax |
| 808 | func (parser *Parser) getConditionalExpression(leftSide token.Token, isAnonymitifier bool) (bool, *ast.ConditionExpression, error) { |
| 809 | conditionalExpression := &ast.ConditionExpression{Condition: parser.currentToken} |
| 810 | |
| 811 | if isAnonymitifier { |
| 812 | conditionalExpression.Left = ast.Anonymitifier{Token: leftSide} |
| 813 | } else { |
| 814 | conditionalExpression.Left = ast.Identifier{Token: leftSide} |
| 815 | } |
| 816 | |
| 817 | // skip EQUAL or NOT |
| 818 | parser.nextToken() |
| 819 | |
| 820 | if parser.currentToken.Type == token.IDENT || parser.currentToken.Type == token.LITERAL || |
| 821 | parser.currentToken.Type == token.NULL || parser.currentToken.Type == token.APOSTROPHE { |
| 822 | startedWithApostrophe := parser.skipIfCurrentTokenIsApostrophe() |
| 823 | |
| 824 | if !startedWithApostrophe && parser.currentToken.Type == token.IDENT { |
| 825 | conditionalExpression.Right = ast.Identifier{Token: parser.currentToken} |
| 826 | } else { |
| 827 | conditionalExpression.Right = ast.Anonymitifier{Token: parser.currentToken} |
| 828 | } |
| 829 | parser.nextToken() |
| 830 | |
| 831 | finishedWithApostrophe := parser.skipIfCurrentTokenIsApostrophe() |
| 832 | err := validateApostropheWrapping(startedWithApostrophe, finishedWithApostrophe, conditionalExpression.Right.GetToken()) |
| 833 | if err != nil { |
| 834 | return false, nil, err |
| 835 | } |
| 836 | } else { |
| 837 | return false, conditionalExpression, &SyntaxError{expecting: []string{token.APOSTROPHE, token.IDENT, token.LITERAL, token.NULL}, got: parser.currentToken.Literal} |
| 838 | } |
| 839 | |
| 840 | return true, conditionalExpression, nil |
| 841 | } |
| 842 | |
| 843 | // getContainExpression - Return ast.ContainExpression created from tokens and validate the syntax |
| 844 | func (parser *Parser) getContainExpression(leftSide token.Token, isAnonymitifier bool) (bool, *ast.ContainExpression, error) { |
no test coverage detected