Z / libzlang 0.29.0
C99 runtime library and the Zlang 0.29 source-to-source compiler
Loading...
Searching...
No Matches
parser.c File Reference

Recursive-descent parser for the Zlang grammar. More...

#include "zlang/compiler/parser.h"
#include <string.h>

Functions

static const zlang_token_t * zlang_parser_current (const zlang_parser_t *parser)
static void zlang_parser_advance (zlang_parser_t *parser)
static bool zlang_parse_call_arguments (zlang_parser_t *parser, size_t *arguments, size_t *count, size_t capacity)
static bool zlang_parse_expression (zlang_parser_t *parser, size_t *expression)
static bool zlang_parser_expect (zlang_parser_t *parser, const zlang_token_kind_t kind, const char *message)
static void zlang_parser_unsupported (zlang_parser_t *parser, const char *message)
static size_t zlang_parser_add_expression (zlang_parser_t *parser)
static size_t zlang_parser_add_statement (zlang_parser_t *parser)
static bool zlang_token_is_type (const zlang_token_t *token)
static const char * zlang_conversion_target (const char *name)
static bool zlang_parser_is_user_type (const zlang_parser_t *parser, const zlang_token_t *token)
static const zlang_ast_statement_t * zlang_parser_find_struct (const zlang_parser_t *parser, const char *name)
static bool zlang_parser_is_declaration_type (const zlang_parser_t *parser, const zlang_token_t *token)
static bool zlang_parser_starts_declaration (const zlang_parser_t *parser)
static void zlang_parser_remember_string (zlang_parser_t *parser, const char *name)
static bool zlang_parser_is_string_name (const zlang_parser_t *parser, const char *name)
static bool zlang_parse_if (zlang_parser_t *parser)
static bool zlang_parse_for (zlang_parser_t *parser)
static bool zlang_parse_struct (zlang_parser_t *parser)
static bool zlang_parse_trait (zlang_parser_t *parser)
static bool zlang_parse_enum (zlang_parser_t *parser)
static bool zlang_parse_simple_block_statement (zlang_parser_t *parser, zlang_statement_kind_t kind)
static bool zlang_parse_foreach (zlang_parser_t *parser)
static bool zlang_parse_function (zlang_parser_t *parser, const char *owner, bool is_static, bool is_constructor)
static bool zlang_parse_import (zlang_parser_t *parser)
static bool zlang_parse_return (zlang_parser_t *parser)
static bool zlang_parse_jump_statement (zlang_parser_t *parser, zlang_statement_kind_t kind)
static bool zlang_parse_block (zlang_parser_t *parser, size_t statement)
static bool zlang_parse_statements (zlang_parser_t *parser)
static bool zlang_parse_primary (zlang_parser_t *parser, size_t *expression)
static bool zlang_parse_multiplicative (zlang_parser_t *parser, size_t *expression)
static bool zlang_parse_additive (zlang_parser_t *parser, size_t *expression)
static bool zlang_parse_relational (zlang_parser_t *parser, size_t *expression)
static bool zlang_parse_equality (zlang_parser_t *parser, size_t *expression)
static bool zlang_parse_logical_and (zlang_parser_t *parser, size_t *expression)
static bool zlang_parse_logical_or (zlang_parser_t *parser, size_t *expression)
static zlang_expression_kind_t zlang_compound_operator (zlang_token_kind_t kind)
static bool zlang_parse_array_initializer (zlang_parser_t *parser, zlang_ast_statement_t *statement, uint32_t depth, uint32_t extents[ZLANG_ARRAY_MAX_RANK])
static bool zlang_parse_declaration (zlang_parser_t *parser)
static bool zlang_parse_header_expression (zlang_parser_t *parser, size_t statement)
static const zlang_ast_statement_t * zlang_parser_find_array (const zlang_parser_t *parser, const char *name)
static const char * zlang_parser_sequence_type (const zlang_parser_t *parser, const char *name)
static uint32_t zlang_parser_array_rank (const zlang_parser_t *parser, const char *name)
void zlang_parser_init (zlang_parser_t *parser, zlang_token_t *tokens, size_t token_capacity, zlang_ast_expression_t *expressions, size_t expression_capacity, zlang_ast_statement_t *statements, size_t statement_capacity, zlang_parameter_t *parameters, size_t parameter_capacity, zlang_comment_t *comments, size_t comment_capacity, zlang_diagnostics_t *diagnostics)
static const zlang_ast_statement_t * zlang_find_array_statement (const zlang_program_t *program, const char *name)
static bool zlang_expression_constant_int (const zlang_program_t *program, size_t index, int32_t *value)
static bool zlang_expression_contains (const zlang_program_t *program, size_t root, size_t index)
static size_t zlang_find_owner_statement (const zlang_program_t *program, size_t index)
static bool zlang_loop_variable_max (const zlang_program_t *program, size_t owner, const char *name, int32_t *max)
static bool zlang_infer_array_shapes (zlang_program_t *program, zlang_diagnostics_t *diagnostics)
static bool zlang_parameter_has_array (const zlang_program_t *program, const zlang_ast_statement_t *function)
static bool zlang_infer_foreach_shapes (zlang_program_t *program, zlang_diagnostics_t *diagnostics)
static bool zlang_add_inferred_shape (zlang_program_t *program, size_t function_statement, const zlang_ast_statement_t *array)
static bool zlang_collect_inferred_shapes (zlang_program_t *program, size_t function_statement, const zlang_ast_statement_t *function)
static bool zlang_infer_function_array_shapes (zlang_program_t *program, zlang_diagnostics_t *diagnostics)
bool zlang_parse (zlang_parser_t *parser, const char *source, char *scratch, size_t scratch_capacity, zlang_parse_result_t *result)

