コード例 #1
0
 public object VisitSpan(XshdSpan span)
 {
     span.BeginColorReference.AcceptVisitor(this);
     span.SpanColorReference.AcceptVisitor(this);
     span.EndColorReference.AcceptVisitor(this);
     return(span.RuleSetReference.AcceptVisitor(this));
 }
コード例 #2
0
        object IXshdVisitor.VisitSpan(XshdSpan span)
        {
            writer.WriteStartElement("Span", Namespace);
            WriteColorReference(span.SpanColorReference);
            if (span.BeginRegexType == XshdRegexType.Default && span.BeginRegex != null)
            {
                writer.WriteAttributeString("begin", span.BeginRegex);
            }
            if (span.EndRegexType == XshdRegexType.Default && span.EndRegex != null)
            {
                writer.WriteAttributeString("end", span.EndRegex);
            }
            WriteRuleSetReference(span.RuleSetReference);
            if (span.Multiline)
            {
                writer.WriteAttributeString("multiline", "true");
            }

            if (span.BeginRegexType == XshdRegexType.IgnorePatternWhitespace)
            {
                WriteBeginEndElement("Begin", span.BeginRegex, span.BeginColorReference);
            }
            if (span.EndRegexType == XshdRegexType.IgnorePatternWhitespace)
            {
                WriteBeginEndElement("End", span.EndRegex, span.EndColorReference);
            }

            if (span.RuleSetReference.InlineElement != null)
            {
                span.RuleSetReference.InlineElement.AcceptVisitor(this);
            }

            writer.WriteEndElement();
            return(null);
        }
コード例 #3
0
            public object VisitSpan(XshdSpan span)
            {
                string endRegex = span.EndRegex;

                if (string.IsNullOrEmpty(span.BeginRegex) && string.IsNullOrEmpty(span.EndRegex))
                {
                    throw Error(span, "Span has no start/end regex.");
                }
                if (!span.Multiline)
                {
                    if (endRegex == null)
                    {
                        endRegex = "$";
                    }
                    else if (span.EndRegexType == XshdRegexType.IgnorePatternWhitespace)
                    {
                        endRegex = "($|" + endRegex + "\n)";
                    }
                    else
                    {
                        endRegex = "($|" + endRegex + ")";
                    }
                }
                HighlightingColor wholeSpanColor = GetColor(span, span.SpanColorReference);

                return(new HighlightingSpan {
                    StartExpression = CreateRegex(span, span.BeginRegex, span.BeginRegexType),
                    EndExpression = CreateRegex(span, endRegex, span.EndRegexType),
                    RuleSet = GetRuleSet(span, span.RuleSetReference),
                    StartColor = MergeColor(wholeSpanColor, GetColor(span, span.BeginColorReference)),
                    SpanColor = wholeSpanColor,
                    EndColor = MergeColor(wholeSpanColor, GetColor(span, span.EndColorReference)),
                });
            }
コード例 #4
0
			public object VisitSpan(XshdSpan span)
			{
				span.BeginColorReference.AcceptVisitor(this);
				span.SpanColorReference.AcceptVisitor(this);
				span.EndColorReference.AcceptVisitor(this);
				return span.RuleSetReference.AcceptVisitor(this);
			}
コード例 #5
0
        static XshdSpan ParseSpan(XmlReader reader)
        {
            XshdSpan span = new XshdSpan();

            SetPosition(span, reader);
            span.BeginRegex         = reader.GetAttribute("begin");
            span.EndRegex           = reader.GetAttribute("end");
            span.Multiline          = reader.GetBoolAttribute("multiline") ?? false;
            span.SpanColorReference = ParseColorReference(reader);
            span.RuleSetReference   = ParseRuleSetReference(reader);
            if (!reader.IsEmptyElement)
            {
                reader.Read();
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    Debug.Assert(reader.NodeType == XmlNodeType.Element);
                    switch (reader.Name)
                    {
                    case "Begin":
                        if (span.BeginRegex != null)
                        {
                            throw Error(reader, "Duplicate Begin regex");
                        }
                        span.BeginColorReference = ParseColorReference(reader);
                        span.BeginRegex          = reader.ReadElementString();
                        span.BeginRegexType      = XshdRegexType.IgnorePatternWhitespace;
                        break;

                    case "End":
                        if (span.EndRegex != null)
                        {
                            throw Error(reader, "Duplicate End regex");
                        }
                        span.EndColorReference = ParseColorReference(reader);
                        span.EndRegex          = reader.ReadElementString();
                        span.EndRegexType      = XshdRegexType.IgnorePatternWhitespace;
                        break;

                    case "RuleSet":
                        if (span.RuleSetReference.ReferencedElement != null)
                        {
                            throw Error(reader, "Cannot specify both inline RuleSet and RuleSet reference");
                        }
                        span.RuleSetReference = new XshdReference <XshdRuleSet>(ParseRuleSet(reader));
                        reader.Read();
                        break;

                    default:
                        throw new NotSupportedException("Unknown element " + reader.Name);
                    }
                }
            }
            return(span);
        }
