0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Token.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #include <Common/Compat.h>
28 
29 #include "Token.h"
30 #include "TranslatorCode.h"
31 #include "TranslatorRole.h"
32 #include "TranslatorTask.h"
33 #include "TranslatorVariable.h"
34 
35 #include <Common/Logger.h>
36 
37 #include <memory>
38 
39 using namespace Hypertable;
40 using namespace Hypertable::ClusterDefinitionFile;
41 
43  switch (type) {
44  case(VARIABLE):
45  translator = make_shared<TranslatorVariable>(fname, line, text);
46  break;
47  case (ROLE):
48  translator = make_shared<TranslatorRole>(fname, line, text);
49  break;
50  case (TASK):
51  translator = make_shared<TranslatorTask>(fname, line, text);
52  break;
53  case (FUNCTION):
54  case (CONTROLFLOW):
55  case (COMMENT):
56  case (CODE):
57  case (BLANKLINE):
58  translator = make_shared<TranslatorCode>(fname, line, text);
59  break;
60  default:
61  break;
62  }
63 }
64 
65 const char *Token::type_to_text(int type) {
66  switch (type) {
67  case(NONE):
68  return "NONE";
69  case(INCLUDE):
70  return "INCLUDE";
71  case(VARIABLE):
72  return "VARIABLE";
73  case(ROLE):
74  return "ROLE";
75  case(TASK):
76  return "TASK";
77  case(FUNCTION):
78  return "FUNCTION";
79  case(CONTROLFLOW):
80  return "CONTROLFLOW";
81  case(COMMENT):
82  return "COMMENT";
83  case(CODE):
84  return "CODE";
85  case(BLANKLINE):
86  return "BLANKLINE";
87  default:
88  HT_ASSERT(!"Unknown token type");
89  }
90  return nullptr;
91 }
Declarations for TranslatorTask.
TranslatorPtr translator
Translator object for token text.
Definition: Token.h:75
Declarations for TranslatorVariable.
string fname
Pathname of file from which token was extracted.
Definition: Token.h:81
#define HT_ASSERT(_e_)
Definition: Logger.h:396
Declarations for TranslatorRole.
void create_translator()
Creates a translator for the token.
Definition: Token.cc:42
size_t line
Starting line number of token.
Definition: Token.h:79
Logging routines and macros.
Compatibility Macros for C/C++.
Hypertable definitions
Declarations for TranslatorCode.
static const char * type_to_text(int type)
Returns human-readable string of token type.
Definition: Token.cc:65
Cluster definition file translation definitions.
Definition: Compiler.h:35
Declarations for Token.