KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > antlr > LexerSharedInputState


1 package antlr;
2
3 /* ANTLR Translator Generator
4  * Project led by Terence Parr at http://www.jGuru.com
5  * Software rights: http://www.antlr.org/RIGHTS.html
6  *
7  * $Id: //depot/code/org.antlr/main/main/antlr/LexerSharedInputState.java#8 $
8  */

9
10 import java.io.Reader JavaDoc;
11 import java.io.InputStream JavaDoc;
12
13 /** This object contains the data associated with an
14  * input stream of characters. Multiple lexers
15  * share a single LexerSharedInputState to lex
16  * the same input stream.
17  */

18 public class LexerSharedInputState {
19     protected int column = 1;
20     protected int line = 1;
21     protected int tokenStartColumn = 1;
22     protected int tokenStartLine = 1;
23     protected InputBuffer input;
24
25     /** What file (if known) caused the problem? */
26     protected String JavaDoc filename;
27
28     public int guessing = 0;
29
30     public LexerSharedInputState(InputBuffer inbuf) {
31         input = inbuf;
32     }
33
34     public LexerSharedInputState(InputStream JavaDoc in) {
35         this(new ByteBuffer(in));
36     }
37
38     public LexerSharedInputState(Reader JavaDoc in) {
39         this(new CharBuffer(in));
40     }
41
42     public void reset() {
43         column = 1;
44         line = 1;
45         tokenStartColumn = 1;
46         tokenStartLine = 1;
47         guessing = 0;
48         filename = null;
49         input.reset();
50     }
51 }
52
Popular Tags