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)); }
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); }
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)); }