feat: add comment support to saccharine language #25

Merged
mvhutz merged 3 commits from feat/comment-support into main 2026-01-13 02:00:01 +00:00
2 changed files with 7 additions and 7 deletions
Showing only changes of commit b588754552 - Show all commits

View File

@@ -78,17 +78,15 @@ func getToken(i *iterator.Iterator[rune]) (*Token, error) {
case letter == ';':
return NewHardBreak(index), nil
case letter == '#':
// Skip everything until the next newline or EOF
for {
if i.Done() {
break
}
// Skip everything until the next newline or EOF.
for i.Done() {
r, err := i.Next()
if err != nil {
return nil, trace.Wrap(err, "error while parsing comment")
}
if r == '\n' {
// Put the newline back so it can be processed as a soft break
// Put the newline back so it can be processed as a soft break.
i.Back()
break
}

View File

@@ -3,7 +3,9 @@
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))
twice := \f.\x.(f
# Comments can be anywhere!
(f x))
# Test that comments don't interfere with expressions
result := (twice identity VALUE) # Should just return VALUE