cling/lib/MetaProcessor/MetaParser.h
manasij7479 024b16df11 Init TagsExtension Module, for extending cling to provide interactive hints
AutoloadCallback: Implementing InterpreterCallbacks to attach the module to cling
   The main focus is on overriding LookupObject so that the information about
   lookup failures are obtained from clang.
   The type of the name is not taken into consideration for now.

TagManager: To manage and lookup information from various sorts of tag files.
   Currently a TagManager object is owned by the callback system.
   This may change in future.

Wrapper: As a base class for handling particular types of tagfiles.
   The TagManager maintains a container of Wrappers.

CtagsFileWrapper: Implementing a wrapper for ctags.
   This class is responsible for generating a tagfile from a given path or list of files.
   It also performs lookups in the file generated by it.

And a few simple file system utils to complement llvm::sys::fs and path utilities
2014-06-04 09:20:14 +02:00

130 lines
4.9 KiB
C++

//--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// author: Vassil Vassilev <vasil.georgiev.vasilev@cern.ch>
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------
#ifndef CLING_META_PARSER_H
#define CLING_META_PARSER_H
#include "MetaLexer.h" // for cling::Token
#include "MetaSema.h" // for ActionResult
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallVector.h"
namespace llvm {
class StringRef;
}
namespace cling {
class MetaLexer;
class MetaSema;
class Value;
// Command syntax: MetaCommand := <CommandSymbol><Command>
// CommandSymbol := '.' | '//.'
// Command := LCommand | XCommand | qCommand | UCommand |
// ICommand | OCommand | RawInputCommand |
// PrintDebugCommand | DynamicExtensionsCommand |
// HelpCommand | FileExCommand | FilesCommand |
// ClassCommand | GCommand | StoreStateCommand |
// CompareStateCommand | StatsCommand | undoCommand
// LCommand := 'L' FilePath
// TCommand := 'T' FilePath
// >Command := '>' FilePath
// qCommand := 'q'
// XCommand := 'x' FilePath[ArgList] | 'X' FilePath[ArgList]
// UCommand := 'U' FilePath
// ICommand := 'I' [FilePath]
// OCommand := 'O'[' ']Constant
// RawInputCommand := 'rawInput' [Constant]
// PrintDebugCommand := 'printDebug' [Constant]
// StoreStateCommand := 'storeState' "Ident"
// CompareStateCommand := 'compareState' "Ident"
// StatsCommand := 'stats' ['ast']
// undoCommand := 'undo' [Constant]
// DynamicExtensionsCommand := 'dynamicExtensions' [Constant]
// HelpCommand := 'help'
// FileExCommand := 'fileEx'
// FilesCommand := 'files'
// ClassCommand := 'class' AnyString | 'Class'
// GCommand := 'g' [Ident]
// FilePath := AnyString
// ArgList := (ExtraArgList) ' ' [ArgList]
// ExtraArgList := AnyString [, ExtraArgList]
// AnyString := *^(' ' | '\t')
// Constant := {0-9}
// Ident := a-zA-Z{a-zA-Z0-9}
//
class MetaParser {
private:
llvm::OwningPtr<MetaLexer> m_Lexer;
llvm::OwningPtr<MetaSema> m_Actions;
llvm::SmallVector<Token, 2> m_TokenCache;
llvm::SmallVector<Token, 4> m_MetaSymbolCache;
private:
///\brief Returns the current token without consuming it.
///
inline const Token& getCurTok() { return lookAhead(0); }
///\brief Consume the current 'peek' token.
///
void consumeToken();
void consumeAnyStringToken(tok::TokenKind stopAt = tok::space);
const Token& lookAhead(unsigned Num);
void skipWhitespace();
bool isCommandSymbol();
bool isCommand(MetaSema::ActionResult& actionResult,
Value* resultValue);
bool isLCommand(MetaSema::ActionResult& actionResult);
bool isTCommand(MetaSema::ActionResult& actionResult);
bool isRedirectCommand(MetaSema::ActionResult& actionResult);
bool isExtraArgList();
bool isXCommand(MetaSema::ActionResult& actionResult,
Value* resultValue);
bool isAtCommand();
bool isqCommand();
bool isUCommand(MetaSema::ActionResult& actionResult);
bool isICommand();
bool isOCommand();
bool israwInputCommand();
bool isprintDebugCommand();
bool isstoreStateCommand();
bool iscompareStateCommand();
bool isstatsCommand();
bool isundoCommand();
bool isdynamicExtensionsCommand();
bool ishelpCommand();
bool isfileExCommand();
bool isfilesCommand();
bool isClassCommand();
bool isNamespaceCommand();
bool isgCommand();
bool isTypedefCommand();
bool isShellCommand(MetaSema::ActionResult& actionResult,
Value* resultValue);
public:
MetaParser(MetaSema* Actions);
void enterNewInputLine(llvm::StringRef Line);
///\brief Drives the recursive decendent parsing.
///
///\returns true if it was meta command.
///
bool isMetaCommand(MetaSema::ActionResult& actionResult,
Value* resultValue);
///\brief Returns whether quit was requested via .q command
///
bool isQuitRequested() const;
MetaSema& getActions() const { return *m_Actions.get(); }
};
} // end namespace cling
#endif // CLING_META_PARSER_H