[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master dd2ac71 3/4: Make data-member names end in '_
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master dd2ac71 3/4: Make data-member names end in '_' |
Date: |
Fri, 3 Feb 2017 13:40:57 +0000 (UTC) |
branch: master
commit dd2ac717c3e024634805e85ee167bc2df538130d
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Make data-member names end in '_'
---
input_sequence.cpp | 412 ++++++++++++++++++++++++++--------------------------
input_sequence.hpp | 66 ++++-----
2 files changed, 239 insertions(+), 239 deletions(-)
diff --git a/input_sequence.cpp b/input_sequence.cpp
index aefeb0b..fa3b538 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -58,18 +58,18 @@ SequenceParser::SequenceParser
,std::vector<std::string> const& a_allowed_keywords
,bool a_keywords_only
)
- :input_stream (input_expression.c_str())
- ,years_to_maturity (a_years_to_maturity)
- ,issue_age (a_issue_age)
- ,retirement_age (a_retirement_age)
- ,inforce_duration (a_inforce_duration)
- ,effective_year (a_effective_year)
- ,allowed_keywords (a_allowed_keywords)
- ,keywords_only (a_keywords_only)
- ,current_token_type (e_startup)
- ,previous_duration_scalar_mode (e_inception)
- ,current_duration_scalar_mode (e_inception)
- ,last_input_duration (0)
+ :input_stream_ (input_expression.c_str())
+ ,years_to_maturity_ (a_years_to_maturity)
+ ,issue_age_ (a_issue_age)
+ ,retirement_age_ (a_retirement_age)
+ ,inforce_duration_ (a_inforce_duration)
+ ,effective_year_ (a_effective_year)
+ ,allowed_keywords_ (a_allowed_keywords)
+ ,keywords_only_ (a_keywords_only)
+ ,current_token_type_ (e_startup)
+ ,previous_duration_scalar_mode_ (e_inception)
+ ,current_duration_scalar_mode_ (e_inception)
+ ,last_input_duration_ (0)
{
sequence();
}
@@ -78,12 +78,12 @@ SequenceParser::~SequenceParser() = default;
std::string SequenceParser::EXPEDIENTdiagnostics() const
{
- return diagnostics.str();
+ return diagnostics_.str();
}
std::vector<ValueInterval> const& SequenceParser::EXPEDIENTintervals() const
{
- return intervals;
+ return intervals_;
}
InputSequence::InputSequence
@@ -97,36 +97,36 @@ InputSequence::InputSequence
,bool a_keywords_only
,std::string const& a_default_keyword
)
- :years_to_maturity (a_years_to_maturity)
- ,issue_age (a_issue_age)
- ,retirement_age (a_retirement_age)
- ,inforce_duration (a_inforce_duration)
- ,effective_year (a_effective_year)
- ,allowed_keywords (a_allowed_keywords)
- ,keywords_only (a_keywords_only)
- ,default_keyword (a_default_keyword)
+ :years_to_maturity_ (a_years_to_maturity)
+ ,issue_age_ (a_issue_age)
+ ,retirement_age_ (a_retirement_age)
+ ,inforce_duration_ (a_inforce_duration)
+ ,effective_year_ (a_effective_year)
+ ,allowed_keywords_ (a_allowed_keywords)
+ ,keywords_only_ (a_keywords_only)
+ ,default_keyword_ (a_default_keyword)
{
SequenceParser parser
(input_expression
- ,years_to_maturity
- ,issue_age
- ,retirement_age
- ,inforce_duration
- ,effective_year
- ,allowed_keywords
- ,keywords_only
+ ,years_to_maturity_
+ ,issue_age_
+ ,retirement_age_
+ ,inforce_duration_
+ ,effective_year_
+ ,allowed_keywords_
+ ,keywords_only_
);
- EXPEDIENTdiagnostics = parser.EXPEDIENTdiagnostics();
- intervals = parser.EXPEDIENTintervals();
+ EXPEDIENTdiagnostics_ = parser.EXPEDIENTdiagnostics();
+ intervals_ = parser.EXPEDIENTintervals();
// Inception and maturity endpoints exist, so the interval they
// define must exist. However, parsing an empty expression
// constructs zero intervals, so a default one must be created
// to make the physical reality meet the conceptual requirement.
- if(intervals.empty())
+ if(intervals_.empty())
{
- intervals.push_back(ValueInterval());
+ intervals_.push_back(ValueInterval());
}
// Extend the last interval's endpoint to maturity, replicating
@@ -137,11 +137,11 @@ InputSequence::InputSequence
// This invariant has not yet been established, whether or not the
// sequence was empty.
- intervals.back().end_duration = years_to_maturity;
+ intervals_.back().end_duration = years_to_maturity_;
// This invariant is established by realize_vector(), but it does
// no harm to repeat it here, and it would be confusing not to do
// so in conjunction with the line above.
- intervals.back().end_mode = e_maturity;
+ intervals_.back().end_mode = e_maturity;
realize_vector();
}
@@ -162,7 +162,7 @@ InputSequence::InputSequence
// when the vectors are of length zero, and
// for the last interval.
// As a consequence, we always push_back a dummy interval exactly when
-// we know that it will be needed, and then write to intervals.back().
+// we know that it will be needed, and then write to intervals_.back().
//
// An alternative design would work with a temporary interval and
// call push_back as needed. I tried that and concluded that this
@@ -176,30 +176,30 @@ InputSequence::InputSequence
// unintended use.
InputSequence::InputSequence(std::vector<double> const& v)
- :years_to_maturity(v.size())
+ :years_to_maturity_(v.size())
{
ValueInterval dummy;
double prior_value = v.empty() ? 0.0 : v.front();
double current_value = prior_value;
- intervals.push_back(dummy);
- intervals.back().value_number = current_value;
+ intervals_.push_back(dummy);
+ intervals_.back().value_number = current_value;
for(auto const& vi : v)
{
current_value = vi;
if(prior_value == current_value)
{
- ++intervals.back().end_duration;
+ ++intervals_.back().end_duration;
}
else
{
- int value_change_duration = intervals.back().end_duration;
- intervals.push_back(dummy);
- intervals.back().value_number = current_value;
- intervals.back().begin_duration = value_change_duration;
- intervals.back().end_duration = ++value_change_duration;
+ int value_change_duration = intervals_.back().end_duration;
+ intervals_.push_back(dummy);
+ intervals_.back().value_number = current_value;
+ intervals_.back().begin_duration = value_change_duration;
+ intervals_.back().end_duration = ++value_change_duration;
prior_value = current_value;
}
}
@@ -208,7 +208,7 @@ InputSequence::InputSequence(std::vector<double> const& v)
}
InputSequence::InputSequence(std::vector<std::string> const& v)
- :years_to_maturity(v.size())
+ :years_to_maturity_(v.size())
{
ValueInterval dummy;
dummy.value_is_keyword = true;
@@ -216,23 +216,23 @@ InputSequence::InputSequence(std::vector<std::string>
const& v)
std::string prior_value = v.empty() ? std::string() : v.front();
std::string current_value = prior_value;
- intervals.push_back(dummy);
- intervals.back().value_keyword = current_value;
+ intervals_.push_back(dummy);
+ intervals_.back().value_keyword = current_value;
for(auto const& vi : v)
{
current_value = vi;
if(prior_value == current_value)
{
- ++intervals.back().end_duration;
+ ++intervals_.back().end_duration;
}
else
{
- int value_change_duration = intervals.back().end_duration;
- intervals.push_back(dummy);
- intervals.back().value_keyword = current_value;
- intervals.back().begin_duration = value_change_duration;
- intervals.back().end_duration = ++value_change_duration;
+ int value_change_duration = intervals_.back().end_duration;
+ intervals_.push_back(dummy);
+ intervals_.back().value_keyword = current_value;
+ intervals_.back().begin_duration = value_change_duration;
+ intervals_.back().end_duration = ++value_change_duration;
prior_value = current_value;
}
}
@@ -244,7 +244,7 @@ InputSequence::InputSequence
(std::vector<double> const& n_v
,std::vector<std::string> const& s_v
)
- :years_to_maturity(n_v.size())
+ :years_to_maturity_(n_v.size())
{
if(n_v.size() != s_v.size())
{
@@ -262,10 +262,10 @@ InputSequence::InputSequence
std::string s_prior_value = s_v.empty() ? std::string() : s_v.front();
std::string s_current_value = s_prior_value;
- intervals.push_back(dummy);
- intervals.back().value_number = n_current_value;
- intervals.back().value_keyword = s_current_value;
- intervals.back().value_is_keyword = "" != s_current_value;
+ intervals_.push_back(dummy);
+ intervals_.back().value_number = n_current_value;
+ intervals_.back().value_keyword = s_current_value;
+ intervals_.back().value_is_keyword = "" != s_current_value;
std::vector<double>::const_iterator n_vi;
std::vector<std::string>::const_iterator s_vi;
@@ -279,17 +279,17 @@ InputSequence::InputSequence
s_current_value = *s_vi;
if(n_prior_value == n_current_value && s_prior_value ==
s_current_value)
{
- ++intervals.back().end_duration;
+ ++intervals_.back().end_duration;
}
else
{
- int value_change_duration = intervals.back().end_duration;
- intervals.push_back(dummy);
- intervals.back().value_number = n_current_value;
- intervals.back().value_keyword = s_current_value;
- intervals.back().value_is_keyword = "" != s_current_value;
- intervals.back().begin_duration = value_change_duration;
- intervals.back().end_duration = ++value_change_duration;
+ int value_change_duration = intervals_.back().end_duration;
+ intervals_.push_back(dummy);
+ intervals_.back().value_number = n_current_value;
+ intervals_.back().value_keyword = s_current_value;
+ intervals_.back().value_is_keyword = "" != s_current_value;
+ intervals_.back().begin_duration = value_change_duration;
+ intervals_.back().end_duration = ++value_change_duration;
n_prior_value = n_current_value;
s_prior_value = s_current_value;
}
@@ -304,18 +304,18 @@ void InputSequence::realize_vector()
{
// Post-construction invariants.
// Every ctor must already have established this...
- LMI_ASSERT(!intervals.empty());
+ LMI_ASSERT(!intervals_.empty());
// ...and this:
- LMI_ASSERT(years_to_maturity == intervals.back().end_duration);
+ LMI_ASSERT(years_to_maturity_ == intervals_.back().end_duration);
// It cannot be assumed that all ctors have yet established this...
- intervals.back().end_mode = e_maturity;
+ intervals_.back().end_mode = e_maturity;
// ...though now of course it has been established:
- LMI_ASSERT(e_maturity == intervals.back().end_mode );
+ LMI_ASSERT(e_maturity == intervals_.back().end_mode );
- std::vector<double> r(years_to_maturity);
- std::vector<std::string> s(years_to_maturity, default_keyword);
- number_result = r;
- keyword_result = s;
+ std::vector<double> r(years_to_maturity_);
+ std::vector<std::string> s(years_to_maturity_, default_keyword_);
+ number_result_ = r;
+ keyword_result_ = s;
// Vectors have default values if the input expression could not be parsed.
if(!formatted_diagnostics().empty())
@@ -324,7 +324,7 @@ void InputSequence::realize_vector()
}
int prior_begin_duration = 0;
- for(auto const& interval_i : intervals)
+ for(auto const& interval_i : intervals_)
{
if(interval_i.insane)
{
@@ -380,7 +380,7 @@ void InputSequence::realize_vector()
bool interval_is_ok =
0 <= interval_i.begin_duration
&& interval_i.begin_duration <= interval_i.end_duration
- && interval_i.end_duration <= years_to_maturity
+ && interval_i.end_duration <= years_to_maturity_
;
if(!interval_is_ok)
{
@@ -410,8 +410,8 @@ void InputSequence::realize_vector()
}
}
- number_result = r;
- keyword_result = s;
+ number_result_ = r;
+ keyword_result_ = s;
}
// GRAMMAR interval-begin: one of [ (
@@ -428,44 +428,44 @@ void InputSequence::realize_vector()
void SequenceParser::duration_scalar()
{
- switch(current_token_type)
+ switch(current_token_type_)
{
case e_age_prefix:
{
- current_duration_scalar_mode = e_attained_age;
- match(current_token_type);
+ current_duration_scalar_mode_ = e_attained_age;
+ match(current_token_type_);
}
break;
case e_cardinal_prefix:
{
- current_duration_scalar_mode = e_number_of_years;
- match(current_token_type);
+ current_duration_scalar_mode_ = e_number_of_years;
+ match(current_token_type_);
}
break;
case e_number:
{
- current_duration_scalar_mode = e_duration;
+ current_duration_scalar_mode_ = e_duration;
}
break;
case e_keyword:
{
- if("retirement" == current_keyword)
+ if("retirement" == current_keyword_)
{
- current_duration_scalar_mode = e_retirement;
- current_duration_scalar = retirement_age - issue_age;
+ current_duration_scalar_mode_ = e_retirement;
+ current_duration_scalar_ = retirement_age_ - issue_age_;
match(e_keyword);
return;
}
- else if("maturity" == current_keyword)
+ else if("maturity" == current_keyword_)
{
- current_duration_scalar_mode = e_maturity;
- current_duration_scalar = years_to_maturity;
+ current_duration_scalar_mode_ = e_maturity;
+ current_duration_scalar_ = years_to_maturity_;
match(e_keyword);
return;
}
else
{
- diagnostics
+ diagnostics_
<< "Expected keyword "
<< "'retirement' "
<< " or 'maturity'. "
@@ -476,15 +476,15 @@ void SequenceParser::duration_scalar()
break;
default:
{
- diagnostics << "Expected keyword, number, '@', or '#'. ";
+ diagnostics_ << "Expected keyword, number, '@', or '#'. ";
mark_diagnostic_context();
}
}
- current_duration_scalar = static_cast<int>(current_number);
+ current_duration_scalar_ = static_cast<int>(current_number_);
match(e_number);
- switch(current_duration_scalar_mode)
+ switch(current_duration_scalar_mode_)
{
case e_duration:
{
@@ -493,17 +493,17 @@ void SequenceParser::duration_scalar()
break;
case e_attained_age:
{
- current_duration_scalar -= issue_age;
+ current_duration_scalar_ -= issue_age_;
}
break;
case e_number_of_years:
{
- current_duration_scalar += last_input_duration;
+ current_duration_scalar_ += last_input_duration_;
}
break;
default:
{
- diagnostics << "Expected number, '@', or '#'. ";
+ diagnostics_ << "Expected number, '@', or '#'. ";
mark_diagnostic_context();
}
}
@@ -511,9 +511,9 @@ void SequenceParser::duration_scalar()
void SequenceParser::null_duration()
{
- int tentative_begin_duration = last_input_duration++;
- duration_mode tentative_begin_duration_mode =
previous_duration_scalar_mode;
- int tentative_end_duration = last_input_duration;
+ int tentative_begin_duration = last_input_duration_++;
+ duration_mode tentative_begin_duration_mode =
previous_duration_scalar_mode_;
+ int tentative_end_duration = last_input_duration_;
duration_mode tentative_end_duration_mode = e_duration;
validate_duration
(tentative_begin_duration
@@ -528,14 +528,14 @@ void SequenceParser::null_duration()
void SequenceParser::single_duration()
{
duration_scalar();
- int tentative_begin_duration = last_input_duration;
-// last_input_duration += static_cast<int>(current_duration_scalar);
-// last_input_duration = static_cast<int>(current_duration_scalar);
+ int tentative_begin_duration = last_input_duration_;
+// last_input_duration_ += static_cast<int>(current_duration_scalar_);
+// last_input_duration_ = static_cast<int>(current_duration_scalar_);
// duration_mode tentative_begin_duration_mode = e_duration;
- duration_mode tentative_begin_duration_mode =
previous_duration_scalar_mode;
- int tentative_end_duration = current_duration_scalar;
-// int tentative_end_duration = last_input_duration +
static_cast<int>(current_duration_scalar);
- duration_mode tentative_end_duration_mode = current_duration_scalar_mode;
+ duration_mode tentative_begin_duration_mode =
previous_duration_scalar_mode_;
+ int tentative_end_duration = current_duration_scalar_;
+// int tentative_end_duration = last_input_duration_ +
static_cast<int>(current_duration_scalar_);
+ duration_mode tentative_end_duration_mode =
current_duration_scalar_mode_;
validate_duration
(tentative_begin_duration
,tentative_begin_duration_mode
@@ -548,35 +548,35 @@ void SequenceParser::single_duration()
void SequenceParser::intervalic_duration()
{
- bool begin_excl = (e_begin_excl == current_token_type);
- match(current_token_type);
+ bool begin_excl = (e_begin_excl == current_token_type_);
+ match(current_token_type_);
duration_scalar();
// Add one to the interval-beginning if it was expressed
// as exclusive, because we store [begin, end).
int tentative_begin_duration =
- static_cast<int>(current_duration_scalar)
+ static_cast<int>(current_duration_scalar_)
+ begin_excl
;
- duration_mode tentative_begin_duration_mode = current_duration_scalar_mode;
+ duration_mode tentative_begin_duration_mode =
current_duration_scalar_mode_;
int tentative_end_duration = -1;
duration_mode tentative_end_duration_mode = e_invalid_mode;
match(e_minor_separator); // TODO ?? Require this?
duration_scalar();
if
- ( e_end_incl == current_token_type
- || e_end_excl == current_token_type
+ ( e_end_incl == current_token_type_
+ || e_end_excl == current_token_type_
)
{
- bool end_incl = (e_end_incl == current_token_type);
- match(current_token_type);
+ bool end_incl = (e_end_incl == current_token_type_);
+ match(current_token_type_);
// Add one to the interval-end if it was expressed
// as inclusive, because we store [begin, end).
- tentative_end_duration = current_duration_scalar + end_incl;
- tentative_end_duration_mode = current_duration_scalar_mode;
+ tentative_end_duration = current_duration_scalar_ + end_incl;
+ tentative_end_duration_mode = current_duration_scalar_mode_;
}
else
{
- diagnostics << "Expected ')' or ']'. ";
+ diagnostics_ << "Expected ')' or ']'. ";
mark_diagnostic_context();
return;
}
@@ -597,8 +597,8 @@ void SequenceParser::validate_duration
{
if(tentative_begin_duration < 0)
{
- current_interval.insane = true;
- diagnostics
+ current_interval_.insane = true;
+ diagnostics_
<< "Interval "
<< "[ " << tentative_begin_duration << ", "
<< tentative_end_duration << " )"
@@ -616,8 +616,8 @@ void SequenceParser::validate_duration
// [B, E) is improper if B == E.
else if(tentative_end_duration <= tentative_begin_duration)
{
- current_interval.insane = true;
- diagnostics
+ current_interval_.insane = true;
+ diagnostics_
<< "Interval "
<< "[ " << tentative_begin_duration << ", "
<< tentative_end_duration << " )"
@@ -627,10 +627,10 @@ void SequenceParser::validate_duration
mark_diagnostic_context();
return;
}
- else if(years_to_maturity < tentative_end_duration)
+ else if(years_to_maturity_ < tentative_end_duration)
{
- current_interval.insane = true;
- diagnostics
+ current_interval_.insane = true;
+ diagnostics_
<< "Interval "
<< "[ " << tentative_begin_duration << ", "
<< tentative_end_duration << " )"
@@ -645,8 +645,8 @@ void SequenceParser::validate_duration
|| e_invalid_mode == tentative_end_duration_mode
)
{
- current_interval.insane = true;
- diagnostics
+ current_interval_.insane = true;
+ diagnostics_
<< "Interval "
<< "[ " << tentative_begin_duration << ", "
<< tentative_end_duration << " )"
@@ -657,17 +657,17 @@ void SequenceParser::validate_duration
}
else
{
- current_interval.begin_duration = tentative_begin_duration ;
- current_interval.end_duration = tentative_end_duration ;
- current_interval.begin_mode = tentative_begin_duration_mode;
- current_interval.end_mode = tentative_end_duration_mode ;
- last_input_duration = current_interval.end_duration;
+ current_interval_.begin_duration = tentative_begin_duration ;
+ current_interval_.end_duration = tentative_end_duration ;
+ current_interval_.begin_mode = tentative_begin_duration_mode;
+ current_interval_.end_mode = tentative_end_duration_mode ;
+ last_input_duration_ = current_interval_.end_duration;
}
}
void SequenceParser::duration()
{
- switch(current_token_type)
+ switch(current_token_type_)
{
case e_eof:
case e_major_separator:
@@ -691,13 +691,13 @@ void SequenceParser::duration()
break;
default:
{
- diagnostics
+ diagnostics_
<< "Expected number, '[', '(', 'retirement', or 'maturity'. "
;
mark_diagnostic_context();
}
}
- previous_duration_scalar_mode = current_duration_scalar_mode;
+ previous_duration_scalar_mode_ = current_duration_scalar_mode_;
}
// GRAMMAR value: floating-point-number
@@ -705,61 +705,61 @@ void SequenceParser::duration()
void SequenceParser::value()
{
- switch(current_token_type)
+ switch(current_token_type_)
{
case e_number:
{
- current_interval.value_is_keyword = false;
- if(keywords_only)
+ current_interval_.value_is_keyword = false;
+ if(keywords_only_)
{
- diagnostics
+ diagnostics_
<< "Expected keyword chosen from { "
;
std::copy
- (allowed_keywords.begin()
- ,allowed_keywords.end()
- ,std::ostream_iterator<std::string>(diagnostics, " ")
+ (allowed_keywords_.begin()
+ ,allowed_keywords_.end()
+ ,std::ostream_iterator<std::string>(diagnostics_, " ")
);
- diagnostics << "}. ";
+ diagnostics_ << "}. ";
mark_diagnostic_context();
break;
}
- current_interval.value_number = current_number;
- match(current_token_type);
+ current_interval_.value_number = current_number_;
+ match(current_token_type_);
}
break;
case e_keyword:
{
- current_interval.value_is_keyword = true;
- if(allowed_keywords.empty())
+ current_interval_.value_is_keyword = true;
+ if(allowed_keywords_.empty())
{
- diagnostics << "Expected number. ";
+ diagnostics_ << "Expected number. ";
mark_diagnostic_context();
break;
}
- if(contains(allowed_keywords, current_keyword))
+ if(contains(allowed_keywords_, current_keyword_))
{
- current_interval.value_keyword = current_keyword;
- match(current_token_type);
+ current_interval_.value_keyword = current_keyword_;
+ match(current_token_type_);
}
else
{
- diagnostics
+ diagnostics_
<< "Expected keyword chosen from { "
;
std::copy
- (allowed_keywords.begin()
- ,allowed_keywords.end()
- ,std::ostream_iterator<std::string>(diagnostics, " ")
+ (allowed_keywords_.begin()
+ ,allowed_keywords_.end()
+ ,std::ostream_iterator<std::string>(diagnostics_, " ")
);
- diagnostics << "}. ";
+ diagnostics_ << "}. ";
mark_diagnostic_context();
}
}
break;
default:
{
- diagnostics << "Expected number or keyword. ";
+ diagnostics_ << "Expected number or keyword. ";
mark_diagnostic_context();
}
}
@@ -771,9 +771,9 @@ void SequenceParser::value()
void SequenceParser::span()
{
// Assume interval is sane until shown otherwise.
- current_interval.insane = false;
+ current_interval_.insane = false;
value();
- switch(current_token_type)
+ switch(current_token_type_)
{
case e_minor_separator:
{
@@ -795,16 +795,16 @@ void SequenceParser::span()
break;
default:
{
- diagnostics
+ diagnostics_
<< "Expected ';', ',', '@', '#', '[', '(',"
<< " number, 'retirement', or 'maturity'. "
;
mark_diagnostic_context();
}
}
- if(!current_interval.insane)
+ if(!current_interval_.insane)
{
- intervals.push_back(current_interval);
+ intervals_.push_back(current_interval_);
}
}
@@ -817,18 +817,18 @@ void SequenceParser::sequence()
// Numbers should always be set explicitly, so we initialize
// them to recognizable, implausible values. Set the 'insane'
// flag: assume the sequence is insane until known otherwise.
- current_interval.value_number = -999999999999.999;
- current_interval.value_keyword = "daft";
- current_interval.value_is_keyword = true;
- current_interval.begin_duration = -1;
- current_interval.begin_mode = e_invalid_mode;
- current_interval.end_duration = -2;
- current_interval.end_mode = e_invalid_mode;
- current_interval.insane = true;
+ current_interval_.value_number = -999999999999.999;
+ current_interval_.value_keyword = "daft";
+ current_interval_.value_is_keyword = true;
+ current_interval_.begin_duration = -1;
+ current_interval_.begin_mode = e_invalid_mode;
+ current_interval_.end_duration = -2;
+ current_interval_.end_mode = e_invalid_mode;
+ current_interval_.insane = true;
for(;;)
{
- switch(current_token_type)
+ switch(current_token_type_)
{
case e_eof:
{
@@ -836,8 +836,8 @@ void SequenceParser::sequence()
}
case e_major_separator:
{
- match(current_token_type);
- if(e_eof == current_token_type)
+ match(current_token_type_);
+ if(e_eof == current_token_type_)
{
return;
}
@@ -847,8 +847,8 @@ void SequenceParser::sequence()
// TODO ?? Superfluous. Same comment elsewhere. Fall through instead.
case e_startup:
{
- match(current_token_type);
- if(e_eof == current_token_type)
+ match(current_token_type_);
+ if(e_eof == current_token_type_)
{
return;
}
@@ -857,7 +857,7 @@ void SequenceParser::sequence()
break;
default:
{
- diagnostics << "Expected ';'. ";
+ diagnostics_ << "Expected ';'. ";
mark_diagnostic_context();
return;
}
@@ -870,7 +870,7 @@ SequenceParser::token_type SequenceParser::get_token()
char c = '\0';
do
{
- if(!input_stream.get(c))
+ if(!input_stream_.get(c))
{
// COMPILER !! bc++5.02 puts garbage into 'c': reset to '\0'.
// I believe [27.6.1.3] doesn't allow the garbage.
@@ -884,7 +884,7 @@ SequenceParser::token_type SequenceParser::get_token()
{
case 0:
{
- return current_token_type = e_eof;
+ return current_token_type_ = e_eof;
}
case e_major_separator:
case e_minor_separator:
@@ -895,24 +895,24 @@ SequenceParser::token_type SequenceParser::get_token()
case e_age_prefix:
case e_cardinal_prefix:
{
- return current_token_type = token_type(c);
+ return current_token_type_ = token_type(c);
}
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
case '.': case '-':
{
- input_stream.putback(c);
+ input_stream_.putback(c);
// TODO ?? Assigning 0.0 here at least gives a predictable
// value upon failure. We can't read both '.' and the
// following character and then reliably put both back.
- current_number = 0.0;
- input_stream >> current_number;
- if(input_stream.fail())
+ current_number_ = 0.0;
+ input_stream_ >> current_number_;
+ if(input_stream_.fail())
{
- diagnostics << "Invalid number '" << c << "'. ";
+ diagnostics_ << "Invalid number '" << c << "'. ";
mark_diagnostic_context();
}
- return current_token_type = e_number;
+ return current_token_type_ = e_number;
}
// An arbitrary rule must be selected for keyword names;
// we choose the regexp '[a-z][a-z0-9_]*'.
@@ -923,9 +923,9 @@ SequenceParser::token_type SequenceParser::get_token()
case 'u': case 'v': case 'w': case 'x': case 'y':
case 'z':
{
- current_keyword = c;
+ current_keyword_ = c;
while
- ( input_stream.get(c)
+ ( input_stream_.get(c)
&& ((is_ok_for_cctype(c) && std::isalnum(c)) || '_' == c)
)
{
@@ -934,16 +934,16 @@ SequenceParser::token_type SequenceParser::get_token()
// whence this and other ideas are borrowed, but gcc-2.95.x
// seems not to support it; operator+=() is likely to be
// implemented the same way anyway.
- current_keyword += c;
+ current_keyword_ += c;
}
- input_stream.putback(c);
- return current_token_type = e_keyword;
+ input_stream_.putback(c);
+ return current_token_type_ = e_keyword;
}
default:
{
- diagnostics << "Unknown token '" << c << "'. ";
+ diagnostics_ << "Unknown token '" << c << "'. ";
mark_diagnostic_context();
- return current_token_type = token_type(0);
+ return current_token_type_ = token_type(0);
}
}
}
@@ -990,13 +990,13 @@ std::string
SequenceParser::token_type_name(SequenceParser::token_type t)
void SequenceParser::match(SequenceParser::token_type t)
{
- if(current_token_type == t)
+ if(current_token_type_ == t)
{
- current_token_type = get_token();
+ current_token_type_ = get_token();
}
else
{
- diagnostics
+ diagnostics_
<< "Expected '"
<< token_type_name(t)
<< "' . "
@@ -1007,10 +1007,10 @@ void SequenceParser::match(SequenceParser::token_type t)
void SequenceParser::mark_diagnostic_context()
{
- diagnostics
+ diagnostics_
<< "Current token '"
- << token_type_name(current_token_type)
- << "' at position " << input_stream.tellg()
+ << token_type_name(current_token_type_)
+ << "' at position " << input_stream_.tellg()
<< ".\n"
;
}
@@ -1022,7 +1022,7 @@ std::string InputSequence::formatted_diagnostics
(bool show_first_message_only
) const
{
- std::string s(EXPEDIENTdiagnostics);
+ std::string s(EXPEDIENTdiagnostics_);
if(show_first_message_only)
{
std::string::size_type z(s.find('\n'));
@@ -1036,12 +1036,12 @@ std::string InputSequence::formatted_diagnostics
std::vector<double> const& InputSequence::linear_number_representation() const
{
- return number_result;
+ return number_result_;
}
std::vector<std::string> const& InputSequence::linear_keyword_representation()
const
{
- return keyword_result;
+ return keyword_result_;
}
/// Regularized representation in [x,y) interval notation.
@@ -1064,7 +1064,7 @@ std::vector<std::string> const&
InputSequence::linear_keyword_representation() c
std::string InputSequence::mathematical_representation() const
{
std::ostringstream oss;
- for(auto const& interval_i : intervals)
+ for(auto const& interval_i : intervals_)
{
if(interval_i.value_is_keyword)
{
@@ -1075,12 +1075,12 @@ std::string
InputSequence::mathematical_representation() const
oss << value_cast<std::string>(interval_i.value_number);
}
- if(1 == intervals.size())
+ if(1 == intervals_.size())
{
break;
}
- if(interval_i.end_duration != years_to_maturity)
+ if(interval_i.end_duration != years_to_maturity_)
{
oss
<< " ["
@@ -1106,6 +1106,6 @@ std::string InputSequence::mathematical_representation()
const
std::vector<ValueInterval> const& InputSequence::interval_representation()
const
{
- return intervals;
+ return intervals_;
}
diff --git a/input_sequence.hpp b/input_sequence.hpp
index a4bea13..a85ff32 100644
--- a/input_sequence.hpp
+++ b/input_sequence.hpp
@@ -225,29 +225,29 @@ class SequenceParser
void mark_diagnostic_context();
- std::istringstream input_stream;
+ std::istringstream input_stream_;
// Copies of ctor args that are identical to class InputSequence's.
- int years_to_maturity;
- int issue_age;
- int retirement_age;
- int inforce_duration;
- int effective_year;
- std::vector<std::string> allowed_keywords;
- bool keywords_only;
-
- token_type current_token_type;
- double current_number;
- std::string current_keyword;
- int current_duration_scalar;
- duration_mode previous_duration_scalar_mode;
- duration_mode current_duration_scalar_mode;
- ValueInterval current_interval;
- int last_input_duration;
-
- std::ostringstream diagnostics;
-
- std::vector<ValueInterval> intervals;
+ int years_to_maturity_;
+ int issue_age_;
+ int retirement_age_;
+ int inforce_duration_;
+ int effective_year_;
+ std::vector<std::string> allowed_keywords_;
+ bool keywords_only_;
+
+ token_type current_token_type_;
+ double current_number_;
+ std::string current_keyword_;
+ int current_duration_scalar_;
+ duration_mode previous_duration_scalar_mode_;
+ duration_mode current_duration_scalar_mode_;
+ ValueInterval current_interval_;
+ int last_input_duration_;
+
+ std::ostringstream diagnostics_;
+
+ std::vector<ValueInterval> intervals_;
};
class LMI_SO InputSequence
@@ -289,21 +289,21 @@ class LMI_SO InputSequence
void realize_vector();
// Copies of ctor args that are identical to class SequenceParser's.
- int years_to_maturity;
- int issue_age;
- int retirement_age;
- int inforce_duration;
- int effective_year;
- std::vector<std::string> allowed_keywords;
- bool keywords_only;
+ int years_to_maturity_;
+ int issue_age_;
+ int retirement_age_;
+ int inforce_duration_;
+ int effective_year_;
+ std::vector<std::string> allowed_keywords_;
+ bool keywords_only_;
// Copy of a ctor arg that is unique to this class.
- std::string default_keyword;
+ std::string default_keyword_;
- std::string EXPEDIENTdiagnostics;
+ std::string EXPEDIENTdiagnostics_;
- std::vector<ValueInterval> intervals;
- std::vector<double> number_result;
- std::vector<std::string> keyword_result;
+ std::vector<ValueInterval> intervals_;
+ std::vector<double> number_result_;
+ std::vector<std::string> keyword_result_;
};
#endif // input_sequence_hpp