@@ -1295,7 +1295,7 @@ static Token readIdentifier(char firstChar, bool raw) {
12951295 }
12961296
12971297 // Label scopes `.` and `..` are the only nonlocal identifiers that start with a dot
1298- if (identifier. find_first_not_of ( ' . ' ) == identifier. npos ) {
1298+ if (sym_IsDotScope ( identifier) ) {
12991299 tokenType = T_ (SYMBOL);
13001300 }
13011301
@@ -1939,11 +1939,12 @@ static Token yylex_NORMAL() {
19391939
19401940 // `token` is either a `SYMBOL` or a `LOCAL`, and both have a `std::string` value.
19411941 assume (std::holds_alternative<std::string>(token.value ));
1942+ std::string const &identifier = std::get<std::string>(token.value );
19421943
19431944 // Raw symbols and local symbols cannot be string expansions
19441945 if (!raw && token.type == T_ (SYMBOL) && lexerState->expandStrings ) {
19451946 // Attempt string expansion
1946- if (Symbol const *sym = sym_FindExactSymbol (std::get<std::string>(token. value ) );
1947+ if (Symbol const *sym = sym_FindExactSymbol (identifier );
19471948 sym && sym->type == SYM_EQUS) {
19481949 beginExpansion (sym->getEqus (), sym->name );
19491950 continue ; // Restart, reading from the new buffer
@@ -1954,6 +1955,7 @@ static Token yylex_NORMAL() {
19541955 // - label definitions (which are followed by a ':' and use the token `LABEL`)
19551956 // - quiet macro invocations (which are followed by a '?' and use the token `QMACRO`)
19561957 // - regular macro invocations (which use the token `SYMBOL`)
1958+ // - label scopes "." and ".." (which use the token `SYMBOL` no matter what)
19571959 //
19581960 // If we had one `IDENTIFIER` token, the parser would need to perform "lookahead" to
19591961 // determine which rule applies. But since macros need to enter "raw" mode to parse
@@ -1964,7 +1966,7 @@ static Token yylex_NORMAL() {
19641966 // one to lex depending on the character *immediately* following the identifier.
19651967 // Thus "name:" is a label definition, and "name?" is a quiet macro invocation, but
19661968 // "name :" and "name ?" and just "name" are all regular macro invocations.
1967- if (token.type == T_ (SYMBOL)) {
1969+ if (token.type == T_ (SYMBOL) && ! sym_IsDotScope (identifier) ) {
19681970 c = peek ();
19691971 token.type = c == ' :' ? T_ (LABEL) : c == ' ?' ? T_ (QMACRO) : T_ (SYMBOL);
19701972 }
0 commit comments