예제 #1
0
			protected override void ScanSpan (ref int i)
			{
				bool hasJayDefinitonSpan = spanStack.Any (s => s is JayDefinitionSpan);
				
				if (i + 1 < doc.Length && doc.GetCharAt (i) == '%')  {
					char next = doc.GetCharAt (i + 1);
					if (next == '{') {
						ForcedJayBlockSpan forcedBlockSpan = new ForcedJayBlockSpan ();
						OnFoundSpanBegin (forcedBlockSpan, i, 2);
						spanStack.Push (forcedBlockSpan);
						ruleStack.Push (GetRule (forcedBlockSpan));
						i++;
						return;
					}
					
					if (!hasJayDefinitonSpan && next == '%') {
						JayDefinitionSpan jayDefinitionSpan = new JayDefinitionSpan ();
						OnFoundSpanBegin (jayDefinitionSpan, i, 2);
						spanStack.Push (jayDefinitionSpan);
						ruleStack.Push (GetRule (jayDefinitionSpan));
						return;
					}
					
					if (next == '}' && spanStack.Any (s => s is ForcedJayBlockSpan)) {
						foreach (Span span in spanStack.ToArray ().Reverse ()) {
							OnFoundSpanEnd (span, i, span.End.Pattern.Length);
							if (spanStack.Count > 0) {
								spanStack.Pop ();
							}
							if (ruleStack.Count > 1) // rulStack[1] is always syntax mode
								ruleStack.Pop ();
							if (span is ForcedJayBlockSpan)
								break;
						}
						return;
					}
				}
				
				
				if (CurSpan is JayDefinitionSpan && doc.GetCharAt (i) == '{' && hasJayDefinitonSpan && !spanStack.Any (s => s is JayBlockSpan)) {
					JayBlockSpan jayBlockSpan = new JayBlockSpan (i);
					OnFoundSpanBegin (jayBlockSpan, i, 1);
					spanStack.Push (jayBlockSpan);
					ruleStack.Push (GetRule (jayBlockSpan));
					return;
				}
				
				
				base.ScanSpan (ref i);
			}
예제 #2
0
            protected override void ScanSpan(ref int i)
            {
                bool hasJayDefinitonSpan = spanStack.Any(s => s is JayDefinitionSpan);

                if (i + 1 < doc.Length && doc.GetCharAt(i) == '%')
                {
                    char next = doc.GetCharAt(i + 1);
                    if (next == '{')
                    {
                        ForcedJayBlockSpan forcedBlockSpan = new ForcedJayBlockSpan();
                        OnFoundSpanBegin(forcedBlockSpan, i, 2);
                        spanStack.Push(forcedBlockSpan);
                        ruleStack.Push(GetRule(forcedBlockSpan));
                        i++;
                        return;
                    }

                    if (!hasJayDefinitonSpan && next == '%')
                    {
                        JayDefinitionSpan jayDefinitionSpan = new JayDefinitionSpan();
                        OnFoundSpanBegin(jayDefinitionSpan, i, 2);
                        spanStack.Push(jayDefinitionSpan);
                        ruleStack.Push(GetRule(jayDefinitionSpan));
                        return;
                    }

                    if (next == '}' && spanStack.Any(s => s is ForcedJayBlockSpan))
                    {
                        foreach (Span span in spanStack.ToArray().Reverse())
                        {
                            OnFoundSpanEnd(span, i, span.End.Pattern.Length);
                            if (spanStack.Count > 0)
                            {
                                spanStack.Pop();
                            }
                            if (ruleStack.Count > 1)                             // rulStack[1] is always syntax mode
                            {
                                ruleStack.Pop();
                            }
                            if (span is ForcedJayBlockSpan)
                            {
                                break;
                            }
                        }
                        return;
                    }
                }


                if (CurSpan is JayDefinitionSpan && doc.GetCharAt(i) == '{' && hasJayDefinitonSpan && !spanStack.Any(s => s is JayBlockSpan))
                {
                    JayBlockSpan jayBlockSpan = new JayBlockSpan(i);
                    OnFoundSpanBegin(jayBlockSpan, i, 1);
                    spanStack.Push(jayBlockSpan);
                    ruleStack.Push(GetRule(jayBlockSpan));
                    return;
                }


                base.ScanSpan(ref i);
            }