mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-15 01:45:02 +01:00
fix span error
This commit is contained in:
parent
87790d4049
commit
53c2cdb085
4 changed files with 15 additions and 6 deletions
|
|
@ -14,7 +14,7 @@ mod span {
|
|||
}
|
||||
|
||||
impl Span {
|
||||
pub fn new(start: usize, len: usize) -> Self {
|
||||
pub fn start_len(start: usize, len: usize) -> Self {
|
||||
Self {
|
||||
start,
|
||||
end: start + len,
|
||||
|
|
@ -22,7 +22,7 @@ mod span {
|
|||
}
|
||||
|
||||
pub fn start_end(start: usize, end: usize) -> Self {
|
||||
Self::new(start, end)
|
||||
Self { start, end }
|
||||
}
|
||||
|
||||
pub fn single(start: usize) -> Self {
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ impl<'code> Lexer<'code> {
|
|||
if self.expect(expect_char) {
|
||||
let _ = self.code.next(); // consume first one
|
||||
Token {
|
||||
span: Span::new(start, start + 2),
|
||||
span: Span::start_len(start, start + 2),
|
||||
kind: true_type,
|
||||
}
|
||||
} else {
|
||||
|
|
@ -192,7 +192,7 @@ impl<'code> Iterator for Lexer<'code> {
|
|||
if self.expect('=') {
|
||||
let _ = self.code.next(); // consume =;
|
||||
break Token {
|
||||
span: Span::new(start, start + 2),
|
||||
span: Span::start_len(start, start + 2),
|
||||
kind: TokenType::BangEqual,
|
||||
};
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -331,7 +331,10 @@ impl<'code> Parser<'code> {
|
|||
span: next.span,
|
||||
}))
|
||||
}
|
||||
_ => Err(ParseErr::InvalidTokenPrimary(next)),
|
||||
_ => {
|
||||
println!("{:?}", next);
|
||||
Err(ParseErr::InvalidTokenPrimary(next))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
8
test.sl
8
test.sl
|
|
@ -1,3 +1,9 @@
|
|||
fn test() {
|
||||
"u" + "w" + "u";
|
||||
if true {
|
||||
print;
|
||||
} else if false {
|
||||
dont_print;
|
||||
} else {
|
||||
"uwu";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue