init
This commit is contained in:
commit
5ff3ac2c4d
14
.clang-format
Normal file
14
.clang-format
Normal file
@ -0,0 +1,14 @@
|
||||
BasedOnStyle: WebKit
|
||||
IndentWidth: 4
|
||||
ColumnLimit: 80
|
||||
IndentCaseLabels: true
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterFunction: true
|
||||
SplitEmptyFunction: false
|
||||
AlignAfterOpenBracket: BlockIndent
|
||||
AlignOperands: AlignAfterOperator
|
||||
BreakBeforeBinaryOperators: true
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
|
19
.clangd
Normal file
19
.clangd
Normal file
@ -0,0 +1,19 @@
|
||||
Diagnostics:
|
||||
ClangTidy:
|
||||
Add:
|
||||
- bugprone-*
|
||||
- clang-analyser-*
|
||||
- cppcoreguidelines-*
|
||||
- modernize-*
|
||||
- readability-*
|
||||
Remove:
|
||||
- readability-magic-numbers
|
||||
CheckOptions:
|
||||
readability-identifier-naming.IgnoreMainLikeFunctions: true
|
||||
readability-identifier-length.IgnoredVariableNames: (x|y|z|i|id)
|
||||
readability-identifier-length.IgnoredParameterNames: (x|y|z|i|id)
|
||||
|
||||
readability-identifier-naming.FunctionCase: lower_case
|
||||
readability-identifier-naming.ParameterCase: lower_case
|
||||
readability-identifier-naming.VariableCase: lower_case
|
||||
UnusedIncludes: Strict
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
build/
|
||||
compile_flags.txt
|
||||
|
41
Makefile
Normal file
41
Makefile
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
PROGRAM = ol
|
||||
CC = clang
|
||||
|
||||
C_FLAGS = \
|
||||
-std=c17 \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wpedantic \
|
||||
-Wconversion \
|
||||
-Wno-gnu-case-range
|
||||
|
||||
LINKER_FLAGS = \
|
||||
-fsanitize=address,undefined
|
||||
|
||||
SOURCE_FOLDER = src
|
||||
BUILD_FOLDER = build
|
||||
C_FILES = $(shell find $(SOURCE_FOLDER) -name "*.c")
|
||||
H_FILES = $(shell find $(SOURCE_FOLDER) -name "*.h")
|
||||
|
||||
C_FLAGS += -I$(SOURCE_FOLDER)
|
||||
|
||||
OBJECT_FILES = $(patsubst $(SOURCE_FOLDER)/%.c, $(BUILD_FOLDER)/%.o, $(C_FILES))
|
||||
|
||||
all: build_folder $(PROGRAM) compile_flags.txt
|
||||
|
||||
$(PROGRAM): $(OBJECT_FILES)
|
||||
$(CC) $^ -o $(BUILD_FOLDER)/$@ $(LINKER_FLAGS)
|
||||
|
||||
$(BUILD_FOLDER)/%.o: $(SOURCE_FOLDER)/%.c $(H_FILES)
|
||||
$(CC) $< -c -o $@ $(C_FLAGS)
|
||||
|
||||
build_folder:
|
||||
mkdir $(BUILD_FOLDER) -p
|
||||
|
||||
compile_flags.txt:
|
||||
echo -xc $(CPP_FLAGS) | sed 's/\s\+/\n/g' > compile_flags.txt
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_FOLDER) compile_flags.txt
|
||||
|
1
src/lexer.c
Normal file
1
src/lexer.c
Normal file
@ -0,0 +1 @@
|
||||
#include "lexer.h"
|
4
src/lexer.h
Normal file
4
src/lexer.h
Normal file
@ -0,0 +1,4 @@
|
||||
#ifndef LEXER_H
|
||||
#define LEXER_H
|
||||
|
||||
#endif
|
24
src/main.c
Normal file
24
src/main.c
Normal file
@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
printf("usage: ol <file>\n");
|
||||
return 1;
|
||||
}
|
||||
const char* file_path = argv[1];
|
||||
|
||||
FILE* file = fopen(file_path, "r");
|
||||
if (!file) {
|
||||
printf("could not open file '%s'\n", file_path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("file:\n");
|
||||
int read_char = fgetc(file);
|
||||
while (read_char != EOF) {
|
||||
fputc(read_char, stdout);
|
||||
read_char = fgetc(file);
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
Loading…
Reference in New Issue
Block a user