Purple  0.1
Standard Language Specification
parse.h
Go to the documentation of this file.
1
30#ifndef PARSE
31#define PARSE
32
33#include "tree.h"
34#include "types/number.h"
35
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
52 [T_ASSIGN] = 1,
53};
54
56void match_token(TokenType type);
57int match_type(Number* out);
59void variable_declaration(void);
63
64#endif /* PARSE */
Definitions and function headers for the internal "Number" type.
static TokenType rightAssociativeOperators[TOKENTYPE_MAX+1]
Definition: parse.h:51
ASTNode * function_call_expression(void)
Parse a function call expression into an AST.
Definition: expression.c:127
ASTNode * function_declaration(void)
Parse a function declaration statement into an AST.
Definition: declaration.c:43
static TokenType operatorPrecedence[]
Operator precedence values. Precedence ranges from 0-15, 15 being the first to be computed.
Definition: parse.h:39
TokenType check_for_type(void)
Ensure current token is a type token, and scan the next token if so.
Definition: statement.c:84
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:324
int match_type(Number *out)
Matches a valid type in the input stream.
Definition: statement.c:53
ASTNode * parse_binary_expression(void)
Convenience wrapper for parse_binary_expression_recursive.
Definition: expression.c:236
TokenType
Types of scannable tokens.
Definition: scan.h:20
@ T_AND
Definition: scan.h:36
@ T_NAND
Definition: scan.h:39
@ TOKENTYPE_MAX
Definition: scan.h:81
@ 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:60
@ 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
Container for various kinds of number data.
Definition: number.h:56
Function headers for abstract syntax tree parsing.