Updated the parser a bit
This commit is contained in:
@@ -492,7 +492,43 @@ shared_ptr<Statement> Parser::matchStatementRawFunction() {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
#include "StatementType.h"
|
||||
|
||||
StatementType::StatementType(string identifier, vector<shared_ptr<StatementVariable>> statementVariable):
|
||||
Statement(StatementKind::TYPE), identifier(identifier), statementVariables(statementVariable) { }
|
||||
#include "Parser/ValueType.h"
|
||||
|
||||
StatementType::StatementType(string identifier, vector<pair<string, shared_ptr<ValueType>>> variables):
|
||||
Statement(StatementKind::TYPE), identifier(identifier), variables(variables) { }
|
||||
|
||||
string StatementType::getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
vector<shared_ptr<StatementVariable>> StatementType::getStatementVariables() {
|
||||
return statementVariables;
|
||||
vector<pair<string, shared_ptr<ValueType>>> StatementType::getVariables() {
|
||||
return variables;
|
||||
}
|
||||
@@ -4,16 +4,17 @@
|
||||
#include "Statement.h"
|
||||
|
||||
class StatementVariable;
|
||||
class ValueType;
|
||||
|
||||
class StatementType: public Statement {
|
||||
private:
|
||||
string identifier;
|
||||
vector<shared_ptr<StatementVariable>> statementVariables;
|
||||
vector<pair<string, shared_ptr<ValueType>>> variables;
|
||||
|
||||
public:
|
||||
StatementType(string identifier, vector<shared_ptr<StatementVariable>> statementVariables);
|
||||
StatementType(string identifier, vector<pair<string, shared_ptr<ValueType>>> variables);
|
||||
string getIdentifier();
|
||||
vector<shared_ptr<StatementVariable>> getStatementVariables();
|
||||
vector<pair<string, shared_ptr<ValueType>>> getVariables();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user