func consumeExpr(parser *Parser, offset, maxTokens int) (ast.Node, int, error) {
	originalOffset := offset
	var parts []interface{}
	var err error
	for consumed := 0; offset < len(parser.tokens) && consumed < maxTokens; consumed++ {
		tok := parser.tokens[offset]
		if offset > originalOffset && parser.tokens[offset-1].IsEndOfLine {
			break
		}
		if tok.Kind == lexer.TokenColon || tok.Kind == lexer.TokenComma {
			break
		}
		if consumed%2 == 1 {
			switch tok.Kind {
			case
				lexer.TokenPlus, lexer.TokenMinus, lexer.TokenTimes,
				lexer.TokenDivide, lexer.TokenRemainder,
				lexer.TokenAnd, lexer.TokenOr,
				lexer.TokenEqual, lexer.TokenNotEqual,
				lexer.TokenGreaterThan, lexer.TokenGreaterThanEqual,
				lexer.TokenLessThan, lexer.TokenLessThanEqual,
				lexer.TokenAssign, lexer.TokenPlusAssign, lexer.TokenMinusAssign,
				lexer.TokenTimesAssign, lexer.TokenDivideAssign,
				lexer.TokenRemainderAssign:
				parts = append(parts, tok)
				offset++
				continue
			default:
				break
			}
		}
		var fn *ast.Func
		var fnAnon bool
		fn, offset, fnAnon, err = consumeFunc(parser, offset)
		if err == nil {
			if !fnAnon {
				parser.appendError(fn, "function literals cannot be named")
			}
			parts = append(parts, fn)
			continue
		}
		var literal *ast.Literal
		literal, offset, err = consumeLiteral(parser, offset)
		if err == nil {
			parts = append(parts, literal)
			continue
		}
		var interpolate *ast.Interpolate
		interpolate, offset, err = consumeInterpolate(parser, offset)
		if err == nil {
			parts = append(parts, interpolate)
			continue
		}
		var array *ast.Array
		array, offset, err = consumeArray(parser, offset)
		if err == nil {
			parts = append(parts, array)
			continue
		}
		var m *ast.Map
		m, offset, err = consumeMap(parser, offset)
		if err == nil {
			parts = append(parts, m)
			continue
		}
		var call *ast.Call
		call, offset, err = consumeTypeCast(parser, offset)
		if err == nil {
			parts = append(parts, call)
			continue
		}
		var group *ast.Group
		group, offset, err = consumeGroup(parser, offset)
		if err == nil {
			parts = append(parts, group)
			continue
		}
		var expr ast.Node
		expr, offset, err = consumeChainedExpr(parser, offset)
		if err == nil {
			parts = append(parts, expr)
			continue
		}
		break
	}
	if len(parts) == 0 {
		return nil, originalOffset, newTokenMismatch("expression",
			parser.tokens[originalOffset-1].Kind,
			parser.tokens[originalOffset].Kind)
	}
	return reduceExpr(parts), offset, nil
}
maxTokens can be unlimitedTokens.
package parser
import (
	"github.com/elliotchance/ok/ast"
	"github.com/elliotchance/ok/ast/asttest"
	"github.com/elliotchance/ok/lexer"
)
const unlimitedTokens = 1000000