1 package com.quadcap.sql; 2 3 40 41 import java.io.IOException ; 42 43 import antlr.Token; 44 import antlr.TokenStream; 45 46 import com.quadcap.util.Debug; 47 48 53 public class JdbcEscapeTokenStream implements TokenStream, SQLTokenTypes { 54 TokenStream in; 55 int escCnt = 0; 56 57 public JdbcEscapeTokenStream(TokenStream in) { 58 this.in = in; 59 } 60 61 123 124 public Token nextToken() throws antlr.TokenStreamException { 125 Token t = in.nextToken(); 126 int typ = t.getType(); 127 while (typ == RCURLY) { 128 if (--escCnt < 0) throw new antlr.TokenStreamException("unexpected '}'"); 129 t = in.nextToken(); 130 typ = t.getType(); 131 } 132 if (typ == LCURLY) { 133 escCnt++; 134 t = in.nextToken(); 135 typ = t.getType(); 136 if (typ == ID) { 137 String txt = t.getText().toLowerCase(); 138 if (txt.equals("fn") || txt.equals("oj")) { 139 t = in.nextToken(); 140 } else if (txt.equals("escape")) { 141 } else if (txt.equals("d")) { 142 t = new Token(LITERAL_date, "date"); 143 } else if (txt.equals("t")) { 144 t = new Token(LITERAL_time, "time"); 145 } else if (txt.equals("ts")) { 146 t = new Token(LITERAL_timestamp, "timestamp"); 147 } else { 148 throw new antlr.TokenStreamException("Unrecognized escape: " + 149 t.getText()); 150 } 151 } 152 } 153 return t; 155 } 156 } 157 158 | Popular Tags |