use this interface if you like to change token properties generated by lexer
before send to parser.
if you change a source token's TSourceToken#tokencode to
TBaseType#cmtslashstar
TBaseType#cmtdoublehyphen
then, this token will be treated as comment
you may also like to change tokencode of a keyword to TBaseType#ident,
this will let parser treat this keyword as an identifier.
Here is a demo illustrates how to use this interface to ignore token you don't need.
package test.interfaceDemo;
import gudusoft.gsqlparser.*;
import junit.framework.TestCase;
class myTokenHandle implements ITokenHandle{
public boolean processToken(TSourceToken st){
if (st.toString().equalsIgnoreCase("limit")){
st.tokencode = TBaseType.cmtslashstar;//treat this token as a comment
}
return true;
}
}
public class testITokenHandle extends TestCase {
public void test1(){
TGSqlParser sqlparser = new TGSqlParser(EDbVendor.dbvmysql);
sqlparser.sqltext = "select * from dual limit";
sqlparser.setTokenHandle(new myTokenHandle());
assertTrue(sqlparser.parse() == 0);
}
}