Skip to content

Commit

Permalink
token structure
Browse files Browse the repository at this point in the history
  • Loading branch information
omdxp committed Jan 28, 2024
1 parent b3669ca commit 6e0eeb1
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions compiler.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,48 @@
#ifndef ROSEBUDCOMPILER_H
#define ROSEBUDCOMPILER_H
#include <stdio.h>
#include <stdbool.h>

struct pos
{
int line;
int col;
const char *filename;
};

enum
{
TOKEN_TYPE_IDENTIFIER,
TOKEN_TYPE_KEYWORD,
TOKEN_TYPE_OPERATOR,
TOKEN_TYPE_SYMBOL,
TOKEN_TYPE_NUMBER,
TOKEN_TYPE_STRING,
TOKEN_TYPE_COMMENT,
TOKEN_TYPE_NEWLINE,
};

struct tokent
{
int type;
int flags;

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

// True if there is a whitespace between the current token and next token
bool whitespace;

// (5+10+20)
const char *between_brackets;
};

enum
{
Expand Down

0 comments on commit 6e0eeb1

Please sign in to comment.