// expand a rule where an occurrence on an action does not match its pattern // replacing combination directions and symbols by individuals (absolute or relative) // could be fixed by more powerful vm code IList <AtomicRule> ExpandRule(AtomicRule oldrule) { if (!oldrule.HasAction) { return(ExpandDirectionSimple(oldrule)); } // check each cell of each subrule for (var riter = new RuleIterator { Rule = oldrule }; !riter.Done; riter.Step()) { // Do no expansion on random actions if (riter.ActionAtoms.Any(a => a.IsRandom)) { oldrule.Prefixes.Add(RulePrefix.Final); } else { // check for action atom with ambiguous direction and no matching pattern atom var datom = riter.ActionAtoms.FirstOrDefault(a => _expanddirlookup.ContainsKey(a.Direction) && !riter.PatternAtoms.Any(p => p.Matches(a) && p.Direction == a.Direction)); if (datom != null) { return(ExpandDirectionMulti(oldrule, datom.Direction)); } // check for action atom with property symbol and no matching pattern atom var satom = riter.ActionAtoms.FirstOrDefault(a => a.Symbol.Kind == SymbolKind.Property && !a.IsNegated && !a.IsRandom && !riter.PatternAtoms.Any(p => p.Matches(a))); if (satom != null) { var newrules = ExpandSymbolMulti(oldrule, satom.Symbol) ?? ExpandPropertyMatcher(riter); if (newrules == null) { _parser.CompileError("'{0}' in action cannot be matched", satom.Symbol.Name); } else { return(newrules); } } } } return(ExpandDirectionSimple(oldrule)); }
// check validity of call at parse time internal void CheckParse() { if (_manager.scriptMain == null) { _parser.CompileError($"no scripts defined"); } // if (scriptMain.Globals.RawGet(Name) == null) // _parser.CompileError($"unknown function: {Name}"); }
internal void AddScript(ParseManager parser, IList <string> lines) { Script script = new Script(); try { _vartable = new Table(script); script.Globals["state"] = _vartable; var prog = String.Join("\n", lines.ToArray()); script.DoString(prog, null, "lua script"); } catch (SyntaxErrorException ex) { parser.CompileError(ex.DecoratedMessage); } scriptMain = script; }