mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 07:18:39 +09:00
Issue #2559 - Implement hashbang grammar
This adds special-case #! comment handling at the top level, treating any hashbang line as a single-line comment in the parser. This only applies to Eval(), module script or global context.
This commit is contained in:
parent
9d6ffb5814
commit
7cc9551e79
5 changed files with 46 additions and 1 deletions
|
|
@ -1300,6 +1300,21 @@ TokenStream::putIdentInTokenbuf(const char16_t* identStart)
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
TokenStream::consumeOptionalHashbangComment() {
|
||||
int c = userbuf.getRawChar();
|
||||
if (c == '#') {
|
||||
if (matchChar('!')) {
|
||||
// Hashbang; ignore rest of line as comment.
|
||||
while ((c = getChar()) != EOF && c != '\n')
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ungetChar(c);
|
||||
cursor = (cursor - 1) & ntokensMask;
|
||||
}
|
||||
|
||||
|
||||
enum FirstCharKind {
|
||||
// A char16_t has the 'OneChar' kind if it, by itself, constitutes a valid
|
||||
// token that cannot also be a prefix of a longer token. E.g. ';' has the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue