Skip to content

Commit

Permalink
token: header file and include statement refactoring
Browse files Browse the repository at this point in the history
added token forward declarations to header files as needed
(cannot remove include from table until token type is replaced)
- required moving rpn item equality operator function to source file
- moved token includes to source files as needed
- cleaned up some other forward declarations
  • Loading branch information
thunder422 committed Jan 2, 2015
1 parent 1bfb76a commit 0777959
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion basic/basic.h
Expand Up @@ -30,11 +30,11 @@
#include <vector>

#include "ibcp.h"
#include "token.h"
#include "dictionary.h"

class Translator;
class Token;
using TokenPtr = std::shared_ptr<Token>;
class ProgramModel;
class Recreator;
class RpnItem;
Expand Down
1 change: 1 addition & 0 deletions parser.cpp
Expand Up @@ -24,6 +24,7 @@

#include "parser.h"
#include "table.h"
#include "token.h"
#include "utility.h"


Expand Down
3 changes: 2 additions & 1 deletion parser.h
Expand Up @@ -27,9 +27,10 @@

#include <sstream>

#include "token.h"
#include "ibcp.h"

class Table;
class Token;


class Parser
Expand Down
9 changes: 9 additions & 0 deletions rpnlist.cpp
Expand Up @@ -24,6 +24,15 @@

#include "rpnlist.h"
#include "table.h"
#include "token.h"


// function to overload the comparison operator
bool RpnItem::operator==(const RpnItem &other) const
{
return *m_token == *other.m_token
&& m_attached.size() == other.m_attached.size();
}


// function to overload the comparison operator
Expand Down
13 changes: 5 additions & 8 deletions rpnlist.h
Expand Up @@ -29,13 +29,12 @@
#include <memory>
#include <vector>

#include "token.h"

class Table;
class Token;
using TokenPtr = std::shared_ptr<Token>;
class RpnItem;
using RpnItemPtr = std::shared_ptr<RpnItem>;
using RpnItemVector = std::vector<RpnItemPtr>;
using RpnItemList = std::list<RpnItemPtr>;


// class for holding an item in the RPN output list
Expand All @@ -61,11 +60,7 @@ class RpnItem
return m_attached;
}

bool operator==(const RpnItem &other) const
{
return *m_token == *other.m_token
&& m_attached.size() == other.m_attached.size();
}
bool operator==(const RpnItem &other) const;
bool operator!=(const RpnItem &other) const
{
return !(*this == other);
Expand All @@ -76,6 +71,8 @@ class RpnItem
RpnItemVector m_attached; // array of attached item pointers
};

using RpnItemList = std::list<RpnItemPtr>;


// class for holding a list of RPN items
class RpnList
Expand Down
1 change: 1 addition & 0 deletions table.cpp
Expand Up @@ -28,6 +28,7 @@
#include <vector>

#include "table.h"
#include "token.h"
#include "utility.h"
#include "basic/basic.h"

Expand Down
4 changes: 4 additions & 0 deletions table.h
Expand Up @@ -30,9 +30,13 @@
#include <unordered_map>

#include "ibcp.h"
// TODO remove this include once token type is replaced with code type
#include "token.h"
#include "utility.h"

class Token;
using TokenPtr = std::shared_ptr<Token>;


// bit definitions for flags field
enum TableFlag : unsigned
Expand Down
6 changes: 2 additions & 4 deletions token.h
Expand Up @@ -32,10 +32,6 @@
#include "ibcp.h"


class Token;
using TokenPtr = std::shared_ptr<Token>;


class Token
{
public:
Expand Down Expand Up @@ -263,6 +259,8 @@ class Token
int m_index; // index within encoded program code line
};

using TokenPtr = std::shared_ptr<Token>;


// structure for holding information about an error exception
struct TokenError
Expand Down
1 change: 1 addition & 0 deletions translator.h
Expand Up @@ -31,6 +31,7 @@
#include "rpnlist.h"

class Table;
class TokenError;


class Translator
Expand Down

0 comments on commit 0777959

Please sign in to comment.