Parsing 95% complete, only missing string parsing
parent
88bd82b762
commit
c4b515491a
10
src/lang.cc
10
src/lang.cc
|
@ -40,8 +40,6 @@ int parse_line(std::string line, int row) {
|
|||
struct parsed_token parsed {
|
||||
empty_token, empty_token
|
||||
};
|
||||
if (line.length() == 0)
|
||||
return 0;
|
||||
std::deque<std::string> tokens;
|
||||
int start = 0;
|
||||
size_t end = line.find(" ");
|
||||
|
@ -50,6 +48,7 @@ int parse_line(std::string line, int row) {
|
|||
start = end + 1;
|
||||
end = line.find(" ", start);
|
||||
}
|
||||
tokens.push_back(line.substr(start));
|
||||
for (std::string &token : tokens) {
|
||||
if (token == "//")
|
||||
return 0;
|
||||
|
@ -57,9 +56,6 @@ int parse_line(std::string line, int row) {
|
|||
try {
|
||||
Token curr_token = CV_Tokens.at(token);
|
||||
parsed.last_token = parsed.current_token;
|
||||
if (curr_token == parsed.last_token &&
|
||||
curr_token.type == TokenType::SPACE)
|
||||
continue;
|
||||
parsed.current_token = curr_token;
|
||||
switch (parsed.current_token.type) {
|
||||
case TokenType::COLONCOLON: {
|
||||
|
@ -87,6 +83,8 @@ int parse_line(std::string line, int row) {
|
|||
ctoken);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (parsed.current_token.intrinsic) {
|
||||
case Intrinsic::INCLUDE: {
|
||||
|
@ -146,7 +144,7 @@ int parse_line(std::string line, int row) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
} catch (std::out_of_range &oor) {
|
||||
} catch (std::out_of_range) {
|
||||
// this is most likely a variable or a string
|
||||
ferr("%s: Invalid token `%s'.\n", here(row, col), ctoken);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue