mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-16 18:35:02 +01:00
fix lex test
This commit is contained in:
parent
dc26b52bd2
commit
bc218efe0e
22 changed files with 437 additions and 160 deletions
|
|
@ -42,7 +42,7 @@ impl<T: ?Sized> Clone for Gc<T> {
|
||||||
impl<T: ?Sized> Copy for Gc<T> {}
|
impl<T: ?Sized> Copy for Gc<T> {}
|
||||||
|
|
||||||
/// An interned String. Hashing and Equality are O(1) and just look at the pointer address
|
/// An interned String. Hashing and Equality are O(1) and just look at the pointer address
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct Symbol {
|
pub struct Symbol {
|
||||||
gc: Gc<str>,
|
gc: Gc<str>,
|
||||||
}
|
}
|
||||||
|
|
@ -83,6 +83,12 @@ impl Deref for Symbol {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Debug for Symbol {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
self.as_str().fmt(f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Object {
|
struct Object {
|
||||||
kind: ObjectKind,
|
kind: ObjectKind,
|
||||||
|
|
|
||||||
195
src/lex.rs
195
src/lex.rs
|
|
@ -353,53 +353,41 @@ fn is_valid_ident_start(char: char) -> bool {
|
||||||
char.is_alphabetic() || char == '_'
|
char.is_alphabetic() || char == '_'
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test_ignore)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::lex::Lexer;
|
use crate::lex::Lexer;
|
||||||
use crate::lex::TokenKind::{self, *};
|
use crate::RtAlloc;
|
||||||
|
|
||||||
type StdString = std::string::String;
|
type StdString = std::string::String;
|
||||||
|
|
||||||
fn lex_types(str: &str) -> Vec<TokenKind> {
|
fn lex_test(code: &str) {
|
||||||
let lexer = Lexer::new(str);
|
// SAFETY: we only work in this tiny scope
|
||||||
lexer.map(|token| token.kind).collect::<Vec<_>>()
|
let mut runtime = unsafe { RtAlloc::new() };
|
||||||
}
|
|
||||||
|
|
||||||
fn lex_test(code: &str, expected: Vec<TokenKind>) {
|
let lexer = Lexer::new(code, &mut runtime);
|
||||||
assert_eq!(lex_types(code), expected)
|
let tokens = lexer.map(|token| token.kind).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
insta::assert_debug_snapshot!(tokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn smiley_face() {
|
fn smiley_face() {
|
||||||
lex_test(">>.<<", vec![Greater, Greater, Dot, Less, Less])
|
lex_test(">>.<<")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn greater_than_less_than_equal() {
|
fn greater_than_less_than_equal() {
|
||||||
lex_test(
|
lex_test(">= <= == < < >=")
|
||||||
">= <= == < < >=",
|
|
||||||
vec![
|
|
||||||
GreaterEqual,
|
|
||||||
LessEqual,
|
|
||||||
EqualEqual,
|
|
||||||
Less,
|
|
||||||
Less,
|
|
||||||
GreaterEqual,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_no_no() {
|
fn no_no_no() {
|
||||||
lex_test("!= != = !=", vec![BangEqual, BangEqual, Equal, BangEqual])
|
lex_test("!= != = !=")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn braces_brackets_parens() {
|
fn braces_brackets_parens() {
|
||||||
lex_test(
|
lex_test("{([]]}");
|
||||||
"{([]]}",
|
|
||||||
vec![BraceO, ParenO, BracketO, BracketC, BracketC, BraceC],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -407,22 +395,18 @@ mod test {
|
||||||
lex_test(
|
lex_test(
|
||||||
"{ ( [ ] ]
|
"{ ( [ ] ]
|
||||||
|
|
||||||
}",
|
}",
|
||||||
vec![BraceO, ParenO, BracketO, BracketC, BracketC, BraceC],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fancy_stuff() {
|
fn fancy_stuff() {
|
||||||
lex_test(
|
lex_test(". ,- * -, .")
|
||||||
". ,- * -, .",
|
|
||||||
vec![Dot, Comma, Minus, Asterisk, Minus, Comma, Dot],
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn comments() {
|
fn comments() {
|
||||||
lex_test("fn # fn", vec![Fn]);
|
lex_test("fn # fn");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -430,15 +414,14 @@ mod test {
|
||||||
lex_test(
|
lex_test(
|
||||||
"fn ## hello i am something
|
"fn ## hello i am something
|
||||||
|
|
||||||
i span multiple lines
|
i span multiple lines
|
||||||
|
|
||||||
will you love me? 🥺🥺🥺🥺🥺
|
will you love me? 🥺🥺🥺🥺🥺
|
||||||
|
|
||||||
pls :) o(* ̄▽ ̄*)ブ
|
pls :) o(* ̄▽ ̄*)ブ
|
||||||
|
|
||||||
i like the indentation here ngl | sneak for -> ## for ## <- sneak for
|
i like the indentation here ngl | sneak for -> ## for ## <- sneak for
|
||||||
## and",
|
## and",
|
||||||
vec![Fn, For, And],
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -446,102 +429,50 @@ mod test {
|
||||||
fn terminate_multiline_comment_correctly() {
|
fn terminate_multiline_comment_correctly() {
|
||||||
lex_test(
|
lex_test(
|
||||||
"fn ## # no not here :( ## let # ## <- this is commented out
|
"fn ## # no not here :( ## let # ## <- this is commented out
|
||||||
# so no multiline comment
|
# so no multiline comment
|
||||||
##
|
##
|
||||||
|
|
||||||
here it starts
|
here it starts
|
||||||
# let #
|
# let #
|
||||||
# # and
|
# # and
|
||||||
## or
|
## or
|
||||||
",
|
",
|
||||||
vec![Fn, Let, Or],
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn greeting() {
|
fn greeting() {
|
||||||
lex_test("-.- /%", vec![Minus, Dot, Minus, Slash, Percent])
|
lex_test("-.- /%")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn countdown() {
|
fn countdown() {
|
||||||
lex_test(
|
lex_test("3 . . 2 . . 1 . . 0")
|
||||||
"3 . . 2 . . 1 . . 0",
|
|
||||||
vec![
|
|
||||||
Number(3.0),
|
|
||||||
Dot,
|
|
||||||
Dot,
|
|
||||||
Number(2.0),
|
|
||||||
Dot,
|
|
||||||
Dot,
|
|
||||||
Number(1.0),
|
|
||||||
Dot,
|
|
||||||
Dot,
|
|
||||||
Number(0.0),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn larger_numbers() {
|
fn larger_numbers() {
|
||||||
lex_test(
|
lex_test("123456789, 123456789.1234, 64785903")
|
||||||
"123456789, 123456789.1234, 64785903",
|
|
||||||
vec![
|
|
||||||
Number(123456789.0),
|
|
||||||
Comma,
|
|
||||||
Number(123456789.1234),
|
|
||||||
Comma,
|
|
||||||
Number(64785903.0),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn string() {
|
fn string() {
|
||||||
lex_test(r#""uwu""#, vec![String("uwu".to_string())])
|
lex_test(r#""uwu""#)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn strings() {
|
fn strings() {
|
||||||
lex_test(
|
lex_test(r#"( "hi" "uwu" "\"uwu\"" "no \\ u" )"#)
|
||||||
r#"( "hi" "uwu" "\"uwu\"" "no \\ u" )"#,
|
|
||||||
vec![
|
|
||||||
ParenO,
|
|
||||||
String("hi".to_string()),
|
|
||||||
String("uwu".to_string()),
|
|
||||||
String("\"uwu\"".to_string()),
|
|
||||||
String("no \\ u".to_string()),
|
|
||||||
ParenC,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn keywords() {
|
fn keywords() {
|
||||||
lex_test(
|
lex_test("let fn if else loop while break for true false null and not or print")
|
||||||
"let fn if else loop while break for true false null and not or print",
|
|
||||||
vec![
|
|
||||||
Let, Fn, If, Else, Loop, While, Break, For, True, False, Null, And, Not, Or, Print,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn keyword_and_ident() {
|
fn keyword_and_ident() {
|
||||||
lex_test(
|
lex_test("let variable be a loop if false is true")
|
||||||
"let variable be a loop if false is true",
|
|
||||||
vec![
|
|
||||||
Let,
|
|
||||||
Ident("variable"),
|
|
||||||
Ident("be"),
|
|
||||||
Ident("a"),
|
|
||||||
Loop,
|
|
||||||
If,
|
|
||||||
False,
|
|
||||||
Ident("is"),
|
|
||||||
True,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -569,61 +500,21 @@ mod test {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|word| format!("{} ", word))
|
.map(|word| format!("{} ", word))
|
||||||
.collect::<StdString>();
|
.collect::<StdString>();
|
||||||
let expected = words.map(TokenKind::Ident).to_vec();
|
|
||||||
|
|
||||||
lex_test(&sentences, expected)
|
lex_test(&sentences)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serious_program() {
|
fn serious_program() {
|
||||||
lex_test(
|
lex_test(
|
||||||
r#"let string = "hallol"
|
r#"let string = "hallol"
|
||||||
let number = 5
|
let number = 5
|
||||||
let me out ._.
|
let me out ._.
|
||||||
fn world() {
|
fn world() {
|
||||||
if number == 5 or true == false and not false {
|
if number == 5 or true == false and not false {
|
||||||
println("Hello \\ World!")
|
println("Hello \\ World!")
|
||||||
}
|
}
|
||||||
}"#,
|
}"#,
|
||||||
vec![
|
|
||||||
Let,
|
|
||||||
Ident("string"),
|
|
||||||
Equal,
|
|
||||||
String("hallol".to_string()),
|
|
||||||
Let,
|
|
||||||
Ident("number"),
|
|
||||||
Equal,
|
|
||||||
Number(5.0),
|
|
||||||
Let,
|
|
||||||
Ident("me"),
|
|
||||||
Ident("out"),
|
|
||||||
Dot,
|
|
||||||
Ident("_"),
|
|
||||||
Dot,
|
|
||||||
Fn,
|
|
||||||
Ident("world"),
|
|
||||||
ParenO,
|
|
||||||
ParenC,
|
|
||||||
BraceO,
|
|
||||||
If,
|
|
||||||
Ident("number"),
|
|
||||||
EqualEqual,
|
|
||||||
Number(5.0),
|
|
||||||
Or,
|
|
||||||
True,
|
|
||||||
EqualEqual,
|
|
||||||
False,
|
|
||||||
And,
|
|
||||||
Not,
|
|
||||||
False,
|
|
||||||
BraceO,
|
|
||||||
Ident("println"),
|
|
||||||
ParenO,
|
|
||||||
String("Hello \\ World!".to_string()),
|
|
||||||
ParenC,
|
|
||||||
BraceC,
|
|
||||||
BraceC,
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ mod parse;
|
||||||
mod vm;
|
mod vm;
|
||||||
|
|
||||||
use crate::ast::Program;
|
use crate::ast::Program;
|
||||||
|
|
||||||
use crate::gc::RtAlloc;
|
use crate::gc::RtAlloc;
|
||||||
|
|
||||||
pub use bumpalo::Bump;
|
pub use bumpalo::Bump;
|
||||||
pub use lex::*;
|
pub use lex::*;
|
||||||
pub use parse::*;
|
pub use parse::*;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
//! It's a handwritten recursive descent parser. It has an internal peekable iterator from where
|
//! It's a handwritten recursive descent parser. It has an internal peekable iterator from where
|
||||||
//! it gets its next tokens. Only a lookahead of one is required.
|
//! it gets its next tokens. Only a lookahead of one is required.
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test_ignore_lol)]
|
||||||
mod test;
|
mod test;
|
||||||
|
|
||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
BraceO,
|
||||||
|
ParenO,
|
||||||
|
BracketO,
|
||||||
|
BracketC,
|
||||||
|
BracketC,
|
||||||
|
BraceC,
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
BraceO,
|
||||||
|
ParenO,
|
||||||
|
BracketO,
|
||||||
|
BracketC,
|
||||||
|
BracketC,
|
||||||
|
BraceC,
|
||||||
|
]
|
||||||
9
src/snapshots/dilaria__lex__test__comments.snap
Normal file
9
src/snapshots/dilaria__lex__test__comments.snap
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Fn,
|
||||||
|
]
|
||||||
26
src/snapshots/dilaria__lex__test__countdown.snap
Normal file
26
src/snapshots/dilaria__lex__test__countdown.snap
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Number(
|
||||||
|
3.0,
|
||||||
|
),
|
||||||
|
Dot,
|
||||||
|
Dot,
|
||||||
|
Number(
|
||||||
|
2.0,
|
||||||
|
),
|
||||||
|
Dot,
|
||||||
|
Dot,
|
||||||
|
Number(
|
||||||
|
1.0,
|
||||||
|
),
|
||||||
|
Dot,
|
||||||
|
Dot,
|
||||||
|
Number(
|
||||||
|
0.0,
|
||||||
|
),
|
||||||
|
]
|
||||||
15
src/snapshots/dilaria__lex__test__fancy_stuff.snap
Normal file
15
src/snapshots/dilaria__lex__test__fancy_stuff.snap
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Dot,
|
||||||
|
Comma,
|
||||||
|
Minus,
|
||||||
|
Asterisk,
|
||||||
|
Minus,
|
||||||
|
Comma,
|
||||||
|
Dot,
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
GreaterEqual,
|
||||||
|
LessEqual,
|
||||||
|
EqualEqual,
|
||||||
|
Less,
|
||||||
|
Less,
|
||||||
|
GreaterEqual,
|
||||||
|
]
|
||||||
13
src/snapshots/dilaria__lex__test__greeting.snap
Normal file
13
src/snapshots/dilaria__lex__test__greeting.snap
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Minus,
|
||||||
|
Dot,
|
||||||
|
Minus,
|
||||||
|
Slash,
|
||||||
|
Percent,
|
||||||
|
]
|
||||||
25
src/snapshots/dilaria__lex__test__keyword_and_ident.snap
Normal file
25
src/snapshots/dilaria__lex__test__keyword_and_ident.snap
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Let,
|
||||||
|
Ident(
|
||||||
|
"variable",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"be",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"a",
|
||||||
|
),
|
||||||
|
Loop,
|
||||||
|
If,
|
||||||
|
False,
|
||||||
|
Ident(
|
||||||
|
"is",
|
||||||
|
),
|
||||||
|
True,
|
||||||
|
]
|
||||||
23
src/snapshots/dilaria__lex__test__keywords.snap
Normal file
23
src/snapshots/dilaria__lex__test__keywords.snap
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Let,
|
||||||
|
Fn,
|
||||||
|
If,
|
||||||
|
Else,
|
||||||
|
Loop,
|
||||||
|
While,
|
||||||
|
Break,
|
||||||
|
For,
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
Null,
|
||||||
|
And,
|
||||||
|
Not,
|
||||||
|
Or,
|
||||||
|
Print,
|
||||||
|
]
|
||||||
19
src/snapshots/dilaria__lex__test__larger_numbers.snap
Normal file
19
src/snapshots/dilaria__lex__test__larger_numbers.snap
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Number(
|
||||||
|
123456789.0,
|
||||||
|
),
|
||||||
|
Comma,
|
||||||
|
Number(
|
||||||
|
123456789.1234,
|
||||||
|
),
|
||||||
|
Comma,
|
||||||
|
Number(
|
||||||
|
64785903.0,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Fn,
|
||||||
|
For,
|
||||||
|
And,
|
||||||
|
]
|
||||||
12
src/snapshots/dilaria__lex__test__no_no_no.snap
Normal file
12
src/snapshots/dilaria__lex__test__no_no_no.snap
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
BangEqual,
|
||||||
|
BangEqual,
|
||||||
|
Equal,
|
||||||
|
BangEqual,
|
||||||
|
]
|
||||||
59
src/snapshots/dilaria__lex__test__not_quite_a_keyword.snap
Normal file
59
src/snapshots/dilaria__lex__test__not_quite_a_keyword.snap
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Ident(
|
||||||
|
"letter",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"fori",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"fnfn",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"iffy",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"bloop",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"loopy_yeah",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"whileTrue",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"truefalse",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"falsetrue",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"nullability",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"rot",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"ornot",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"nor",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"andnowQuestionMark",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"notOrAnd",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"breakMe",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"Ibreak",
|
||||||
|
),
|
||||||
|
]
|
||||||
69
src/snapshots/dilaria__lex__test__serious_program.snap
Normal file
69
src/snapshots/dilaria__lex__test__serious_program.snap
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Let,
|
||||||
|
Ident(
|
||||||
|
"string",
|
||||||
|
),
|
||||||
|
Equal,
|
||||||
|
String(
|
||||||
|
"hallol",
|
||||||
|
),
|
||||||
|
Let,
|
||||||
|
Ident(
|
||||||
|
"number",
|
||||||
|
),
|
||||||
|
Equal,
|
||||||
|
Number(
|
||||||
|
5.0,
|
||||||
|
),
|
||||||
|
Let,
|
||||||
|
Ident(
|
||||||
|
"me",
|
||||||
|
),
|
||||||
|
Ident(
|
||||||
|
"out",
|
||||||
|
),
|
||||||
|
Dot,
|
||||||
|
Ident(
|
||||||
|
"_",
|
||||||
|
),
|
||||||
|
Dot,
|
||||||
|
Fn,
|
||||||
|
Ident(
|
||||||
|
"world",
|
||||||
|
),
|
||||||
|
ParenO,
|
||||||
|
ParenC,
|
||||||
|
BraceO,
|
||||||
|
If,
|
||||||
|
Ident(
|
||||||
|
"number",
|
||||||
|
),
|
||||||
|
EqualEqual,
|
||||||
|
Number(
|
||||||
|
5.0,
|
||||||
|
),
|
||||||
|
Or,
|
||||||
|
True,
|
||||||
|
EqualEqual,
|
||||||
|
False,
|
||||||
|
And,
|
||||||
|
Not,
|
||||||
|
False,
|
||||||
|
BraceO,
|
||||||
|
Ident(
|
||||||
|
"println",
|
||||||
|
),
|
||||||
|
ParenO,
|
||||||
|
String(
|
||||||
|
"Hello \\ World!",
|
||||||
|
),
|
||||||
|
ParenC,
|
||||||
|
BraceC,
|
||||||
|
BraceC,
|
||||||
|
]
|
||||||
13
src/snapshots/dilaria__lex__test__smiley_face.snap
Normal file
13
src/snapshots/dilaria__lex__test__smiley_face.snap
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Greater,
|
||||||
|
Greater,
|
||||||
|
Dot,
|
||||||
|
Less,
|
||||||
|
Less,
|
||||||
|
]
|
||||||
11
src/snapshots/dilaria__lex__test__string.snap
Normal file
11
src/snapshots/dilaria__lex__test__string.snap
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
String(
|
||||||
|
"uwu",
|
||||||
|
),
|
||||||
|
]
|
||||||
22
src/snapshots/dilaria__lex__test__strings.snap
Normal file
22
src/snapshots/dilaria__lex__test__strings.snap
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
ParenO,
|
||||||
|
String(
|
||||||
|
"hi",
|
||||||
|
),
|
||||||
|
String(
|
||||||
|
"uwu",
|
||||||
|
),
|
||||||
|
String(
|
||||||
|
"\"uwu\"",
|
||||||
|
),
|
||||||
|
String(
|
||||||
|
"no \\ u",
|
||||||
|
),
|
||||||
|
ParenC,
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
source: src/lex.rs
|
||||||
|
assertion_line: 370
|
||||||
|
expression: tokens
|
||||||
|
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Fn,
|
||||||
|
Let,
|
||||||
|
Or,
|
||||||
|
]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue