Ejemplo n.º 1
0
        public SyntaxColorParser(IClassificationTypeRegistryService classificationTypeRegistry, IUserKeywords userKeywords)
        {
            if (classificationTypeRegistry is null)
            {
                throw new System.ArgumentNullException(nameof(classificationTypeRegistry));
            }

            if (userKeywords is null)
            {
                throw new System.ArgumentNullException(nameof(userKeywords));
            }

            Comment             = classificationTypeRegistry.GetClassificationType(PredefinedClassificationTypeNames.Comment);
            Identifier          = classificationTypeRegistry.GetClassificationType(PredefinedClassificationTypeNames.Identifier);
            Number              = classificationTypeRegistry.GetClassificationType(PredefinedClassificationTypeNames.Number);
            Operator            = classificationTypeRegistry.GetClassificationType(PredefinedClassificationTypeNames.Operator);
            QuotedString        = classificationTypeRegistry.GetClassificationType(PredefinedClassificationTypeNames.String);
            PreprocessorKeyword = classificationTypeRegistry.GetClassificationType(PredefinedClassificationTypeNames.PreprocessorKeyword);

            Function     = classificationTypeRegistry.GetClassificationType(GlslClassificationTypes.Function);
            Keyword      = classificationTypeRegistry.GetClassificationType(GlslClassificationTypes.Keyword);
            UserKeyword1 = classificationTypeRegistry.GetClassificationType(GlslClassificationTypes.UserKeyword1);
            UserKeyword2 = classificationTypeRegistry.GetClassificationType(GlslClassificationTypes.UserKeyword2);
            Variable     = classificationTypeRegistry.GetClassificationType(GlslClassificationTypes.Variable);
            parser       = new GlslParser();
            userKeywords.PropertyChanged += (s, a) =>
            {
                ResetUserKeywords(userKeywords);
                Changed?.Invoke(this);
            };
            ResetUserKeywords(userKeywords);
        }
Ejemplo n.º 2
0
        public void TokenizeSingleTest(string text, TokenType expectedType)
        {
            var tokenizer = new GlslParser();
            var token     = tokenizer.Tokenize(text).First();

            Assert.AreEqual(expectedType, token.Type);
            Assert.AreEqual(text, text.Substring(token.Start, token.Length));
        }
 public void TokenizeTest(string text, TokenType[] expectedTypes)
 {
     var tokenizer = new GlslParser();
     var tokens    = tokenizer.Tokenize(text);
     var types     = tokens.Select(token => token.Type).ToArray();