001package gudusoft.gsqlparser; 002 003/** 004* use this interface if you like to change token properties generated by lexer 005 * before send to parser.<br> 006 * if you change a source token's TSourceToken#tokencode to 007 * TBaseType#cmtslashstar 008 * TBaseType#cmtdoublehyphen 009 * then, this token will be treated as comment 010 * 011 * <br>you may also like to change tokencode of a keyword to TBaseType#ident, 012 * this will let parser treat this keyword as an identifier. 013 * 014 * <br>Here is a demo illustrates how to use this interface to ignore token you don't need. 015 * 016 * <pre> 017 * package test.interfaceDemo; 018* 019* import gudusoft.gsqlparser.*; 020* import junit.framework.TestCase; 021* 022* class myTokenHandle implements ITokenHandle{ 023* public boolean processToken(TSourceToken st){ 024* 025* if (st.toString().equalsIgnoreCase("limit")){ 026* st.tokencode = TBaseType.cmtslashstar;//treat this token as a comment 027* } 028* return true; 029* } 030* } 031* 032* public class testITokenHandle extends TestCase { 033* 034* public void test1(){ 035* TGSqlParser sqlparser = new TGSqlParser(EDbVendor.dbvmysql); 036* sqlparser.sqltext = "select * from dual limit"; 037* sqlparser.setTokenHandle(new myTokenHandle()); 038* 039* assertTrue(sqlparser.parse() == 0); 040* } 041* 042* } 043 * </pre> 044 * 045 * 046*/ 047public interface ITokenHandle { 048 049 public boolean processToken(TSourceToken st); 050}