Implement continuation for #if* #endif.
This commit is contained in:
parent
c38d4dc5b4
commit
212259918a
@ -22,10 +22,28 @@ namespace cling {
|
||||
MetaLexer::LexPunctuatorAndAdvance(curPos, Tok);
|
||||
int kind = (int)Tok.getKind();
|
||||
|
||||
// If there is " or ' we don't need to look for balancing until we
|
||||
// enounter matching " or '
|
||||
if (kind == tok::hash) {
|
||||
// Handle #ifdef ...
|
||||
// ...
|
||||
// #endif
|
||||
MetaLexer Lexer(curPos);
|
||||
Lexer.Lex(Tok);
|
||||
if (Tok.getKind() == tok::ident) {
|
||||
if (Tok.getIdent().startswith("if")) {
|
||||
Res = kIncomplete;
|
||||
m_ParenStack.push(kind);
|
||||
}
|
||||
else if (Tok.getIdent().startswith("end")) {
|
||||
assert(m_ParenStack.top() == kind && "No coresponding # to pop?");
|
||||
m_ParenStack.pop();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (kind >= (int)tok::quote && kind <= (int)tok::apostrophe) {
|
||||
MetaLexer::LexQuotedStringAndAdvance(curPos, Tok);
|
||||
// If there is " or ' we don't need to look for balancing until we
|
||||
// enounter matching " or '
|
||||
if (kind != (int)Tok.getKind()) {
|
||||
Res = kIncomplete;
|
||||
m_ParenStack.push(kind);
|
||||
|
@ -46,7 +46,7 @@ namespace cling {
|
||||
switch (C) {
|
||||
case '[': case ']': case '(': case ')': case '{': case '}': case '"':
|
||||
case '\'': case '\\': case ',': case '.': case '!': case '?': case '>':
|
||||
case '&': case '@':
|
||||
case '&': case '#': case '@':
|
||||
// INTENTIONAL FALL THROUGHs
|
||||
return LexPunctuator(C, Tok);
|
||||
|
||||
@ -115,6 +115,7 @@ namespace cling {
|
||||
case '>' : Tok.setKind(tok::greater); break;
|
||||
case '@' : Tok.setKind(tok::at); break;
|
||||
case '&' : Tok.setKind(tok::ampersand); break;
|
||||
case '#' : Tok.setKind(tok::hash); break;
|
||||
case '\0' : Tok.setKind(tok::eof); Tok.setLength(0); break;// if static call
|
||||
default: Tok.setLength(0); break;
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ namespace cling {
|
||||
backslash, // "\"
|
||||
greater, // ">"
|
||||
ampersand, // "&"
|
||||
hash, // "#"
|
||||
ident, // (a-zA-Z)[(0-9a-zA-Z)*]
|
||||
raw_ident, // .*^(' '|'\t')
|
||||
comment, // //
|
||||
|
@ -11,6 +11,11 @@
|
||||
#include "cling/Interpreter/Interpreter.h"
|
||||
#include "cling/Interpreter/Value.h"
|
||||
|
||||
.rawInput 1
|
||||
#ifdef MACOS
|
||||
#endif // MACOS
|
||||
.rawInput 0
|
||||
|
||||
cling::Value V;
|
||||
V // CHECK: (cling::Value &) <<<invalid>>> @0x{{.*}}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user