Zen-C
Loading...
Searching...
No Matches
parser.h File Reference
#include "ast.h"
#include "zprep.h"
Include dependency graph for parser.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ZenSymbol
 Represents a symbol in the symbol table. More...
 
struct  Scope
 Represents a lexical scope (block). More...
 
struct  FuncSig
 Registry entry for a function signature. More...
 
struct  LambdaRef
 Tracks a lambda (anonymous function) within the parser. More...
 
struct  GenericTemplate
 Template for a generic struct. More...
 
struct  GenericFuncTemplate
 Template for a generic function. More...
 
struct  GenericImplTemplate
 Template for a generic implementation block. More...
 
struct  ImportedFile
 Represents an imported source file (to prevent cycles/duplication). More...
 
struct  Instantiation
 Tracks a concrete instantiation of a generic template. More...
 
struct  StructRef
 Reference to a parsed struct (list node). More...
 
struct  StructDef
 Definition of a struct (lookup cache). More...
 
struct  SliceType
 Track used slice types for generation. More...
 
struct  TupleType
 Track used tuple signatures for generation. More...
 
struct  EnumVariantReg
 Registry of enum variants. More...
 
struct  DeprecatedFunc
 Functions marked as deprecated. More...
 
struct  Module
 Represents a module (namespace/file). More...
 
struct  SelectiveImport
 Symbol imported via selective import (import { X }). More...
 
struct  ImplReg
 Registry for trait implementations. More...
 
struct  ImportedPlugin
 Loaded compiler plugin. More...
 
struct  TypeAlias
 Type alias definition. More...
 
struct  ParserContext
 Global compilation state and symbol table. More...
 
struct  TypeUsage
 

Macros

#define MAX_KNOWN_GENERICS   1024
 

Typedefs

typedef struct ParserContext ParserContext
 
typedef struct ZenSymbol ZenSymbol
 Represents a symbol in the symbol table.
 
typedef struct Scope Scope
 Represents a lexical scope (block).
 
typedef struct FuncSig FuncSig
 Registry entry for a function signature.
 
typedef struct LambdaRef LambdaRef
 Tracks a lambda (anonymous function) within the parser.
 
typedef struct GenericTemplate GenericTemplate
 Template for a generic struct.
 
typedef struct GenericFuncTemplate GenericFuncTemplate
 Template for a generic function.
 
typedef struct GenericImplTemplate GenericImplTemplate
 Template for a generic implementation block.
 
typedef struct ImportedFile ImportedFile
 Represents an imported source file (to prevent cycles/duplication).
 
typedef struct Instantiation Instantiation
 Tracks a concrete instantiation of a generic template.
 
typedef struct StructRef StructRef
 Reference to a parsed struct (list node).
 
typedef struct StructDef StructDef
 Definition of a struct (lookup cache).
 
typedef struct SliceType SliceType
 Track used slice types for generation.
 
typedef struct TupleType TupleType
 Track used tuple signatures for generation.
 
typedef struct EnumVariantReg EnumVariantReg
 Registry of enum variants.
 
typedef struct DeprecatedFunc DeprecatedFunc
 Functions marked as deprecated.
 
typedef struct Module Module
 Represents a module (namespace/file).
 
typedef struct SelectiveImport SelectiveImport
 Symbol imported via selective import (import { X }).
 
typedef struct ImplReg ImplReg
 Registry for trait implementations.
 
typedef struct ImportedPlugin ImportedPlugin
 Loaded compiler plugin.
 
typedef struct TypeAlias TypeAlias
 Type alias definition.
 
typedef struct TypeUsage TypeUsage
 

Enumerations

enum  Precedence {
  PREC_NONE , PREC_ASSIGNMENT , PREC_TERNARY , PREC_OR ,
  PREC_AND , PREC_EQUALITY , PREC_COMPARISON , PREC_TERM ,
  PREC_FACTOR , PREC_UNARY , PREC_CALL , PREC_PRIMARY
}
 Operator precedence for expression parsing. More...
 

Functions

ASTNodeparse_program (ParserContext *ctx, Lexer *l)
 Parses a program.
 
void register_type_usage (ParserContext *ctx, const char *name, Token t)
 Registers a type usage.
 
int validate_types (ParserContext *ctx)
 Validates types.
 
char * token_strdup (Token t)
 Duplicates a token.
 
int is_token (Token t, const char *s)
 Checks if a token matches a string.
 
Token expect (Lexer *l, TokenType type, const char *msg)
 Expects a token of a specific type.
 
void skip_comments (Lexer *l)
 Skips comments in the lexer.
 
char * consume_until_semicolon (Lexer *l)
 Consumes tokens until a semicolon is found.
 
