Skip to content

Commit 01cc46c

Browse files
committed
Removed lexical position
1 parent 5a02fd8 commit 01cc46c

File tree

4 files changed

+10
-23
lines changed

4 files changed

+10
-23
lines changed

include/easycc/Lexical.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ namespace ecc {
5050
* @param token value
5151
* @param line
5252
* @param column
53-
* @param position
5453
*/
5554
std::shared_ptr<LexicalToken> createToken(
56-
std::string tokenName, std::string tokenValue, const int &line, const int &column, const int &position);
55+
std::string tokenName, std::string tokenValue, const int &line, const int &column);
5756

5857
/**
5958
* Generate an error message based on the error token name

include/easycc/LexicalToken.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ namespace ecc {
1616
NORMAL_FINAL_TOKEN
1717
};
1818

19-
LexicalToken(LexicalToken::Type type,std::string name, std::string value, int line, int column, int position) :
20-
m_type(type), m_name(name), m_value(value), m_line(line), m_column(column), m_position(position){};
19+
LexicalToken(LexicalToken::Type type,std::string name, std::string value, int line, int column) :
20+
m_type(type), m_name(name), m_value(value), m_line(line), m_column(column){};
2121

2222
/**
2323
* Get token name
@@ -43,12 +43,6 @@ namespace ecc {
4343
*/
4444
int getColumn() const {return this->m_column;}
4545

46-
/**
47-
* Get token position
48-
* @return position
49-
*/
50-
int getPosition() const {return this->m_position;}
51-
5246
/**
5347
* Get lexical token type
5448
* @return lexical token type
@@ -65,7 +59,6 @@ namespace ecc {
6559
std::string m_value;
6660
int m_line;
6761
int m_column;
68-
int m_position;
6962
LexicalToken::Type m_type;
7063
};
7164
}

src/lexical/Lexical.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ namespace ecc {
3535
// Keep track of file information
3636
int tokenLine = 1;
3737
int tokenColumn = 1;
38-
int tokenPosition = 0;
3938
int line = 1;
4039
int column = 1;
41-
int position = 0;
4240

4341
// Keep track of the state
4442
std::shared_ptr<State> state = m_graph->getInitialState();
@@ -60,7 +58,6 @@ namespace ecc {
6058
if(state->getType() == State::INITIAL) {
6159
tokenLine = line;
6260
tokenColumn = column;
63-
tokenPosition = position;
6461
}
6562

6663
// Jump to the next state
@@ -79,7 +76,7 @@ namespace ecc {
7976

8077
// Create token
8178
std::shared_ptr<LexicalToken> token =createToken(state->getTokenName(), tokenValueStream.str(),
82-
tokenLine, tokenColumn, tokenPosition);
79+
tokenLine, tokenColumn);
8380

8481
// If token created
8582
if(token) {
@@ -121,8 +118,6 @@ namespace ecc {
121118
} else {
122119
column++;
123120
}
124-
125-
position++;
126121
}
127122

128123
// One more call for the end of file
@@ -140,7 +135,7 @@ namespace ecc {
140135
// If final state, then create the last token
141136
if(state->getType() == State::FINAL) {
142137
std::shared_ptr<LexicalToken> token = createToken(state->getTokenName(), tokenValueStream.str(),
143-
tokenLine, tokenColumn, tokenPosition);
138+
tokenLine, tokenColumn);
144139

145140
// If token created
146141
if(token) {
@@ -157,7 +152,7 @@ namespace ecc {
157152
// Add final token
158153
lexicalVector.push_back(std::make_shared<LexicalToken>(
159154
LexicalToken::Type::NORMAL_FINAL_TOKEN, LexicalToken::END_OF_FILE,
160-
LexicalToken::END_OF_FILE, line, column, position));
155+
LexicalToken::END_OF_FILE, line, column));
161156

162157
// Log generate tokens
163158
BOOST_LOG(ecc_logger::get()) << "Finished generating lexical tokens:";
@@ -174,18 +169,18 @@ namespace ecc {
174169
* @return object | null if the token should be ignored
175170
*/
176171
std::shared_ptr<LexicalToken> Lexical::createToken(
177-
std::string tokenName, std::string tokenValue, const int &line, const int &column, const int &position) {
172+
std::string tokenName, std::string tokenValue, const int &line, const int &column) {
178173

179174
// Check the type of the token name
180175
if(m_config->isErrorToken(tokenName)) {
181176
return std::make_shared<LexicalToken>(
182177
LexicalToken::Type::ERROR_TOKEN, tokenName,
183-
tokenValue, line, column, position);
178+
tokenValue, line, column);
184179
} else if(!m_config->mustIgnoreToken(tokenName)) {
185180
tokenName = m_config->updateTokenName(tokenName, tokenValue);
186181
return std::make_shared<LexicalToken>(
187182
LexicalToken::Type::NORMAL_TOKEN, tokenName,
188-
tokenValue, line, column, position);
183+
tokenValue, line, column);
189184
}
190185
return nullptr;
191186
}

src/lexical/token/LexicalToken.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace ecc{
88

99
std::string LexicalToken::getString() {
1010
std::ostringstream ss;
11-
ss << "<" << m_name << ",l:" << m_line << ",c:" << m_column << ",p:" << m_position << ">";
11+
ss << "<" << m_name << ",l:" << m_line << ",c:" << m_column << ">";
1212
return ss.str();
1313
}
1414
}

0 commit comments

Comments
 (0)