删除Scanner.cpp
This commit is contained in:
parent
b6d6df0894
commit
61f5dde8c9
@ -1,94 +0,0 @@
|
||||
#include "Scanner.h"
|
||||
#include <sstream>
|
||||
|
||||
int Scanner::process_const_table(int index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Scanner::process_identifier_table(int index) {
|
||||
std::stringstream buffer;
|
||||
int old_index = index;
|
||||
if (std::isalpha(m_source_code[index])) {
|
||||
buffer << m_source_code[index];
|
||||
index += 1;
|
||||
while(std::isalnum(m_source_code[index])) {
|
||||
buffer << m_source_code[index];
|
||||
index += 1;
|
||||
}
|
||||
|
||||
std::string identifier = buffer.str();
|
||||
for (const auto& key : m_tables.KeyTable) {
|
||||
if (identifier == key.second) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
m_tables.IdTable.insert({identifier_index, identifier});
|
||||
m_token_list.push_back(Token{identifier_index, ID_TABLE});
|
||||
identifier_index++;
|
||||
return index - old_index;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int Scanner::process_key_table(int index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Scanner::process_punct_table(int index) {
|
||||
//identify the Punct in map
|
||||
string s;
|
||||
int n = this->m_source_code.size();
|
||||
char c1= this->m_source_code[index];
|
||||
char c2 = '@';
|
||||
char c3 = '@';
|
||||
if (index + 1 < n) c2 = this->m_source_code[index + 1];
|
||||
if (index + 2 < n) c3 = this->m_source_code[index + 2];
|
||||
if (((c1 == c2 && c2 == '<') || (c1 == c2&& c2 == '>'))&& c3 =='=') {
|
||||
this->m_token_list.push_back({c1=='<'?31:32,PUNCT_TABLE});
|
||||
return 3;
|
||||
}
|
||||
if (c1 == c2 ) {
|
||||
if (c1 =='=') {
|
||||
this->m_token_list.push_back({15,PUNCT_TABLE});
|
||||
return 2;
|
||||
}
|
||||
if (c1 =='|') {
|
||||
this->m_token_list.push_back({21,PUNCT_TABLE});
|
||||
return 2;
|
||||
}
|
||||
if (c1=='&') {
|
||||
this->m_token_list.push_back({20,PUNCT_TABLE});
|
||||
return 2;
|
||||
}
|
||||
if (c1=='<') {
|
||||
this->m_token_list.push_back({9,PUNCT_TABLE});
|
||||
return 2;
|
||||
}
|
||||
if (c1=='>') {
|
||||
this->m_token_list.push_back({10,PUNCT_TABLE});
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
string t;
|
||||
t.push_back(c1);
|
||||
t.push_back(c2);
|
||||
for (auto e : this->m_tables.PunctTable) {
|
||||
if (e.second == t) {
|
||||
this->m_token_list.push_back({e.first,PUNCT_TABLE});
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
t.pop_back();
|
||||
for (auto e : this->m_tables.PunctTable) {
|
||||
if (e.second == t) {
|
||||
this->m_token_list.push_back({e.first,PUNCT_TABLE});
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user