char * consume_and_rewrite (ParserContext *ctx, Lexer *l)
 Consumes and rewrites tokens.
 
int is_c_reserved_word (const char *name)
 Checks if a name is a C reserved word.
 
void warn_c_reserved_word (Token t, const char *name)
 Warns about a C reserved word.
 
void enter_scope (ParserContext *ctx)
 Enters a new scope (pushes to scope stack).
 
void exit_scope (ParserContext *ctx)
 Exits the current scope (pops from scope stack).
 
void add_symbol (ParserContext *ctx, const char *n, const char *t, Type *type_info)
 Adds a symbol to the current scope.
 
void add_symbol_with_token (ParserContext *ctx, const char *n, const char *t, Type *type_info, Token tok)
 Adds a symbol with definition token location.
 
Typefind_symbol_type_info (ParserContext *ctx, const char *n)
 Finds a symbol's type information.
 
char * find_symbol_type (ParserContext *ctx, const char *n)
 Finds a symbol's type.
 
ZenSymbolfind_symbol_entry (ParserContext *ctx, const char *n)
 Finds a symbol's entry.
 
ZenSymbolfind_symbol_in_all (ParserContext *ctx, const char *n)
 Finds a symbol in all scopes.
 
char * find_similar_symbol (ParserContext *ctx, const char *name)
 
void register_func (ParserContext *ctx, const char *name, int count, char **defaults, Type **arg_types, Type *ret_type, int is_varargs, int is_async, Token decl_token)
 Registers a function.
 
void register_func_template (ParserContext *ctx, const char *name, const char *param, ASTNode *node)
 Registers a function template.
 
GenericFuncTemplatefind_func_template (ParserContext *ctx, const char *name)
 Finds a function template.
 
void register_generic (ParserContext *ctx, char *name)
 Registers a known generic type parameter.
 
int is_known_generic (ParserContext *ctx, char *name)
 Checks if a name is a known generic parameter.
 
void register_impl_template (ParserContext *ctx, const char *sname, const char *param, ASTNode *node)
 
void add_to_struct_list (ParserContext *ctx, ASTNode *node)
 
void add_to_enum_list (ParserContext *ctx, ASTNode *node)
 
void add_to_func_list (ParserContext *ctx, ASTNode *node)
 
void add_to_impl_list (ParserContext *ctx, ASTNode *node)
 
void add_to_global_list (ParserContext *ctx, ASTNode *node)
 
void register_builtins (ParserContext *ctx)
 
void add_instantiated_func (ParserContext *ctx, ASTNode *fn)
 
void instantiate_generic (ParserContext *ctx, const char *name, const char *concrete_type, const char *unmangled_type, Token t)
 Instantiates a generic struct/function.
 
void instantiate_generic_multi (ParserContext *ctx, const char *name, char **args, int arg_count, Token t)
 Instantiates a multi-parameter generic.
 
char * sanitize_mangled_name (const char *name)
 Sanitizes a mangled name for use in codegen.
 
TypeAliasfind_type_alias_node (ParserContext *ctx, const char *name)
 Registers a type alias.
 
void register_type_alias (ParserContext *ctx, const char *alias, const char *original, int is_opaque, const char *defined_in_file)
 
void register_impl (ParserContext *ctx, const char *trait, const char *strct)
 Registers an implementation.
 
int check_impl (ParserContext *ctx, const char *trait, const char *strct)
 Checks if a type implements a trait.
 
void register_template (ParserContext *ctx, const char *name, ASTNode *node)
 Registers a template.
 
void register_deprecated_func (ParserContext *ctx, const char *name, const char *reason)
 Registers a deprecated function.
 
DeprecatedFuncfind_deprecated_func (ParserContext *ctx, const char *name)
 Finds a deprecated function.
 
ASTNodeparse_arrow_lambda_single (ParserContext *ctx, Lexer *l, char *param_name)
 Parses a single parameter arrow lambda.
 
ASTNodeparse_arrow_lambda_multi (ParserContext *ctx, Lexer *l, char **param_names, int num_params)
 Parses a multi-parameter arrow lambda.
 
char * parse_and_convert_args (ParserContext *ctx, Lexer *l, char ***defaults_out, int *count_out, Type ***types_out, char ***names_out, int *is_varargs_out, char ***ctype_overrides_out)
 Parses and converts arguments.
 
int is_file_imported (ParserContext *ctx, const char *path)
 Checks if a file has been imported.
 
void mark_file_imported (ParserContext *ctx, const char *path)
 Marks a file as imported.
 
void register_plugin (ParserContext *ctx, const char *name, const char *alias)
 Registers a plugin.
 
const char * resolve_plugin (ParserContext *ctx, const char *name_or_alias)
 Resolves a plugin by name or alias.
 
