From c335917226bf3cf9fe21570c58bc35355f8aad86 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sun, 7 Jul 2024 10:06:15 -0400 Subject: [PATCH] add comments, starting with # --- f.go | 7 +++++-- makefile | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/f.go b/f.go index 06c844c..c1f6480 100644 --- a/f.go +++ b/f.go @@ -345,9 +345,12 @@ func runRepl(stack Stack, reader *bufio.Reader) Stack { replForLoop: for { new_line, _ := reader.ReadString('\n') - words := strings.Split(strings.TrimSpace(new_line), " ") + new_line_before_comments, _, _ := strings.Cut(new_line, "#") + new_line_trimmed := strings.TrimSpace(new_line_before_comments) + words := strings.Split(new_line_trimmed, " ") + switch { - case strings.TrimSpace(new_line) == "": /* Empty line case */ + case strings.TrimSpace(new_line_trimmed) == "": /* Empty line case */ /* Parenthesis */ case len(words) == 2 && (words[0] == "*" || words[0] == "+" || words[0] == "-" || words[0] == "/") && words[1] == "(": new_stack := runRepl(Stack{old_dist: INIT_DIST, vars: stack.vars}, reader) diff --git a/makefile b/makefile index ae8dbbd..e7df766 100644 --- a/makefile +++ b/makefile @@ -6,4 +6,5 @@ build: install: f sudo mv f /usr/bin/f + rm /usr/bin/fermi sudo ln -s /usr/bin/f /usr/bin/fermi