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

Go to the source code of this file.

Data Structures

struct  Type
 Represents a formal type in the type system. More...
 
struct  Attribute
 
struct  ASTNode
 

Typedefs

typedef struct ASTNode ASTNode
 
typedef struct Type Type
 Represents a formal type in the type system.
 
typedef struct Attribute Attribute
 

Enumerations

enum  LiteralKind { LITERAL_INT = 0 , LITERAL_FLOAT = 1 , LITERAL_STRING = 2 , LITERAL_CHAR = 3 }
 Kind of literal value. More...
 
enum  TypeKind {
  TYPE_VOID , TYPE_BOOL , TYPE_CHAR , TYPE_STRING ,
  TYPE_U0 , TYPE_I8 , TYPE_U8 , TYPE_I16 ,
  TYPE_U16 , TYPE_I32 , TYPE_U32 , TYPE_I64 ,
  TYPE_U64 , TYPE_I128 , TYPE_U128 , TYPE_F32 ,
  TYPE_F64 , TYPE_INT , TYPE_FLOAT , TYPE_USIZE ,
  TYPE_ISIZE , TYPE_BYTE , TYPE_RUNE , TYPE_UINT ,
  TYPE_C_INT , TYPE_C_UINT , TYPE_C_LONG , TYPE_C_ULONG ,
  TYPE_C_SHORT , TYPE_C_USHORT , TYPE_C_CHAR , TYPE_C_UCHAR ,
  TYPE_STRUCT , TYPE_ENUM , TYPE_POINTER , TYPE_ARRAY ,
  TYPE_FUNCTION , TYPE_GENERIC , TYPE_ALIAS , TYPE_BITINT ,
  TYPE_UBITINT , TYPE_UNKNOWN
}
 Formal type system kinds. More...
 
enum  NodeType {
  NODE_ROOT , NODE_FUNCTION , NODE_BLOCK , NODE_RETURN ,
  NODE_VAR_DECL , NODE_CONST , NODE_TYPE_ALIAS , NODE_IF ,
  NODE_WHILE , NODE_FOR , NODE_FOR_RANGE , NODE_LOOP ,
  NODE_REPEAT , NODE_UNLESS , NODE_GUARD , NODE_BREAK ,
  NODE_CONTINUE , NODE_MATCH , NODE_MATCH_CASE , NODE_EXPR_BINARY ,
  NODE_EXPR_UNARY , NODE_EXPR_LITERAL , NODE_EXPR_VAR , NODE_EXPR_CALL ,
  NODE_EXPR_MEMBER , NODE_EXPR_INDEX , NODE_EXPR_CAST , NODE_EXPR_SIZEOF ,
  NODE_EXPR_STRUCT_INIT , NODE_EXPR_ARRAY_LITERAL , NODE_EXPR_SLICE , NODE_STRUCT ,
  NODE_FIELD , NODE_ENUM , NODE_ENUM_VARIANT , NODE_TRAIT ,
  NODE_IMPL , NODE_IMPL_TRAIT , NODE_INCLUDE , NODE_RAW_STMT ,
  NODE_TEST , NODE_ASSERT , NODE_DEFER , NODE_DESTRUCT_VAR ,
  NODE_TERNARY , NODE_ASM , NODE_LAMBDA , NODE_PLUGIN ,
  NODE_GOTO , NODE_LABEL , NODE_DO_WHILE , NODE_TYPEOF ,
  NODE_TRY , NODE_REFLECTION , NODE_AWAIT , NODE_REPL_PRINT ,
  NODE_CUDA_LAUNCH , NODE_VA_START , NODE_VA_END , NODE_VA_COPY ,
  NODE_VA_ARG
}
 AST Node Types. More...
 

Functions

ASTNodeast_create (NodeType type)
 
void ast_free (ASTNode *node)
 
Typetype_new (TypeKind kind)
 
Typetype_new_ptr (Type *inner)
 
int type_eq (Type *a, Type *b)
 
int is_integer_type (Type *t)
 
char * type_to_string (Type *t)
 
char * type_to_c_string (Type *t)
 

Typedef Documentation

◆ ASTNode

typedef struct ASTNode ASTNode

◆ Attribute

typedef struct Attribute Attribute

◆ Type

typedef struct Type Type

Represents a formal type in the type system.

Enumeration Type Documentation

◆ LiteralKind

Kind of literal value.

Enumerator
LITERAL_INT 

Integer literal.

LITERAL_FLOAT 

Floating point literal.

LITERAL_STRING 

String literal.

LITERAL_CHAR 

Character literal.

◆ NodeType

enum NodeType

AST Node Types.

Enumerator
NODE_ROOT 

Root of the AST.

NODE_FUNCTION 

Function definition.

NODE_BLOCK 

Code block { ... }.

NODE_RETURN 

Return statement.

NODE_VAR_DECL 

Variable declaration.

NODE_CONST 

Constant definition.

NODE_TYPE_ALIAS 

Type alias (typedef).

NODE_IF 

If statement.

NODE_WHILE 

While loop.

NODE_FOR 

For loop.

NODE_FOR_RANGE 

For-range loop (iterator).

NODE_LOOP 

Infinite loop.

NODE_REPEAT 

Repeat loop (n times).

