Skip to content

Commit

Permalink
[cling] Support bare # in input line:
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel-Naumann authored and devajithvs committed Jan 25, 2024
1 parent 261945d commit 5b0a3bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
14 changes: 8 additions & 6 deletions interpreter/cling/lib/MetaProcessor/InputValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,19 @@ namespace cling {
case tok::hash:
Lex.SkipWhitespace();
Lex.LexAnyString(Tok);
const llvm::StringRef PPtk = Tok.getIdent();
if (PPtk.startswith("if")) {
m_ParenStack.push_back(tok::hash);
} else if (PPtk.startswith("endif") &&
(PPtk.size() == 5 || PPtk[5]=='/' || isspace(PPtk[5]))) {
if (Tok.isNot(tok::eof)) {
const llvm::StringRef PPtk = Tok.getIdent();
if (PPtk.startswith("if")) {
m_ParenStack.push_back(tok::hash);
} else if (PPtk.startswith("endif") &&
(PPtk.size() == 5 || PPtk[5] == '/' || isspace(PPtk[5]))) {
if (m_ParenStack.empty() || m_ParenStack.back() != tok::hash)
Res = kMismatch;
else
m_ParenStack.pop_back();
}
break;
}
break;
}
} while (Tok.isNot(tok::eof) && Res != kMismatch);

Expand Down
7 changes: 7 additions & 0 deletions interpreter/cling/lib/MetaProcessor/MetaLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ namespace cling {
void MetaLexer::LexAnyString(Token& Tok) {
Tok.startToken(curPos);
// consume until we reach one of the "AnyString" delimiters or EOF.
if (*curPos == '\0') {
Tok.setBufStart(curPos);
Tok.setKind(tok::eof);
Tok.setLength(0);
return;
}

while(*curPos != ' ' && *curPos != '\t' && *curPos != '\0') {
curPos++;
}
Expand Down

0 comments on commit 5b0a3bd

Please sign in to comment.