Add \r skipping code from @jespada
This commit is contained in:
@@ -266,16 +266,27 @@ namespace chaiscript
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Skips ChaiScript whitespace, which means space and tab, but not cr/lf
|
/// Skips ChaiScript whitespace, which means space and tab, but not cr/lf
|
||||||
/// jespada: Modified SkipWS to skip optionally CR ('\n')
|
/// jespada: Modified SkipWS to skip optionally CR ('\n') and/or LF+CR ("\r\n")
|
||||||
bool SkipWS(const bool skip_cr=false) {
|
bool SkipWS(bool skip_cr=false) {
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
|
|
||||||
while (has_more_input()) {
|
while (has_more_input()) {
|
||||||
if ( char_in_alphabet(*m_input_pos,detail::white_alphabet) || (skip_cr && (*m_input_pos == '\n'))) {
|
auto end_line = (*m_input_pos != 0) && ((*m_input_pos == '\n') || (*m_input_pos == '\r' && *(m_input_pos+1) == '\n'));
|
||||||
if(*m_input_pos == '\n') {
|
|
||||||
|
if ( char_in_alphabet(*m_input_pos,detail::white_alphabet) || (skip_cr && end_line)) {
|
||||||
|
|
||||||
|
if(end_line) {
|
||||||
m_col = 1;
|
m_col = 1;
|
||||||
++m_line;
|
++m_line;
|
||||||
} else {
|
|
||||||
|
if(*(m_input_pos) == '\r') {
|
||||||
|
// discards lf
|
||||||
|
++m_input_pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
++m_col;
|
++m_col;
|
||||||
}
|
}
|
||||||
++m_input_pos;
|
++m_input_pos;
|
||||||
@@ -284,14 +295,14 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
else if (SkipComment()) {
|
else if (SkipComment()) {
|
||||||
retval = true;
|
retval = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Reads a floating point value from input, without skipping initial whitespace
|
/// Reads a floating point value from input, without skipping initial whitespace
|
||||||
bool Float_() {
|
bool Float_() {
|
||||||
if (has_more_input() && char_in_alphabet(*m_input_pos,detail::float_alphabet) ) {
|
if (has_more_input() && char_in_alphabet(*m_input_pos,detail::float_alphabet) ) {
|
||||||
|
Reference in New Issue
Block a user