|
Zen-C
|
#include "../codegen/codegen.h"#include "../plugins/plugin_manager.h"#include "parser.h"#include <ctype.h>#include <stdio.h>#include <stdlib.h>#include <string.h>
Functions | |
| void | instantiate_methods (ParserContext *ctx, GenericImplTemplate *it, const char *mangled_struct_name, const char *arg, const char *unmangled_arg) |
| Token | expect (Lexer *l, TokenType type, const char *msg) |
| Expects a token of a specific type. | |
| int | is_token (Token t, const char *s) |
| Checks if a token matches a string. | |
| char * | token_strdup (Token t) |
| Duplicates a token. | |
| void | skip_comments (Lexer *l) |
| Skips comments in the lexer. | |
| 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. | |
| char * | consume_until_semicolon (Lexer *l) |
| Consumes tokens until a semicolon is found. | |
| 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. | |
| Type * | find_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. | |
| ZenSymbol * | find_symbol_entry (ParserContext *ctx, const char *n) |
| Finds a symbol's entry. | |
| ZenSymbol * | find_symbol_in_all (ParserContext *ctx, const char *n) |
| Finds a symbol in all scopes. | |
| void | init_builtins () |
| Initializes built-in types and symbols. | |
| 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. | |
| void | register_deprecated_func (ParserContext *ctx, const char *name, const char *reason) |
| Registers a deprecated function. | |
| DeprecatedFunc * | find_deprecated_func (ParserContext *ctx, const char *name) |
| Finds a deprecated function. | |
| GenericFuncTemplate * | find_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 | register_type_alias (ParserContext *ctx, const char *alias, const char *original, int is_opaque, const char *defined_in_file) |
| const char * | find_type_alias (ParserContext *ctx, const char *alias) |
| Finds a type alias. | |
| TypeAlias * | find_type_alias_node (ParserContext *ctx, const char *alias) |
| Registers a type alias. | |
| 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 | register_enum_variant (ParserContext *ctx, const char *ename, const char *vname, int tag) |
| Registers an enum variant. | |
| EnumVariantReg * | find_enum_variant (ParserContext *ctx, const char *vname) |
| Finds an enum variant. | |
| void | register_lambda (ParserContext *ctx, ASTNode *node) |
| Registers a lambda. | |
| 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 | register_slice (ParserContext *ctx, const char *type) |
| Registers a slice type. | |
| void | register_tuple (ParserContext *ctx, const char *sig) |
| Registers a tuple type. | |
| void | register_struct_def (ParserContext *ctx, const char *name, ASTNode *node) |
| Registers a struct definition. | |
| ASTNode * | find_struct_def (ParserContext *ctx, const char *name) |
| Finds a struct definition. | |
| Module * | find_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. | |
| SelectiveImport * | find_selective_import (ParserContext *ctx, const char *name) |
| Finds a selective import. | |
| char * | extract_module_name (const char *path) |
| int | is_ident_char (char c) |
| ASTNode * | copy_fields (ASTNode *fields) |
| 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. | |
| 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. | |
| Type * | type_from_string_helper (const char *c) |
| 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. | |
| char * | replace_mangled_part (const char *src, const char *param, const char *concrete) |
| char * | sanitize_mangled_name (const char *s) |
| Sanitizes a mangled name for use in codegen. | |
| char * | unmangle_ptr_suffix (const char *s) |
| FuncSig * | find_func (ParserContext *ctx, const char *name) |
| Finds a function. | |
| char * | instantiate_function_template (ParserContext *ctx, const char *name, const char *concrete_type, const char *unmangled_type) |
| Instantiates a function template. | |
| char * | process_fstring (ParserContext *ctx, const char *content, char ***used_syms, int *count) |
| Processes a formatted string. | |
| 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. | |
| ASTNode * | copy_fields_replacing (ParserContext *ctx, ASTNode *fields, const char *param, const char *concrete) |
| void | instantiate_generic (ParserContext *ctx, const char *tpl, const char *arg, const char *unmangled_arg, Token token) |
| Instantiates a generic struct/function. | |
| void | instantiate_generic_multi (ParserContext *ctx, const char *tpl, char **args, int arg_count, Token token) |
| Instantiates a multi-parameter generic. | |
| int | is_file_imported (ParserContext *ctx, const char *p) |
| Checks if a file has been imported. | |
| void | mark_file_imported (ParserContext *ctx, const char *p) |
| Marks a file as imported. | |
| char * | parse_condition_raw (ParserContext *ctx, Lexer *l) |
| Parses a condition. | |
| char * | rewrite_expr_methods (ParserContext *ctx, char *raw) |
| Rewrites expression methods. | |
| char * | consume_and_rewrite (ParserContext *ctx, Lexer *l) |
| Consumes and rewrites tokens. | |
| 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. | |
| char * | find_similar_symbol (ParserContext *ctx, const char *name) |
| 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 | register_type_usage (ParserContext *ctx, const char *name, Token t) |
| Registers a type usage. | |
| int | validate_types (ParserContext *ctx) |
| Validates types. | |
| void add_instantiated_func | ( | ParserContext * | ctx, |
| ASTNode * | fn | ||
| ) |

