protected void transmit(String event) { out.println(event); out.flush(); ack(); }
protected void serializeText(StringBuffer buf, String text) { buf.append("\t\""); if ( text==null ) { text = ""; } // escape \n and \r all text for token appears to exist on one line // this escape is slow but easy to understand text = escapeNewlines(text); buf.append(text); }
@Override public void consumeNode(Object t) { StringBuffer buf = new StringBuffer(50); buf.append("consumeNode"); serializeNode(buf, t); transmit(buf.toString()); }
@Override public void consumeToken(Token t) { String buf = serializeToken(t); transmit("consumeToken\t"+buf); }
@Override public void semanticPredicate(boolean result, String predicate) { StringBuffer buf = new StringBuffer(50); buf.append("semanticPredicate\t"); buf.append(result); serializeText(buf, predicate); transmit(buf.toString()); }
@Override public void terminate() { transmit("terminate"); out.close(); try { socket.close(); } catch (IOException ioe) { ioe.printStackTrace(System.err); } }
protected String serializeToken(Token t) { StringBuffer buf = new StringBuffer(50); buf.append(t.getTokenIndex()); buf.append('\t'); buf.append(t.getType()); buf.append('\t'); buf.append(t.getChannel()); buf.append('\t'); buf.append(t.getLine()); buf.append('\t'); buf.append(t.getCharPositionInLine()); serializeText(buf, t.getText()); return buf.toString(); }
@Override public void consumeHiddenToken(Token t) { String buf = serializeToken(t); transmit("consumeHiddenToken\t"+buf); }
@Override public void semanticPredicate(boolean result, String predicate) { StringBuffer buf = new StringBuffer(50); buf.append("semanticPredicate\t"); buf.append(result); serializeText(buf, predicate); transmit(buf.toString()); }
@Override public void terminate() { transmit("terminate"); out.close(); try { socket.close(); } catch (IOException ioe) { ioe.printStackTrace(System.err); } }
protected String serializeToken(Token t) { StringBuffer buf = new StringBuffer(50); buf.append(t.getTokenIndex()); buf.append('\t'); buf.append(t.getType()); buf.append('\t'); buf.append(t.getChannel()); buf.append('\t'); buf.append(t.getLine()); buf.append('\t'); buf.append(t.getCharPositionInLine()); serializeText(buf, t.getText()); return buf.toString(); }
@Override public void consumeHiddenToken(Token t) { String buf = serializeToken(t); transmit("consumeHiddenToken\t"+buf); }
@Override public void semanticPredicate(boolean result, String predicate) { StringBuffer buf = new StringBuffer(50); buf.append("semanticPredicate\t"); buf.append(result); serializeText(buf, predicate); transmit(buf.toString()); }
public void consumeNode(Object t) { StringBuffer buf = new StringBuffer(50); buf.append("consumeNode"); serializeNode(buf, t); transmit(buf.toString()); }
@Override public void terminate() { transmit("terminate"); out.close(); try { socket.close(); } catch (IOException ioe) { ioe.printStackTrace(System.err); } }
protected void transmit(String event) { out.println(event); out.flush(); ack(); }
protected String serializeToken(Token t) { StringBuffer buf = new StringBuffer(50); buf.append(t.getTokenIndex()); buf.append('\t'); buf.append(t.getType()); buf.append('\t'); buf.append(t.getChannel()); buf.append('\t'); buf.append(t.getLine()); buf.append('\t'); buf.append(t.getCharPositionInLine()); serializeText(buf, t.getText()); return buf.toString(); }
protected void serializeText(StringBuffer buf, String text) { buf.append("\t\""); if ( text==null ) { text = ""; } // escape \n and \r all text for token appears to exist on one line // this escape is slow but easy to understand text = escapeNewlines(text); buf.append(text); }
@Override public void consumeToken(Token t) { String buf = serializeToken(t); transmit("consumeToken\t"+buf); }
public void semanticPredicate(boolean result, String predicate) { StringBuffer buf = new StringBuffer(50); buf.append("semanticPredicate\t"); buf.append(result); serializeText(buf, predicate); transmit(buf.toString()); }