ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/antlr/InputBuffer.cpp
Revision: 1879
Committed: Sun Jun 16 15:15:42 2013 UTC (11 years, 10 months ago) by gezelter
File size: 1832 byte(s)
Log Message:
MERGE OpenMD development 1783:1878 into trunk

File Contents

# User Rev Content
1 tim 770 /* ANTLR Translator Generator
2     * Project led by Terence Parr at http://www.jGuru.com
3     * Software rights: http://www.antlr.org/license.html
4     *
5 gezelter 1442 * $Id$
6 tim 770 */
7    
8     #include "antlr/config.hpp"
9     #include "antlr/InputBuffer.hpp"
10 gezelter 1610 #include <iostream>
11 tim 770
12 gezelter 1782 #include <iostream>
13 gezelter 1879 #include <iostream>
14 tim 770 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
15     namespace antlr {
16     #endif
17    
18     /** Ensure that the character buffer is sufficiently full */
19     void InputBuffer::fill(unsigned int amount)
20     {
21     syncConsume();
22     // Fill the buffer sufficiently to hold needed characters
23     while (queue.entries() < amount + markerOffset)
24     {
25     // Append the next character
26     queue.append(getChar());
27     }
28     }
29    
30     /** get the current lookahead characters as a string
31     * @warning it may treat 0 and EOF values wrong
32     */
33     ANTLR_USE_NAMESPACE(std)string InputBuffer::getLAChars( void ) const
34     {
35     ANTLR_USE_NAMESPACE(std)string ret;
36    
37     for(unsigned int i = markerOffset; i < queue.entries(); i++)
38     ret += queue.elementAt(i);
39    
40     return ret;
41     }
42    
43     /** get the current marked characters as a string
44     * @warning it may treat 0 and EOF values wrong
45     */
46     ANTLR_USE_NAMESPACE(std)string InputBuffer::getMarkedChars( void ) const
47     {
48     ANTLR_USE_NAMESPACE(std)string ret;
49    
50     for(unsigned int i = 0; i < markerOffset; i++)
51     ret += queue.elementAt(i);
52    
53     return ret;
54     }
55    
56     /** Return an integer marker that can be used to rewind the buffer to
57     * its current state.
58     */
59     unsigned int InputBuffer::mark()
60     {
61     syncConsume();
62     nMarkers++;
63     return markerOffset;
64     }
65    
66     /** Rewind the character buffer to a marker.
67     * @param mark Marker returned previously from mark()
68     */
69     void InputBuffer::rewind(unsigned int mark)
70     {
71     syncConsume();
72     markerOffset = mark;
73     nMarkers--;
74     }
75    
76     unsigned int InputBuffer::entries() const
77     {
78     //assert(queue.entries() >= markerOffset);
79     return queue.entries() - markerOffset;
80     }
81    
82     #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
83     }
84     #endif

Properties

Name Value
svn:keywords Author Id Revision Date