Updated the parser a bit
This commit is contained in:
@@ -492,7 +492,43 @@ shared_ptr<Statement> Parser::matchStatementRawFunction() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Statement> Parser::matchStatementType() {
|
shared_ptr<Statement> Parser::matchStatementType() {
|
||||||
return nullptr;
|
ParseeResultsGroup resultsGroup;
|
||||||
|
|
||||||
|
string identifier;
|
||||||
|
vector<pair<string, shared_ptr<ValueType>>> variables;
|
||||||
|
|
||||||
|
resultsGroup = parseeResultsGroupForParseeGroup(
|
||||||
|
ParseeGroup(
|
||||||
|
{
|
||||||
|
Parsee::tokenParsee(TokenKind::IDENTIFIER, true, true),
|
||||||
|
Parsee::tokenParsee(TokenKind::TYPE, true, false)
|
||||||
|
},
|
||||||
|
ParseeGroup(
|
||||||
|
{
|
||||||
|
Parsee::tokenParsee(TokenKind::IDENTIFIER, true, true),
|
||||||
|
Parsee::valueTypeParsee(true)
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
switch (resultsGroup.getKind()) {
|
||||||
|
case ParseeResultsGroupKind::SUCCESS:
|
||||||
|
identifier = resultsGroup.getResults().at(0).getToken()->getLexme();
|
||||||
|
for (int i=1; i<resultsGroup.getResults().size(); i+=2) {
|
||||||
|
pair<string, shared_ptr<ValueType>> arg;
|
||||||
|
arg.first = resultsGroup.getResults().at(i).getToken()->getLexme();
|
||||||
|
arg.second = resultsGroup.getResults().at(i+1).getValueType();
|
||||||
|
variables.push_back(arg);
|
||||||
|
}
|
||||||
|
case ParseeResultsGroupKind::NO_MATCH:
|
||||||
|
case ParseeResultsGroupKind::FAILURE:
|
||||||
|
return nullptr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return make_shared<StatementType>(identifier, variables);
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Statement> Parser::matchStatementBlock(vector<TokenKind> terminalTokenKinds) {
|
shared_ptr<Statement> Parser::matchStatementBlock(vector<TokenKind> terminalTokenKinds) {
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
#include "StatementType.h"
|
#include "StatementType.h"
|
||||||
|
|
||||||
StatementType::StatementType(string identifier, vector<shared_ptr<StatementVariable>> statementVariable):
|
#include "Parser/ValueType.h"
|
||||||
Statement(StatementKind::TYPE), identifier(identifier), statementVariables(statementVariable) { }
|
|
||||||
|
StatementType::StatementType(string identifier, vector<pair<string, shared_ptr<ValueType>>> variables):
|
||||||
|
Statement(StatementKind::TYPE), identifier(identifier), variables(variables) { }
|
||||||
|
|
||||||
string StatementType::getIdentifier() {
|
string StatementType::getIdentifier() {
|
||||||
return identifier;
|
return identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<shared_ptr<StatementVariable>> StatementType::getStatementVariables() {
|
vector<pair<string, shared_ptr<ValueType>>> StatementType::getVariables() {
|
||||||
return statementVariables;
|
return variables;
|
||||||
}
|
}
|
||||||
@@ -4,16 +4,17 @@
|
|||||||
#include "Statement.h"
|
#include "Statement.h"
|
||||||
|
|
||||||
class StatementVariable;
|
class StatementVariable;
|
||||||
|
class ValueType;
|
||||||
|
|
||||||
class StatementType: public Statement {
|
class StatementType: public Statement {
|
||||||
private:
|
private:
|
||||||
string identifier;
|
string identifier;
|
||||||
vector<shared_ptr<StatementVariable>> statementVariables;
|
vector<pair<string, shared_ptr<ValueType>>> variables;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StatementType(string identifier, vector<shared_ptr<StatementVariable>> statementVariables);
|
StatementType(string identifier, vector<pair<string, shared_ptr<ValueType>>> variables);
|
||||||
string getIdentifier();
|
string getIdentifier();
|
||||||
vector<shared_ptr<StatementVariable>> getStatementVariables();
|
vector<pair<string, shared_ptr<ValueType>>> getVariables();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user