From bb662f60797674f4eb2bb75c860ffd59b9412c69 Mon Sep 17 00:00:00 2001 From: cannoli-fruit Date: Sun, 26 Jul 2026 20:30:38 -0400 Subject: [PATCH] Added comments --- flagpole/src/main.c | 6 +++++- flagpole/tests/numbers.fp | 1 + flagpole/tests/numinp.fp | 1 + flagpole/tests/sub.fp | 6 ++++++ flagpole/tests/truthmachine.fp | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 flagpole/tests/sub.fp diff --git a/flagpole/src/main.c b/flagpole/src/main.c index 7941235..4f489ad 100644 --- a/flagpole/src/main.c +++ b/flagpole/src/main.c @@ -138,6 +138,7 @@ int main(uint argc, char **argv) { bool isQuote = false; bool isProc = false; bool isInclude = false; + bool isComment = false; Lz_DA(int) labelStack = {0}; uint64_t allocHead = 0x7000000000000000; char funcName[128]; @@ -164,6 +165,9 @@ int main(uint argc, char **argv) { compileStart: while ((newchar = fgetc(currFile)) != EOF) { ++counter; + if (isComment && newchar == '\n') isComment = false; + if (!isComment && newchar == '#') isComment = true; + if (isComment) continue; if (isspace(newchar) && !isQuote) { if (tokenAccumulator.cnt == 0) continue; if (is_int_literal(&tokenAccumulator)) { @@ -396,7 +400,7 @@ codegen: char *fname = malloc(tokenAccumulator.cnt+1); memcpy(fname, tokenAccumulator.data, tokenAccumulator.cnt); fname[tokenAccumulator.cnt] = 0; - FILE *f = fopen(fname, "rb"); + FILE *f = fopen(fname, "r"); if (!f) { fprintf(stderr, "Could not open file %s or doesn't exist\n", fname); diff --git a/flagpole/tests/numbers.fp b/flagpole/tests/numbers.fp index 4c43518..b124581 100644 --- a/flagpole/tests/numbers.fp +++ b/flagpole/tests/numbers.fp @@ -1,6 +1,7 @@ $inc fvmstd.fp proc main + # Test for the putuint function in fvmstd "Hello World!" :puts :newline 23 :putuint :newline 0 :putuint :newline diff --git a/flagpole/tests/numinp.fp b/flagpole/tests/numinp.fp index d30d1f8..4e83b8c 100644 --- a/flagpole/tests/numinp.fp +++ b/flagpole/tests/numinp.fp @@ -1,6 +1,7 @@ $inc fvmstd.fp proc main + # Basic test for getuint and putuint "Sum Program" :puts :newline :getuint :getuint u+ diff --git a/flagpole/tests/sub.fp b/flagpole/tests/sub.fp new file mode 100644 index 0000000..0e3b792 --- /dev/null +++ b/flagpole/tests/sub.fp @@ -0,0 +1,6 @@ +$inc fvmstd.fp + +proc main + 49 48 u- + :putuint :newline +endproc diff --git a/flagpole/tests/truthmachine.fp b/flagpole/tests/truthmachine.fp index 158b7a5..9685798 100644 --- a/flagpole/tests/truthmachine.fp +++ b/flagpole/tests/truthmachine.fp @@ -1,6 +1,7 @@ $inc fvmstd.fp proc main + # Truth machine (https://esolangs.org/wiki/Truth-machine) :getchar while dup "1" ld8 == do dup :putchar