Implement line comments
This commit is contained in:
parent
2ea2aa5203
commit
49ada446f8
@ -42,7 +42,7 @@
|
|||||||
- [ ] If else statement `if X { ... } else { ... }`
|
- [ ] If else statement `if X { ... } else { ... }`
|
||||||
- [ ] If Statement
|
- [ ] If Statement
|
||||||
- [ ] Else statement
|
- [ ] Else statement
|
||||||
- [ ] Line comments `//`
|
- [x] Line comments `//`
|
||||||
- [ ] Strings
|
- [ ] Strings
|
||||||
- [ ] IO Intrinsics
|
- [ ] IO Intrinsics
|
||||||
- [ ] Print
|
- [ ] Print
|
||||||
|
|||||||
@ -129,6 +129,8 @@ impl<'a> Lexer<'a> {
|
|||||||
self.next();
|
self.next();
|
||||||
tokens.push(Token::LArrow);
|
tokens.push(Token::LArrow);
|
||||||
}
|
}
|
||||||
|
// Line comment. Consume every char until linefeed (next line)
|
||||||
|
'/' if matches!(self.peek(), '/') => while self.next() != '\n' {},
|
||||||
|
|
||||||
';' => tokens.push(Token::Semicolon),
|
';' => tokens.push(Token::Semicolon),
|
||||||
'+' => tokens.push(Token::Add),
|
'+' => tokens.push(Token::Add),
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
use std::io::Write;
|
|
||||||
|
|
||||||
use nek_lang::{lexer::lex, parser::parse, interpreter::Interpreter};
|
use nek_lang::{lexer::lex, parser::parse, interpreter::Interpreter};
|
||||||
|
|
||||||
|
|
||||||
@ -10,6 +8,7 @@ fn main() {
|
|||||||
// let mut code = String::new();
|
// let mut code = String::new();
|
||||||
let code = "
|
let code = "
|
||||||
a <- 5;
|
a <- 5;
|
||||||
|
// nek-lang best lang
|
||||||
a * 2;
|
a * 2;
|
||||||
";
|
";
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user