1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

[FunC] Reserve '!' for the future, identifiers can't start with it

This commit is contained in:
Aleksandr Kirsanov 2024-06-22 01:19:57 +03:00
parent 79721d230e
commit e2467b8ba4
No known key found for this signature in database
GPG key ID: B758BBAA01FFB3D3
6 changed files with 48 additions and 7 deletions

View file

@ -311,12 +311,16 @@ const Lexem& Lexer::next() {
return lexem;
}
int len = 0, pc = -0x100;
bool starts_with_excl = false;
while (end < src.get_end_ptr()) {
c = *end;
bool repeated = (c == pc && is_repeatable(c));
if (c == ' ' || c == 9 || (len && is_left_active(c) && !repeated)) {
break;
}
if (c == '!' && !len) {
starts_with_excl = true;
}
++len;
++end;
if (is_right_active(c) && !repeated) {
@ -325,6 +329,9 @@ const Lexem& Lexer::next() {
pc = c;
}
lexem.set(std::string{src.get_ptr(), end}, src.here());
if (starts_with_excl && is_FunC() && lexem.str != "!=") {
throw ParseError(lexem.loc, "'!' is reserved for the future, don't use it in FunC code");
}
src.set_ptr(end);
// std::cerr << lexem.name_str() << ' ' << lexem.str << std::endl;
return lexem;