Exemplo n.º 1
0
        public BracePos Push(CharPos brace)
        {
            var bp = new BracePos(brace, this.pairs.Count);

            this.pairs.Push(bp);
            return(bp);
        }
Exemplo n.º 2
0
        public BracePos Push(CharPos brace)
        {
            var bp = brace.AsBrace(pairs.Count);

            pairs.Push(bp);
            return(bp);
        }
Exemplo n.º 3
0
 public BracePos Push(CharPos brace)
 {
     var pairs = stack[brace.Char];
       var bp = brace.AsBrace(pairs.Count);
       pairs.Push(bp);
       return bp;
 }
Exemplo n.º 4
0
 private void MatchBrace(IBraceStacker pairs, CharPos cp)
 {
     if (IsOpeningBrace(cp))
     {
         Add(pairs.Push(cp));
     }
     else if (pairs.Count(cp.Char) > 0)
     {
         // check if this is a closing brace matching
         // the opening on the stack
         BracePos p = pairs.Peek(cp.Char);
         if (braceList[p.Brace] == cp.Char)
         {
             // it does, add it
             pairs.Pop(cp.Char);
             Add(cp.AsBrace(p.Depth));
         }
         else
         {
             // it doesn't; it's an error
             this.braceErrors.Add(cp);
         }
     }
     else
     {
         // closing brace has no opening brace
         this.braceErrors.Add(cp);
     }
 }
Exemplo n.º 5
0
        public BracePos Push(CharPos brace)
        {
            var pairs = this.stack[brace.Char];
            var bp    = new BracePos(brace, pairs.Count);

            pairs.Push(bp);
            return(bp);
        }
Exemplo n.º 6
0
        private void ExtractFromLine(IBraceStacker pairs, ITextSnapshotLine line, int lineOffset)
        {
            var     lc = new LineChars(line, lineOffset);
            CharPos cp = CharPos.Empty;

            while (!lc.EndOfLine)
            {
                if (!this.braceScanner.Extract(lc, ref cp))
                {
                    continue;
                }
                MatchBrace(pairs, cp);
            }
            this.LastParsedPosition = line.End;
        }
Exemplo n.º 7
0
        private void ExtractFromLine(Stack <BracePos> pairs, ITextSnapshotLine line, int lineOffset)
        {
            var     lc = new LineChars(line, lineOffset);
            CharPos cp = CharPos.Empty;

            while (!lc.EndOfLine)
            {
                if (!this.braceScanner.Extract(lc, ref cp))
                {
                    continue;
                }
                if (IsOpeningBrace(cp))
                {
                    BracePos p = cp.AsBrace(pairs.Count);
                    pairs.Push(p);
                    Add(p);
                    // we don't need to check if it's a closing brace
                    // because the extractor won't return anything else
                }
                else if (pairs.Count > 0)
                {
                    BracePos p = pairs.Peek();
                    if (braceList[p.Brace] == cp.Char)
                    {
                        // yield closing brace
                        pairs.Pop();
                        BracePos c = cp.AsBrace(p.Depth);
                        Add(c);
                    }
                    else
                    {
                        // closing brace does not correspond
                        // to opening brace at same depth
                        this.braceErrors.Add(cp);
                    }
                }
                else
                {
                    // closing brace has no opening brace
                    this.braceErrors.Add(cp);
                }
            }
            this.LastParsedPosition = line.End;
        }
Exemplo n.º 8
0
        private void InvalidateBraceErrorsFromPos(int position)
        {
            // invalidate brace errors
            int lastPos = -1;

            for (int i = 0; i < this.braceErrors.Count; i++)
            {
                lastPos = i;
                CharPos ch = this.braceErrors[i];
                if (ch.Position >= position)
                {
                    break;
                }
            }
            if (lastPos >= 0 && lastPos < braceErrors.Count)
            {
                braceErrors.RemoveRange(lastPos, braceErrors.Count - lastPos);
            }
        }
Exemplo n.º 9
0
 public BracePos(CharPos pos, int depth)
 {
     this.charPos = pos;
     this.depth   = depth;
 }
Exemplo n.º 10
0
 public BracePos(char ch, int pos, int depth)
 {
     this.charPos = new CharPos(ch, pos);
     this.depth   = depth;
 }
Exemplo n.º 11
0
 public BracePos(CharPos pos, int depth)
 {
     this.charPos = pos;
       this.depth = depth;
 }
Exemplo n.º 12
0
 public BracePos(char ch, int pos, int depth)
 {
     this.charPos = new CharPos(ch, pos);
       this.depth = depth;
 }