Initial commit.
This commit is contained in:
commit
433905f5ea
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
*.o
|
||||
*.so
|
||||
*.out
|
||||
obj/
|
||||
compile_commands.json
|
46
Makefile
Normal file
46
Makefile
Normal file
@ -0,0 +1,46 @@
|
||||
NAME = scl
|
||||
|
||||
CC = gcc
|
||||
CFLAGS_REG = -Wall -O2
|
||||
CFLAGS_DBG = -ggdb -fsanitize=address -O0
|
||||
LDFLAGS = -lm
|
||||
|
||||
SRC_DIR = src
|
||||
OBJ_DIR = obj
|
||||
TARGET = $(NAME).out
|
||||
|
||||
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
|
||||
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC_FILES))
|
||||
|
||||
COL_BOLD = \x1b[37;1m
|
||||
COL_CLEAR = \x1b[0m
|
||||
|
||||
all: reg
|
||||
|
||||
reg: CFLAGS = $(CFLAGS_REG)
|
||||
reg: $(TARGET)
|
||||
|
||||
dbg: CFLAGS = $(CFLAGS_DBG)
|
||||
dbg: clean
|
||||
dbg: $(TARGET)
|
||||
|
||||
msg_compiling:
|
||||
@ echo -e "$(COL_BOLD)Compiling...$(COL_CLEAR)"
|
||||
|
||||
msg_linking:
|
||||
@ echo -e "$(COL_BOLD)Linking...$(COL_CLEAR)"
|
||||
|
||||
msg_cleaning:
|
||||
@ echo -e "$(COL_BOLD)Cleaning up...$(COL_CLEAR)"
|
||||
|
||||
$(TARGET): msg_compiling $(OBJ_FILES) msg_linking
|
||||
$(CC) $(LDFLAGS) $(OBJ_FILES) -o $@
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
@ mkdir -p $(OBJ_DIR)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean: msg_cleaning
|
||||
rm -rf $(OBJ_DIR) $(TARGET) $(TARGET_DBG)
|
||||
|
||||
.PHONY: all clean reg dbg msg_compiling msg_linking msg_cleaning
|
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# SCCL: Simple C Calculator Language
|
||||
|
||||
Parses infix operators.
|
6
src/include/main.h
Normal file
6
src/include/main.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#endif
|
30
src/include/parser.h
Normal file
30
src/include/parser.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef PARSER_H
|
||||
#define PARSER_H
|
||||
|
||||
// Expression one of:
|
||||
// - Operation
|
||||
// - Number
|
||||
|
||||
// Operation contains:
|
||||
// - Type
|
||||
// - Expression 1
|
||||
// - Expression 2
|
||||
|
||||
typedef enum OpType {
|
||||
OPTYPE_PLUS,
|
||||
OPTYPE_MINUS
|
||||
} optype_t;
|
||||
|
||||
typedef union Exp {
|
||||
typedef struct Op {
|
||||
optype_t type;
|
||||
Exp* exp1;
|
||||
Exp* exp2;
|
||||
} op_t;
|
||||
|
||||
int n;
|
||||
} exp_t;
|
||||
|
||||
|
||||
|
||||
#endif
|
12
src/include/util.c
Normal file
12
src/include/util.c
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
// Utilies.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Exit with an error. Returns int for ease of use, but should be treated as void.
|
||||
int die(char* msg);
|
||||
|
||||
#endif
|
6
src/main.c
Normal file
6
src/main.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
printf("Hello, world!");
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user