13447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein/* 23447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein [The "BSD license"] 33447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein Copyright (c) 2005-2009 Terence Parr 43447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein All rights reserved. 53447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 63447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein Redistribution and use in source and binary forms, with or without 73447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein modification, are permitted provided that the following conditions 83447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein are met: 93447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 1. Redistributions of source code must retain the above copyright 103447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein notice, this list of conditions and the following disclaimer. 113447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 2. Redistributions in binary form must reproduce the above copyright 123447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein notice, this list of conditions and the following disclaimer in the 133447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein documentation and/or other materials provided with the distribution. 143447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 3. The name of the author may not be used to endorse or promote products 153447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein derived from this software without specific prior written permission. 163447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 173447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 183447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 193447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 203447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 213447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 223447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 233447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 243447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 253447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 263447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 273447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein */ 283447a5916aa62f44de24cc441fc9987116ddff52Andrew Sappersteinpackage org.antlr.runtime; 293447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 303447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein/** A source of characters for an ANTLR lexer */ 313447a5916aa62f44de24cc441fc9987116ddff52Andrew Sappersteinpublic interface CharStream extends IntStream { 323447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public static final int EOF = -1; 333447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 343447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein /** For infinite streams, you don't need this; primarily I'm providing 353447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * a useful interface for action code. Just make sure actions don't 363447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * use this on streams that don't support it. 373447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein */ 383447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public String substring(int start, int stop); 393447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 403447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein /** Get the ith character of lookahead. This is the same usually as 413447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * LA(i). This will be used for labels in the generated 423447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * lexer code. I'd prefer to return a char here type-wise, but it's 433447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * probably better to be 32-bit clean and be consistent with LA. 443447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein */ 453447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public int LT(int i); 463447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 473447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein /** ANTLR tracks the line information automatically */ 483447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein int getLine(); 493447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 503447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein /** Because this stream can rewind, we need to be able to reset the line */ 513447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein void setLine(int line); 523447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 533447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein void setCharPositionInLine(int pos); 543447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 553447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein /** The index of the character relative to the beginning of the line 0..n-1 */ 563447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein int getCharPositionInLine(); 573447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein} 58