-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToken.cpp
More file actions
32 lines (27 loc) · 771 Bytes
/
Copy pathToken.cpp
File metadata and controls
32 lines (27 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
Carlos Villagomez & Andrew Zenoni
CPSC 326 - Organization of Programming Languages
Assignment 2
v 1.0.0
January 29, 2018
Defines the implementation of a MyPL token for a Lexeme
*/
#include "Token.h"
// You shouldn't need to modify this file for HW2
/* Provide an output operator allowing Tokens to be outputted to std::cout
or to any other ostream using << */
std::ostream& operator<<(std::ostream &out, Token token) {
out << toString(token);
return out;
}
/* Use the x-macro pattern to create a giant switch statement to return a
string representations of the passed-in token */
std::string toString(Token token) {
switch(token) {
#define x(ident) case Token::ident: \
return #ident; \
break;
#include "tokens-inc.h"
#undef x
}
}