All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java_cup.runtime.ScannerBuffer Maven / Gradle / Ivy

The newest version!
package java_cup.runtime;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class ScannerBuffer implements Scanner {
	private Scanner inner;
	private List buffer = new LinkedList();
	/**
	 * Wraps around a custom scanner and stores all so far produced tokens in a buffer
	 * @param inner the scanner to buffer
	 */
	public ScannerBuffer(Scanner inner){
		this.inner=inner;
	}
	/**
	 * Read-Only access to the buffered Symbols 
	 * @return an unmodifiable Version of the buffer
	 */
	public List getBuffered() {
		return Collections.unmodifiableList(buffer);
	}
	@Override
	public Symbol next_token() throws Exception {
		Symbol buffered = inner.next_token();
		buffer.add(buffered);
		return buffered;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy