feat: Implement single-line comments

This commit is contained in:
Alvin
2025-07-22 16:57:24 +02:00
parent 7ef8f820b4
commit 3461ed8863
2 changed files with 12 additions and 0 deletions

6
examples/comments.fem Normal file
View File

@@ -0,0 +1,6 @@
# This is a single-line comment
UwU Boy "Hello, Femcode!" # This is also a comment
# Another comment line
my_variable is 10 # Assigning a value
UwU Boy my_variable

View File

@@ -29,6 +29,12 @@ class Lexer:
current_char = self.text[self.pos]
# Handle comments
if current_char == '#':
while self.pos < len(self.text) and self.text[self.pos] != '\n':
self.pos += 1
return self.get_next_token() # Recursively call to get the next actual token
if current_char == '"':
self.pos += 1
string_start = self.pos