コード例 #1
0
            public override object VisitInit_block([NotNull] scheme_langParser.Init_blockContext context)
            {
                if (CompiledScheme.GetFunctionByName("init") != null)
                {
                    Errors.Add(new ErrorDescriptor($"This scheme already contains an init block.", context));
                }

                //Sign start of init block
                currentFunc = new SchemeFunction("init");
                VariableManager.NewBlock();

                return(base.VisitInit_block(context));
            }
コード例 #2
0
        public SchemeFunction GetFunctionByName(string functionName)
        {
            SchemeFunction matchingFunction = CompiledScheme.GetFunctionByName(functionName);

            //If given name was not found in this scheme, we try the parents
            if (matchingFunction == null)
            {
                foreach (Scheme parent in Parents)
                {
                    matchingFunction = parent.GetFunctionByName(functionName);
                    if (matchingFunction != null)
                    {
                        return(matchingFunction);
                    }
                }
            }
            else
            {
                return(matchingFunction);
            }

            return(null);
        }
コード例 #3
0
            public override object VisitAction_block([NotNull] scheme_langParser.Action_blockContext context)
            {
                //Sign start of action
                string name         = context.action_name()?.GetText();
                int    actionPoints = 0;

                if (context.action_point() != null)
                {
                    int.TryParse(context.action_point().GetText(), out actionPoints);
                }
                //else
                //Errors.Add(new ErrorDescriptor("Missing action points"));

                if (CompiledScheme.GetFunctionByName(name) != null)
                {
                    Errors.Add(new ErrorDescriptor($"This scheme already contains an action named '{name}'.", context.action_name()));
                }

                currentFunc = new SchemeFunction(name, actionPoints);
                VariableManager.NewBlock();

                return(base.VisitAction_block(context));
            }