Example #1
0
        //TODO TESTS
        private static void Command(ListController <TokenModel> lc)
        {
            var beg = lc.GetNext();

            if (TypesTools.IsType(beg.Text))
            {
                lc.SetBack();
                Initialization(lc);
            }
            else if (VarTable.Contains(beg.Text))
            {
                lc.SetBack();
                var node = VariableAssign(lc);
                Commands.Add(node);
            }
            else if (FuncTable.Contains(beg.Text))
            {
                lc.SetBack();
                var node = FuncExecute(lc);
                Commands.Add(node);
            }
            else
            {
                throw new ParseException($"Cannot resolve '{beg.Text}'", beg);
            }

            //todo lately var = Arithmetic Expression
            //todo more lately type func
        }
Example #2
0
        public bool CheckFunc(string name, List <string> args)
        {
            if (!Contains(name))
            {
                throw new Exception($"Cannot find function '{name}'");
            }

            var argsType = TypesTools.ToTypes(args);
            var item     = Get(name);

            return(Funcs.Exists(model => model.ArgsType.Contains(argsType)));
        }
Example #3
0
        public void Add(string name, List <string> argsType)
        {
            var types = TypesTools.ToTypes(argsType);

            if (Contains(name))
            {
                Get(name).ArgsType.Add(types);
            }
            else
            {
                if (CheckFunc(name, types))
                {
                    throw new Exception($"Function '{name}' with such arguments is already declared");
                }

                Funcs.Add(new FuncModel(name, types));
            }
        }