diff options
author | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
commit | cfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch) | |
tree | 18d94153a302445196fc0c18586abf44a1ce4a38 /Sluift/tokenize.cpp | |
parent | 1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff) | |
download | swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2 |
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines
in the process.
Changed CheckTabs.py tool to disallow hard tabs in source
files.
Test-Information:
Manually checked 30 random files that the conversion worked
as expected.
Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Sluift/tokenize.cpp')
-rw-r--r-- | Sluift/tokenize.cpp | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/Sluift/tokenize.cpp b/Sluift/tokenize.cpp index e0252f7..ff162d6 100644 --- a/Sluift/tokenize.cpp +++ b/Sluift/tokenize.cpp @@ -13,75 +13,75 @@ using namespace Swift; namespace { - struct LuaTokenizeFunctor { - void reset() { - } + struct LuaTokenizeFunctor { + void reset() { + } - template<typename InputIterator, typename Token> - bool operator()(InputIterator& next, InputIterator& end, Token& result) { - while (next != end && std::isspace(*next)) { - ++next; - } - if (next == end) { - return false; - } + template<typename InputIterator, typename Token> + bool operator()(InputIterator& next, InputIterator& end, Token& result) { + while (next != end && std::isspace(*next)) { + ++next; + } + if (next == end) { + return false; + } - std::vector<char> token; - char c = *next++; - token.push_back(c); + std::vector<char> token; + char c = *next++; + token.push_back(c); - // String literal - if (c == '\'' || c == '"') { - char quote = c; - bool inEscape = false; - for (; next != end; ++next) { - c = *next; - token.push_back(c); - if (inEscape) { - inEscape = false; - } - else if (c == '\\') { - inEscape = true; - } - else if (c == quote) { - break; - } - } - if (next != end) { - ++next; - } - } - // Identifier - else if (std::isalpha(c) || c == '_') { - while (next != end && (std::isalpha(*next) || *next == '_' || std::isdigit(*next))) { - token.push_back(*next); - ++next; - } - } - // Digit - else if (std::isdigit(c)) { - while (next != end && !std::isspace(*next)) { - token.push_back(*next); - ++next; - } - } - // Dots - else if (c == '.') { - while (next != end && *next == '.') { - token.push_back(*next); - ++next; - } - } - - result = Token(&token[0], token.size()); - return true; - } - }; + // String literal + if (c == '\'' || c == '"') { + char quote = c; + bool inEscape = false; + for (; next != end; ++next) { + c = *next; + token.push_back(c); + if (inEscape) { + inEscape = false; + } + else if (c == '\\') { + inEscape = true; + } + else if (c == quote) { + break; + } + } + if (next != end) { + ++next; + } + } + // Identifier + else if (std::isalpha(c) || c == '_') { + while (next != end && (std::isalpha(*next) || *next == '_' || std::isdigit(*next))) { + token.push_back(*next); + ++next; + } + } + // Digit + else if (std::isdigit(c)) { + while (next != end && !std::isspace(*next)) { + token.push_back(*next); + ++next; + } + } + // Dots + else if (c == '.') { + while (next != end && *next == '.') { + token.push_back(*next); + ++next; + } + } + + result = Token(&token[0], token.size()); + return true; + } + }; } std::vector<std::string> Lua::tokenize(const std::string& input) { - boost::tokenizer<LuaTokenizeFunctor> tokenizer(input); - return std::vector<std::string>(tokenizer.begin(), tokenizer.end()); + boost::tokenizer<LuaTokenizeFunctor> tokenizer(input); + return std::vector<std::string>(tokenizer.begin(), tokenizer.end()); } |