Purple  0.1
Standard Language Specification
parse.h
Go to the documentation of this file.
1
30#ifndef PARSE_H
31#define PARSE_H
32
33#include "tree.h"
34#include "types/number.h"
35
39static int operatorPrecedence[] = {
40 [T_PLUS] = 12, [T_MINUS] = 12, [T_STAR] = 13, [T_SLASH] = 13, [T_EXPONENT] = 15,
41
42 [T_EQ] = 9, [T_NEQ] = 9,
43
44 [T_LT] = 10, [T_GT] = 10, [T_LE] = 10, [T_GE] = 10,
45
46 [T_AND] = 6, [T_OR] = 4, [T_XOR] = 5, [T_NAND] = 6, [T_NOR] = 4, [T_XNOR] = 5,
47
48 [T_ASSIGN] = 2,
49};
50
52void match_token(TokenType type);
54void variable_declaration(void);
58
59#endif /* PARSE_H */
Definitions and function headers for the internal "Number" type.
ASTNode * function_call_expression(void)
Definition: expression.c:28
ASTNode * function_declaration(void)
Parse a function declaration statement into an AST.
Definition: declaration.c:39
void match_token(TokenType type)
Ensure current token is of a given type, and scan the next token if so.
Definition: statement.c:18
void variable_declaration(void)
Parse a variable declaration statement into an AST.
Definition: declaration.c:18
ASTNode * parse_statements(void)
Parse a set of statements into ASTs and generate them into an AST.
Definition: statement.c:277
TokenType match_type(void)
Ensure current token is a type token, and scan the next token if so.
Definition: statement.c:32
ASTNode * parse_binary_expression(void)
Convenience wrapper for parse_binary_expression_recursive.
Definition: expression.c:154
static int operatorPrecedence[]
Definition: parse.h:39
TokenType
Types of scannable tokens.
Definition: scan.h:20
@ T_AND
Definition: scan.h:36
@ T_NAND
Definition: scan.h:39
@ T_XOR
Definition: scan.h:38
@ T_NOR
Definition: scan.h:40
@ T_GE
Definition: scan.h:34
@ T_STAR
Definition: scan.h:25
@ T_LT
Definition: scan.h:31
@ T_LE
Definition: scan.h:33
@ T_SLASH
Definition: scan.h:26
@ T_XNOR
Definition: scan.h:41
@ T_EQ
Definition: scan.h:29
@ T_ASSIGN
Definition: scan.h:59
@ T_GT
Definition: scan.h:32
@ T_PLUS
Definition: scan.h:23
@ T_MINUS
Definition: scan.h:24
@ T_OR
Definition: scan.h:37
@ T_NEQ
Definition: scan.h:30
@ T_EXPONENT
Definition: scan.h:27
Component of the abstract syntax tree built during parsing.
Definition: tree.h:20
Function headers for abstract syntax tree parsing.