translator.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include "translator.h"
  2. namespace NSQLTranslation {
  3. namespace {
  4. class TDummyTranslator : public ITranslator {
  5. public:
  6. TDummyTranslator(const TString& name)
  7. : Name_(name)
  8. {}
  9. NSQLTranslation::ILexer::TPtr MakeLexer(const NSQLTranslation::TTranslationSettings& settings) final {
  10. Y_UNUSED(settings);
  11. ThrowNotSupported();
  12. }
  13. NYql::TAstParseResult TextToAst(const TString& query, const NSQLTranslation::TTranslationSettings& settings,
  14. NYql::TWarningRules* warningRules, NYql::TStmtParseInfo* stmtParseInfo) final {
  15. Y_UNUSED(query);
  16. Y_UNUSED(settings);
  17. Y_UNUSED(warningRules);
  18. Y_UNUSED(stmtParseInfo);
  19. ThrowNotSupported();
  20. }
  21. google::protobuf::Message* TextToMessage(const TString& query, const TString& queryName,
  22. NYql::TIssues& issues, size_t maxErrors, const TTranslationSettings& settings) final {
  23. Y_UNUSED(query);
  24. Y_UNUSED(queryName);
  25. Y_UNUSED(issues);
  26. Y_UNUSED(maxErrors);
  27. Y_UNUSED(settings);
  28. ThrowNotSupported();
  29. }
  30. NYql::TAstParseResult TextAndMessageToAst(const TString& query, const google::protobuf::Message& protoAst,
  31. const TSQLHints& hints, const TTranslationSettings& settings) final {
  32. Y_UNUSED(query);
  33. Y_UNUSED(protoAst);
  34. Y_UNUSED(hints);
  35. Y_UNUSED(settings);
  36. ThrowNotSupported();
  37. }
  38. TVector<NYql::TAstParseResult> TextToManyAst(const TString& query, const TTranslationSettings& settings,
  39. NYql::TWarningRules* warningRules, TVector<NYql::TStmtParseInfo>* stmtParseInfo) final {
  40. Y_UNUSED(query);
  41. Y_UNUSED(settings);
  42. Y_UNUSED(warningRules);
  43. Y_UNUSED(stmtParseInfo);
  44. ThrowNotSupported();
  45. }
  46. private:
  47. [[noreturn]] void ThrowNotSupported() {
  48. throw yexception() << "Translator '" << Name_ << "' is not supported";
  49. }
  50. private:
  51. const TString Name_;
  52. };
  53. }
  54. TTranslatorPtr MakeDummyTranslator(const TString& name) {
  55. return MakeIntrusive<TDummyTranslator>(name);
  56. }
  57. } // namespace NSQLTranslation