コード例 #6
0
ファイル: SaveXshdVisitor.cs プロジェクト: Gobiner/ILSpy
		object IXshdVisitor.VisitSpan(XshdSpan span)
		{
			writer.WriteStartElement("Span", Namespace);
			WriteColorReference(span.SpanColorReference);
			if (span.BeginRegexType == XshdRegexType.Default && span.BeginRegex != null)
				writer.WriteAttributeString("begin", span.BeginRegex);
			if (span.EndRegexType == XshdRegexType.Default && span.EndRegex != null)
				writer.WriteAttributeString("end", span.EndRegex);
			WriteRuleSetReference(span.RuleSetReference);
			if (span.Multiline)
				writer.WriteAttributeString("multiline", "true");
			
			if (span.BeginRegexType == XshdRegexType.IgnorePatternWhitespace)
				WriteBeginEndElement("Begin", span.BeginRegex, span.BeginColorReference);
			if (span.EndRegexType == XshdRegexType.IgnorePatternWhitespace)
				WriteBeginEndElement("End", span.EndRegex, span.EndColorReference);
			
			if (span.RuleSetReference.InlineElement != null)
				span.RuleSetReference.InlineElement.AcceptVisitor(this);
			
			writer.WriteEndElement();
			return null;
		}
コード例 #7
0
ファイル: V1Loader.cs プロジェクト: blueluna/IronInstruments
        XshdSpan ImportSpan(XmlElement element)
        {
            XshdSpan span = new XshdSpan();

            if (element.HasAttribute("rule"))
            {
                span.RuleSetReference = new XshdReference <XshdRuleSet>(null, element.GetAttribute("rule"));
            }
            char escapeCharacter = ruleSetEscapeCharacter;

            if (element.HasAttribute("escapecharacter"))
            {
                escapeCharacter = element.GetAttribute("escapecharacter")[0];
            }
            span.Multiline = !(element.GetBoolAttribute("stopateol") ?? false);

            span.SpanColorReference = GetColorReference(element);

            span.BeginRegexType = XshdRegexType.IgnorePatternWhitespace;
            span.BeginRegex     = ImportRegex(element["Begin"].InnerText,
                                              element["Begin"].GetBoolAttribute("singleword") ?? false,
                                              element["Begin"].GetBoolAttribute("startofline"));
            span.BeginColorReference = GetColorReference(element["Begin"]);

            string endElementText = string.Empty;

            if (element["End"] != null)
            {
                span.EndRegexType = XshdRegexType.IgnorePatternWhitespace;
                endElementText    = element["End"].InnerText;
                span.EndRegex     = ImportRegex(endElementText,
                                                element["End"].GetBoolAttribute("singleword") ?? false,
                                                null);
                span.EndColorReference = GetColorReference(element["End"]);
            }

            if (escapeCharacter != '\0')
            {
                XshdRuleSet ruleSet = new XshdRuleSet();
                if (endElementText.Length == 1 && endElementText[0] == escapeCharacter)
                {
                    // ""-style escape
                    ruleSet.Elements.Add(new XshdSpan {
                        BeginRegex = Regex.Escape(endElementText + endElementText),
                        EndRegex   = ""
                    });
                }
                else
                {
                    // \"-style escape
                    ruleSet.Elements.Add(new XshdSpan {
                        BeginRegex = Regex.Escape(escapeCharacter.ToString()),
                        EndRegex   = "."
                    });
                }
                if (span.RuleSetReference.ReferencedElement != null)
                {
                    ruleSet.Elements.Add(new XshdImport {
                        RuleSetReference = span.RuleSetReference
                    });
                }
                span.RuleSetReference = new XshdReference <XshdRuleSet>(ruleSet);
            }
            return(span);
        }
