This repository has been archived by the owner on Dec 2, 2020. It is now read-only.
Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
finch/src/Syntax/FinchParser.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
53 lines (43 sloc)
1.46 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "Array.h" | |
#include "Expr.h" | |
#include "FinchString.h" | |
#include "Macros.h" | |
#include "Parser.h" | |
#include "Ref.h" | |
namespace Finch | |
{ | |
class ILineReader; | |
class MessageExpr; | |
// Parser for the Finch grammar. | |
class FinchParser : public Parser | |
{ | |
public: | |
FinchParser(ITokenSource & tokens, IErrorReporter & errorReporter) | |
: Parser(tokens, errorReporter) | |
{} | |
virtual ~FinchParser() {} | |
// Reads from the token source and returns the parsed expression. If | |
// this is an infinite source, it will return as soon as a complete | |
// expression is parsed. Otherwise, it will parse the entire source. | |
Ref<Expr> Parse(); | |
private: | |
// The grammar productions, from lowest to highest precedence. | |
Ref<Expr> Expression(); | |
Ref<Expr> Sequence(); | |
Ref<Expr> Variable(); | |
Ref<Expr> Bind(); | |
Ref<Expr> Assignment(); | |
Ref<Expr> Cascade(); | |
Ref<Expr> Keyword(bool & isMessage); | |
Ref<Expr> Operator(bool & isMessage); | |
Ref<Expr> Unary(bool & isMessage); | |
Ref<Expr> Primary(); | |
Ref<Expr> ParseKeyword(Ref<Expr> object); | |
void ParseDefines(DefineExpr & expr, TokenType endToken); | |
void ParseDefine(DefineExpr & expr); | |
void ParseDefineBody(DefineExpr & expr, String name, | |
const Array<String> & params); | |
NO_COPY(FinchParser); | |
}; | |
} | |