Detailed Description

Recursive-descent parser for the Zlang grammar.

Function Documentation

◆ zlang_add_inferred_shape()

bool zlang_add_inferred_shape ( zlang_program_t * program,
size_t function_statement,
const zlang_ast_statement_t * array )
static

◆ zlang_collect_inferred_shapes()

bool zlang_collect_inferred_shapes ( zlang_program_t * program,
size_t function_statement,
const zlang_ast_statement_t * function )
static

◆ zlang_compound_operator()

zlang_expression_kind_t zlang_compound_operator ( zlang_token_kind_t kind)
static

◆ zlang_conversion_target()

const char * zlang_conversion_target ( const char * name)
static

◆ zlang_expression_constant_int()

bool zlang_expression_constant_int ( const zlang_program_t * program,
size_t index,
int32_t * value )
static

◆ zlang_expression_contains()

bool zlang_expression_contains ( const zlang_program_t * program,
size_t root,
size_t index )
static

◆ zlang_find_array_statement()

const zlang_ast_statement_t * zlang_find_array_statement ( const zlang_program_t * program,
const char * name )
static

◆ zlang_find_owner_statement()

size_t zlang_find_owner_statement ( const zlang_program_t * program,
size_t index )
static

◆ zlang_infer_array_shapes()

bool zlang_infer_array_shapes ( zlang_program_t * program,
zlang_diagnostics_t * diagnostics )
static

◆ zlang_infer_foreach_shapes()

bool zlang_infer_foreach_shapes ( zlang_program_t * program,
zlang_diagnostics_t * diagnostics )
static

◆ zlang_infer_function_array_shapes()

bool zlang_infer_function_array_shapes ( zlang_program_t * program,
zlang_diagnostics_t * diagnostics )
static

◆ zlang_loop_variable_max()

bool zlang_loop_variable_max ( const zlang_program_t * program,
size_t owner,
const char * name,
int32_t * max )
static

◆ zlang_parameter_has_array()

bool zlang_parameter_has_array ( const zlang_program_t * program,
const zlang_ast_statement_t * function )
static

◆ zlang_parse()

bool zlang_parse ( zlang_parser_t * parser,
const char * source,
char * scratch,
size_t scratch_capacity,
zlang_parse_result_t * result )

◆ zlang_parse_additive()

bool zlang_parse_additive ( zlang_parser_t * parser,
size_t * expression )
static

◆ zlang_parse_array_initializer()

bool zlang_parse_array_initializer ( zlang_parser_t * parser,
zlang_ast_statement_t * statement,
uint32_t depth,
uint32_t extents[ZLANG_ARRAY_MAX_RANK] )
static

◆ zlang_parse_block()

bool zlang_parse_block ( zlang_parser_t * parser,
size_t statement )
static

◆ zlang_parse_call_arguments()

bool zlang_parse_call_arguments ( zlang_parser_t * parser,
size_t * arguments,
size_t * count,
size_t capacity )
static

◆ zlang_parse_declaration()

bool zlang_parse_declaration ( zlang_parser_t * parser)
static

◆ zlang_parse_enum()

bool zlang_parse_enum ( zlang_parser_t * parser)
static

◆ zlang_parse_equality()

bool zlang_parse_equality ( zlang_parser_t * parser,
size_t * expression )
static

◆ zlang_parse_expression()

bool zlang_parse_expression ( zlang_parser_t * parser,
size_t * expression )
static

◆ zlang_parse_for()

bool zlang_parse_for ( zlang_parser_t * parser)
static

