From 44b2cf820149eb751474d9ccd2746359da73a4e9 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Tue, 14 Jan 2020 22:24:50 +0100 Subject: Lex (WIP) --- minicc.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'minicc.cpp') 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 Lex(std::string s, std::string Top, BNF bnf) { + std::vector 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 Tokens, std::string Top, BNF bnf, Terminals terminals) -- cgit v1.2.3