#ifndef PARSER_H #define PARSER_H #include #include "Lexer/Token.h" #include "Expression.h" #include "Statement.h" using namespace std; class Parser { private: vector> tokens; int currentIndex = 0; shared_ptr nextStatement(); shared_ptr matchStatementFunctionDeclaration(); shared_ptr matchStatementVarDeclaration(); shared_ptr matchStatementBlock(vector terminalTokenKinds, bool shouldConsumeTerminal); shared_ptr matchStatementReturn(); shared_ptr matchStatementExpression(); shared_ptr matchStatementMetaExternFunction(); shared_ptr matchStatementInvalid(string message = ""); shared_ptr nextExpression(); shared_ptr matchEquality(); // =, != shared_ptr matchComparison(); // <, <=, >, >= shared_ptr matchTerm(); // +, - shared_ptr matchFactor(); // *, /, % shared_ptr matchPrimary(); // integer, () shared_ptr matchExpressionLiteral(); shared_ptr matchExpressionGrouping(); shared_ptr matchExpressionBinary(shared_ptr left); shared_ptr matchExpressionIfElse(); shared_ptr matchExpressionVar(); shared_ptr matchExpressionCall(); shared_ptr matchExpressionInvalid(); bool tryMatchingTokenKinds(vector kinds, bool shouldMatchAll, bool shouldAdvance); optional valueTypeForToken(shared_ptr token); public: Parser(vector> tokens); vector> getStatements(); }; #endif