◆ zlang_parse_foreach()

bool zlang_parse_foreach ( zlang_parser_t * parser)
static

◆ zlang_parse_function()

bool zlang_parse_function ( zlang_parser_t * parser,
const char * owner,
bool is_static,
bool is_constructor )
static

◆ zlang_parse_header_expression()

bool zlang_parse_header_expression ( zlang_parser_t * parser,
size_t statement )
static

◆ zlang_parse_if()

bool zlang_parse_if ( zlang_parser_t * parser)
static

◆ zlang_parse_import()

bool zlang_parse_import ( zlang_parser_t * parser)
static

◆ zlang_parse_jump_statement()

bool zlang_parse_jump_statement ( zlang_parser_t * parser,
zlang_statement_kind_t kind )
static

◆ zlang_parse_logical_and()

bool zlang_parse_logical_and ( zlang_parser_t * parser,
size_t * expression )
static

◆ zlang_parse_logical_or()

bool zlang_parse_logical_or ( zlang_parser_t * parser,
size_t * expression )
static

◆ zlang_parse_multiplicative()

bool zlang_parse_multiplicative ( zlang_parser_t * parser,
size_t * expression )
static

◆ zlang_parse_primary()

bool zlang_parse_primary ( zlang_parser_t * parser,
size_t * expression )
static

◆ zlang_parse_relational()

bool zlang_parse_relational ( zlang_parser_t * parser,
size_t * expression )
static

◆ zlang_parse_return()

bool zlang_parse_return ( zlang_parser_t * parser)
static

◆ zlang_parse_simple_block_statement()

bool zlang_parse_simple_block_statement ( zlang_parser_t * parser,
zlang_statement_kind_t kind )
static

◆ zlang_parse_statements()

bool zlang_parse_statements ( zlang_parser_t * parser)
static

◆ zlang_parse_struct()

bool zlang_parse_struct ( zlang_parser_t * parser)
static

◆ zlang_parse_trait()

bool zlang_parse_trait ( zlang_parser_t * parser)
static

◆ zlang_parser_add_expression()

size_t zlang_parser_add_expression ( zlang_parser_t * parser)
static

◆ zlang_parser_add_statement()

size_t zlang_parser_add_statement ( zlang_parser_t * parser)
static

◆ zlang_parser_advance()

void zlang_parser_advance ( zlang_parser_t * parser)
static

◆ zlang_parser_array_rank()

uint32_t zlang_parser_array_rank ( const zlang_parser_t * parser,
const char * name )
static

◆ zlang_parser_current()

const zlang_token_t * zlang_parser_current ( const zlang_parser_t * parser)
static

◆ zlang_parser_expect()

bool zlang_parser_expect ( zlang_parser_t * parser,
const zlang_token_kind_t kind,
const char * message )
static

◆ zlang_parser_find_array()

const zlang_ast_statement_t * zlang_parser_find_array ( const zlang_parser_t * parser,
const char * name )
static

◆ zlang_parser_find_struct()

const zlang_ast_statement_t * zlang_parser_find_struct ( const zlang_parser_t * parser,
const char * name )
static

◆ zlang_parser_init()

void zlang_parser_init ( zlang_parser_t * parser,
zlang_token_t * tokens,
size_t token_capacity,
zlang_ast_expression_t * expressions,
size_t expression_capacity,
zlang_ast_statement_t * statements,
size_t statement_capacity,
zlang_parameter_t * parameters,
size_t parameter_capacity,
zlang_comment_t * comments,
size_t comment_capacity,
zlang_diagnostics_t * diagnostics )

◆ zlang_parser_is_declaration_type()

bool zlang_parser_is_declaration_type ( const zlang_parser_t * parser,
const zlang_token_t * token )
static

◆ zlang_parser_is_string_name()

bool zlang_parser_is_string_name ( const zlang_parser_t * parser,
const char * name )
static

◆ zlang_parser_is_user_type()

bool zlang_parser_is_user_type ( const zlang_parser_t * parser,
const zlang_token_t * token )
static

◆ zlang_parser_remember_string()

void zlang_parser_remember_string ( zlang_parser_t * parser,
const char * name )
static

◆ zlang_parser_sequence_type()

const char * zlang_parser_sequence_type ( const zlang_parser_t * parser,
const char * name )
static

◆ zlang_parser_starts_declaration()

bool zlang_parser_starts_declaration ( const zlang_parser_t * parser)
static

◆ zlang_parser_unsupported()

void zlang_parser_unsupported ( zlang_parser_t * parser,
const char * message )
static

◆ zlang_token_is_type()

bool zlang_token_is_type ( const zlang_token_t * token)
static