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:
parent
79721d230e
commit
e2467b8ba4
6 changed files with 48 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue