/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This file is part of J102. * * See the file "J102-LICENSE" for Copyright information and the * * terms and conditions for copying, distribution and * * modification of J102. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ package org.sablecc.java; import org.sablecc.java.unicodepreprocessor.lexer.*; import org.sablecc.java.unicodepreprocessor.node.*; import org.sablecc.java.unicodepreprocessor.analysis.*; import org.sablecc.java.unicodepreprocessor.*; import java.io.*; public class UnicodePreprocessor extends Reader { private UnicodeLexer lexer; private ProcessToken processor = new ProcessToken(); public UnicodePreprocessor(PushbackReader in) { lexer = new UnicodeLexer(in); } public int read() throws IOException { if(available == 0) { try { lexer.next().apply(processor); } catch(LexerException e) { throw new RuntimeException(e.toString()); } } if(available == 0) { return -1; } char c = buffer[0]; buffer[0] = buffer[1]; available--; // System.out.print((char) c); return c; } public int read( char cbuf[], int off, int len) throws IOException { for(int i = 0; i