[antlr-interest] Using PipedWriter & PipedReader

defordusa defordusa at yahoo.com
Thu Jul 10 04:39:47 PDT 2003


I am attempting to create an instance of a lexer using a PipedReader 
that is connected to a PipedWriter. However I am having problems with 
the program hanging, it will process the frist write to the 
PipedWriter instance but hangs after processing it and never returns.

What I am trying to do is create the lexer (FnfL) and parser (FnfP)
one time only and reuse it, for performance reasons I can't afford 
the overhead of continually creating new instances of the lexer and 
parser.

Here is the code I use (has anyone else done this or maybe done it a 
different way)?

        /*
         * Execute the Scanner Recognizer
         */
        FnfL lexer = null;
        PipedReader in = null;
        PipedWriter pw = null;
        try
        {
            pw = new PipedWriter();
            in = new PipedReader(pw);
        }
        catch( IOException e )
        {
            e.printStackTrace();
            System.exit(1);
        }

        // Initialize the lexer
        lexer = new FnfL( in );

        // Initialize and start the parser
        try
        {
            String names[] =
            {
                "Joe Shmoe;",
                "Jane D Shmoe;",
                "Paddy O'Furniture;",
            };

            FnfP parser = new FnfP(lexer);
            for( int nn=0; nn<names.length; nn++ )
            {
                pw.write(names[nn]);
                pw.flush();
                parser.startRule();    // <<-- PROGRAM HANGS HERE!!!!
            }
        }
        catch(Exception e)
        {
            System.err.println("exception: "+e);
            e.printStackTrace();
        }



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list