[antlr-interest] Parsing a continous stream of data ...
Nigel Sheridan-Smith
nbsherid at secsme.org.au
Wed Dec 29 01:01:37 PST 2004
Sriyansa,
In Java, you can choose between java.io.InputStream, java.io.Reader or
antlr.InputBuffer to supply to your ANTLR-generated lexer. Just derive your
custom I/O class (or "interfacing" class) from one of those, and then pass
it to the lexer when you construct it...
Here is the definition of my lexer's constructors:
...
public TypeinfoLexer(InputStream in) {
this(new ByteBuffer(in));
}
public TypeinfoLexer(Reader in) {
this(new CharBuffer(in));
}
public TypeinfoLexer(InputBuffer ib) {
this(new LexerSharedInputState(ib));
}
...
In C++, ANTLR-generated lexers can use either std::istream or
antlr::InputBuffer. I imagine there will be similar classes in C#...
Nigel
--
Nigel Sheridan-Smith
PhD research student
Faculty of Engineering
University of Technology, Sydney
Phone: 02 9514 7946
Fax: 02 9514 2435
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Sriyansa
> Sent: Wednesday, 29 December 2004 6:57 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Parsing a continous stream of data ...
>
> Hi,
>
> I am trying to write a parser module which takes in a streaming input
> and converts it to an operation stack. All the steps (char stream ->
> token stream -> operation stack) are asynchronous and the modules read
> from and write into incomplete data structures.
>
> The grammar for the parsing is itself not very complicated and I could
> use ANTLR to generate the parser. However, embedding the code for the
> customized I/O (a significant piece) in the grammar file does not look
> feasible.
>
> Now the questions:
>
> 1. Is there any other parser generator more suitable for such a task?
> 2. Or am I missing something in ANTLR irself?
> 3. If I have to change the ANTLR source to allow for such I/O where do
> I start?
>
> Thanks,
> Sriyansa
>
>
More information about the antlr-interest
mailing list