Beispiel #1
0
        ///////////////////////
        // Private

        private void VerifyFieldsPresent(HqlFunction func)
        {
            if (func.HasScalar)
            {
                HqlField field = func.Field;
                VerifyFieldsPresent(field);
            }
        }
Beispiel #2
0
 public HqlField(HqlFieldType type, HqlFunction func) // for FUNCTION
 {
     if (type != HqlFieldType.FUNCTION)
     {
         throw new Exception("Instance is for FUNCTION only");
     }
     Init(type);
     _func = func;
 }
Beispiel #3
0
 public bool Equals(HqlFunction func)
 {
     if (FuncType != func.FuncType)
     {
         return(false);
     }
     if (!Field.Equals(func.Field))
     {
         return(false);
     }
     if (!(_options == null && func._options == null) && !_options.Equals(func._options))
     {
         return(false);
     }
     return(true);
 }
Beispiel #4
0
        private bool MoveNextTokenCheckFunction()
        {
            if (_token.WordType == HqlWordType.KEYWORD && _token.Keyword == HqlKeyword.FUNCTION && MatchNext("("))
            {
                HqlFunction func     = null;
                HqlToken    funcName = _token;

                MoveNextToken();
                HqlToken paren = _token;
                if (paren.WordType != HqlWordType.KEYWORD || paren.Keyword != HqlKeyword.OPENPAREN)
                {
                    throw new Exception("Expected an open-paren in function declaration.");
                }

                MoveNextToken();
                HqlToken next = _token;

                if (next.WordType == HqlWordType.FIELD)
                {
                    if (next.Field.HasFunction)
                    {
                        throw new Exception("Cannot have nested functions");
                    }
                    func = new HqlFunction(HqlFunction.ResolveFunctionType(funcName.Data), next.Field);
                    next = new HqlToken(HqlWordType.FIELD, new HqlField(HqlFieldType.FUNCTION, func));
                }
                else if (next.WordType == HqlWordType.KEYWORD && next.Keyword == HqlKeyword.STAR)
                {
                    HqlField star = new HqlField(HqlFieldType.STAR);
                    func = new HqlFunction(HqlFunction.ResolveFunctionType(funcName.Data), star);
                    next = new HqlToken(HqlWordType.FIELD, new HqlField(HqlFieldType.FUNCTION, func));
                }
                else if (next.WordType == HqlWordType.SCALAR)
                {
                    func = new HqlFunction(HqlFunction.ResolveFunctionType(funcName.Data), next.Field);
                    next = new HqlToken(HqlWordType.FIELD, new HqlField(HqlFieldType.FUNCTION, func));
                }
                else if (next.WordType == HqlWordType.INT || next.WordType == HqlWordType.FLOAT)
                {
                    func = new HqlFunction(HqlFunction.ResolveFunctionType(funcName.Data), HqlField.CreateObject(next));
                    next = new HqlToken(HqlWordType.FIELD, new HqlField(HqlFieldType.FUNCTION, func));
                }
                else
                {
                    throw new Exception("Expected a valid field instead of this unknown object");
                }

                MoveNextToken();
                HqlToken lookForComma = _token;
                while (lookForComma.WordType == HqlWordType.KEYWORD && lookForComma.Keyword == HqlKeyword.COMMA)
                {
                    MoveNextToken();
                    HqlToken option = _token;
                    func.SetOption(option);

                    MoveNextToken();
                    lookForComma = _token;
                }

                HqlToken closedparen = _token;
                if (closedparen.WordType != HqlWordType.KEYWORD || closedparen.Keyword != HqlKeyword.CLOSEDPAREN)
                {
                    throw new Exception("Expected an close-paren in function declaration.");
                }

                _token = next;
                return(true);
            }

            return(false);
        }