コード例 #1
0
        /**
         *  Create a writer that combines userHandlers with the normal type handlers
         *  built into Fressian.
         */
        public FressianWriter(Stream stream, org.fressian.handlers.ILookup <Type, IDictionary <String, WriteHandler> > userHandlers)
        {
            this.writeHandlerLookup = new WriteHandlerLookup(userHandlers);

            clearCaches();
            this.stream = stream;
            this.rawOut = new RawOutput(this.stream);
        }
コード例 #2
0
 private void Clear()
 {
     if (InvokeRequired)
     {
         Invoke(new Action(Clear));
         return;
     }
     tbOutput.Clear();
     RawOutput.Clear();
 }
コード例 #3
0
        private void AddMessage(string line)
        {
            if (IsDisposed)
            {
                return;
            }

            RawOutput.Add(line);
            if (CurrentThread != ALL)
            {
                if (CurrentThread == STOPWATCH)
                {
                    if (!line.Contains("Stopwatch"))
                    {
                        return;
                    }
                }
                if (CurrentThread == HIDE_STOPWATCH)
                {
                    if (line.Contains("Stopwatch"))
                    {
                        return;
                    }
                }
                else
                {
                    var threadId = GetThreadId(line);
                    if (threadId.HasValue)
                    {
                        if (threadId.Value.ToString(CultureInfo.InvariantCulture) != CurrentThread)
                        {
                            return;
                        }
                    }
                }
            }

            tbOutput.AppendText(line);
        }
コード例 #4
0
ファイル: Parser.cs プロジェクト: darrelmiller/Parrot
        /// <summary>
        /// Parses a token stream creating the largest statement possible
        /// </summary>
        /// <param name="stream">Stream of tokens to parse</param>
        /// <returns>Statement</returns>
        private StatementList ParseStatement(Stream stream)
        {
            var tokenType = stream.Peek().Type;
            Token identifier = null;
            switch (tokenType)
            {
                case TokenType.Identifier:
                    //standard identifier
                    identifier = stream.Next();
                    break;
                case TokenType.OpenBracket:
                case TokenType.OpenParenthesis:
                    //ignore these
                    break;
                case TokenType.StringLiteral:
                case TokenType.MultiLineStringLiteral:
                case TokenType.StringLiteralPipe:
                case TokenType.QuotedStringLiteral:
                    //string statement
                    identifier = stream.Next();
                    break;
            }

            Statement statement = null;
            StatementTail tail = null;

            while (stream.Peek() != null)
            {
                var token = stream.Peek();
                if (token == null)
                {
                    break;
                }

                switch (token.Type)
                {
                    case TokenType.OpenParenthesis:
                    case TokenType.OpenBrace:
                    case TokenType.OpenBracket:
                        tail = ParseStatementTail(stream);
                        break;
                    case TokenType.GreaterThan:
                        //consume greater than
                        stream.NextNoReturn();

                        //might be a single child or a statement list of siblings
                        tail = ParseSingleStatementTail(stream);
                        break;
                    case TokenType.Colon:
                        //next thing must be an identifier
                        var colon = stream.Next();
                        identifier = stream.Next();
                        statement = new EncodedOutput(_host, identifier.Content);
                        goto checkForSiblings;
                    case TokenType.Equal:
                        //next thing must be an identifier
                        var equal = stream.Next();
                        identifier = stream.Next();
                        statement = new RawOutput(_host, identifier.Content);
                        goto checkForSiblings;

                    default:
                        statement = GetStatementFromToken(identifier, tail);
                        goto checkForSiblings;
                }
            }

            statement = GetStatementFromToken(identifier, tail);

            checkForSiblings:

            var list = new StatementList(_host);
            list.Add(statement);

            while (stream.Peek() != null)
            {
                //Parrot.Debugger.Debug.WriteLine("Looking for siblings");
                if (stream.Peek().Type == TokenType.Plus)
                {
                    //it's now a statementlist not a statement
                    stream.NextNoReturn();
                    var siblings = ParseStatement(stream);
                    foreach (var sibling in siblings)
                    {
                        list.Add(sibling);
                    }
                }
                else
                {
                    break;
                }
            }

            return list;
        }
コード例 #5
0
ファイル: Parser.cs プロジェクト: darrelmiller/Parrot
        /// <summary>
        /// Parses a token stream creating the largest statement possible
        /// </summary>
        /// <param name="stream">Stream of tokens to parse</param>
        /// <returns>Statement</returns>
        private StatementList ParseStatement(Stream stream)
        {
            var   tokenType  = stream.Peek().Type;
            Token identifier = null;

            switch (tokenType)
            {
            case TokenType.Identifier:
                //standard identifier
                identifier = stream.Next();
                break;

            case TokenType.OpenBracket:
            case TokenType.OpenParenthesis:
                //ignore these
                break;

            case TokenType.StringLiteral:
            case TokenType.MultiLineStringLiteral:
            case TokenType.StringLiteralPipe:
            case TokenType.QuotedStringLiteral:
                //string statement
                identifier = stream.Next();
                break;
            }


            Statement     statement = null;
            StatementTail tail      = null;

            while (stream.Peek() != null)
            {
                var token = stream.Peek();
                if (token == null)
                {
                    break;
                }

                switch (token.Type)
                {
                case TokenType.OpenParenthesis:
                case TokenType.OpenBrace:
                case TokenType.OpenBracket:
                    tail = ParseStatementTail(stream);
                    break;

                case TokenType.GreaterThan:
                    //consume greater than
                    stream.NextNoReturn();

                    //might be a single child or a statement list of siblings
                    tail = ParseSingleStatementTail(stream);
                    break;

                case TokenType.Colon:
                    //next thing must be an identifier
                    var colon = stream.Next();
                    identifier = stream.Next();
                    statement  = new EncodedOutput(_host, identifier.Content);
                    goto checkForSiblings;

                case TokenType.Equal:
                    //next thing must be an identifier
                    var equal = stream.Next();
                    identifier = stream.Next();
                    statement  = new RawOutput(_host, identifier.Content);
                    goto checkForSiblings;

                default:
                    statement = GetStatementFromToken(identifier, tail);
                    goto checkForSiblings;
                }
            }

            statement = GetStatementFromToken(identifier, tail);

checkForSiblings:


            var list = new StatementList(_host);

            list.Add(statement);

            while (stream.Peek() != null)
            {
                //Parrot.Debugger.Debug.WriteLine("Looking for siblings");
                if (stream.Peek().Type == TokenType.Plus)
                {
                    //it's now a statementlist not a statement
                    stream.NextNoReturn();
                    var siblings = ParseStatement(stream);
                    foreach (var sibling in siblings)
                    {
                        list.Add(sibling);
                    }
                }
                else
                {
                    break;
                }
            }

            return(list);
        }