public Grammar() { Options = RuntimeOptions.Default; Productions = new ProductionCollection(this); Symbols = new SymbolCollection(this); Conditions = new ConditionCollection(this); Matchers = new MatcherCollection(this); Mergers = new MergerCollection(this); Contexts = new ForeignContextCollection(this); Reports = new ReportCollection(); GlobalContextProvider = new ForeignContextProvider { Owner = this.Contexts }; Joint = new Joint(); for (int i = PredefinedTokens.Count; i != 0; --i) { Symbols.Add(null); // stub } Symbols[PredefinedTokens.Propagated] = new Symbol("#"); Symbols[PredefinedTokens.Epsilon] = new Symbol("$eps"); Symbols[PredefinedTokens.AugmentedStart] = new Symbol("$start"); Symbols[PredefinedTokens.Eoi] = new Symbol("$") { Categories = SymbolCategory.DoNotInsert | SymbolCategory.DoNotDelete }; Symbols[PredefinedTokens.Error] = new Symbol("$error"); AugmentedProduction = Productions.Define((Symbol)Symbols[PredefinedTokens.AugmentedStart], new Symbol[] { null }); }
private static Matcher.NameAndValue CreateRemovalMatcher(FilterMode filterMode, MatcherCollection except) { Matcher.NameAndValue shouldRemove = null; switch (filterMode) { case FilterMode.IncludeUnknownCommands: // To include unknown commands, we remove blacklisted // and 'except' commands. shouldRemove = delegate(string name, string value) { return DefaultBlacklist.IsMatch(name, value) || except.IsMatch(name, value); }; break; case FilterMode.ExcludeUnknownCommands: // To exclude unknown commands, we *keep* whitelisted // and 'except' commands. shouldRemove = delegate(string name, string value) { return !(DefaultWhitelist.IsMatch(name, value) || except.IsMatch(name, value)); }; break; case FilterMode.IncludeAllCommands: // To include all commands, we remove any of the 'except' // commands. shouldRemove = delegate(string name, string value) { return except.IsMatch(name, value); }; break; case FilterMode.ExcludeAllCommands: // To exclude all commands, we only keep the 'except' // commands. shouldRemove = delegate(string name, string value) { return !except.IsMatch(name, value); }; break; } return shouldRemove; }
private static Matcher.NameAndValue CreateRemovalMatcher(FilterMode filterMode, MatcherCollection except) { Matcher.NameAndValue shouldRemove = null; switch (filterMode) { case FilterMode.IncludeUnknownCommands: // To include unknown commands, we remove blacklisted // and 'except' commands. shouldRemove = delegate(string name, string value) { return(DefaultBlacklist.IsMatch(name, value) || except.IsMatch(name, value)); }; break; case FilterMode.ExcludeUnknownCommands: // To exclude unknown commands, we *keep* whitelisted // and 'except' commands. shouldRemove = delegate(string name, string value) { return(!(DefaultWhitelist.IsMatch(name, value) || except.IsMatch(name, value))); }; break; case FilterMode.IncludeAllCommands: // To include all commands, we remove any of the 'except' // commands. shouldRemove = delegate(string name, string value) { return(except.IsMatch(name, value)); }; break; case FilterMode.ExcludeAllCommands: // To exclude all commands, we only keep the 'except' // commands. shouldRemove = delegate(string name, string value) { return(!except.IsMatch(name, value)); }; break; } return(shouldRemove); }