diff options
| author | Roland Reichwein <mail@reichwein.it> | 2020-01-14 22:24:50 +0100 | 
|---|---|---|
| committer | Roland Reichwein <mail@reichwein.it> | 2020-01-14 22:24:50 +0100 | 
| commit | 44b2cf820149eb751474d9ccd2746359da73a4e9 (patch) | |
| tree | 1aefe20b72a7320cd7c0b8a94b4f13daf1a6e9f0 | |
| parent | 76363501a43fa1743b0685dc32d43b3c0f5f0bf1 (diff) | |
Lex (WIP)
| -rw-r--r-- | minicc.cpp | 13 | 
1 files changed, 9 insertions, 4 deletions
| @@ -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) | 
