-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
J Ninja
committed
Jun 27, 2019
1 parent
e7fbd13
commit acb1e54
Showing
8 changed files
with
172 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <sstream> | ||
#include <string> | ||
|
||
using std::vector; | ||
using std::string; | ||
|
||
namespace Lexer | ||
{ | ||
vector<string> strip_lines(const string& encoded_or_fname) | ||
{ | ||
vector<string> lines; | ||
std::stringstream ss(encoded_or_fname); | ||
string line = ""; | ||
|
||
while (std::getline(ss, line, '\n')) | ||
lines.push_back(line); | ||
|
||
return lines; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
|
||
#include "hexagram.h" | ||
|
||
using std::vector; | ||
|
||
namespace Parser | ||
{ | ||
static vector<string> lines_to_hexagrams(const vector<string>& lines) | ||
{ | ||
vector<string> continuous_hexagrams(NUM_HEXAGRAM_LINES); | ||
int i = 0; | ||
for (const string& line : lines) { | ||
i = i % NUM_HEXAGRAM_LINES == 0 ? 0 : i; | ||
continuous_hexagrams[i] += line; | ||
i += 1; | ||
} | ||
|
||
vector<string> hexagrams; | ||
for (size_t offset = 0; offset < continuous_hexagrams[0].length(); offset += HEXAGRAM_WIDTH) { | ||
string hexagram = ""; | ||
for (const string& line : continuous_hexagrams) { | ||
for (size_t j = offset; j < offset + HEXAGRAM_WIDTH; j++) | ||
hexagram += line[j]; | ||
hexagram += "\n"; | ||
} | ||
hexagrams.push_back(hexagram); | ||
} | ||
|
||
return hexagrams; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.