Skip to content

Commit

Permalink
setup parser structure
Browse files Browse the repository at this point in the history
  • Loading branch information
omdxp committed Mar 9, 2024
1 parent 9fb98db commit d87841f
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,66 @@ struct compile_process
FILE *ofile;
};

enum
{
NODE_TYPE_EXPRESSION,
NODE_TYPE_EXPRESSION_PARENTHESIS,
NODE_TYPE_NUMBER,
NODE_TYPE_IDENTIFIER,
NODE_TYPE_STRING,
NODE_TYPE_VARIABLE,
NODE_TYPE_VARIABLE_LIST,
NODE_TYPE_FUNCTION,
NODE_TYPE_BODY,
NODE_TYPE_STATEMENT_RETURN,
NODE_TYPE_STATEMENT_IF,
NODE_TYPE_STATEMENT_ELSE,
NODE_TYPE_STATEMENT_WHILE,
NODE_TYPE_STATEMENT_DO_WHILE,
NODE_TYPE_STATEMENT_FOR,
NODE_TYPE_STATEMENT_BREAK,
NODE_TYPE_STATEMENT_CONTINUE,
NODE_TYPE_STATEMENT_SWITCH,
NODE_TYPE_STATEMENT_CASE,
NODE_TYPE_STATEMENT_DEFAULT,
NODE_TYPE_STATEMENT_GOTO,

NODE_TYPE_UNARY,
NODE_TYPE_TENARY,
NODE_TYPE_LABEL,
NODE_TYPE_STRUCT,
NODE_TYPE_UNION,
NODE_TYPE_BRACKET,
NODE_TYPE_CAST,
NODE_TYPE_BLANK
};

struct node
{
int type;
int flags;

struct pos;

struct node_binded
{
// Pointer to body node
struct node *owner;

// Pointer to function this node is in
struct node *function;
} binded;

union
{
char cval;
const char *sval;
unsigned int inum;
unsigned long lnum;
unsigned long long llnum;
};
};

int compile_file(const char *filename, const char *out_filename, int flags);
struct compile_process *compile_process_create(const char *filename, const char *filename_out, int flags);

Expand Down

0 comments on commit d87841f

Please sign in to comment.