Beispiel #1
0
        internal void AddBrace(Stream stream, string classification = Classifications.Operator)
        {
            var brace = stream.Current;

            if (brace == '{' || brace == '[' || brace == '(' || brace == ')' || brace == ']' || brace == '}')
            {
                var token = new Token { Classification = classification, Start = stream.Position, Length = 1 };

                if (brace == '{' || brace == '[' || brace == '(')
                {
                    token.IsOpen = true;
                    braces.Push(token, stream.Current);
                }
                else
                {
                    var match = braces.Pop(brace);
                    if (match != null)
                    {
                        token.MatchingToken = match;
                        match.MatchingToken = token;
                    }
                }

                Add(token);
            }
        }
Beispiel #2
0
 public void Add(Token token)
 {
     tokenDictionary[token.Start] = token;
 }
Beispiel #3
0
 public void Push(Token token, char brace)
 {
     if (brace == '{') curlyBraceStack.Push(token);
     else if (brace == '[') braceStack.Push(token);
     else if (brace == '(') functionBraceStack.Push(token);
 }