mirror of
https://github.com/Alvin-Zilverstand/femcode.git
synced 2026-03-06 02:56:56 +01:00
feat: Implement single-line comments
This commit is contained in:
6
examples/comments.fem
Normal file
6
examples/comments.fem
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user