Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 10 additions & 84 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@ CC = gcc
CFLAGS = -Isrc -Wall -Wextra -std=c11 -g
LDFLAGS =

SRC = src/main.c src/lexer/lexer.c
SRC = src/main.c src/lexer/lexer.c src/parser/ast.c src/parser/parser.c
OBJ = $(SRC:.c=.o)

TARGET = eac

# Determine if a specific test file was provided on the command line
TEST_GOAL := $(firstword $(filter %.eac,$(MAKECMDGOALS)))

ifeq ($(TEST_GOAL),)
SELECTED_TEST := tests/test.eac
else ifneq ($(findstring /,$(TEST_GOAL)),)
SELECTED_TEST := $(TEST_GOAL)
else
SELECTED_TEST := tests/$(TEST_GOAL)
endif

.PHONY: all clean test test-all $(TEST_GOAL)
.PHONY: all clean test-lexer test-parser

all: $(TARGET)

Expand All @@ -28,77 +17,14 @@ $(TARGET): $(OBJ)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@

test: $(TARGET)
@echo "Running test file: $(SELECTED_TEST)"
@./$(TARGET) $(SELECTED_TEST)

ifneq ($(TEST_GOAL),)
$(TEST_GOAL):
endif

test-all: $(TARGET)
@echo "========================================================================"
@echo " EaC LEXICAL ANALYZER - COMPREHENSIVE TEST SUITE"
@echo "========================================================================"
@echo ""
@echo "[CRITERION 1] File Type Validation Tests:"
@echo " Testing non-.eac files (should be rejected)..."
-@./$(TARGET) tests/test_file.py 2>nul
-@./$(TARGET) tests/test_file.txt 2>nul
-@./$(TARGET) tests/test_file.c 2>nul
@echo " File type validation complete (non-.eac files rejected)"
@echo ""
@echo "[CRITERION 2] Identifiers Test (10 cases):"
@./$(TARGET) tests/test_identifiers.eac
@echo ""
@echo "[CRITERION 3] Keywords Test (24 keywords, 240 cases):"
@./$(TARGET) tests/test_all_keywords.eac
@echo ""
@echo "[CRITERION 4] Reserved Words Test (5 types, 50 cases):"
@./$(TARGET) tests/test_reserved_words.eac
@echo ""
@echo "[CRITERION 5] Constant Values Test (5 types, 50 cases):"
@./$(TARGET) tests/test_constant_values.eac
@echo ""
@echo "[CRITERION 6] Noise Words Test (10 cases):"
@./$(TARGET) tests/test_noise_words.eac
@echo ""
@echo "[CRITERION 7] Comments Test (10 cases):"
@./$(TARGET) tests/test_all_comments.eac
@echo ""
@echo "[CRITERION 8a] Arithmetic Operators Test (7 operators, 70 cases):"
@./$(TARGET) tests/test_arithmetic_operators.eac
@echo ""
@echo "[CRITERION 8b] Boolean Operators Test (9 operators, 90 cases):"
@./$(TARGET) tests/test_boolean_operators.eac
@echo ""
@echo "[CRITERION 9] Delimiters & Brackets Test (10 cases):"
@./$(TARGET) tests/test_delimiters.eac
@echo ""
@echo "[CRITERION 10] Invalid Tokens Test (10 cases):"
-@./$(TARGET) tests/test_all_invalid.eac
@echo ""
@echo "[BONUS] Python-Style Indentation Test:"
@./$(TARGET) tests/test_indentation.eac
@echo ""
@echo "[BONUS] Comprehensive All-in-One Test:"
@./$(TARGET) tests/test_comprehensive_all.eac
@echo ""
@echo "========================================================================"
@echo " ALL TESTS COMPLETED"
@echo "========================================================================"
@echo ""
@echo "Total Test Files: 14"
@echo "Total Test Cases: 544+"
@echo ""
@echo "Check the output/ directory for detailed token tables."
@echo ""
test-lexer: $(TARGET)
@echo "Running Lexer Test..."
@./$(TARGET) --lexer tests/demo/test_lexer.eac

TARGET_BIN := $(TARGET)$(EXEEXT)
OBJ_CLEAN := $(subst /,\,$(OBJ))
test-parser: $(TARGET)
@echo "Running Parser Test..."
@./$(TARGET) --parse tests/demo/test_main.eac

clean:
@if exist $(TARGET_BIN) del /f /q $(TARGET_BIN) >nul 2>&1
@if exist $(TARGET) del /f /q $(TARGET) >nul 2>&1
@if not "$(OBJ_CLEAN)"=="" del /f /q $(OBJ_CLEAN) >nul 2>&1
@if exist output rmdir /s /q output >nul 2>&1
rm -f $(TARGET) $(TARGET).exe $(OBJ)
rm -rf output
Loading