コード例 #8
0
ファイル: V1Loader.cs プロジェクト: Amichai/PhysicsPad
        XshdSpan ImportSpan(XmlElement element)
        {
            XshdSpan span = new XshdSpan();
            if (element.HasAttribute("rule")) {
                span.RuleSetReference = new XshdReference<XshdRuleSet>(null, element.GetAttribute("rule"));
            }
            char escapeCharacter = ruleSetEscapeCharacter;
            if (element.HasAttribute("escapecharacter")) {
                escapeCharacter = element.GetAttribute("escapecharacter")[0];
            }
            span.Multiline = !(element.GetBoolAttribute("stopateol") ?? false);

            span.SpanColorReference = GetColorReference(element);

            span.BeginRegexType = XshdRegexType.IgnorePatternWhitespace;
            span.BeginRegex = ImportRegex(element["Begin"].InnerText,
                                          element["Begin"].GetBoolAttribute("singleword") ?? false,
                                          element["Begin"].GetBoolAttribute("startofline"));
            span.BeginColorReference = GetColorReference(element["Begin"]);

            string endElementText = string.Empty;
            if (element["End"] != null) {
                span.EndRegexType = XshdRegexType.IgnorePatternWhitespace;
                endElementText = element["End"].InnerText;
                span.EndRegex = ImportRegex(endElementText,
                                            element["End"].GetBoolAttribute("singleword") ?? false,
                                            null);
                span.EndColorReference = GetColorReference(element["End"]);
            }

            if (escapeCharacter != '\0') {
                XshdRuleSet ruleSet = new XshdRuleSet();
                if (endElementText.Length == 1 && endElementText[0] == escapeCharacter) {
                    // ""-style escape
                    ruleSet.Elements.Add(new XshdSpan {
                                         	BeginRegex = Regex.Escape(endElementText + endElementText),
                                         	EndRegex = ""
                                         });
                } else {
                    // \"-style escape
                    ruleSet.Elements.Add(new XshdSpan {
                                         	BeginRegex = Regex.Escape(escapeCharacter.ToString()),
                                         	EndRegex = "."
                                         });
                }
                if (span.RuleSetReference.ReferencedElement != null) {
                    ruleSet.Elements.Add(new XshdImport { RuleSetReference = span.RuleSetReference });
                }
                span.RuleSetReference = new XshdReference<XshdRuleSet>(ruleSet);
            }
            return span;
        }
コード例 #9
0
			public object VisitSpan(XshdSpan span)
			{
				if (span.RuleSetReference.InlineElement != null)
					return span.RuleSetReference.AcceptVisitor(this);
				XshdSyntaxDefinition definition = allSyntaxDefinitions.SingleOrDefault(def => def.Name == span.RuleSetReference.ReferencedDefinition);
				if (definition != null && visitedDefinitons.Add(definition))
					foundColors.AddRange(definition.Elements.OfType<XshdColor>());
				return null;
			}
コード例 #10
0
ファイル: V2Loader.cs プロジェクト: hefnerliu/SharpDevelop
		static XshdSpan ParseSpan(XmlReader reader)
		{
			XshdSpan span = new XshdSpan();
			SetPosition(span, reader);
			span.BeginRegex = reader.GetAttribute("begin");
			span.EndRegex = reader.GetAttribute("end");
			span.Multiline = reader.GetBoolAttribute("multiline") ?? false;
			span.SpanColorReference = ParseColorReference(reader);
			span.RuleSetReference = ParseRuleSetReference(reader);
			if (!reader.IsEmptyElement) {
				reader.Read();
				while (reader.NodeType != XmlNodeType.EndElement) {
					Debug.Assert(reader.NodeType == XmlNodeType.Element);
					switch (reader.Name) {
						case "Begin":
							if (span.BeginRegex != null)
								throw Error(reader, "Duplicate Begin regex");
							span.BeginColorReference = ParseColorReference(reader);
							span.BeginRegex = reader.ReadElementString();
							span.BeginRegexType = XshdRegexType.IgnorePatternWhitespace;
							break;
						case "End":
							if (span.EndRegex != null)
								throw Error(reader, "Duplicate End regex");
							span.EndColorReference = ParseColorReference(reader);
							span.EndRegex = reader.ReadElementString();
							span.EndRegexType = XshdRegexType.IgnorePatternWhitespace;
							break;
						case "RuleSet":
							if (span.RuleSetReference.ReferencedElement != null)
								throw Error(reader, "Cannot specify both inline RuleSet and RuleSet reference");
							span.RuleSetReference = new XshdReference<XshdRuleSet>(ParseRuleSet(reader));
							reader.Read();
							break;
						default:
							throw new NotSupportedException("Unknown element " + reader.Name);
					}
				}
			}
			return span;
		}
コード例 #11
0
 public object VisitSpan(XshdSpan span)
 {
     string endRegex = span.EndRegex;
     if (string.IsNullOrEmpty(span.BeginRegex) && string.IsNullOrEmpty(span.EndRegex))
         throw Error(span, "Span has no start/end regex.");
     if (!span.Multiline) {
         if (endRegex == null)
             endRegex = "$";
         else if (span.EndRegexType == XshdRegexType.IgnorePatternWhitespace)
             endRegex = "($|" + endRegex + "\n)";
         else
             endRegex = "($|" + endRegex + ")";
     }
     HighlightingColor wholeSpanColor = GetColor(span, span.SpanColorReference);
     return new HighlightingSpan {
         StartExpression = CreateRegex(span, span.BeginRegex, span.BeginRegexType),
         EndExpression = CreateRegex(span, endRegex, span.EndRegexType),
         RuleSet = GetRuleSet(span, span.RuleSetReference),
         StartColor = GetColor(span, span.BeginColorReference),
         SpanColor = wholeSpanColor,
         EndColor = GetColor(span, span.EndColorReference),
         SpanColorIncludesStart = true,
         SpanColorIncludesEnd = true
     };
 }
