Exemplo n.º 1
0
        public static bool IsVariable(string v)
        {
            var lx     = new lexicProcessor.Lexer(v);
            var tokens = lx.GenerateTokens();

            return(!((tokens.Count != 1 || tokens.Item().type != lexicProcessor.Token.Type.VARIABLE)));
        }
Exemplo n.º 2
0
        public static Type GetType(string data)
        {
            var lexer  = new lexicProcessor.Lexer(data);
            var tokens = lexer.GenerateTokens();

            if (tokens.Count == 0)
            {
                return(Type.NONE);
            }
            if (tokens.Count == 1 || (data.IndexOf(Const.DEL_LIST) == -1 && data.IndexOf(Const.DEL_RANGE) == -1))
            {
                return(Type.FIXED);
            }
            var elems = data.Split(Const.DEL_LIST).ToList();

            if (elems.Count > 1)
            {
                var seemsList = true;
                foreach (var elem in elems)
                {
                    if (BracketProcessor.BracketCheck(elem) != BracketProcessor.ERRORTYPE.OK)
                    {
                        seemsList = false;
                        break;
                    }
                }
                if (seemsList)
                {
                    return(Type.LIST);
                }
            }
            elems = data.Split(Const.DEL_RANGE).ToList();
            if (elems.Count() != 2)
            {
                return(Type.NONE);
            }
            else
            {
                var seemsRange = true;
                foreach (var elem in elems)
                {
                    if (BracketProcessor.BracketCheck(elem) != BracketProcessor.ERRORTYPE.OK)
                    {
                        seemsRange = false;
                        break;
                    }
                }
                if (seemsRange)
                {
                    return(Type.RANGE);
                }
                else
                {
                    return(Type.NONE);
                }
            }
        }