add comments, starting with #

This commit is contained in:
NunoSempere 2024-07-07 10:06:15 -04:00
parent 8b88beae88
commit c335917226
2 changed files with 6 additions and 2 deletions

7
f.go
View File

@ -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)

View File

@ -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