Compare commits

..

No commits in common. "12d39043ecc1eb30fbf3b5a073d58f52ced68816" and "aa1898fd6660b8df99cfac2ce23dfdef8a08e4a3" have entirely different histories.

7 changed files with 13 additions and 36 deletions

3
.gitattributes vendored
View File

@ -1,3 +0,0 @@
*.h linguist-language=C
*.c linguist-language=C
Makefile -linguist-detectable

View File

@ -238,7 +238,6 @@ void striplabels(ASSEMBLER* a) {
a->lns = curln->next;
LINELIST* tmp = curln;
curln = curln->next;
free(tmp->content);
free(tmp);
}
else {
@ -373,17 +372,8 @@ void translate(ASSEMBLER* a) {
}
}
void freelns(LINELIST* lns) {
LINELIST* next = lns->next;
free(lns->content);
free(lns);
if(next != NULL)
freelns(next);
}
void freeassembler(ASSEMBLER* a) {
freesymbols(a->vars);
freesymbols(a->labels);
freelns(a->lns);
free(a);
}

9
main.c
View File

@ -12,6 +12,14 @@ char* getoutname(char* fname, int fnamelen) {
return outf;
}
void printlns(LINELIST* lns, FILE* stream) {
LINELIST* curln = lns;
while(curln != NULL) {
fprintf(stream, "%s\n", curln->content);
curln = curln->next;
}
}
int main(int argc, char* argv[]) {
if(argc < 2) {
printf("Usage: %s {input}\n", argv[0]);
@ -35,7 +43,6 @@ int main(int argc, char* argv[]) {
parse(p);
ASSEMBLER* a = mkassembler(p->output);
free(p);
// variable substitution
preprocess(a);

View File

@ -4,7 +4,6 @@
#include <stdlib.h>
#include <ctype.h>
#include "parser.h"
#include "util.h"
void pushln(LINELIST** curln, char* tmpln, int lnind, int truen) {
int size = (lnind+1)*sizeof(char);

View File

@ -1,11 +1,14 @@
#ifndef PARSER_H
#define PARSER_H
#include <stdio.h>
#include "util.h"
#define INST_LIMIT 1<<15
typedef struct lnls {
char* content;
int truen;
struct lnls* next;
} LINELIST;
typedef struct {
FILE* input;

8
util.c
View File

@ -22,11 +22,3 @@ int countplaces(int n) {
}
return places;
}
void printlns(LINELIST* lns, FILE* stream) {
LINELIST* curln = lns;
while(curln != NULL) {
fprintf(stream, "%s\n", curln->content);
curln = curln->next;
}
}

11
util.h
View File

@ -1,16 +1,5 @@
#ifndef UTIL_H
#define UTIL_H
#include <stdio.h>
char* heapstr(const char* str, int len);
int countplaces(int n);
typedef struct lnls {
char* content;
int truen;
struct lnls* next;
} LINELIST;
void printlns(LINELIST* lns, FILE* stream);
#endif