This repository was archived by the owner on Dec 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathFinchParser.h
More file actions
53 lines (43 loc) · 1.46 KB
/
Copy pathFinchParser.h
File metadata and controls
53 lines (43 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#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);
};
}