feat: add comment support to saccharine language

Add '#' comment syntax that works like Python comments.
Comments can take up a whole line or appear at the end of a line.
All characters after '#' until the next newline or EOF are ignored.

Closes #24
This commit is contained in:
2026-01-12 20:53:38 -05:00
parent 19652563a4
commit 6418e05255
3 changed files with 33 additions and 0 deletions

1
tests/comments.expected Normal file
View File

@@ -0,0 +1 @@
VALUE

15
tests/comments.test Normal file
View File

@@ -0,0 +1,15 @@
# This is a full-line comment at the start
# The following defines the identity function
identity := \x.x # This is an end-of-line comment
# Define a simple function that applies a function twice
twice := \f.\x.(f (f x))
# Test that comments don't interfere with expressions
result := (twice identity VALUE) # Should just return VALUE
# Multiple comments in a row
# can appear anywhere
# without breaking the code
result # Final comment at the end