My work mates and me are using SableCC as tokenizer and parser to a new programming language. We are developing a Netbeans Platform based IDE for that language. Netbeans Platform use Netbeans Parser API to syntax highligter, show erros and things like that. Netbeans Parser API has its own buffer which works like PushbackReader but does not extend it.
To connect that Parser API with SableCC generated lexer we create a simple adaptor. This adaptor is a subclass of PushbackReader that overrides methods used by SableCC Lexer and delegates this methos in the Netbeans buffer. As you can see,
this is not a very clean solution. I belive that the real problem is JDK, which doen't have an interface for PushbackReader, but I don't think Oracle listen my problems :(
Another solution is modify SableCC to use its own interface as buffer rather than PushbackReader. Something like the interface we are using to connect with Netbeans:
public interface PushbackReaderFacade {
public int read() throws IOException;
public void unread(int c) throws IOException;
}
In this way SableCC lexer could use any implementation of that interface, which is trivial to adapt to PushbackReader, the buffer used by Netbeans Parser API or any kind of stream or collection.
I know that this is not a critical issue, but it seems pretty easy to implement.
What do you think?