Added a return statement
[fridhskrift.git] / lexer / lexeme.cpp
blobbb2946cb42e393c9ee1a2616cd4774d156ff73e2
1 #include <fridh/lexer.hpp>
2 #include <ail/string.hpp>
4 namespace fridh
5 {
6 lexeme_type::lexeme()
10 lexeme_type::lexeme(lexeme_type::type type):
11 type(type)
15 lexeme_type::lexeme(types::boolean boolean):
16 type(boolean),
17 boolean(boolean)
21 lexeme_type::lexeme(types::signed_integer signed_integer):
22 type(signed_integer),
23 signed_integer(signed_integer)
27 lexeme_type::lexeme(types::unsigned_integer unsigned_integer):
28 type(unsigned_integer),
29 unsigned_integer(unsigned_integer)
33 lexeme_type::lexeme(types::floating_point_value floating_point_value):
34 type(floating_point_value),
35 floating_point_value(floating_point_value)
39 lexeme_type::lexeme(lexeme_type::type type, std::string const & string):
40 type(type),
41 string(new std::string(string))
45 std::string lexeme_type::to_string() const
47 using namespace lexeme_type;
49 switch(type)
51 case name:
52 return "name: " + *string;
54 case boolean:
55 return "boolean: " + ail::bool_to_string(boolean);
57 case signed_integer:
58 return "integer: " + ail::number_to_string(signed_integer);
60 case unsigned_integer:
61 return "unsigned-integer: " + ail::number_to_string(unsigned_integer);
63 case floating_point_value:
64 return "float: " + ail::number_to_string(floating_point_value);
66 case string:
67 return "string: " + ail::replace_string(*string, "\n", "\\n");
69 case addition:
70 return "+";
72 case subtraction:
73 return "-";
75 case multiplication:
76 return "*";
78 case division:
79 return "/";
81 case modulo:
82 return "%";
84 case assignment:
85 return "=";
87 case addition_assignment:
88 return "+=";
90 case subtraction_assignment:
91 return "-=";
93 case multiplication_assignment:
94 return "*=";
96 case division_assignment:
97 return "/=";
99 case modulo_assignment:
100 return "%=";
102 case exponentiation_assignment:
103 return "**=";
105 case increment:
106 return "++";
108 case decrement:
109 return "--";
111 case exponentiation:
112 return "**";
114 case less_than:
115 return "<";
117 case less_than_or_equal:
118 return "<=";
120 case greater_than:
121 return ">";
123 case greater_than_or_equal:
124 return ">=";
126 case unequal:
127 return "!=";
129 case equal:
130 return "==";
132 case logical_not:
133 return "!";
135 case logical_and:
136 return "&";
138 case logical_or:
139 return "|";
141 case shift_left:
142 return "<<";
144 case shift_right:
145 return ">>";
147 case binary_and:
148 return "&&";
150 case binary_or:
151 return "||";
153 case binary_xor:
154 return "^";
156 case binary_not:
157 return "~";
159 case bracket_start:
160 return "bracket: start";
162 case bracket_end:
163 return "bracket: end";
165 case array_start:
166 return "array: start";
168 case array_end:
169 return "array: end";
171 case scope_start:
172 return "scope: start";
174 case scope_end:
175 return "scope: end";
177 case iteration:
178 return "iteration";
180 case iterator:
181 return "iterator";
183 case while_operator:
184 return "while";
186 case function_declaration:
187 return "function";
189 case anonymous_function_declaration:
190 return "anonymous function";
192 case class_operator:
193 return "class operator";
195 case selection_operator:
196 return ".";
198 case call_operator:
199 return ",";
201 case scope_operator:
202 return ":";
204 default:
205 return "unknown";