ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/antlr/InputBuffer.cpp
Revision: 1610
Committed: Fri Aug 12 14:37:25 2011 UTC (13 years, 8 months ago) by gezelter
File size: 1792 byte(s)
Log Message:
Fixed a clang compilation problem, added the ability to output
particle potential in the dump files.

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     #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
13     namespace antlr {
14     #endif
15    
16     /** Ensure that the character buffer is sufficiently full */
17     void InputBuffer::fill(unsigned int amount)
18     {
19     syncConsume();
20     // Fill the buffer sufficiently to hold needed characters
21     while (queue.entries() < amount + markerOffset)
22     {
23     // Append the next character
24     queue.append(getChar());
25     }
26     }
27    
28     /** get the current lookahead characters as a string
29     * @warning it may treat 0 and EOF values wrong
30     */
31     ANTLR_USE_NAMESPACE(std)string InputBuffer::getLAChars( void ) const
32     {
33     ANTLR_USE_NAMESPACE(std)string ret;
34    
35     for(unsigned int i = markerOffset; i < queue.entries(); i++)
36     ret += queue.elementAt(i);
37    
38     return ret;
39     }
40    
41     /** get the current marked characters as a string
42     * @warning it may treat 0 and EOF values wrong
43     */
44     ANTLR_USE_NAMESPACE(std)string InputBuffer::getMarkedChars( void ) const
45     {
46     ANTLR_USE_NAMESPACE(std)string ret;
47    
48     for(unsigned int i = 0; i < markerOffset; i++)
49     ret += queue.elementAt(i);
50    
51     return ret;
52     }
53    
54     /** Return an integer marker that can be used to rewind the buffer to
55     * its current state.
56     */
57     unsigned int InputBuffer::mark()
58     {
59     syncConsume();
60     nMarkers++;
61     return markerOffset;
62     }
63    
64     /** Rewind the character buffer to a marker.
65     * @param mark Marker returned previously from mark()
66     */
67     void InputBuffer::rewind(unsigned int mark)
68     {
69     syncConsume();
70     markerOffset = mark;
71     nMarkers--;
72     }
73    
74     unsigned int InputBuffer::entries() const
75     {
76     //assert(queue.entries() >= markerOffset);
77     return queue.entries() - markerOffset;
78     }
79    
80     #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
81     }
82     #endif

Properties

Name Value
svn:keywords Author Id Revision Date