KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > hql > ast > HqlLexer


1 // $Id: HqlLexer.java,v 1.13 2005/07/16 17:28:40 epbernard Exp $
2
package org.hibernate.hql.ast;
3
4 import java.io.InputStream JavaDoc;
5 import java.io.Reader JavaDoc;
6
7 import antlr.Token;
8 import org.hibernate.QueryException;
9 import org.hibernate.hql.antlr.HqlBaseLexer;
10
11 /**
12  * Custom lexer for the HQL grammar. Extends the base lexer generated by ANTLR
13  * in order to keep the grammar source file clean.
14  */

15 class HqlLexer extends HqlBaseLexer {
16     /**
17      * A logger for this class. *
18      */

19     private boolean possibleID = false;
20
21     public HqlLexer(InputStream JavaDoc in) {
22         super( in );
23     }
24
25     public HqlLexer(Reader JavaDoc in) {
26         super(in);
27     }
28
29     public void setTokenObjectClass(String JavaDoc cl) {
30         // Ignore the token class name parameter, and use a specific token class.
31
super.setTokenObjectClass( HqlToken.class.getName() );
32     }
33
34     protected void setPossibleID(boolean possibleID) {
35         this.possibleID = possibleID;
36     }
37
38     protected Token makeToken(int i) {
39         HqlToken token = ( HqlToken ) super.makeToken( i );
40         token.setPossibleID( possibleID );
41         possibleID = false;
42         return token;
43     }
44
45     public int testLiteralsTable(int i) {
46         int ttype = super.testLiteralsTable( i );
47         return ttype;
48     }
49
50     public void panic() {
51         //overriden to avoid System.exit
52
panic("CharScanner: panic");
53     }
54
55     public void panic(String JavaDoc s) {
56         //overriden to avoid System.exit
57
throw new QueryException(s);
58     }
59 }
60
Popular Tags