package be.iminds.ilabt.jfed.groovy_dsl.impl;

/**
 * User: twalcari
 * Date: 2/5/2016
 * Time: 10:59
 */
public class DSLEventReaderImpl /*implements DSLEventReader*/ {

/*    private final Reader reader;
    private final GTSLexer lexer;

    public DSLEventReaderImpl(Reader reader) {
        this.reader = reader;


        lexer = new GTSLexer(new UnbufferedCharStream(reader));
        lexer.setTokenFactory(new CommonTokenFactory());

    }

    @Override
    public void close() throws DSLStreamException {
        try {
            reader.close();
        } catch (IOException e) {
            throw new DSLStreamException("Error while closing stream", e);
        }
    }

    @Override
    public boolean hasNext() throws DSLStreamException {
        if (nextEvent == null)
            tryReadNextEvent();
        return nextEvent != null;
    }

    @Override
    public DSLEvent nextEvent() throws DSLStreamException {
        if (hasNext()) {
            DSLEvent nextEvent = this.nextEvent;
            this.nextEvent = null;

            return nextEvent;
        } else
            throw new DSLStreamException("There is no next event!");
    }

    @Override
    public DSLEvent peek() throws DSLStreamException {
        if (hasNext())
            return nextEvent;
        else
            throw new DSLStreamException("There is no next event!");
    }

    private void tryReadNextEvent() throws DSLStreamException {


    }      */
}
