Pass in constraints

This commit is contained in:
Rafał Grodziński
2025-07-14 21:40:18 +09:00
parent 228dd80423
commit 5616036c17
5 changed files with 27 additions and 7 deletions

View File

@@ -240,12 +240,26 @@ shared_ptr<Statement> Parser::matchStatementRawFunction() {
return nullptr;
string name;
string constraints;
string rawSource;
// name
name = tokens.at(currentIndex++)->getLexme();
currentIndex++; // skip raw
// constraints
if (tryMatchingTokenKinds({TokenKind::LESS}, true, true)) {
if (tokens.at(currentIndex)->isOfKind({TokenKind::STRING})) {
constraints = tokens.at(currentIndex++)->getLexme();
// remove enclosing quotes
if (constraints.length() >= 2)
constraints = constraints.substr(1, constraints.length() - 2);
}
if (!tryMatchingTokenKinds({TokenKind::GREATER}, true, true))
markError({TokenKind::GREATER}, {});
}
// consume new line
if (!tryMatchingTokenKinds({TokenKind::NEW_LINE}, true, true)) {
markError(TokenKind::NEW_LINE, {});
@@ -267,7 +281,7 @@ shared_ptr<Statement> Parser::matchStatementRawFunction() {
return nullptr;
}
return make_shared<StatementRawFunction>(name, rawSource);
return make_shared<StatementRawFunction>(name, constraints, rawSource);
}
shared_ptr<Statement> Parser::matchStatementBlock(vector<TokenKind> terminalTokenKinds) {