ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/antlr/InputBuffer.cpp
Revision: 1969
Committed: Wed Feb 26 14:14:50 2014 UTC (11 years, 2 months ago) by gezelter
File size: 1881 byte(s)
Log Message:
Fixes to deal with deprecation of MPI C++ bindings.  We've reverted back to the
C calls.

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

Properties

Name Value
svn:keywords Author Id Revision Date