string _startSymbolsFirsts; //first chars of start-end symbols #endregion #region overrides: Init, GetFirsts, ReadBody, etc... public override void Init(GrammarData grammarData) { base.Init(grammarData); _startSymbolsFirsts = string.Empty; if (_subtypes.Count == 0) { grammarData.Language.Errors.Add(GrammarErrorLevel.Error, null, Resources.ErrInvStrDef, this.Name); //"Error in string literal [{0}]: No start/end symbols specified." return; } //collect all start-end symbols in lists and create strings of first chars var allStartSymbols = new StringSet(); //to detect duplicate start symbols _subtypes.Sort(StringSubType.LongerStartFirst); bool isTemplate = false; foreach (StringSubType subType in _subtypes) { if (allStartSymbols.Contains(subType.Start)) { grammarData.Language.Errors.Add(GrammarErrorLevel.Error, null, Resources.ErrDupStartSymbolStr, subType.Start, this.Name); //"Duplicate start symbol {0} in string literal [{1}]." } allStartSymbols.Add(subType.Start); _startSymbolsFirsts += subType.Start[0].ToString(); if ((subType.Flags & StringOptions.IsTemplate) != 0) { isTemplate = true; } } if (!CaseSensitivePrefixesSuffixes) { _startSymbolsFirsts = _startSymbolsFirsts.ToLower() + _startSymbolsFirsts.ToUpper(); } //Set multiline flag foreach (StringSubType info in _subtypes) { if ((info.Flags & StringOptions.AllowsLineBreak) != 0) { SetFlag(TermFlags.IsMultiline); break; } } //For templates only if (isTemplate) { //Check that template settings object is provided var templateSettings = this.AstConfig.Data as StringTemplateSettings; if (templateSettings == null) { grammarData.Language.Errors.Add(GrammarErrorLevel.Error, null, Resources.ErrTemplNoSettings, this.Name); //"Error in string literal [{0}]: IsTemplate flag is set, but TemplateSettings is not provided." } else if (templateSettings.ExpressionRoot == null) { grammarData.Language.Errors.Add(GrammarErrorLevel.Error, null, Resources.ErrTemplMissingExprRoot, this.Name); //"" } else if (!Grammar.SnippetRoots.Contains(templateSettings.ExpressionRoot)) { grammarData.Language.Errors.Add(GrammarErrorLevel.Error, null, Resources.ErrTemplExprNotRoot, this.Name); //"" } }//if //Create editor info if (this.EditorInfo == null) { this.EditorInfo = new TokenEditorInfo(TokenType.String, TokenColor.String, TokenTriggers.None); } }//method