void print_type_defs (ParserContext *ctx, FILE *out, ASTNode *nodes)
 Prints type definitions to a file.
 
char * replace_in_string (const char *src, const char *old_w, const char *new_w)
 Replaces a substring in a string.
 
char * replace_type_str (const char *src, const char *param, const char *concrete, const char *old_struct, const char *new_struct)
 Replaces a type string in a string.
 
Typereplace_type_formal (Type *t, const char *p, const char *c, const char *os, const char *ns)
 Replaces a type formal in a type.
 
ASTNodecopy_ast_replacing (ASTNode *n, const char *p, const char *c, const char *os, const char *ns)
 Copies an AST node and replaces its type parameters.
 
char * extract_module_name (const char *path)
 
void register_enum_variant (ParserContext *ctx, const char *ename, const char *vname, int tag)
 Registers an enum variant.
 
EnumVariantRegfind_enum_variant (ParserContext *ctx, const char *vname)
 Finds an enum variant.
 
void register_lambda (ParserContext *ctx, ASTNode *node)
 Registers a lambda.
 
void analyze_lambda_captures (ParserContext *ctx, ASTNode *lambda)
 Analyzes lambda captures.
 
void register_slice (ParserContext *ctx, const char *type)
 Registers a slice type.
 
void register_tuple (ParserContext *ctx, const char *sig)
 Registers a tuple type.
 
ASTNodefind_struct_def (ParserContext *ctx, const char *name)
 Finds a struct definition.
 
void register_struct_def (ParserContext *ctx, const char *name, ASTNode *node)
 Registers a struct definition.
 
Modulefind_module (ParserContext *ctx, const char *alias)
 Finds a module.
 
void register_module (ParserContext *ctx, const char *alias, const char *path)
 Registers a module.
 
void register_selective_import (ParserContext *ctx, const char *symbol, const char *alias, const char *source_module)
 Registers a selective import.
 
SelectiveImportfind_selective_import (ParserContext *ctx, const char *name)
 Finds a selective import.
 
const char * find_type_alias (ParserContext *ctx, const char *alias)
 Finds a type alias.
 
void register_extern_symbol (ParserContext *ctx, const char *name)
 Registers an external symbol.
 
int is_extern_symbol (ParserContext *ctx, const char *name)
 Checks if a symbol is external.
 
int should_suppress_undef_warning (ParserContext *ctx, const char *name)
 Checks if a symbol should suppress an undefined warning.
 
void init_builtins ()
 Initializes built-in types and symbols.
 
char * rewrite_expr_methods (ParserContext *ctx, char *raw)
 Rewrites expression methods.
 
char * process_fstring (ParserContext *ctx, const char *content, char ***used_syms, int *count)
 Processes a formatted string.
 
char * instantiate_function_template (ParserContext *ctx, const char *name, const char *concrete_type, const char *unmangled_type)
 Instantiates a function template.
 
FuncSigfind_func (ParserContext *ctx, const char *name)
 Finds a function.
 
Typeparse_type_formal (ParserContext *ctx, Lexer *l)
 Parses a type formal.
 
int check_opaque_alias_compat (ParserContext *ctx, Type *a, Type *b)
 Checks compatibility of opaque aliases (allows access within defining file).
 
char * parse_type (ParserContext *ctx, Lexer *l)
 Parses a type.
 
Typeparse_type_base (ParserContext *ctx, Lexer *l)
 Parses a type base.
 
ASTNodeparse_expression (ParserContext *ctx, Lexer *l)
 Parses an expression.
 
ASTNodeparse_expr_prec (ParserContext *ctx, Lexer *l, Precedence min_prec)
 Parses an expression with minimum precedence.
 
ASTNodeparse_primary (ParserContext *ctx, Lexer *l)
 Parses a primary expression (literal, variable, grouping).
 
ASTNodeparse_lambda (ParserContext *ctx, Lexer *l)
 Parses a lambda.
 
char * parse_condition_raw (ParserContext *ctx, Lexer *l)
 Parses a condition.
 
char * parse_array_literal (ParserContext *ctx, Lexer *l, const char *st)
 Parses an array literal.
 
char * parse_tuple_literal (ParserContext *ctx, Lexer *l, const char *tn)
 Parses a tuple literal.
 
ASTNodeparse_embed (ParserContext *ctx, Lexer *l)
 Parses an embed.
 
ASTNodeparse_macro_call (ParserContext *ctx, Lexer *l, char *name)
 Parses a macro call.
 
ASTNodeparse_statement (ParserContext *ctx, Lexer *l)
 Parses a statement.
 
ASTNodeparse_block (ParserContext *ctx, Lexer *l)
 Parses a block of statements { ... }.
 
