ext/include/iv/lexer.h in iv-phonic-0.0.7 vs ext/include/iv/lexer.h in iv-phonic-0.0.8
- old
+ new
@@ -362,11 +362,11 @@
inline const std::vector<uc16>& Buffer() const {
return buffer16_;
}
- inline const std::string& Buffer8() const {
+ inline const std::vector<char>& Buffer8() const {
return buffer8_;
}
inline const double& Numeric() const {
return numeric_;
@@ -480,10 +480,21 @@
void Initialize() {
Advance();
}
+ void Initialize(const Source* src) {
+ using std::swap;
+ source_ = src;
+ pos_ = 0;
+ end_ = source_->size();
+ has_line_terminator_before_next_ = false;
+ has_shebang_ = false;
+ line_number_ = 1;
+ swap(location_, Location());
+ }
+
inline void Advance() {
if (pos_ == end_) {
c_ = -1;
} else {
c_ = source_->Get(pos_++);
@@ -793,17 +804,18 @@
return Token::ILLEGAL;
}
if (type == OCTAL) {
double val = 0;
- for (std::string::const_iterator it = buffer8_.begin(),
+ for (typename std::vector<char>::const_iterator it = buffer8_.begin(),
last = buffer8_.end(); it != last; ++it) {
val = val * 8 + (*it - '0');
}
numeric_ = val;
} else {
- numeric_ = std::atof(buffer8_.c_str());
+ const std::string buf(buffer8_.begin(), buffer8_.end());
+ numeric_ = std::atof(buf.c_str());
}
type_ = type;
return Token::NUMBER;
}
@@ -855,10 +867,10 @@
}
++line_number_;
}
const Source* source_;
- std::string buffer8_;
+ std::vector<char> buffer8_;
std::vector<uc16> buffer16_;
double numeric_;
State type_;
std::size_t pos_;
const std::size_t end_;