source: trunk/yao/share/antlr-2.7.7/lib/csharp/antlr.runtime/antlr/LexerSharedInputState.cs @ 1

Last change on this file since 1 was 1, checked in by lnalod, 15 years ago

Initial import of YAO sources

File size: 1.8 KB
Line 
1using System;
2using Stream                    = System.IO.Stream;
3using TextReader                = System.IO.TextReader;
4
5namespace antlr
6{
7        /*ANTLR Translator Generator
8        * Project led by Terence Parr at http://www.jGuru.com
9        * Software rights: http://www.antlr.org/license.html
10        *
11        * $Id:$
12        */
13       
14        //
15        // ANTLR C# Code Generator by Micheal Jordan
16        //                            Kunle Odutola       : kunle UNDERSCORE odutola AT hotmail DOT com
17        //                            Anthony Oguntimehin
18        //
19        // With many thanks to Eric V. Smith from the ANTLR list.
20        //
21
22        /*This object contains the data associated with an
23        *  input stream of characters.  Multiple lexers
24        *  share a single LexerSharedInputState to lex
25        *  the same input stream.
26        */
27        public class LexerSharedInputState
28        {
29                protected internal int column;
30                protected internal int line;
31                protected internal int tokenStartColumn;
32                protected internal int tokenStartLine;
33                protected internal InputBuffer input;
34               
35                /*What file (if known) caused the problem? */
36                protected internal string filename;
37               
38                public int guessing;
39               
40                public LexerSharedInputState(InputBuffer inbuf)
41                {
42                        initialize();
43                        input = inbuf;
44                }
45               
46                public LexerSharedInputState(Stream inStream) : this(new ByteBuffer(inStream))
47                {
48                }
49               
50                public LexerSharedInputState(TextReader inReader) : this(new CharBuffer(inReader))
51                {
52                }
53               
54                private void initialize()
55                {
56                        column = 1;
57                        line = 1;
58                        tokenStartColumn = 1;
59                        tokenStartLine = 1;
60                        guessing = 0;
61                        filename = null;
62                }
63               
64                public virtual void reset()
65                {
66                        initialize();
67                        input.reset();
68                }
69
70                public virtual void resetInput(InputBuffer ib)
71                {
72                        reset();
73                        input = ib;
74                }
75
76                public virtual void resetInput(Stream s)
77                {
78                        reset();
79                        input = new ByteBuffer(s);
80                }
81
82                public virtual void resetInput(TextReader tr)
83                {
84                        reset();
85                        input = new CharBuffer(tr);
86                }
87        }
88}
Note: See TracBrowser for help on using the repository browser.