| 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.


| void add_to_enum_list | ( | ParserContext * | ctx, |
| ASTNode * | node | ||
| ) |


| void add_to_func_list | ( | ParserContext * | ctx, |
| ASTNode * | node | ||
| ) |


| void add_to_global_list | ( | ParserContext * | ctx, |
| ASTNode * | node | ||
| ) |


| void add_to_impl_list | ( | ParserContext * | ctx, |
| ASTNode * | node | ||
| ) |


| void add_to_struct_list | ( | ParserContext * | ctx, |
| ASTNode * | node | ||
| ) |


| int check_impl | ( | ParserContext * | ctx, |
| const char * | trait, | ||
| const char * | strct | ||
| ) |
Checks if a type implements a trait.

| char * consume_and_rewrite | ( | ParserContext * | ctx, |
| Lexer * | l | ||
| ) |
Consumes and rewrites tokens.

| char * consume_until_semicolon | ( | Lexer * | l | ) |
Consumes tokens until a semicolon is found.


| 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.




| ASTNode * copy_fields_replacing | ( | ParserContext * | ctx, |
| ASTNode * | fields, | ||
| const char * | param, | ||
| const char * | concrete | ||
| ) |


| 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).

Expects a token of a specific type.


| char * extract_module_name | ( | const char * | path | ) |


| DeprecatedFunc * find_deprecated_func | ( | ParserContext * | ctx, |
| const char * | name | ||
| ) |
Finds a deprecated function.
| EnumVariantReg * find_enum_variant | ( | ParserContext * | ctx, |
| const char * | vname | ||
| ) |
Finds an enum variant.

| FuncSig * find_func | ( | ParserContext * | ctx, |
| const char * | name | ||
| ) |
Finds a function.


| GenericFuncTemplate * find_func_template | ( | ParserContext * | ctx, |
| const char * | name | ||
| ) |
Finds a function template.

| Module * find_module | ( | ParserContext * | ctx, |
| const char * | alias | ||
| ) |
Finds a module.

| SelectiveImport * find_selective_import | ( | ParserContext * | ctx, |
| const char * | name | ||
| ) |
Finds a selective import.

| char * find_similar_symbol | ( | ParserContext * | ctx, |
| const char * | name | ||
| ) |


| ASTNode * find_struct_def | ( | ParserContext * | ctx, |
| const char * | name | ||
| ) |
Finds a struct definition.

| ZenSymbol * find_symbol_entry | ( | ParserContext * | ctx, |
| const char * | n | ||
| ) |
Finds a symbol's entry.

| ZenSymbol * find_symbol_in_all | ( | ParserContext * | ctx, |
| const char * | n | ||
| ) |
Finds a symbol in all scopes.

| char * find_symbol_type | ( | ParserContext * | ctx, |
| const char * | n | ||
| ) |
Finds a symbol's type.

| Type * find_symbol_type_info | ( | ParserContext * | ctx, |
| const char * | n | ||
| ) |
Finds a symbol's type information.

| const char * find_type_alias | ( | ParserContext * | ctx, |
| const char * | alias | ||
| ) |
Finds a type alias.


| TypeAlias * find_type_alias_node | ( | ParserContext * | ctx, |
| const char * | alias | ||
| ) |
Registers a type alias.

| void init_builtins | ( | ) |
Initializes built-in types and symbols.

| char * instantiate_function_template | ( | ParserContext * | ctx, |
| const char * | name, | ||
| const char * | concrete_type, | ||
| const char * | unmangled_type | ||
| ) |
Instantiates a function template.


| void instantiate_generic | ( | ParserContext * | ctx, |
| const char * | tpl, | ||
| const char * | arg, | ||
| const char * | unmangled_arg, | ||
| Token | token | ||
| ) |
Instantiates a generic struct/function.


| void instantiate_generic_multi | ( | ParserContext * | ctx, |
| const char * | tpl, | ||
| char ** | args, | ||
| int | arg_count, | ||
| Token | token | ||
| ) |
Instantiates a multi-parameter generic.


| void instantiate_methods | ( | ParserContext * | ctx, |
| GenericImplTemplate * | it, | ||
| const char * | mangled_struct_name, | ||
| const char * | arg, | ||
| const char * | unmangled_arg | ||
| ) |


| int is_c_reserved_word | ( | const char * | name | ) |
Checks if a name is a C reserved word.

| int is_extern_symbol | ( | ParserContext * | ctx, |
| const char * | name | ||
| ) |
Checks if a symbol is external.

