//============================================================================//
// //
// artichoke programming language //
// //
// Copyright (C) 2025 Erick Saul Guzman Ramos, whoami.artichoke.dev //
// //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as published //
// by the Free Software Foundation, either version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see . //
// //
//============================================================================//
#pragma once
#include
#include
namespace arti::lang {
struct Parser {
Parser(std::string source) noexcept;
Parser(std::string unitName, std::string source) noexcept;
Parser(Parser &&) noexcept;
Parser &operator=(Parser &&) noexcept;
Parser(const Parser &) noexcept = delete;
Parser &operator=(const Parser &) noexcept = delete;
Expected parse();
Expected
consume(TokenV type, std::string_view message);
Expected
matchAndConsume(TokenV type);
Expected
match(TokenV type, std::size_t offset = 0);
Expected>
parseTopLevelDeclaration();
Expected
parseImportDeclaration();
Expected
parseAliasDeclaration();
Expected
parseModuleDeclaration();
Expected
parseStructDeclaration();
Expected
parseEnumDeclaration();
Expected>
parseGenericParamsList();
Expected
parseGenericParam();
Expected>
parseStructMembersList();
Expected
parseStructMember();
Expected>
parseEnumMembersList();
Expected
parseEnumMember();
Expected
parseFunctionDeclaration();
Expected
parseNamespacedIdentifier();
Expected
parseType();
Expected>
parseTypeQualifiers();
Expected>
parseGenericArgumentsList();
Expected>
parseFunctionParamsList();
Expected
parseFunctionParam();
Expected
parseFunctionParamThis();
Expected
parseCodeBlock();
Expected>
parseStatement();
Expected
parseVariableStatement();
Expected
parseIfStatement();
Expected
parseElseStatement();
Expected
parseDeferStatement();
Expected
parseErrDeferStatement();
Expected
parseReturnStatement();
Expected
parseBreakStatement();
Expected
parseContinueStatement();
Expected
parseMatchStatement();
Expected
parseSwitchStatement();
Expected
parseForLoopStatement();
Expected
parseCForStatement();
Expected
parseRangeForStatement();
Expected
parseWhileStatement();
Expected
parseDoWhileStatement();
Expected
parseInfLoopStatement();
Expected
parseExpressionStatement();
Expected
parseExpression(std::uint16_t p = 0);
Expected>
parsePrimaryExpression();
Expected
parsePrefixExpression();
Expected
parseInfixExpression(ast::ExpressionNode lhs);
Expected
parsePostfixExpression(ast::ExpressionNode lhs);
Expected
parseIdentifierExpression();
Expected
parseCharLiteral();
Expected
parseNullLiteral();
Expected
parseStringLiteral();
Expected
parseFloatLiteral();
Expected
parseIntegerLiteral();
Expected
parseBooleanLiteral();
private:
std::string unitName;
std::string sourceCode;
Tokenizer tokenizer;
};
}