ASTNodeparse_if (ParserContext *ctx, Lexer *l)
 Parses an if statement.
 
ASTNodeparse_while (ParserContext *ctx, Lexer *l)
 Parses a while loop.
 
ASTNodeparse_for (ParserContext *ctx, Lexer *l)
 Parses a for loop.
 
ASTNodeparse_loop (ParserContext *ctx, Lexer *l)
 Parses a loop.
 
ASTNodeparse_repeat (ParserContext *ctx, Lexer *l)
 Parses a repeat loop.
 
ASTNodeparse_unless (ParserContext *ctx, Lexer *l)
 Parses an unless statement.
 
ASTNodeparse_guard (ParserContext *ctx, Lexer *l)
 Parses a guard statement.
 
ASTNodeparse_match (ParserContext *ctx, Lexer *l)
 Parses a match statement.
 
ASTNodeparse_return (ParserContext *ctx, Lexer *l)
 Parses a return statement.
 
char * process_printf_sugar (ParserContext *ctx, const char *content, int newline, const char *target, char ***used_syms, int *count, int check_symbols)
 Processes a formatted string.
 
ASTNodeparse_assert (ParserContext *ctx, Lexer *l)
 Parses an assert statement.
 
ASTNodeparse_defer (ParserContext *ctx, Lexer *l)
 Parses a defer statement.
 
ASTNodeparse_asm (ParserContext *ctx, Lexer *l)
 Parses an asm statement.
 
ASTNodeparse_plugin (ParserContext *ctx, Lexer *l)
 Parses a plugin statement.
 
ASTNodeparse_var_decl (ParserContext *ctx, Lexer *l)
 Parses a variable declaration.
 
ASTNodeparse_def (ParserContext *ctx, Lexer *l)
 Parses a def statement.
 
ASTNodeparse_type_alias (ParserContext *ctx, Lexer *l, int is_opaque)
 Parses a type alias.
 
ASTNodeparse_function (ParserContext *ctx, Lexer *l, int is_async)
 Parses a function definition.
 
ASTNodeparse_struct (ParserContext *ctx, Lexer *l, int is_union, int is_opaque)
 Parses a struct definition.
 
ASTNodeparse_enum (ParserContext *ctx, Lexer *l)
 Parses an enum definition.
 
ASTNodeparse_trait (ParserContext *ctx, Lexer *l)
 Parses a trait definition.
 
ASTNodeparse_impl (ParserContext *ctx, Lexer *l)
 Parses an implementation.
 
ASTNodeparse_impl_trait (ParserContext *ctx, Lexer *l)
 Parses an implementation trait.
 
ASTNodeparse_test (ParserContext *ctx, Lexer *l)
 Parses a test definition.
 
int is_type_copy (ParserContext *ctx, Type *t)
 Checks if a type is copyable.
 
void check_move_usage (ParserContext *ctx, ASTNode *node, Token t)
 Checks if a type is copyable.
 
ASTNodeparse_include (ParserContext *ctx, Lexer *l)
 Parses an include statement.
 
ASTNodeparse_import (ParserContext *ctx, Lexer *l)
 Parses an import statement.
 
ASTNodeparse_comptime (ParserContext *ctx, Lexer *l)
 Parses a comptime statement.
 
char * patch_self_args (const char *args, const char *struct_name)
 Patches self arguments in a function.
 
ASTNodeparse_program_nodes (ParserContext *ctx, Lexer *l)
 Main loop to parse top-level nodes in a file.
 

Variables

ParserContextg_parser_ctx
 

Macro Definition Documentation

◆ MAX_KNOWN_GENERICS

#define MAX_KNOWN_GENERICS   1024

Typedef Documentation

◆ DeprecatedFunc

Functions marked as deprecated.

◆ EnumVariantReg

Registry of enum variants.

◆ FuncSig

typedef struct FuncSig FuncSig

Registry entry for a function signature.

Stores metadata about declared functions for type checking and call validation.

◆ GenericFuncTemplate

Template for a generic function.

◆ GenericImplTemplate

Template for a generic implementation block.

◆ GenericTemplate

Template for a generic struct.

◆ ImplReg

typedef struct ImplReg ImplReg

Registry for trait implementations.

◆ ImportedFile

typedef struct ImportedFile ImportedFile

Represents an imported source file (to prevent cycles/duplication).

◆ ImportedPlugin

Loaded compiler plugin.

◆ Instantiation

typedef struct Instantiation Instantiation

Tracks a concrete instantiation of a generic template.

◆ LambdaRef

typedef struct LambdaRef LambdaRef

Tracks a lambda (anonymous function) within the parser.

◆ Module

typedef struct Module Module

Represents a module (namespace/file).

◆ ParserContext

