| 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 | 
  | 
  | 
 * $Id: CharBuffer.cpp,v 1.1 2005-12-02 15:38:02 tim Exp $ | 
| 6 | 
  | 
  | 
 */ | 
| 7 | 
  | 
  | 
 | 
| 8 | 
  | 
  | 
#include "antlr/CharBuffer.hpp" | 
| 9 | 
  | 
  | 
#include <iostream> | 
| 10 | 
  | 
  | 
 | 
| 11 | 
  | 
  | 
//#include <ios> | 
| 12 | 
  | 
  | 
 | 
| 13 | 
  | 
  | 
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE | 
| 14 | 
  | 
  | 
namespace antlr { | 
| 15 | 
  | 
  | 
#endif | 
| 16 | 
  | 
  | 
 | 
| 17 | 
  | 
  | 
/* RK: Per default istream does not throw exceptions. This can be | 
| 18 | 
  | 
  | 
 * enabled with: | 
| 19 | 
  | 
  | 
 * stream.exceptions(ios_base::badbit|ios_base::failbit|ios_base::eofbit); | 
| 20 | 
  | 
  | 
 * | 
| 21 | 
  | 
  | 
 * We could try catching the bad/fail stuff. But handling eof via this is | 
| 22 | 
  | 
  | 
 * not a good idea. EOF is best handled as a 'normal' character. | 
| 23 | 
  | 
  | 
 * | 
| 24 | 
  | 
  | 
 * So this does not work yet with gcc... Comment it until I get to a platform | 
| 25 | 
  | 
  | 
 * that does.. | 
| 26 | 
  | 
  | 
 */ | 
| 27 | 
  | 
  | 
 | 
| 28 | 
  | 
  | 
/** Create a character buffer. Enable fail and bad exceptions, if supported | 
| 29 | 
  | 
  | 
 * by platform. */ | 
| 30 | 
  | 
  | 
CharBuffer::CharBuffer(ANTLR_USE_NAMESPACE(std)istream& input_) | 
| 31 | 
  | 
  | 
: input(input_) | 
| 32 | 
  | 
  | 
{ | 
| 33 | 
  | 
  | 
//      input.exceptions(ANTLR_USE_NAMESPACE(std)ios_base::badbit| | 
| 34 | 
  | 
  | 
//                                                ANTLR_USE_NAMESPACE(std)ios_base::failbit); | 
| 35 | 
  | 
  | 
} | 
| 36 | 
  | 
  | 
 | 
| 37 | 
  | 
  | 
/** Get the next character from the stream. May throw CharStreamIOException | 
| 38 | 
  | 
  | 
 * when something bad happens (not EOF) (if supported by platform). | 
| 39 | 
  | 
  | 
 */ | 
| 40 | 
  | 
  | 
int CharBuffer::getChar() | 
| 41 | 
  | 
  | 
{ | 
| 42 | 
  | 
  | 
//      try { | 
| 43 | 
  | 
  | 
                return input.get(); | 
| 44 | 
  | 
  | 
//      } | 
| 45 | 
  | 
  | 
//      catch (ANTLR_USE_NAMESPACE(std)ios_base::failure& e) { | 
| 46 | 
  | 
  | 
//              throw CharStreamIOException(e); | 
| 47 | 
  | 
  | 
//      } | 
| 48 | 
  | 
  | 
} | 
| 49 | 
  | 
  | 
 | 
| 50 | 
  | 
  | 
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE | 
| 51 | 
  | 
  | 
} | 
| 52 | 
  | 
  | 
#endif |