コード例 #12
0
ファイル: Window1.xaml.cs プロジェクト: Team624/2015Beta
		private void updateStandardWordList(int i)
		{
			OptionsWindow _ow = new OptionsWindow();

			XshdKeywords newKeyWords = new XshdKeywords();
			XshdSpan newSpan = new XshdSpan();
			XshdSpan otherNewSpan = new XshdSpan();
			XshdSpan thirdNewSpan = new XshdSpan();
			XshdSpan thNewSpan = new XshdSpan();
			XshdRule rule = new XshdRule();
			 
			XshdRuleSet mainRuleSet = xshd.Elements.OfType<XshdRuleSet>().Where(o => string.IsNullOrEmpty(o.Name)).First();
			
			if(i==0)
			{
				for(int ii=0;ii<_ow.commands.Count;ii++)
				{
					newKeyWords.Words.Add(_ow.commands[ii].Commnd);
				}
				
				XshdColor xcol = xshd.Elements.OfType<XshdColor>().Where(xc => string.Equals(xc.Name, (_ow.words[i].color+_ow.words[i].fontstyle), StringComparison.CurrentCultureIgnoreCase)).First();
				newKeyWords.ColorReference = new XshdReference<XshdColor>(null, xcol.Name);
				mainRuleSet.Elements.Add(newKeyWords);
			}
			if(i==1)
			{
				for(int ii=0;ii<_ow.subs.Count;ii++)
				{
					newKeyWords.Words.Add(_ow.subs[ii].Sub);
				}
				
				XshdColor xcol = xshd.Elements.OfType<XshdColor>().Where(xc => string.Equals(xc.Name, (_ow.words[i].color+_ow.words[i].fontstyle), StringComparison.CurrentCultureIgnoreCase)).First();
				newKeyWords.ColorReference = new XshdReference<XshdColor>(null, xcol.Name);
				mainRuleSet.Elements.Add(newKeyWords);
			}
			if(i==2)
			{
				XshdColor xcol = xshd.Elements.OfType<XshdColor>().Where(xc => string.Equals(xc.Name, (_ow.words[i].color+_ow.words[i].fontstyle), StringComparison.CurrentCultureIgnoreCase)).First();
				
				newSpan.SpanColorReference = new XshdReference<XshdColor>(null, xcol.Name);
				newSpan.BeginRegex = @"[//]{2,3}";
				
				otherNewSpan.SpanColorReference = new XshdReference<XshdColor>(null, xcol.Name);
				otherNewSpan.BeginRegex = @";.";
				
				mainRuleSet.Elements.Add(newSpan);
				mainRuleSet.Elements.Add(otherNewSpan);
				
			}
			if(i==3)
			{
				XshdColor xcol = xshd.Elements.OfType<XshdColor>().Where(xc => string.Equals(xc.Name, (_ow.words[i].color+_ow.words[i].fontstyle), StringComparison.CurrentCultureIgnoreCase)).First();
				rule.ColorReference = new XshdReference<XshdColor>(null, xcol.Name);
				rule.Regex = @"\b0[xX][0-9a-fA-F]+|\b(\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?";
				mainRuleSet.Elements.Add(rule);
			}
			if(i==4)
			{
				XshdColor xcol = xshd.Elements.OfType<XshdColor>().Where(xc => string.Equals(xc.Name, (_ow.words[i].color+_ow.words[i].fontstyle), StringComparison.CurrentCultureIgnoreCase)).First();
				thNewSpan.SpanColorReference = new XshdReference<XshdColor>(null, xcol.Name);
				thNewSpan.BeginRegex = "\"";
				thNewSpan.EndRegex = "\"";
				mainRuleSet.Elements.Add(thNewSpan);
			}
			if(i==5)
			{
				for(int ii=0;ii<_ow.oc_alias.Count;ii++)
				{
					newKeyWords.Words.Add(_ow.oc_alias[ii].Alias);
				}
				
				XshdColor xcol = xshd.Elements.OfType<XshdColor>().Where(xc => string.Equals(xc.Name, (_ow.words[i].color+_ow.words[i].fontstyle), StringComparison.CurrentCultureIgnoreCase)).First();
				newKeyWords.ColorReference = new XshdReference<XshdColor>(null, xcol.Name);
				mainRuleSet.Elements.Add(newKeyWords);
			}
			
					
		}