s502 assembler
A very simple assembler for the 6502 line of processors written in C
Functions
loadfile.h File Reference

File reading step. More...

#include "tokenslist.h"

Go to the source code of this file.

Functions

TokensListload_file (char *name)
 load and parse one file More...
 

Detailed Description

File reading step.

Definition in file loadfile.h.

Function Documentation

◆ load_file()

TokensList* load_file ( char *  name)

load and parse one file

Load file, parse into tokens, build TokensList, identify token types

Parameters
namefile name / path to load
Returns
list of tokens in file or NULL on error

Definition at line 166 of file loadfile.c.

166  {
167  LOG(3, "Reading file...\n");
168 
169  TokensList* list = read_file(name);
170  if (list == NULL)
171  goto ERROR;
172 
173  LOG(3, "Running first analysis...\n");
174  if (tokenslist_recognize(list) < 0)
175  goto ERROR;
176 
177  return list;
178 
179 ERROR:
180  FAIL("Failed to load file contents: '%s'\n", name);
181  tokenslist_free(list);
182  return NULL;
183 }

References ERROR, FAIL, LOG, read_file(), TokensList::tokenslist_free(), and TokensList::tokenslist_recognize().

Referenced by main().

TokensList::tokenslist_free
void tokenslist_free(TokensList *list)
free ALL memory associated with the TokensList object
Definition: tokenslist.c:78
read_file
TokensList * read_file(char *name)
read all tokens from a file
Definition: loadfile.c:119
LOG
#define LOG(LVL,...)
logging macro - works like printf
Definition: logging.h:28
TokensList::tokenslist_recognize
int tokenslist_recognize(TokensList *t)
Do token recognition on all tokens in a list.
Definition: tokenslist.c:117
TokensList
A doubly-linked list for storing Tokens.
Definition: tokenslist.h:29
FAIL
#define FAIL(...)
Fancy-print a fail (failed step). Works like printf.
Definition: logging.h:45
ERROR
#define ERROR(...)
Fancy-print an error (cause of faliure). Works like printf.
Definition: logging.h:40