typedef struct ParserContext ParserContext

◆ Scope

typedef struct Scope Scope

Represents a lexical scope (block).

Scopes form a hierarchy (parent pointer) and contain a list of symbols defined in that scope.

◆ SelectiveImport

Symbol imported via selective import (import { X }).

◆ SliceType

typedef struct SliceType SliceType

Track used slice types for generation.

◆ StructDef

typedef struct StructDef StructDef

Definition of a struct (lookup cache).

◆ StructRef

typedef struct StructRef StructRef

Reference to a parsed struct (list node).

◆ TupleType

typedef struct TupleType TupleType

Track used tuple signatures for generation.

◆ TypeAlias

typedef struct TypeAlias TypeAlias

Type alias definition.

◆ TypeUsage

typedef struct TypeUsage TypeUsage

◆ ZenSymbol

typedef struct ZenSymbol ZenSymbol

Represents a symbol in the symbol table.

Used for variables, functions, and other named entities.

Enumeration Type Documentation

◆ Precedence

enum Precedence

Operator precedence for expression parsing.

Enumerator
PREC_NONE 

No precedence.

PREC_ASSIGNMENT 

Assignment operators.

PREC_TERNARY 

Ternary operator.

PREC_OR 

Logical OR.

PREC_AND 

Logical AND.

PREC_EQUALITY 

Equality operators.

PREC_COMPARISON 

Comparison operators.

PREC_TERM 

Addition and subtraction.

PREC_FACTOR 

Multiplication and division.

PREC_UNARY 

Unary operators.

PREC_CALL 

Function calls.

PREC_PRIMARY 

Primary expressions.

Function Documentation

◆ add_instantiated_func()

void add_instantiated_func ( ParserContext ctx,
ASTNode fn 
)
Here is the caller graph for this function:

◆ add_symbol()

void add_symbol ( ParserContext ctx,
const char *  n,
const char *  t,
Type type_info 
)

Adds a symbol to the current scope.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_symbol_with_token()

void add_symbol_with_token ( ParserContext ctx,
const char *  n,
const char *  t,
Type type_info,
Token  tok 
)

Adds a symbol with definition token location.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_to_enum_list()

