SableCC lexer input

49 views
Skip to first unread message

Gonzalo Ortiz Jaureguizar

unread,
Sep 12, 2012, 12:07:31 PM9/12/12
to sab...@googlegroups.com
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?

Etienne Gagnon

unread,
Sep 12, 2012, 3:33:29 PM9/12/12
to sab...@googlegroups.com
Hi Gonzalo,

I'll look and see if this could be done without breaking backward compatibility (probably using an additional constructor).

Etienne

On 2012-09-12 12:07, Gonzalo Ortiz Jaureguizar wrote:
[...] 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;
}
[...]

Phuc Luoi

unread,
Sep 13, 2012, 6:39:10 AM9/13/12
to sab...@googlegroups.com
Hi,

I has written a Netbeans Plugin for SableCC. I used a wrapper to wrapp the Netbeans Lexer API to a "faked " extends PushbackReader and give it to
SableCC Lexer. The code is like:

https://github.com/verylazyboy/SableCCNetbeans/blob/master/sccnb/src/org/sableccsupport/lexer/NBPushbackReader.java

I hope is can help you something.

--
-- You received this message because you are subscribed to the SableCC group. To post to this group, send email to sab...@googlegroups.com. To unsubscribe from this group, send email to sablecc+u...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/sablecc?hl=en
 
 

Gonzalo Ortiz Jaureguizar

unread,
Sep 13, 2012, 8:25:26 AM9/13/12
to sab...@googlegroups.com
hehe, is almost the same solution I found :)
Reply all
Reply to author
Forward
0 new messages