/// <summary> /// Implements the visitor for the <see cref="XshtdSyntaxDefinition"/> object. /// </summary> /// <param name="syntax"></param> /// <returns></returns> public object VisitSyntaxDefinition(XshtdSyntaxDefinition syntax) { SyntaxDefinition c; if (syntax.Name != null) { c = def.syntaxDefDict[syntax.Name]; } else { if (syntax.Extensions == null) { return(null); } else { c = new SyntaxDefinition(syntax.Name); } } // Copy extensions to highlighting theme object foreach (var item in syntax.Extensions) { c.Extensions.Add(item); } syntax.AcceptElements(this); return(c); }
/// <summary> /// Implements the visitor for the <see cref="XshtdSyntaxDefinition"/> object. /// </summary> /// <param name="syntax"></param> /// <returns></returns> public object VisitSyntaxDefinition(XshtdSyntaxDefinition syntax) { if (syntax.Name != null) { if (syntax.Name.Length == 0) { throw Error(syntax, "Name must not be the empty string"); } if (def.syntaxDefDict.ContainsKey(syntax.Name)) { throw Error(syntax, "Duplicate syntax definition name '" + syntax.Name + "'."); } def.syntaxDefDict.Add(syntax.Name, new SyntaxDefinition()); } syntax.AcceptElements(this); return(null); }