-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParser.h
51 lines (39 loc) · 1013 Bytes
/
Parser.h
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
#ifndef PARSER_H
#define PARSER_H
#include <QtCore/QString>
#include "ASTNode.h"
#include "Lexer.h"
class Expression;
class PainterContext;
class Scope;
class Parser
{
public:
Parser();
~Parser();
void setContext(PainterContext* context);
ASTNode* parse(const QString& sourceText);
bool hasError() const;
QString errorMessage() const;
private:
ASTNode* parseStatement();
Expression* parseFunctionCall(const QString &qualifiedIdentifier = QString());
ASTNode* parseVariableCreation();
ASTNode* parseVariableAssignment(const QString &qualifiedIdentifier);
Expression* parseTerm();
Expression* parseUnaryExpression();
Expression* parseMultiplicativeExpression();
Expression* parseAdditiveExpression();
Expression* parseExpression();
QString parseQualifiedIdentifier(bool firstIdentifierIsParsed = false);
private:
void getNextToken();
private:
Lexer* lexer;
PainterContext* m_context;
Lexer::Token m_token;
QString m_errorMessage;
int m_currentLine;
int m_currentColumn;
};
#endif