cling/lib/MetaProcessor/InputValidator.h
Vassil Vassilev b66d4750fd Handle properly ticks and quotes.
I know that the lexers are getting too many and soon I will merge both implementations
into one full-blown.
Reduces the test failures a lot.


git-svn-id: http://root.cern.ch/svn/root/trunk@47652 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-27 15:41:08 +00:00

77 lines
1.9 KiB
C++

//--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// version: $Id$
// author: Axel Naumann <axel@cern.ch>
//------------------------------------------------------------------------------
#ifndef CLING_INPUT_VALIDATOR_H
#define CLING_INPUT_VALIDATOR_H
#include "clang/Basic/TokenKinds.h"
#include "llvm/ADT/StringRef.h"
#include <stack>
namespace clang {
class LangOptions;
}
namespace cling {
///\brief Provides storage for the input and tracks down whether the (, [, {
/// are balanced.
///
class InputValidator {
private:
enum {
kTick = clang::tok::r_brace + 1,
kQuote
};
///\brief The input being collected.
///
std::string m_Input;
///\brief Stack used for checking the brace balance.
///
std::stack<int> m_ParenStack;
public:
InputValidator() {}
~InputValidator() {}
///\brief Brace balance validation could encounter.
///
enum ValidationResult {
kIncomplete, ///< There is dangling brace.
kComplete, ///< All braces are in balance.
kMismatch ///< Closing brace doesn't match to opening. Eg: void f(};
};
///\brief Checks whether the input contains balanced number of braces
///
///\param[in] line - Input line to validate.
///\param[in] LO - Langluage options to validate against.
///\returns Information about the outcome of the validation.
///
ValidationResult validate(llvm::StringRef line);
///\returns Reference to the collected input.
///
std::string& getInput() {
return m_Input;
}
///\brief Retrieves the number of spaces that the next input line should be
/// indented.
///
int getExpectedIndent() { return m_ParenStack.size(); }
///\brief Resets the collected input and its corresponding brace stack.
///
void reset();
};
}
#endif // CLING_INPUT_VALIDATOR_H