public SrgsDocument(SrgsRule grammarRootRule) : this() { Helpers.ThrowIfNull(grammarRootRule, "grammarRootRule"); Root = grammarRootRule; Rules.Add(grammarRootRule); }
void IElement.PostParse(IElement parent) { if (_sRoot != null) { bool flag = false; foreach (SrgsRule rule in Rules) { if (rule.Id == _sRoot) { Root = rule; flag = true; break; } } if (!flag) { XmlParser.ThrowSrgsException(SRID.RootNotDefined, _sRoot); } } foreach (XmlParser.ForwardReference item in _scriptsForwardReference) { SrgsRule srgsRule = Rules[item._name]; if (srgsRule != null) { srgsRule.Script += item._value; } else { XmlParser.ThrowSrgsException(SRID.InvalidScriptDefinition); } } Validate(); }
public SrgsRuleRef(SrgsRule rule, string semanticKey) : this(rule) { Helpers.ThrowIfEmptyOrNull(semanticKey, nameof(semanticKey)); _semanticKey = semanticKey; }
public SrgsRuleRef(SrgsRule rule, string semanticKey, string parameters) : this(rule) { Helpers.ThrowIfEmptyOrNull(parameters, "parameters"); _semanticKey = semanticKey; _params = parameters; }
IRule IGrammar.CreateRule(string id, RulePublic publicRule, RuleDynamic dynamic, bool hasScript) { SrgsRule srgsRule = new SrgsRule(id); if (publicRule != RulePublic.NotSet) { srgsRule.Scope = ((publicRule != 0) ? SrgsRuleScope.Private : SrgsRuleScope.Public); } srgsRule.Dynamic = dynamic; return(srgsRule); }
void IElementFactory.AddScript(IGrammar grammar, string sRule, string code) { SrgsGrammar srgsGrammar = (SrgsGrammar)grammar; SrgsRule srgsRule = srgsGrammar.Rules[sRule]; if (srgsRule != null) { srgsRule.Script += code; } else { srgsGrammar.AddScript(sRule, code); } }
void IElement.PostParse(IElement parent) { // Check that the root rule is defined if (_sRoot != null) { bool found = false; foreach (SrgsRule rule in Rules) { if (rule.Id == _sRoot) { Root = rule; found = true; break; } } if (!found) { // "Root rule ""%s"" is undefined." XmlParser.ThrowSrgsException(SRID.RootNotDefined, _sRoot); } } // Resolve the references to the scripts foreach (XmlParser.ForwardReference script in _scriptsForwardReference) { SrgsRule rule = Rules[script._name]; if (rule != null) { rule.Script += script._value; } else { XmlParser.ThrowSrgsException(SRID.InvalidScriptDefinition); } } // Validate the whole grammar Validate(); }
public SrgsRuleRef(SrgsRule rule) { Helpers.ThrowIfNull(rule, nameof(rule)); _uri = new Uri("#" + rule.Id, UriKind.Relative); }
public SrgsRuleDebugDisplay(SrgsRule rule) { _rule = rule; }