1	package antlr;
2	
3	/**
4	 * <b>SOFTWARE RIGHTS</b>
5	 * <p>
6	 * ANTLR 2.5.0 MageLang Institute, 1998
7	 * <p>
8	 * We reserve no legal rights to the ANTLR--it is fully in the
9	 * public domain. An individual or company may do whatever
10	 * they wish with source code distributed with ANTLR or the
11	 * code generated by ANTLR, including the incorporation of
12	 * ANTLR, or its output, into commerical software.
13	 * <p>
14	 * We encourage users to develop software with ANTLR. However,
15	 * we do ask that credit is given to us for developing
16	 * ANTLR. By "credit", we mean that if you use ANTLR or
17	 * incorporate any source code into one of your programs
18	 * (commercial product, research project, or otherwise) that
19	 * you acknowledge this fact somewhere in the documentation,
20	 * research report, etc... If you like ANTLR and have
21	 * developed a nice tool with the output, please mention that
22	 * you developed it using ANTLR. In addition, we ask that the
23	 * headers remain intact in our source code. As long as these
24	 * guidelines are kept, we expect to continue enhancing this
25	 * system and expect to make other tools available as they are
26	 * completed.
27	 * <p>
28	 * The ANTLR gang:
29	 * @version ANTLR 2.5.0 MageLang Institute, 1998
30	 * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
31	 * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
32	 */
33	/**A Stream of characters fed to the lexer from a InputStream that can
34	 * be rewound via mark()/rewind() methods.
35	 * <p>
36	 * A dynamic array is used to buffer up all the input characters.  Normally,
37	 * "k" characters are stored in the buffer.  More characters may be stored during
38	 * guess mode (testing syntactic predicate), or when LT(i>k) is referenced.
39	 * Consumption of characters is deferred.  In other words, reading the next
40	 * character is not done by conume(), but deferred until needed by LA or LT.
41	 * <p>
42	 *
43	 * @see antlr.CharQueue
44	 */
45	// SAS: added this class to handle Binary input w/ FileInputStream
46	import java.io.InputStream;
47	import java.io.IOException;
48	
49	public class ByteBuffer extends InputBuffer{
50	
51		// char source
52		transient InputStream input;
53	
54	
55		/** Create a character buffer */
56		public ByteBuffer(InputStream input_) {
57			super();
58			input = input_;
59		}
60		/** Ensure that the character buffer is sufficiently full */
61		public void fill(int amount) throws IOException
62		{
63			syncConsume();
64			// Fill the buffer sufficiently to hold needed characters
65			while (queue.nbrEntries < amount + markerOffset) {
66				// Append the next character
67				queue.append((char)input.read());
68			}
69		}
70	}
71