|
libpulsar
A modular compiler for the pulsar programming language
|
Parsing routines for nodes and expressions. More...
#include "def.h"#include "frontend/lexer/token.h"#include "frontend/lexer/operator.h"#include "frontend/parser/tstream.h"#include "frontend/parser/ast.h"#include "util/io.h"Go to the source code of this file.
Macros | |
| #define | PS_PARSER_MAX_ERRORS 5 |
| The parser will stop in its tracks after it encounters this many errors. | |
Functions | |
| struct ps_type_tuple * | ps_parse_type_tuple (struct ps_tstream *ts) |
| Parses a tuple type. | |
| struct ps_type * | ps_parse_type_primary (struct ps_tstream *ts) |
| Parses a primary type such as a tuple or unresolved (struct, enum). | |
| struct ps_type * | ps_parse_type (struct ps_tstream *ts) |
Parses a type such as Rectangle or (Point, Point) from the token stream. | |
| struct ps_name * | ps_parse_name (struct ps_tstream *ts, struct ps_token *first) |
Parses a name such as foo::bar::baz. | |
| struct ps_node_block * | ps_parse_block (struct ps_tstream *ts) |
| Parses a block like: | |
| struct ps_node * | ps_parse_let (struct ps_tstream *ts) |
| struct ps_node * | ps_parse_fn (struct ps_tstream *ts) |
| Parses a function definition. | |
| struct ps_node * | ps_parse_import (struct ps_tstream *ts) |
| Parses an import statement. | |
| struct ps_node * | ps_parse_extern (struct ps_tstream *ts) |
| Parses an eexternal declaration. | |
| struct ps_node * | ps_parse_expr_stm (struct ps_tstream *ts) |
| An expression statement consists of an expression followed by a newline. | |
| struct ps_node * | ps_parse_struct (struct ps_tstream *ts) |
| Parses a structure declaration. | |
| struct ps_node * | ps_parse_enum (struct ps_tstream *ts) |
| Parses an enumeration declaration. | |
| struct ps_node * | ps_parse_for (struct ps_tstream *ts) |
| Parses a for loop. | |
| struct ps_node * | ps_parse_while (struct ps_tstream *ts) |
| Parses a while loop. | |
| struct ps_node * | ps_parse_if (struct ps_tstream *ts) |
| Parses an if-else statement. | |
| struct ps_node * | ps_parse_return (struct ps_tstream *ts) |
| Parses a return statement. | |
| struct ps_expr * | ps_parse_interp_str (struct ps_tstream *ts) |
| struct ps_expr * | ps_parse_expr_lit (struct ps_tstream *ts) |
| Parses an expression literal. | |
| struct ps_expr * | ps_parse_expr_call (struct ps_tstream *ts, struct ps_token *callee) |
| Parses a call expression, which involves a token (TODO: an expression) followed by a set of parentheses enclosing arguments. | |
| struct ps_expr * | ps_parse_expr_primary (struct ps_tstream *ts) |
| A primary expression is a literal or call expression. | |
| struct ps_expr * | ps_parse_expr_helper (struct ps_tstream *ts, struct ps_expr *lhs, ps_operator_precedence_t min_prec) |
| Handles predence and associativity in parsing expressions. | |
| struct ps_expr * | ps_parse_expr (struct ps_tstream *ts) |
| Parses a general expression. | |
| struct ps_node * | ps_parse_node (struct ps_tstream *ts) |
Parses and returns the next node in ts. | |
| struct ps_node_arr * | ps_parse (struct ps_token_arr *tokens, const struct ps_file_ctx *file_ctx) |
Constructs a series of nodes from the given tokens. | |
Parsing routines for nodes and expressions.
Definition in file parser.h.
| #define PS_PARSER_MAX_ERRORS 5 |
| struct ps_node_arr * ps_parse | ( | struct ps_token_arr * | tokens, |
| const struct ps_file_ctx * | file_ctx | ||
| ) |
| struct ps_node_block * ps_parse_block | ( | struct ps_tstream * | ts | ) |
| struct ps_node * ps_parse_enum | ( | struct ps_tstream * | ts | ) |
| struct ps_expr * ps_parse_expr | ( | struct ps_tstream * | ts | ) |
| struct ps_expr * ps_parse_expr_call | ( | struct ps_tstream * | ts, |
| struct ps_token * | callee | ||
| ) |
| struct ps_expr * ps_parse_expr_helper | ( | struct ps_tstream * | ts, |
| struct ps_expr * | lhs, | ||
| ps_operator_precedence_t | min_prec | ||
| ) |
| struct ps_expr * ps_parse_expr_lit | ( | struct ps_tstream * | ts | ) |
| struct ps_expr * ps_parse_expr_primary | ( | struct ps_tstream * | ts | ) |
A primary expression is a literal or call expression.
These are used as base cases invoked from ps_parse_expr() and ps_parse_expr_helper() to handle more complicated nesting.
| struct ps_node * ps_parse_expr_stm | ( | struct ps_tstream * | ts | ) |
| struct ps_node * ps_parse_extern | ( | struct ps_tstream * | ts | ) |
| struct ps_node * ps_parse_fn | ( | struct ps_tstream * | ts | ) |
| struct ps_node * ps_parse_for | ( | struct ps_tstream * | ts | ) |
| struct ps_node * ps_parse_if | ( | struct ps_tstream * | ts | ) |
| struct ps_node * ps_parse_import | ( | struct ps_tstream * | ts | ) |
| struct ps_expr * ps_parse_interp_str | ( | struct ps_tstream * | ts | ) |
| struct ps_node * ps_parse_let | ( | struct ps_tstream * | ts | ) |
| struct ps_name * ps_parse_name | ( | struct ps_tstream * | ts, |
| struct ps_token * | first | ||
| ) |
| struct ps_node * ps_parse_node | ( | struct ps_tstream * | ts | ) |
| struct ps_node * ps_parse_return | ( | struct ps_tstream * | ts | ) |
| struct ps_node * ps_parse_struct | ( | struct ps_tstream * | ts | ) |
| struct ps_type * ps_parse_type | ( | struct ps_tstream * | ts | ) |
| struct ps_type * ps_parse_type_primary | ( | struct ps_tstream * | ts | ) |
| struct ps_type_tuple * ps_parse_type_tuple | ( | struct ps_tstream * | ts | ) |
| struct ps_node * ps_parse_while | ( | struct ps_tstream * | ts | ) |