void add_to_enum_list ( ParserContext ctx,
ASTNode node 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_to_func_list()

void add_to_func_list ( ParserContext ctx,
ASTNode node 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_to_global_list()

void add_to_global_list ( ParserContext ctx,
ASTNode node 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_to_impl_list()

void add_to_impl_list ( ParserContext ctx,
ASTNode node 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_to_struct_list()

void add_to_struct_list ( ParserContext ctx,
ASTNode node 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ analyze_lambda_captures()

void analyze_lambda_captures ( ParserContext ctx,
ASTNode lambda 
)

Analyzes lambda captures.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_impl()

int check_impl ( ParserContext ctx,
const char *  trait,
const char *  strct 
)

Checks if a type implements a trait.

Here is the caller graph for this function:

◆ check_move_usage()

void check_move_usage ( ParserContext ctx,
ASTNode node,
Token  t 
)

Checks if a type is copyable.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_opaque_alias_compat()

int check_opaque_alias_compat ( ParserContext ctx,
Type a,
Type b 
)

Checks compatibility of opaque aliases (allows access within defining file).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ consume_and_rewrite()

char * consume_and_rewrite ( ParserContext ctx,
Lexer l 
)

Consumes and rewrites tokens.

Here is the call graph for this function:

◆ consume_until_semicolon()

char * consume_until_semicolon ( Lexer l)

Consumes tokens until a semicolon is found.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_ast_replacing()

ASTNode * copy_ast_replacing ( ASTNode n,
const char *  p,
const char *  c,
const char *  os,
const char *  ns 
)

Copies an AST node and replaces its type parameters.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enter_scope()

void enter_scope ( ParserContext ctx)

Enters a new scope (pushes to scope stack).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exit_scope()

void exit_scope ( ParserContext ctx)

Exits the current scope (pops from scope stack).

Here is the caller graph for this function:

◆ expect()

Token expect ( Lexer l,
TokenType  type,
const char *  msg 
)

Expects a token of a specific type.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extract_module_name()

char * extract_module_name ( const char *  path)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_deprecated_func()

DeprecatedFunc * find_deprecated_func ( ParserContext ctx,
const char *  name 
)

Finds a deprecated function.

◆ find_enum_variant()

EnumVariantReg * find_enum_variant ( ParserContext ctx,
const char *  vname 
)

Finds an enum variant.

Here is the caller graph for this function:

◆ find_func()

FuncSig * find_func ( ParserContext ctx,
const char *  name 
)

Finds a function.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_func_template()

GenericFuncTemplate * find_func_template ( ParserContext ctx,
const char *  name 
)

Finds a function template.

Here is the caller graph for this function:

◆ find_module()

Module * find_module ( ParserContext ctx,
const char *  alias 
)

Finds a module.

Here is the caller graph for this function:

◆ find_selective_import()

SelectiveImport * find_selective_import ( ParserContext ctx,
const char *  name 
)

Finds a selective import.

Here is the caller graph for this function:

◆ find_similar_symbol()

char * find_similar_symbol ( ParserContext ctx,
const char *  name 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_struct_def()

ASTNode * find_struct_def ( ParserContext ctx,
const char *  name 
)

Finds a struct definition.

Here is the caller graph for this function:

◆ find_symbol_entry()

ZenSymbol * find_symbol_entry ( ParserContext ctx,
const char *  n 
)

Finds a symbol's entry.

Here is the caller graph for this function:

◆ find_symbol_in_all()

ZenSymbol * find_symbol_in_all ( ParserContext ctx,
const char *  n 
)

Finds a symbol in all scopes.

Here is the caller graph for this function:

◆ find_symbol_type()

char * find_symbol_type ( ParserContext ctx,
const char *  n 
)

Finds a symbol's type.

Here is the caller graph for this function:

◆ find_symbol_type_info()

Type * find_symbol_type_info ( ParserContext ctx,
const char *  n 
)

Finds a symbol's type information.

Here is the caller graph for this function:

◆ find_type_alias()

const char * find_type_alias ( ParserContext ctx,
const char *  alias 
)

Finds a type alias.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_type_alias_node()

TypeAlias * find_type_alias_node ( ParserContext ctx,
const char *  name 
)

Registers a type alias.

Here is the caller graph for this function:

◆ init_builtins()

void init_builtins ( )

Initializes built-in types and symbols.

Here is the caller graph for this function:

◆ instantiate_function_template()

char * instantiate_function_template ( ParserContext ctx,
const char *  name,
const char *  concrete_type,
const char *  unmangled_type 
)

Instantiates a function template.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ instantiate_generic()

void instantiate_generic ( ParserContext ctx,
const char *  name,
const char *  concrete_type,
const char *  unmangled_type,
Token  t 
)

Instantiates a generic struct/function.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ instantiate_generic_multi()

void instantiate_generic_multi ( ParserContext ctx,
const char *  name,
char **  args,
int  arg_count,
Token  t 
)

Instantiates a multi-parameter generic.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_c_reserved_word()

int is_c_reserved_word ( const char *  name)

Checks if a name is a C reserved word.

Here is the caller graph for this function:

◆ is_extern_symbol()

int is_extern_symbol ( ParserContext ctx,
const char *  name 
)

Checks if a symbol is external.

Here is the caller graph for this function:

◆ is_file_imported()

int is_file_imported ( ParserContext ctx,
const char *  path 
)

Checks if a file has been imported.

Here is the caller graph for this function:

◆ is_known_generic()

int is_known_generic ( ParserContext ctx,
char *  name 
)

Checks if a name is a known generic parameter.

Here is the caller graph for this function:

◆ is_token()

int is_token ( Token  t,
const char *  s 
)

Checks if a token matches a string.

Here is the caller graph for this function:

◆ is_type_copy()

int is_type_copy ( ParserContext ctx,
Type t 
)

Checks if a type is copyable.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mark_file_imported()

void mark_file_imported ( ParserContext ctx,
const char *  path 
)

Marks a file as imported.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_and_convert_args()

char * parse_and_convert_args ( ParserContext ctx,
Lexer l,
char ***  defaults_out,
int *  count_out,
Type ***  types_out,
char ***  names_out,
int *  is_varargs_out,
char ***  ctype_overrides_out 
)

Parses and converts arguments.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_array_literal()

char * parse_array_literal ( ParserContext ctx,
Lexer l,
const char *  st 
)

Parses an array literal.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_arrow_lambda_multi()

ASTNode * parse_arrow_lambda_multi ( ParserContext ctx,
Lexer l,
char **  param_names,
int  num_params 
)

Parses a multi-parameter arrow lambda.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_arrow_lambda_single()

ASTNode * parse_arrow_lambda_single ( ParserContext ctx,
Lexer l,
char *  param_name 
)

Parses a single parameter arrow lambda.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_asm()

ASTNode * parse_asm ( ParserContext ctx,
Lexer l 
)

Parses an asm statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_assert()

ASTNode * parse_assert ( ParserContext ctx,
Lexer l 
)

Parses an assert statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_block()

ASTNode * parse_block ( ParserContext ctx,
Lexer l 
)

Parses a block of statements { ... }.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_comptime()

ASTNode * parse_comptime ( ParserContext ctx,
Lexer l 
)

Parses a comptime statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_condition_raw()

char * parse_condition_raw ( ParserContext ctx,
Lexer l 
)

Parses a condition.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_def()

ASTNode * parse_def ( ParserContext ctx,
Lexer l 
)

Parses a def statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_defer()

ASTNode * parse_defer ( ParserContext ctx,
Lexer l 
)

Parses a defer statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_embed()

ASTNode * parse_embed ( ParserContext ctx,
Lexer l 
)

Parses an embed.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_enum()

ASTNode * parse_enum ( ParserContext ctx,
Lexer l 
)

Parses an enum definition.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_expr_prec()

ASTNode * parse_expr_prec ( ParserContext ctx,
Lexer l,
Precedence  min_prec 
)

Parses an expression with minimum precedence.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_expression()

ASTNode * parse_expression ( ParserContext ctx,
Lexer l 
)

Parses an expression.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_for()

ASTNode * parse_for ( ParserContext ctx,
Lexer l 
)

Parses a for loop.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_function()

ASTNode * parse_function ( ParserContext ctx,
Lexer l,
int  is_async 
)

Parses a function definition.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_guard()

ASTNode * parse_guard ( ParserContext ctx,
Lexer l 
)

Parses a guard statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_if()

ASTNode * parse_if ( ParserContext ctx,
Lexer l 
)

Parses an if statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_impl()

ASTNode * parse_impl ( ParserContext ctx,
Lexer l 
)

Parses an implementation.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_impl_trait()

ASTNode * parse_impl_trait ( ParserContext ctx,
Lexer l 
)

Parses an implementation trait.

◆ parse_import()

ASTNode * parse_import ( ParserContext ctx,
Lexer l 
)

Parses an import statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_include()

ASTNode * parse_include ( ParserContext ctx,
Lexer l 
)

Parses an include statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_lambda()

ASTNode * parse_lambda ( ParserContext ctx,
Lexer l 
)

Parses a lambda.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_loop()

ASTNode * parse_loop ( ParserContext ctx,
Lexer l 
)

Parses a loop.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_macro_call()

ASTNode * parse_macro_call ( ParserContext ctx,
Lexer l,
char *  name 
)

Parses a macro call.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_match()

ASTNode * parse_match ( ParserContext ctx,
Lexer l 
)

Parses a match statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_plugin()

ASTNode * parse_plugin ( ParserContext ctx,
Lexer l 
)

Parses a plugin statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_primary()

ASTNode * parse_primary ( ParserContext ctx,
Lexer l 
)

Parses a primary expression (literal, variable, grouping).

Here is the caller graph for this function:

◆ parse_program()

ASTNode * parse_program ( ParserContext ctx,
Lexer l 
)

Parses a program.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_program_nodes()

ASTNode * parse_program_nodes ( ParserContext ctx,
Lexer l 
)

Main loop to parse top-level nodes in a file.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_repeat()

ASTNode * parse_repeat ( ParserContext ctx,
Lexer l 
)

Parses a repeat loop.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_return()

ASTNode * parse_return ( ParserContext ctx,
Lexer l 
)

Parses a return statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_statement()

ASTNode * parse_statement ( ParserContext ctx,
Lexer l 
)

Parses a statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_struct()

ASTNode * parse_struct ( ParserContext ctx,
Lexer l,
int  is_union,
int  is_opaque 
)

Parses a struct definition.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_test()

ASTNode * parse_test ( ParserContext ctx,
Lexer l 
)

Parses a test definition.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_trait()

ASTNode * parse_trait ( ParserContext ctx,
Lexer l 
)

Parses a trait definition.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_tuple_literal()

char * parse_tuple_literal ( ParserContext ctx,
Lexer l,
const char *  tn 
)

Parses a tuple literal.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_type()

char * parse_type ( ParserContext ctx,
Lexer l 
)

Parses a type.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_type_alias()

ASTNode * parse_type_alias ( ParserContext ctx,
Lexer l,
int  is_opaque 
)

Parses a type alias.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_type_base()

Type * parse_type_base ( ParserContext ctx,
Lexer l 
)

Parses a type base.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_type_formal()

Type * parse_type_formal ( ParserContext ctx,
Lexer l 
)

Parses a type formal.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_unless()

ASTNode * parse_unless ( ParserContext ctx,
Lexer l 
)

Parses an unless statement.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_var_decl()

ASTNode * parse_var_decl ( ParserContext ctx,
Lexer l 
)

Parses a variable declaration.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_while()

ASTNode * parse_while ( ParserContext ctx,
Lexer l 
)

Parses a while loop.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ patch_self_args()

char * patch_self_args ( const char *  args,
const char *  struct_name 
)

Patches self arguments in a function.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_type_defs()

void print_type_defs ( ParserContext ctx,
FILE *  out,
ASTNode nodes 
)

Prints type definitions to a file.

◆ process_fstring()

char * process_fstring ( ParserContext ctx,
const char *  content,
char ***  used_syms,
int *  count 
)

Processes a formatted string.

Here is the call graph for this function:

◆ process_printf_sugar()

char * process_printf_sugar ( ParserContext ctx,
const char *  content,
int  newline,
const char *  target,
char ***  used_syms,
int *  count,
int  check_symbols 
)

Processes a formatted string.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_builtins()

void register_builtins ( ParserContext ctx)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_deprecated_func()

void register_deprecated_func ( ParserContext ctx,
const char *  name,
const char *  reason 
)

Registers a deprecated function.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_enum_variant()

void register_enum_variant ( ParserContext ctx,
const char *  ename,
const char *  vname,
int  tag 
)

Registers an enum variant.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_extern_symbol()

void register_extern_symbol ( ParserContext ctx,
const char *  name 
)

Registers an external symbol.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_func()

void register_func ( ParserContext ctx,
const char *  name,
int  count,
char **  defaults,
Type **  arg_types,
Type ret_type,
int  is_varargs,
int  is_async,
Token  decl_token 
)

Registers a function.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_func_template()

void register_func_template ( ParserContext ctx,
const char *  name,
const char *  param,
ASTNode node 
)

Registers a function template.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_generic()

void register_generic ( ParserContext ctx,
char *  name 
)

Registers a known generic type parameter.

Here is the caller graph for this function:

◆ register_impl()

void register_impl ( ParserContext ctx,
const char *  trait,
const char *  strct 
)

Registers an implementation.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_impl_template()

void register_impl_template ( ParserContext ctx,
const char *  sname,
const char *  param,
ASTNode node 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_lambda()

void register_lambda ( ParserContext ctx,
ASTNode node 
)

Registers a lambda.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_module()

void register_module ( ParserContext ctx,
const char *  alias,
const char *  path 
)

Registers a module.

Here is the call graph for this function:

◆ register_plugin()

void register_plugin ( ParserContext ctx,
const char *  name,
const char *  alias 
)

Registers a plugin.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_selective_import()

void register_selective_import ( ParserContext ctx,
const char *  symbol,
const char *  alias,
const char *  source_module 
)

Registers a selective import.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_slice()

void register_slice ( ParserContext ctx,
const char *  type 
)

Registers a slice type.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_struct_def()

void register_struct_def ( ParserContext ctx,
const char *  name,
ASTNode node 
)

Registers a struct definition.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_template()

void register_template ( ParserContext ctx,
const char *  name,
ASTNode node 
)

Registers a template.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_tuple()

void register_tuple ( ParserContext ctx,
const char *  sig 
)

Registers a tuple type.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_type_alias()

void register_type_alias ( ParserContext ctx,
const char *  alias,
const char *  original,
int  is_opaque,
const char *  defined_in_file 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_type_usage()

void register_type_usage ( ParserContext ctx,
const char *  name,
Token  t 
)

Registers a type usage.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replace_in_string()

char * replace_in_string ( const char *  src,
const char *  old_w,
const char *  new_w 
)

Replaces a substring in a string.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replace_type_formal()

Type * replace_type_formal ( Type t,
const char *  p,
const char *  c,
const char *  os,
const char *  ns 
)

Replaces a type formal in a type.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replace_type_str()

char * replace_type_str ( const char *  src,
const char *  param,
const char *  concrete,
const char *  old_struct,
const char *  new_struct 
)

Replaces a type string in a string.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resolve_plugin()

const char * resolve_plugin ( ParserContext ctx,
const char *  name_or_alias 
)

Resolves a plugin by name or alias.

Here is the caller graph for this function:

◆ rewrite_expr_methods()

char * rewrite_expr_methods ( ParserContext ctx,
char *  raw 
)

Rewrites expression methods.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sanitize_mangled_name()

char * sanitize_mangled_name ( const char *  name)

Sanitizes a mangled name for use in codegen.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ should_suppress_undef_warning()

int should_suppress_undef_warning ( ParserContext ctx,
const char *  name 
)

Checks if a symbol should suppress an undefined warning.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ skip_comments()

void skip_comments ( Lexer l)

Skips comments in the lexer.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ token_strdup()

char * token_strdup ( Token  t)

Duplicates a token.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_types()

int validate_types ( ParserContext ctx)

Validates types.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ warn_c_reserved_word()

void warn_c_reserved_word ( Token  t,
const char *  name 
)

Warns about a C reserved word.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_parser_ctx

ParserContext* g_parser_ctx
extern