#ifndef PARSER_H #define PARSER_H #include class Error; class Token; enum class TokenKind; class ValueType; class Expression; class Statement; class ParseeGroup; class ParseeResult; class ParseeResultsGroup; using namespace std; class Parser { private: vector> errors; vector> tokens; int currentIndex = 0; shared_ptr nextStatement(); shared_ptr nextInBlockStatement(); shared_ptr matchStatementMetaExternFunction(); shared_ptr matchStatementVariable(); shared_ptr matchStatementFunction(); shared_ptr matchStatementRawFunction(); shared_ptr matchStatementBlock(vector terminalTokenKinds); shared_ptr matchStatementAssignment(); shared_ptr matchStatementReturn(); shared_ptr matchStatementRepeat(); shared_ptr matchStatementExpression(); shared_ptr nextExpression(); shared_ptr matchEquality(); // =, != shared_ptr matchComparison(); // <, <=, >, >= shared_ptr matchTerm(); // +, - shared_ptr matchFactor(); // *, /, % shared_ptr matchPrimary(); // integer, () shared_ptr matchExpressionGrouping(); shared_ptr matchExpressionLiteral(); shared_ptr matchExpressionArrayLiteral(); shared_ptr matchExpressionVariable(); shared_ptr matchExpressionCall(); shared_ptr matchExpressionIfElse(); shared_ptr matchExpressionBinary(shared_ptr left); shared_ptr matchExpressionBlock(vector terminalTokenKinds); ParseeResultsGroup parseeResultsGroupForParseeGroup(ParseeGroup group); optional tokenParseeResult(int index, TokenKind tokenKind); optional valueTypeParseeResult(int index); optional expressionParseeResult(int index); bool tryMatchingTokenKinds(vector kinds, bool shouldMatchAll, bool shouldAdvance); void markError(optional expectedTokenKind, optional message); public: Parser(vector> tokens); vector> getStatements(); }; #endif