saqut-compiler/src/parser/parser_base.hpp

63 lines
1.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ============================================================================
// saQut Compiler — Parser Sınıf Tanımı
// ============================================================================
//
// DİZİN: src/parser/parser_base.hpp
// İÇERİK: Parser sınıf tanımı + include'lar. Metot gövdeleri yok.
//
// ============================================================================
#ifndef SAQUT_PARSER_BASE
#define SAQUT_PARSER_BASE
#include <iostream>
#include <cstdint>
#include <string>
#include "parser/token.hpp"
#include "parser/ast.hpp"
#include "tools.hpp"
class Parser {
public:
ASTNode* parse(TokenList tokens);
private:
TokenList tokens; // Tokenizer'dan gelen token listesi
int current = 0; // Şu anki token indeksi
// --- Token navigasyonu ---
ParserToken currentToken();
void nextToken();
ParserToken lookahead(uint32_t forward);
ParserToken parseToken(Token* token);
ParserToken getToken(int offset);
// --- Üst seviye ---
ASTNode* parseProgram();
// --- Deklarasyonlar ---
ASTNode* parseDeclaration();
ASTNode* parseFunctionDecl();
ASTNode* parseStructDecl();
ASTNode* parseVariableDecl();
// --- Statement'lar ---
ASTNode* parseStatement();
ASTNode* parseBlock();
ASTNode* parseIfStatement();
ASTNode* parseWhileStatement();
ASTNode* parseForStatement();
ASTNode* parseDoWhileStatement();
ASTNode* parseReturnStatement();
ASTNode* parseBreakStatement();
ASTNode* parseContinueStatement();
ASTNode* parseExpressionStatement();
// --- İfadeler (Pratt parser) ---
ASTNode* parseExpression();
ASTNode* parseExpression(uint16_t precedence);
ASTNode* parseNullDenotation();
ASTNode* parseLeftDenotation(ASTNode* left);
};
#endif // SAQUT_PARSER_BASE