Skip to content

Commit

Permalink
Lecture 57 - Implementing parser scope entities and functionalities
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonzapeducation committed Feb 25, 2022
1 parent 3fb7783 commit 8c723ef
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Binary file added main
Binary file not shown.
34 changes: 34 additions & 0 deletions parser.c
Expand Up @@ -9,6 +9,35 @@ extern struct node* parser_current_body;

extern struct expressionable_op_precedence_group op_precedence[TOTAL_OPERATOR_GROUPS];


enum
{
PARSER_SCOPE_ENTITY_ON_STACK = 0b00000001,
PARSER_SCOPE_ENTITY_STRUCTURE_SCOPE = 0b00000010,
};

struct parser_scope_entity
{
// The entity flags of the scope entity
int flags;

// The stack offset of the scope entity.
int stack_offset;

// Variable declaration
struct node* node;
};

struct parser_scope_entity* parser_new_scope_entity(struct node* node, int stack_offset, int flags)
{
struct parser_scope_entity* entity = calloc(1, sizeof(struct parser_scope_entity));
entity->node = node;
entity->flags = flags;
entity->stack_offset = stack_offset;
return entity;
}


enum
{
HISTORY_FLAG_INSIDE_UNION = 0b00000001,
Expand Down Expand Up @@ -48,6 +77,11 @@ void parser_scope_finish()
scope_finish(current_process);
}

void parser_scope_push(struct node* node, size_t size)
{
scope_push(current_process, node, size);
}

static void parser_ignore_nl_or_comment(struct token *token)
{
while (token && token_is_nl_or_comment_or_newline_seperator(token))
Expand Down

0 comments on commit 8c723ef

Please sign in to comment.