Started working on argv parsing

This commit is contained in:
Kyler Olsen 2025-11-27 21:38:24 -07:00
parent 46a855abd0
commit dc6be59fab
4 changed files with 71 additions and 2 deletions

View File

@ -5,6 +5,9 @@ CFLAGS ?= -std=c99 -Wall -Wextra -Werror -g -Iinclude -MMD -MP
LDFLAGS ?= LDFLAGS ?=
CTESTFLAGS ?= -std=c99 -Wall -Wextra -Wno-unused-function -Werror -g -O0 -Iinclude -MMD -MP CTESTFLAGS ?= -std=c99 -Wall -Wextra -Wno-unused-function -Werror -g -O0 -Iinclude -MMD -MP
GIT_COMMIT := $(shell git describe --always --dirty --abbrev=7)
CFLAGS += -DGIT_COMMIT_HASH="\"$(GIT_COMMIT)\""
SRCDIR := src SRCDIR := src
OBJDIR := obj OBJDIR := obj
BINDIR := bin BINDIR := bin

34
SLS_C/include/sls/main.h Normal file
View File

@ -0,0 +1,34 @@
// Kyler Olsen
// YREA SLS
// Main Header
// November 2025
#ifndef SLS_MAIN_H
#define SLS_MAIN_H
#define SLS_NAME "SLS_C"
#define SLS_VER "a.0.0"
#ifndef GIT_COMMIT_HASH
#define GIT_COMMIT_HASH "UNKNOWN"
#endif
#if defined(__GNUC__)
#define COMPILER_NAME "GCC"
#define COMPILER_VER __GNUC__
#elif defined(__clang__)
#define COMPILER_NAME "Clang"
#define COMPILER_VER __clang_major__
#elif defined(_MSC_VER)
#define COMPILER_NAME "MSVC"
#define COMPILER_VER _MSC_VER
#else
#define COMPILER_NAME "Unknown compiler"
#define COMPILER_VER 0
#endif
#endif // SLS_MAIN_H

View File

@ -4,8 +4,33 @@
// October 2025 // October 2025
#include <stdio.h> #include <stdio.h>
#include <stddef.h>
#include <string.h>
#include "sls/main.h"
#include "sls/bool.h"
#include "sls/repl.h"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
printf("Hello, world!\n"); Boolean version = FALSE;
Boolean file = FALSE;
char *filename = NULL;
(void)file;
(void)filename;
for (int i = 0; i < argc; i++) {
if (strcmp(argv[i], "--version") == 0) version = TRUE;
if (strcmp(argv[i], "-v") == 0) version = TRUE;
}
if (version) {
printf("YREA SLS (" SLS_NAME ") " SLS_VER " (" GIT_COMMIT_HASH ")\n");
printf("Compiled with " COMPILER_NAME " %d at " __DATE__ " " __TIME__ "\n", COMPILER_VER);
return 0; return 0;
} else if (file) {
return 1;
} else {
return repl(0, NULL);
}
} }

View File

@ -4,3 +4,10 @@
// November 2025 // November 2025
#include "sls/repl.h" #include "sls/repl.h"
int repl(int argc, char *argv[]) {
(void)argc;
(void)argv;
return 1;
}