Luma 0.1.0
A low-level compiled alternative to C, C++, and more!
Loading...
Searching...
No Matches
Macros | Functions
ast_utils.h File Reference
#include "ast.h"
#include <stdio.h>
Include dependency graph for ast_utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IS_EXPR(node)   ((node)->type >= AST_EXPR_LITERAL && (node)->type <= AST_EXPR_GROUPING)
 
#define IS_STMT(node)   ((node)->type >= AST_STMT_EXPRESSION && (node)->type <= AST_STMT_STRUCT)
 
#define IS_TYPE(node)   ((node)->type >= AST_TYPE_BASIC && (node)->type <= AST_TYPE_ENUM)
 
#define IS_PROGRAM(node)   ((node)->type == AST_PROGRAM)
 
#define IS_EXPR_STMT(node)   ((node)->type == AST_STMT_EXPRESSION)
 
#define IS_LITERAL(node)   ((node)->type == AST_EXPR_LITERAL)
 
#define IS_BINARY(node)   ((node)->type == AST_EXPR_BINARY)
 
#define IS_GROUPING(node)   ((node)->type == AST_EXPR_GROUPING)
 
#define IS_UNARY(node)   ((node)->type == AST_EXPR_UNARY)
 
#define IS_CALL(node)   ((node)->type == AST_EXPR_CALL)
 
#define IS_VAR_DECL(node)   ((node)->type == AST_STMT_VAR_DECL)
 
#define IS_FUNC_DECL(node)   ((node)->type == AST_STMT_FUNCTION)
 
#define IS_BLOCK(node)   ((node)->type == AST_STMT_BLOCK)
 
#define IS_IF(node)   ((node)->type == AST_STMT_IF)
 
#define IS_LOOP(node)   ((node)->type == AST_STMT_LOOP)
 
#define IS_RETURN(node)   ((node)->type == AST_STMT_RETURN)
 

Functions

const char * node_type_to_string (NodeType type)
 
const char * binop_to_string (BinaryOp op)
 
const char * unop_to_string (UnaryOp op)
 
const char * literal_type_to_string (LiteralType type)
 
void print_prefix (const char *prefix, bool is_last)
 
void print_ast (const AstNode *node, const char *prefix, bool is_last, bool root)
 

Macro Definition Documentation

◆ IS_BINARY

#define IS_BINARY (   node)    ((node)->type == AST_EXPR_BINARY)

◆ IS_BLOCK

#define IS_BLOCK (   node)    ((node)->type == AST_STMT_BLOCK)

◆ IS_CALL

#define IS_CALL (   node)    ((node)->type == AST_EXPR_CALL)

◆ IS_EXPR

#define IS_EXPR (   node)    ((node)->type >= AST_EXPR_LITERAL && (node)->type <= AST_EXPR_GROUPING)

◆ IS_EXPR_STMT

#define IS_EXPR_STMT (   node)    ((node)->type == AST_STMT_EXPRESSION)

◆ IS_FUNC_DECL

#define IS_FUNC_DECL (   node)    ((node)->type == AST_STMT_FUNCTION)

◆ IS_GROUPING

#define IS_GROUPING (   node)    ((node)->type == AST_EXPR_GROUPING)

◆ IS_IF

#define IS_IF (   node)    ((node)->type == AST_STMT_IF)

◆ IS_LITERAL

#define IS_LITERAL (   node)    ((node)->type == AST_EXPR_LITERAL)

◆ IS_LOOP

#define IS_LOOP (   node)    ((node)->type == AST_STMT_LOOP)

◆ IS_PROGRAM

#define IS_PROGRAM (   node)    ((node)->type == AST_PROGRAM)

◆ IS_RETURN

#define IS_RETURN (   node)    ((node)->type == AST_STMT_RETURN)

◆ IS_STMT

#define IS_STMT (   node)    ((node)->type >= AST_STMT_EXPRESSION && (node)->type <= AST_STMT_STRUCT)

◆ IS_TYPE

#define IS_TYPE (   node)    ((node)->type >= AST_TYPE_BASIC && (node)->type <= AST_TYPE_ENUM)

◆ IS_UNARY

#define IS_UNARY (   node)    ((node)->type == AST_EXPR_UNARY)

◆ IS_VAR_DECL

#define IS_VAR_DECL (   node)    ((node)->type == AST_STMT_VAR_DECL)

Function Documentation

◆ binop_to_string()

const char * binop_to_string ( BinaryOp  op)

◆ literal_type_to_string()

const char * literal_type_to_string ( LiteralType  type)

◆ node_type_to_string()

const char * node_type_to_string ( NodeType  type)

◆ print_ast()

void print_ast ( const AstNode node,
const char *  prefix,
bool  is_last,
bool  root 
)

◆ print_prefix()

void print_prefix ( const char *  prefix,
bool  is_last 
)

◆ unop_to_string()

const char * unop_to_string ( UnaryOp  op)