Skip to content

Commit

Permalink
fix i triggering eof message
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdruppe committed Jun 23, 2024
1 parent 8f01b25 commit 1986ea8
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions compiler/src/dmd/lexer.d
Original file line number Diff line number Diff line change
Expand Up @@ -586,25 +586,7 @@ class Lexer
case '_':
case_ident:
{
while (1)
{
const c = *++p;
if (isidchar(c))
continue;
else if (c & 0x80)
{
const s = p;
const u = decodeUTF();
if (isUniAlpha(u))
continue;
error(t.loc, "char 0x%04x not allowed in identifier", u);
p = s;
}
break;
}
Identifier id = Identifier.idPool((cast(char*)t.ptr)[0 .. p - t.ptr], false);
t.ident = id;
t.value = cast(TOK)id.getValue();
Identifier id = lexIdent(t);

anyToken = 1;

Expand Down Expand Up @@ -1216,6 +1198,31 @@ class Lexer
return t;
}

private Identifier lexIdent(Token* t)
{
while (1)
{
const c = *++p;
if (isidchar(c))
continue;
else if (c & 0x80)
{
const s = p;
const u = decodeUTF();
if (isUniAlpha(u))
continue;
error(t.loc, "char 0x%04x not allowed in identifier", u);
p = s;
}
break;
}
Identifier id = Identifier.idPool((cast(char*)t.ptr)[0 .. p - t.ptr], false);
t.ident = id;
t.value = cast(TOK)id.getValue();

return id;
}

/*********************************
* tk is on the opening (.
* Look ahead and return token that is past the closing ).
Expand Down Expand Up @@ -1893,8 +1900,12 @@ class Lexer

// identifier, scan it with the lexer to follow all rules
auto pstart = p;

Token tok;
scan(&tok);
tok.ptr = p;
tok.loc = loc();
lexIdent(&tok);
assert (tok.value == TOK.identifier);

// then put the interpolated string segment
token.appendInterpolatedPart(pstart[0 .. p - pstart]);
Expand Down

0 comments on commit 1986ea8

Please sign in to comment.