summaryrefslogtreecommitdiffhomepage
path: root/minicc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'minicc.cpp')
-rw-r--r--minicc.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/minicc.cpp b/minicc.cpp
index f283e1f..07090a8 100644
--- a/minicc.cpp
+++ b/minicc.cpp
@@ -37,17 +37,22 @@ BNF Reverse(BNF bnf){
std::vector<std::string> Lex(std::string s, std::string Top, BNF bnf)
{
+ std::vector<std::string> result;
+ std::string token;
+
BNF ReverseBNF{ Reverse(bnf)};
- size_t pos{0};
+ std::string Whitespace{"\t \n\r"};
- while (pos < s.size()) {
+ for (size_t pos{0}; pos < s.size(); pos++) {
char c{s[pos]};
+ if (token.empty() and Whitespace.find(c) != std::string::npos)
+ continue; // skip whitespace between tokens
+
auto Path = GetPath(std::string{1, c}, ReverseBNF, Top);
- pos++;
}
- return {};
+ return result;
}
ProgramNode Compile(std::vector<std::string> Tokens, std::string Top, BNF bnf, Terminals terminals)