KDevelop API Documentation

lib/antlr/src/TokenBuffer.cpp

Go to the documentation of this file.
00001 /* ANTLR Translator Generator 00002 * Project led by Terence Parr at http://www.jGuru.com 00003 * Software rights: http://www.antlr.org/RIGHTS.html 00004 * 00005 * $Id: TokenBuffer.cpp,v 1.2 2003/05/02 00:36:20 okellogg Exp $ 00006 */ 00007 00008 #include "antlr/TokenBuffer.hpp" 00009 00010 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 00011 namespace antlr { 00012 #endif 00013 00030 TokenBuffer::TokenBuffer( TokenStream& input_ ) 00031 : input(input_), nMarkers(0), markerOffset(0), numToConsume(0) 00032 { 00033 } 00034 00036 void TokenBuffer::fill(int amount) 00037 { 00038 syncConsume(); 00039 // Fill the buffer sufficiently to hold needed tokens 00040 while (queue.entries() < amount + markerOffset) { 00041 // Append the next token 00042 queue.append(input.nextToken()); 00043 } 00044 } 00045 00047 int TokenBuffer::LA(int i) 00048 { 00049 fill(i); 00050 return queue.elementAt(markerOffset+i-1)->type; 00051 } 00052 00054 RefToken TokenBuffer::LT(int i) 00055 { 00056 fill(i); 00057 return queue.elementAt(markerOffset+i-1); 00058 } 00059 00063 int TokenBuffer::mark() 00064 { 00065 syncConsume(); 00066 nMarkers++; 00067 return markerOffset; 00068 } 00069 00073 void TokenBuffer::rewind(int mark) 00074 { 00075 syncConsume(); 00076 markerOffset=mark; 00077 nMarkers--; 00078 } 00079 00080 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 00081 } 00082 #endif 00083
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Oct 19 08:01:47 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003