Esempio n. 1
0
        /// <summary>
        /// This can not handle all idtoken based expressions.
        /// </summary>
        /// <param name="current"></param>
        /// <returns></returns>
        public override bool CanHandle(Token current)
        {
            if (!(current.Kind == TokenKind.Ident))
            {
                return(false);
            }

            var next = _tokenIt.Peek(1, false);

            if (!(next.Token.Kind == TokenKind.Ident))
            {
                return(false);
            }

            // Check if multi-word function name.
            // e.g. "refill inventory"
            // 1. Is it a function call?
            var tokens = _tokenIt.PeekConsequetiveIdsAppendedWithTokenCounts(true, _tokenIt.LLK);

            _result = FluentHelper.MatchFunctionName(_parser.Context, tokens);

            // Validate.
            // 1. The function must exist.
            if (!_result.Exists)
            {
                return(false);
            }

            // 2. Only fluentscript functions support wildcard.
            if (_result.FunctionMode != MemberMode.FunctionScript)
            {
                return(false);
            }

            // 3. Has wildcard flag must be turned on.
            var sym  = _parser.Context.Symbols.GetSymbol(_result.Name) as SymbolFunction;
            var func = sym.FuncExpr as FunctionExpr;

            //var func = _parser.Context.Functions.GetByName(_result.Name);
            if (!func.Meta.HasWildCard)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// This can not handle all idtoken based expressions.
        /// </summary>
        /// <param name="current"></param>
        /// <returns></returns>
        public override bool CanHandle(Token current)
        {
            if (!(current.Kind == TokenKind.Ident))
            {
                return(false);
            }

            var next = _tokenIt.Peek(1, false);

            if (!(next.Token.Kind == TokenKind.Ident))
            {
                return(false);
            }

            // Check if multi-word function name.
            var ids = _tokenIt.PeekConsequetiveIdsAppendedWithTokenCounts(true, _tokenIt.LLK);

            _result = FluentHelper.MatchFunctionName(_parser.Context, ids);
            return(_result.Exists);
        }