Add comments to the lexer

This commit is contained in:
Slendi 2024-02-09 01:49:40 +02:00
parent 90a495ba1b
commit 7478a0d29f
2 changed files with 11 additions and 1 deletions

View File

@ -93,6 +93,14 @@ lexer_skip_whitespace :: proc(lexer: ^Lexer) {
lexer_next :: proc(lexer: ^Lexer) -> (ret: Token) {
lexer_skip_whitespace(lexer)
if lexer.char == '\\' {
lexer_advance(lexer)
for lexer.char != '\n' && lexer.char != 0 {
lexer_advance(lexer)
}
return lexer_next(lexer)
}
if lexer.should_return_semicolon {
lexer.should_return_semicolon = false
return token_create(.Semicolon, TextRange { start = lexer.position, end = lexer.position })

View File

@ -1,10 +1,12 @@
use "fmt.cat"
use lib "directory/long_library_name"
\ This is a comment, it should be ignored by the compiler
fmt.printf "%d + %d = %d File length: %d" a b a + b (io.file_size "file.txt")
fmt.println "Hello world!"
let a := 123
let a := 123 \ This is another comment, that should be ignored by the compiler
let uninitialized : u32
let multiple variables here : u32 = 1 2 3
let string : str, number : i32