Updated the structure of symbols and tokens to hopefully help make computing symbol values easier.
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
#ifndef LIST_H
|
||||
#define LIST_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define LISTDEFAULTSIZE 4
|
||||
|
||||
typedef struct {
|
||||
void** content;
|
||||
int size;
|
||||
int capacity;
|
||||
} List;
|
||||
|
||||
List* CreateList(void);
|
||||
int AddListItem(void *, List *);
|
||||
void RemoveItem(int index, List * list);
|
||||
void DestroyList(List*);
|
||||
|
||||
#endif
|
||||
+1
-2
@@ -6,11 +6,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include "list.h"
|
||||
#include "token.h"
|
||||
#include "opcodes.h"
|
||||
#include "symbols_table.h"
|
||||
|
||||
void ParseTokens(List* tokens, SymbolTable** symbolsTable);
|
||||
void ParseTokens(TokenList* tokens, SymbolTable** symbolsTable);
|
||||
|
||||
#endif
|
||||
+1
-2
@@ -7,9 +7,8 @@
|
||||
#include <errno.h>
|
||||
#include "stdlib.h"
|
||||
#include "token.h"
|
||||
#include "list.h"
|
||||
#include "opcodes.h"
|
||||
|
||||
List* GenerateTokenList(const char*);
|
||||
TokenList* GenerateTokenList(const char*);
|
||||
|
||||
#endif
|
||||
@@ -12,23 +12,11 @@
|
||||
|
||||
#define SYMBOLSTABLE_DEFAULT_CAPACITY 128
|
||||
|
||||
typedef enum {
|
||||
RefUnknown,
|
||||
RefLiteral,
|
||||
RefExpression,
|
||||
RefPointer
|
||||
} ReferenceType;
|
||||
|
||||
typedef struct _symbol {
|
||||
char* Name;
|
||||
int Address;
|
||||
int Length;
|
||||
union {
|
||||
Token* Mnemonic;
|
||||
struct _symbol* Symbol;
|
||||
unsigned short Number;
|
||||
} Value;
|
||||
ReferenceType Type;
|
||||
Token* Token;
|
||||
} Symbol;
|
||||
|
||||
typedef struct {
|
||||
|
||||
+13
-3
@@ -25,8 +25,6 @@ typedef enum {
|
||||
DB,
|
||||
Include,
|
||||
Byte
|
||||
// Load,
|
||||
// Store
|
||||
} Directive;
|
||||
|
||||
typedef enum {
|
||||
@@ -41,7 +39,7 @@ typedef enum {
|
||||
AddressClass = LabelClass | IdentifierClass
|
||||
} TokenClass;
|
||||
|
||||
typedef struct {
|
||||
typedef struct __token {
|
||||
char* Lemexe;
|
||||
TokenClass Class;
|
||||
int LineNumber;
|
||||
@@ -54,9 +52,21 @@ typedef struct {
|
||||
Directive Directive;
|
||||
int Number;
|
||||
} Value;
|
||||
|
||||
struct __token* Prev;
|
||||
struct __token* Next;
|
||||
} Token;
|
||||
|
||||
typedef struct {
|
||||
Token** content;
|
||||
int size;
|
||||
int capacity;
|
||||
} TokenList;
|
||||
|
||||
Token* CreateToken(int lineNumber, TokenClass tokenClass);
|
||||
TokenList* CreateTokenList(void);
|
||||
int AddToken(Token* token, TokenList* list);
|
||||
void RemoveToken(int index, TokenList* list);
|
||||
void FreeToken(Token* token);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user