| int is_file_imported | ( | ParserContext * | ctx, |
| const char * | p | ||
| ) |
Checks if a file has been imported.

| int is_ident_char | ( | char | c | ) |

| int is_known_generic | ( | ParserContext * | ctx, |
| char * | name | ||
| ) |
Checks if a name is a known generic parameter.

| int is_token | ( | Token | t, |
| const char * | s | ||
| ) |
Checks if a token matches a string.

| void mark_file_imported | ( | ParserContext * | ctx, |
| const char * | p | ||
| ) |
Marks a file as imported.


| 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.


| char * parse_condition_raw | ( | ParserContext * | ctx, |
| Lexer * | l | ||
| ) |
Parses a condition.


| char * process_fstring | ( | ParserContext * | ctx, |
| const char * | content, | ||
| char *** | used_syms, | ||
| int * | count | ||
| ) |
Processes a formatted string.

| void register_builtins | ( | ParserContext * | ctx | ) |


| void register_deprecated_func | ( | ParserContext * | ctx, |
| const char * | name, | ||
| const char * | reason | ||
| ) |
Registers a deprecated function.


| void register_enum_variant | ( | ParserContext * | ctx, |
| const char * | ename, | ||
| const char * | vname, | ||
| int | tag | ||
| ) |
Registers an enum variant.


| void register_extern_symbol | ( | ParserContext * | ctx, |
| const char * | name | ||
| ) |
Registers an external symbol.


| 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.


| void register_generic | ( | ParserContext * | ctx, |
| char * | name | ||
| ) |
Registers a known generic type parameter.

| void register_impl | ( | ParserContext * | ctx, |
| const char * | trait, | ||
| const char * | strct | ||
| ) |
Registers an implementation.


| void register_impl_template | ( | ParserContext * | ctx, |
| const char * | sname, | ||
| const char * | param, | ||
| ASTNode * | node | ||
| ) |


| void register_lambda | ( | ParserContext * | ctx, |
| ASTNode * | node | ||
| ) |
Registers a lambda.


| void register_module | ( | ParserContext * | ctx, |
| const char * | alias, | ||
| const char * | path | ||
| ) |
Registers a module.

| void register_plugin | ( | ParserContext * | ctx, |
| const char * | name, | ||
| const char * | alias | ||
| ) |
Registers a plugin.


| void register_selective_import | ( | ParserContext * | ctx, |
| const char * | symbol, | ||
| const char * | alias, | ||
| const char * | source_module | ||
| ) |
Registers a selective import.


| void register_slice | ( | ParserContext * | ctx, |
| const char * | type | ||
| ) |
Registers a slice type.


| void register_struct_def | ( | ParserContext * | ctx, |
| const char * | name, | ||
| ASTNode * | node | ||
| ) |
Registers a struct definition.


| void register_template | ( | ParserContext * | ctx, |
| const char * | name, | ||
| ASTNode * | node | ||
| ) |
Registers a template.


| void register_tuple | ( | ParserContext * | ctx, |
| const char * | sig | ||
| ) |
Registers a tuple type.


| void register_type_alias | ( | ParserContext * | ctx, |
| const char * | alias, | ||
| const char * | original, | ||
| int | is_opaque, | ||
| const char * | defined_in_file | ||
| ) |


| void register_type_usage | ( | ParserContext * | ctx, |
| const char * | name, | ||
| Token | t | ||
| ) |
Registers a type usage.


| char * replace_in_string | ( | const char * | src, |
| const char * | old_w, | ||
| const char * | new_w | ||
| ) |
Replaces a substring in a string.


| char * replace_mangled_part | ( | const char * | src, |
| const char * | param, | ||
| const char * | concrete | ||
| ) |


| 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.


| 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.


| const char * resolve_plugin | ( | ParserContext * | ctx, |
| const char * | name_or_alias | ||
| ) |
Resolves a plugin by name or alias.

| char * rewrite_expr_methods | ( | ParserContext * | ctx, |
| char * | raw | ||
| ) |
Rewrites expression methods.


| char * sanitize_mangled_name | ( | const char * | s | ) |
Sanitizes a mangled name for use in codegen.


| int should_suppress_undef_warning | ( | ParserContext * | ctx, |
| const char * | name | ||
| ) |
Checks if a symbol should suppress an undefined warning.


| void skip_comments | ( | Lexer * | l | ) |
Skips comments in the lexer.


| char * token_strdup | ( | Token | t | ) |
Duplicates a token.


| Type * type_from_string_helper | ( | const char * | c | ) |


| char * unmangle_ptr_suffix | ( | const char * | s | ) |


| int validate_types | ( | ParserContext * | ctx | ) |
Validates types.


| void warn_c_reserved_word | ( | Token | t, |
| const char * | name | ||
| ) |
Warns about a C reserved word.

