initial
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
bin/
|
16
Makefile
Normal file
16
Makefile
Normal file
@@ -0,0 +1,16 @@
|
||||
TARGET=sc
|
||||
BUILDDIR=bin/
|
||||
PREFIX=/usr/local/bin/
|
||||
SOURCES=$(wildcard src/*.c)
|
||||
MAIN=main.c
|
||||
override CFLAGS+=-Werror -Wall -g -fPIC -O2 -DNDEBUG -ftrapv -Wfloat-equal -Wundef -Wwrite-strings -Wuninitialized -pedantic -std=c11
|
||||
|
||||
all: main.c
|
||||
mkdir -p $(BUILDDIR)
|
||||
$(CC) $(MAIN) $(SOURCES) -o $(BUILDDIR)$(TARGET) $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
install: all
|
||||
install $(BUILDDIR)$(TARGET) $(PREFIX)$(TARGET)
|
||||
|
||||
uninstall:
|
||||
rm -rf $(PREFIX)$(TARGET)
|
34
main.c
Normal file
34
main.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "src/parser.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
char* inp;
|
||||
long size;
|
||||
|
||||
if (argc != 2) {
|
||||
printf("usage: %s FILE\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE* f = fopen(argv[1], "r");
|
||||
|
||||
if (!f) {
|
||||
puts("Error while opening the file.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
size = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
inp = malloc(size+1);
|
||||
fread(inp, size, 1, f);
|
||||
fclose(f);
|
||||
|
||||
inp[size] = '\0';
|
||||
|
||||
printf("%p\n", (void*) parse(inp));
|
||||
|
||||
return 0;
|
||||
}
|
5
src/parser.c
Normal file
5
src/parser.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "parser.h"
|
||||
|
||||
sc_ast* parse(char* input) {
|
||||
return NULL;
|
||||
}
|
12
src/parser.h
Normal file
12
src/parser.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct sc_ast {
|
||||
short tag;
|
||||
char* value;
|
||||
|
||||
int n_children;
|
||||
struct sc_ast** children;
|
||||
} sc_ast;
|
||||
|
||||
|
||||
sc_ast* parse(char*);
|
Reference in New Issue
Block a user