// Define some character classification predicates and
// conversions here to avoid dependences upon <cctype> and
// also to accomodate Fortran tokenization.
+// TODO: EBCDIC?
#include <cstddef>
#include <optional>
enum class Encoding { UTF8, EUC_JP };
inline constexpr bool IsUpperCaseLetter(char ch) {
- if constexpr ('A' == static_cast<char>(0xc1)) {
- // EBCDIC
- // TODO: Handle EBCDIC in a more generalized character set
- // encoding framework; don't just assume that the native
- // C++ character set is the same as that of the Fortran source.
- return (ch >= 'A' && ch <= 'I') || (ch >= 'J' && ch <= 'R') ||
- (ch >= 'S' && ch <= 'Z');
- } else {
- return ch >= 'A' && ch <= 'Z';
- }
+ return ch >= 'A' && ch <= 'Z';
}
inline constexpr bool IsLowerCaseLetter(char ch) {
- if constexpr ('a' == static_cast<char>(0x81)) {
- // EBCDIC
- return (ch >= 'a' && ch <= 'i') || (ch >= 'j' && ch <= 'r') ||
- (ch >= 's' && ch <= 'z');
- } else {
- return ch >= 'a' && ch <= 'z';
- }
+ return ch >= 'a' && ch <= 'z';
}
inline constexpr bool IsLetter(char ch) {
return IsLowerCaseLetter(ch) ? ch - 'a' + 'A' : ch;
}
-static inline std::string ToUpperCaseLetters(const std::string &str) {
+inline std::string ToUpperCaseLetters(const std::string &str) {
std::string raised{str};
for (char &ch : raised) {
ch = ToUpperCaseLetter(ch);
: IsLowerCaseLetter(ch) ? ch - 'a' + 10 : DecimalDigitValue(ch);
}
-constexpr std::optional<char> BackslashEscapeValue(char ch) {
+inline constexpr std::optional<char> BackslashEscapeValue(char ch) {
switch (ch) {
// case 'a': return {'\a'}; pgf90 doesn't know about \a
case 'b': return {'\b'};
}
}
-constexpr std::optional<char> BackslashEscapeChar(char ch) {
+inline constexpr std::optional<char> BackslashEscapeChar(char ch) {
switch (ch) {
// case '\a': return {'a'}; pgf90 doesn't know about \a
case '\b': return {'b'};
#include <cstddef>
#include <cstdio>
#include <cstring>
+#include <string>
namespace Fortran {
namespace parser {
bool isExpected{isExpected_};
if (string_.empty()) {
if (fixedText_ != nullptr) {
- if (fixedBytes_ > 0 &&
- fixedBytes_ < std::numeric_limits<std::size_t>::max()) {
+ if (fixedBytes_ > 0 && fixedBytes_ < std::string::npos) {
s = std::string(fixedText_, fixedBytes_);
} else {
s = std::string{fixedText_}; // NUL-terminated
// Skips a space that in free form requires a warning if it precedes a
// character that could begin an identifier or keyword. Always succeeds.
-static inline void MissingSpace(ParseState *state) {
+inline void MissingSpace(ParseState *state) {
if (!state->inFixedForm()) {
state->set_anyConformanceViolation();
if (state->warnOnNonstandardUsage()) {
private:
const char *const str_;
- const std::size_t bytes_{std::numeric_limits<std::size_t>::max()};
+ const std::size_t bytes_{std::string::npos};
const bool mandatoryFreeFormSpace_;
};