Compare commits
5 Commits
aa1898fd66
...
12d39043ec
Author | SHA1 | Date |
---|---|---|
Augusto Gunsch | 12d39043ec | |
Augusto Gunsch | dfd8a85a5d | |
Augusto Gunsch | 2cb621f6ea | |
Augusto Gunsch | c8dabe7abc | |
Augusto Gunsch | e456ace07b |
|
@ -0,0 +1,3 @@
|
|||
*.h linguist-language=C
|
||||
*.c linguist-language=C
|
||||
Makefile -linguist-detectable
|
10
assembler.c
10
assembler.c
|
@ -238,6 +238,7 @@ void striplabels(ASSEMBLER* a) {
|
|||
a->lns = curln->next;
|
||||
LINELIST* tmp = curln;
|
||||
curln = curln->next;
|
||||
free(tmp->content);
|
||||
free(tmp);
|
||||
}
|
||||
else {
|
||||
|
@ -372,8 +373,17 @@ 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
9
main.c
|
@ -12,14 +12,6 @@ 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]);
|
||||
|
@ -43,6 +35,7 @@ int main(int argc, char* argv[]) {
|
|||
parse(p);
|
||||
|
||||
ASSEMBLER* a = mkassembler(p->output);
|
||||
free(p);
|
||||
|
||||
// variable substitution
|
||||
preprocess(a);
|
||||
|
|
1
parser.c
1
parser.c
|
@ -4,6 +4,7 @@
|
|||
#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);
|
||||
|
|
7
parser.h
7
parser.h
|
@ -1,14 +1,11 @@
|
|||
#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
8
util.c
|
@ -22,3 +22,11 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue