#include <stdlib.h>
#include "ast.h"
#include "stack.h"
#include "types/err.h"
Go to the source code of this file.
◆ _stack_ensure_size()
void _stack_ensure_size |
( |
stack_t * | stack | ) |
|
Definition at line 65 of file stack.c.
66{
68 return;
69 }
70
73}
A struct representing a dynamic stack.
unsigned int length
Number of elements on the stack.
ast_node_t * values
Array of values on the stack.
unsigned int _size
Current number of elements that fits on the stack.
struct ast_node ast_node_t
#define STACK_LENGTH_INCREMENT
◆ stack_close()
void stack_close |
( |
stack_t * | stack | ) |
|
Closes the given stack.
- Parameters
-
stack | The stack to be closed. |
Definition at line 20 of file stack.c.
◆ stack_init()
Initializes the given stack.
- Parameters
-
stack | The stack to be initialized. |
Definition at line 11 of file stack.c.
12{
14
17}
#define STACK_INITIAL_LENGTH
◆ stack_insert()
Push a new value on the stack copying from source
pointer.
- Parameters
-
stack | The stack where tbe value will be pushed. |
source | The AST node content. |
- Returns
- A pointer for the new value inside the stack.
Definition at line 37 of file stack.c.
38{
40
42
44}
void ast_copy(ast_node_t *destiny, ast_node_t *source)
Copies the content of source to destinty AST nodes.
void _stack_ensure_size(stack_t *stack)
◆ stack_isempty()
bool stack_isempty |
( |
stack_t * | stack | ) |
|
Check if the given stack is empty.
- Parameters
-
- Returns
- true on stack is empty.
-
false if stack has values.
Definition at line 59 of file stack.c.
◆ stack_pop()
Pop a value from the stack.
- Parameters
-
stack | The stack from where the value will be poped. |
value | Pointer for where the poped value will be saved. |
- Returns
- ERR_EMPTY on stack is empty.
-
ERR_OK on value is poped successful.
Definition at line 47 of file stack.c.
48{
51 }
52
54
56}
bool stack_isempty(stack_t *stack)
Check if the given stack is empty.
◆ stack_push()
Push a new value on the stack.
- Parameters
-
stack | The stack where tbe value will be pushed. |
type | The AST node type. |
token | The AST node token. |
- Returns
- A pointer for the new value inside the stack.
Definition at line 27 of file stack.c.
28{
30
32
34}
void ast_node_init(ast_node_t *node, ast_node_t *parent, node_type_t type, token_t *token)
Initializes an AST node.