Allow underscores in idents
This commit is contained in:
parent
0cdf1abf82
commit
fa8c4b0e74
@ -159,13 +159,13 @@ namespace token {
|
||||
i++; // Skip second "
|
||||
tokens.push_back(token::Token{ token::Type::LiteralStr, content, meta + (content.size() + 2) });
|
||||
}
|
||||
else if (std::isalpha(c)) {
|
||||
else if (std::isalpha(c) || c == '_') {
|
||||
std::string content{};
|
||||
do {
|
||||
content += c;
|
||||
if ((i + 1) >= text_length) break;
|
||||
c = text[++i];
|
||||
} while (std::isalnum(c));
|
||||
} while (std::isalnum(c) || c == '_');
|
||||
|
||||
token::Type type = token::Type::Ident;
|
||||
if (content == "return") {
|
||||
|
||||
4
test.c
4
test.c
@ -6,13 +6,13 @@ int fibonacci(int n) {
|
||||
return fibonacci(n - 1) + fibonacci(n - 2);
|
||||
}
|
||||
|
||||
void modifyvalue(char* otus) {
|
||||
void modify_value(char* otus) {
|
||||
*otus = 20;
|
||||
}
|
||||
|
||||
int main() {
|
||||
printf("10th fibonacci number is %d!", fibonacci(10));
|
||||
char res = 10;
|
||||
modifyvalue(&res);
|
||||
modify_value(&res);
|
||||
return res;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user