Skip to content

Commit

Permalink
setup validator
Browse files Browse the repository at this point in the history
  • Loading branch information
omdxp committed Sep 9, 2024
1 parent 84c5a65 commit 6c8b277
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
OBJECTS= ./build/stddef.o ./build/stdarg.o ./build/static_include.o ./build/native.o ./build/preprocessor.o ./build/compiler.o ./build/codegen.o ./build/resolver.o ./build/rdefault.o ./build/stackframe.o ./build/array.o ./build/fixup.o ./build/helper.o ./build/scope.o ./build/symresolver.o ./build/cprocess.o ./build/datatype.o ./build/expressionable.o ./build/lexer.o ./build/token.o ./build/lex_process.o ./build/parser.o ./build/node.o ./build/helpers/buffer.o ./build/helpers/vector.o
OBJECTS= ./build/validator.o ./build/stddef.o ./build/stdarg.o ./build/static_include.o ./build/native.o ./build/preprocessor.o ./build/compiler.o ./build/codegen.o ./build/resolver.o ./build/rdefault.o ./build/stackframe.o ./build/array.o ./build/fixup.o ./build/helper.o ./build/scope.o ./build/symresolver.o ./build/cprocess.o ./build/datatype.o ./build/expressionable.o ./build/lexer.o ./build/token.o ./build/lex_process.o ./build/parser.o ./build/node.o ./build/helpers/buffer.o ./build/helpers/vector.o
INCLUDES= -I./

all: ${OBJECTS}
gcc main.c ${INCLUDES} ${OBJECTS} -g -o ./main

./build/validator.o: ./validator.c
gcc ./validator.c ${INCLUDES} -o ./build/validator.o -g -c

./build/stddef.o: ./preprocessor/static_includes/stddef.c
gcc ./preprocessor/static_includes/stddef.c ${INCLUDES} -o ./build/stddef.o -g -c

Expand Down
5 changes: 5 additions & 0 deletions compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ int compile_file(const char *filename, const char *out_filename, int flags) {
return COMPILER_FAILED_WITH_ERRORS;
}

// Perform validation
if (validate(process) != VALIDATION_ALL_OK) {
return COMPILER_FAILED_WITH_ERRORS;
}

// Perfom code generation
if (codegen(process) != CODEGEN_ALL_OK) {
return COMPILER_FAILED_WITH_ERRORS;
Expand Down
4 changes: 4 additions & 0 deletions compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ struct compile_process {

enum { PARSE_ALL_OK, PARSE_GENERAL_ERROR };

enum { VALIDATION_ALL_OK, VALIDATION_GENERAL_ERROR };

enum { CODEGEN_ALL_OK, CODEGEN_GENERAL_ERROR };

enum {
Expand Down Expand Up @@ -1665,4 +1667,6 @@ struct preprocessor_definition *preprocessor_definition_create_native(
struct preprocessor *preprocessor);
void preprocessor_create_defs(struct preprocessor *preprocessor);

int validate(struct compile_process *process);

#endif
19 changes: 19 additions & 0 deletions validator.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "compiler.h"

void validate_init(struct compile_process *process) {
// TODO: Implement
}

void validate_destroy(struct compile_process *process) {
// TODO: Implement
}

int validate_tree() { return VALIDATION_ALL_OK; }

int validate(struct compile_process *process) {
int res = 0;
validate_init(process);
res = validate_tree();
validate_destroy(process);
return res;
}

0 comments on commit 6c8b277

Please sign in to comment.