NODE_UNLESS 

Unless statement (if !cond).

NODE_GUARD 

Guard clause (if !cond return).

NODE_BREAK 

Break statement.

NODE_CONTINUE 

Continue statement.

NODE_MATCH 

Match statement.

NODE_MATCH_CASE 

Case within match.

NODE_EXPR_BINARY 

Binary expression (a + b).

NODE_EXPR_UNARY 

Unary expression (!a).

NODE_EXPR_LITERAL 

Literal value.

NODE_EXPR_VAR 

Variable reference.

NODE_EXPR_CALL 

Function call.

NODE_EXPR_MEMBER 

Member access (a.b).

NODE_EXPR_INDEX 

Array index (a[b]).

NODE_EXPR_CAST 

Type cast.

NODE_EXPR_SIZEOF 

Sizeof expression.

NODE_EXPR_STRUCT_INIT 

Struct initializer.

NODE_EXPR_ARRAY_LITERAL 

Array literal.

NODE_EXPR_SLICE 

Slice operation.

NODE_STRUCT 

Struct definition.

NODE_FIELD 

Struct field.

NODE_ENUM 

Enum definition.

NODE_ENUM_VARIANT 

Enum variant.

NODE_TRAIT 

Trait definition.

NODE_IMPL 

Impl block.

NODE_IMPL_TRAIT 

Trait implementation.

NODE_INCLUDE 

Include directive.

NODE_RAW_STMT 

Raw statement (transpiler bypass).

NODE_TEST 

Test block.

NODE_ASSERT 

Assert statement.

NODE_DEFER 

Defer statement.

NODE_DESTRUCT_VAR 

Destructuring declaration.

NODE_TERNARY 

Ternary expression (?:).

NODE_ASM 

Assembly block.

NODE_LAMBDA 

Lambda function.

NODE_PLUGIN 

Plugin invocation.

NODE_GOTO 

Goto statement.

NODE_LABEL 

Label.

NODE_DO_WHILE 

Do-while loop.

NODE_TYPEOF 

Typeof operator.

NODE_TRY 

Try statement (error handling).

NODE_REFLECTION 

Reflection info.

NODE_AWAIT 

Await expression.

NODE_REPL_PRINT 

Implicit print (REPL).

NODE_CUDA_LAUNCH 

CUDA kernel launch (<<<...>>>).

NODE_VA_START 

va_start intrinsic.

NODE_VA_END 

va_end intrinsic.

NODE_VA_COPY 

va_copy intrinsic.

NODE_VA_ARG 

va_arg intrinsic.

◆ TypeKind

enum TypeKind

Formal type system kinds.

Enumerator
TYPE_VOID 

void type.

TYPE_BOOL 

bool type.

TYPE_CHAR 

char type.

TYPE_STRING 

string type.

TYPE_U0 

u0 type.

TYPE_I8 

i8 type.

TYPE_U8 

u8 type.

TYPE_I16 

i16 type.

TYPE_U16 

u16 type.

TYPE_I32 

i32 type.

TYPE_U32 

u32 type.

TYPE_I64 

i64 type.

TYPE_U64 

u64 type.

TYPE_I128 

i128 type.

TYPE_U128 

u128 type.

TYPE_F32 

f32 type.

TYPE_F64 

f64 type.

TYPE_INT 

int (alias, usually i32).

TYPE_FLOAT 

float (alias).

TYPE_USIZE 

usize (pointer size unsigned).

TYPE_ISIZE 

isize (pointer size signed).

TYPE_BYTE 

byte.

TYPE_RUNE 

rune.

TYPE_UINT 

uint (alias).

TYPE_C_INT 

c_int (int).

TYPE_C_UINT 

c_uint (unsigned int).

TYPE_C_LONG 

c_long (long).

TYPE_C_ULONG 

c_ulong (unsigned long).

TYPE_C_SHORT 

c_short (short).

TYPE_C_USHORT 

c_ushort (unsigned short).

TYPE_C_CHAR 

c_char (char).

TYPE_C_UCHAR 

c_uchar (unsigned char).

TYPE_STRUCT 

Struct type.

TYPE_ENUM 

Enum type.

TYPE_POINTER 

Pointer type (*).

TYPE_ARRAY 

Fixed size array [N].

TYPE_FUNCTION 

Function pointer or reference.

TYPE_GENERIC 

Generic type parameter (T).

TYPE_ALIAS 

Opaque type alias.

TYPE_BITINT 

C23 _BitInt(N).

TYPE_UBITINT 

C23 unsigned _BitInt(N).

TYPE_UNKNOWN 

Unknown/unresolved type.

Function Documentation

◆ ast_create()

ASTNode * ast_create ( NodeType  type)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ast_free()

void ast_free ( ASTNode node)

◆ is_integer_type()

int is_integer_type ( Type t)
Here is the caller graph for this function:

◆ type_eq()

int type_eq ( Type a,
Type b 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ type_new()

Type * type_new ( TypeKind  kind)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ type_new_ptr()

Type * type_new_ptr ( Type inner)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ type_to_c_string()

char * type_to_c_string ( Type t)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ type_to_string()

char * type_to_string ( Type t)
Here is the call graph for this function:
Here is the caller graph for this function: