Readd custom meta command support.
git-svn-id: http://root.cern.ch/svn/root/trunk@47776 27541ba8-7e3a-0410-8455-c3a389f83636
This commit is contained in:
parent
17884114d5
commit
a530a63d15
@ -9,6 +9,9 @@
|
||||
#include "MetaLexer.h"
|
||||
#include "MetaSema.h"
|
||||
|
||||
#include "cling/Interpreter/Interpreter.h"
|
||||
#include "cling/Interpreter/InvocationOptions.h"
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
|
||||
@ -17,6 +20,15 @@ namespace cling {
|
||||
MetaParser::MetaParser(MetaSema* Actions) {
|
||||
m_Lexer.reset(0);
|
||||
m_Actions.reset(Actions);
|
||||
const InvocationOptions& Opts = Actions->getInterpreter().getOptions();
|
||||
MetaLexer metaSymbolLexer(Opts.MetaString);
|
||||
Token Tok;//Tok.startToken();
|
||||
while(true) {
|
||||
metaSymbolLexer.Lex(Tok);
|
||||
if (Tok.is(tok::eof))
|
||||
break;
|
||||
m_MetaSymbolCache.push_back(Tok);
|
||||
}
|
||||
}
|
||||
|
||||
void MetaParser::enterNewInputLine(llvm::StringRef Line) {
|
||||
@ -74,14 +86,15 @@ namespace cling {
|
||||
}
|
||||
|
||||
bool MetaParser::isCommandSymbol() {
|
||||
consumeToken();
|
||||
if (getCurTok().is(tok::dot) /*TODO: || Tok.is(//.)*/)
|
||||
return true;
|
||||
return false;
|
||||
for (size_t i = 0; i < m_MetaSymbolCache.size(); ++i) {
|
||||
if (getCurTok().getKind() != m_MetaSymbolCache[i].getKind())
|
||||
return false;
|
||||
consumeToken();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MetaParser::isCommand() {
|
||||
consumeToken();
|
||||
return isLCommand() || isXCommand() || isqCommand()
|
||||
|| isUCommand() || isICommand() || israwInputCommand()
|
||||
|| isprintASTCommand() || isdynamicExtensionsCommand() || ishelpCommand()
|
||||
|
@ -52,6 +52,7 @@ namespace cling {
|
||||
llvm::OwningPtr<MetaLexer> m_Lexer;
|
||||
llvm::OwningPtr<MetaSema> m_Actions;
|
||||
llvm::SmallVector<Token, 2> m_TokenCache;
|
||||
llvm::SmallVector<Token, 4> m_MetaSymbolCache;
|
||||
private:
|
||||
inline const Token& getCurTok() { return lookAhead(0); }
|
||||
void consumeToken();
|
||||
|
@ -33,7 +33,8 @@ namespace cling {
|
||||
public:
|
||||
MetaSema(Interpreter& interp, MetaProcessor& meta)
|
||||
: m_Interpreter(interp), m_MetaProcessor(meta) {}
|
||||
|
||||
const Interpreter& getInterpreter() { return m_Interpreter; }
|
||||
|
||||
///\brief L command includes the given file or loads the given library.
|
||||
///
|
||||
///\param[in] path - The file/library to be loaded.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// RUN: cat %s | %cling --metastr=META | FileCheck %s
|
||||
// RUN: cat %s | %cling --metastr=//. | FileCheck %s
|
||||
|
||||
// Test setting of meta escape
|
||||
METAhelp // CHECK: Cling meta commands usage
|
||||
//.help // CHECK: Cling meta commands usage
|
||||
|
Loading…
x
Reference in New Issue
Block a user