コード例 #1
0
            public SpanParser(Document doc, SyntaxMode mode, LineSegment line, Stack <Span> spanStack)
            {
                if (doc == null)
                {
                    throw new ArgumentNullException("doc");
                }
                this.doc       = doc;
                this.mode      = mode;
                this.line      = line;
                this.spanStack = spanStack ?? new Stack <Span> (line != null && line.StartSpan != null ? line.StartSpan : new Span[0]);
                //this.ruleStack = ruleStack ?? new Stack<Span> (line.StartRule != null ? line.StartRule : new Rule[0]);

                ruleStack = new Stack <Rule> ();
                if (mode != null)
                {
                    ruleStack.Push(mode);
                }
                List <Rule> rules = new List <Rule> ();

                foreach (Span span in this.spanStack)
                {
                    Rule rule = CurRule.GetRule(span.Rule);
                    rules.Add(rule ?? CurRule);
                }
                for (int i = rules.Count - 1; i >= 0; i--)
                {
                    ruleStack.Push(rules[i]);
                }
            }
コード例 #2
0
 public Rule GetRule(Span span)
 {
     if (string.IsNullOrEmpty(span.Rule))
     {
         return(new Rule());
     }
     return(CurRule.GetRule(doc, span.Rule));
 }