blob: 057c6bc645954f2514911f1b854f70b82e365dda (
plain)
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
|
#ifndef PARSER_H
#define PARSER_H
#include "ast.h"
#include "lexer.h"
enum parser_status
{
PARSER_OK,
PARSER_UNEXPECTED_TOKEN,
};
/**
* \brief Parses an expression or nothing.
*
* input = EOF
* | exp EOF ;
*/
struct ast *parse(enum parser_status *status, struct lexer *lexer);
/**
* \brief Parses sexp expressions separated by + and -.
*
* exp = sexp { ( '+' | '-' ) sexp } ;
*/
struct ast *parse_exp(enum parser_status *status, struct lexer *lexer);
/**
* \brief Parses texp expressions separated by * and /.
*
* sexp = texp { ('*' | '/' ) texp } ;
*/
struct ast *parse_sexp(enum parser_status *status, struct lexer *lexer);
/**
* \brief Parses a number, a - a number, or a parenthesized expression.
*
* texp = NUMBER
* | '-' NUMBER
* | '-' '(' exp ')'
* | '(' exp ')'
* ;
*/
struct ast *parse_texp(enum parser_status *status, struct lexer *lexer);
#endif /* !PARSER_H */
|