Skip to content

Commit

Permalink
I_Language_lexer --> lexer
Browse files Browse the repository at this point in the history
  • Loading branch information
ElBe-Plaq committed Dec 31, 2023
1 parent 76abd0e commit e64fe41
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 157 deletions.
6 changes: 3 additions & 3 deletions crates/lexer/src/lex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ use tools::iterator::ConditionalPeeking;
/// # Examples
///
/// ```rust
/// # use I_Language_lexer::lex;
/// # use I_Language_lexer::tokens::mark;
/// # use I_Language_lexer::tokens::token;
/// # use lexer::lex;
/// # use lexer::tokens::mark;
/// # use lexer::tokens::token;
/// assert_eq!(lex::lex("1 + 1", "<stdin>"),
/// [
/// token::Token {
Expand Down
26 changes: 13 additions & 13 deletions crates/lexer/tests/lex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,39 @@ mod tests {
#[test]
fn test_lex() {
assert_eq!(
I_Language_lexer::lex::lex("1 + 1", "<stdin>"),
lexer::lex::lex("1 + 1", "<stdin>"),
[
I_Language_lexer::tokens::token::Token {
location: I_Language_lexer::tokens::token::Location {
lexer::tokens::token::Token {
location: lexer::tokens::token::Location {
file: "<stdin>".to_owned(),
line: 1,
column: 1,
},
content: "1".to_owned(),
token_type: I_Language_lexer::tokens::token::TokenType::TypeDefinition(
I_Language_lexer::tokens::token::TypeDefinition::Integer,
token_type: lexer::tokens::token::TokenType::TypeDefinition(
lexer::tokens::token::TypeDefinition::Integer,
),
},
I_Language_lexer::tokens::token::Token {
location: I_Language_lexer::tokens::token::Location {
lexer::tokens::token::Token {
location: lexer::tokens::token::Location {
file: "<stdin>".to_owned(),
line: 1,
column: 3,
},
content: "+".to_owned(),
token_type: I_Language_lexer::tokens::token::TokenType::Mark(
I_Language_lexer::tokens::mark::Mark::Add,
token_type: lexer::tokens::token::TokenType::Mark(
lexer::tokens::mark::Mark::Add,
),
},
I_Language_lexer::tokens::token::Token {
location: I_Language_lexer::tokens::token::Location {
lexer::tokens::token::Token {
location: lexer::tokens::token::Location {
file: "<stdin>".to_owned(),
line: 1,
column: 5,
},
content: "1".to_owned(),
token_type: I_Language_lexer::tokens::token::TokenType::TypeDefinition(
I_Language_lexer::tokens::token::TypeDefinition::Integer,
token_type: lexer::tokens::token::TokenType::TypeDefinition(
lexer::tokens::token::TypeDefinition::Integer,
),
},
]
Expand Down
104 changes: 51 additions & 53 deletions crates/lexer/tests/tokens/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,71 +27,70 @@

#[cfg(test)]
mod tests {
use I_Language_lexer::tokens::token::GetToken;
use lexer::tokens::token::GetToken;

#[test]
fn test_constant() {
let location: I_Language_lexer::tokens::token::Location =
I_Language_lexer::tokens::token::Location {
file: "tests".to_owned(),
line: 1,
column: 1,
};
let location: lexer::tokens::token::Location = lexer::tokens::token::Location {
file: "tests".to_owned(),
line: 1,
column: 1,
};

assert_eq!(
I_Language_lexer::tokens::constant::Constant::get_token(
lexer::tokens::constant::Constant::get_token(
location.clone(),
&"true".chars().collect::<Vec<char>>()
),
Some((
I_Language_lexer::tokens::token::Token {
lexer::tokens::token::Token {
location: location.clone(),
content: "true".to_owned(),
token_type: I_Language_lexer::tokens::token::TokenType::TypeDefinition(
I_Language_lexer::tokens::token::TypeDefinition::Boolean(
I_Language_lexer::tokens::constant::Constant::True
token_type: lexer::tokens::token::TokenType::TypeDefinition(
lexer::tokens::token::TypeDefinition::Boolean(
lexer::tokens::constant::Constant::True
)
),
},
4,
))
);
assert_eq!(
I_Language_lexer::tokens::constant::Constant::get_token(
lexer::tokens::constant::Constant::get_token(
location.clone(),
&"false".chars().collect::<Vec<char>>()
),
Some((
I_Language_lexer::tokens::token::Token {
lexer::tokens::token::Token {
location: location.clone(),
content: "false".to_owned(),
token_type: I_Language_lexer::tokens::token::TokenType::TypeDefinition(
I_Language_lexer::tokens::token::TypeDefinition::Boolean(
I_Language_lexer::tokens::constant::Constant::False
token_type: lexer::tokens::token::TokenType::TypeDefinition(
lexer::tokens::token::TypeDefinition::Boolean(
lexer::tokens::constant::Constant::False
)
),
},
5,
))
);
assert_eq!(
I_Language_lexer::tokens::constant::Constant::get_token(
lexer::tokens::constant::Constant::get_token(
location.clone(),
&"None".chars().collect::<Vec<char>>()
),
Some((
I_Language_lexer::tokens::token::Token {
lexer::tokens::token::Token {
location: location.clone(),
content: "None".to_owned(),
token_type: I_Language_lexer::tokens::token::TokenType::TypeDefinition(
I_Language_lexer::tokens::token::TypeDefinition::None
token_type: lexer::tokens::token::TokenType::TypeDefinition(
lexer::tokens::token::TypeDefinition::None
),
},
4,
))
);
assert_eq!(
I_Language_lexer::tokens::constant::Constant::get_token(
lexer::tokens::constant::Constant::get_token(
location.clone(),
&"/".chars().collect::<Vec<char>>()
),
Expand All @@ -101,111 +100,110 @@ mod tests {

#[test]
fn test_type() {
let location: I_Language_lexer::tokens::token::Location =
I_Language_lexer::tokens::token::Location {
file: "tests".to_owned(),
line: 1,
column: 1,
};
let location: lexer::tokens::token::Location = lexer::tokens::token::Location {
file: "tests".to_owned(),
line: 1,
column: 1,
};

assert_eq!(
I_Language_lexer::tokens::constant::Type::get_token(
lexer::tokens::constant::Type::get_token(
location.clone(),
&"str".chars().collect::<Vec<char>>()
),
Some((
I_Language_lexer::tokens::token::Token {
lexer::tokens::token::Token {
location: location.clone(),
content: "string".to_owned(),
token_type: I_Language_lexer::tokens::token::TokenType::Type(
I_Language_lexer::tokens::constant::Type::Str
token_type: lexer::tokens::token::TokenType::Type(
lexer::tokens::constant::Type::Str
),
},
3,
))
);
assert_eq!(
I_Language_lexer::tokens::constant::Type::get_token(
lexer::tokens::constant::Type::get_token(
location.clone(),
&"string".chars().collect::<Vec<char>>()
),
Some((
I_Language_lexer::tokens::token::Token {
lexer::tokens::token::Token {
location: location.clone(),
content: "string".to_owned(),
token_type: I_Language_lexer::tokens::token::TokenType::Type(
I_Language_lexer::tokens::constant::Type::Str
token_type: lexer::tokens::token::TokenType::Type(
lexer::tokens::constant::Type::Str
),
},
6,
))
);
assert_eq!(
I_Language_lexer::tokens::constant::Type::get_token(
lexer::tokens::constant::Type::get_token(
location.clone(),
&"int".chars().collect::<Vec<char>>()
),
Some((
I_Language_lexer::tokens::token::Token {
lexer::tokens::token::Token {
location: location.clone(),
content: "integer".to_owned(),
token_type: I_Language_lexer::tokens::token::TokenType::Type(
I_Language_lexer::tokens::constant::Type::Int
token_type: lexer::tokens::token::TokenType::Type(
lexer::tokens::constant::Type::Int
),
},
3,
))
);
assert_eq!(
I_Language_lexer::tokens::constant::Type::get_token(
lexer::tokens::constant::Type::get_token(
location.clone(),
&"integer".chars().collect::<Vec<char>>()
),
Some((
I_Language_lexer::tokens::token::Token {
lexer::tokens::token::Token {
location: location.clone(),
content: "integer".to_owned(),
token_type: I_Language_lexer::tokens::token::TokenType::Type(
I_Language_lexer::tokens::constant::Type::Int
token_type: lexer::tokens::token::TokenType::Type(
lexer::tokens::constant::Type::Int
),
},
7,
))
);
assert_eq!(
I_Language_lexer::tokens::constant::Type::get_token(
lexer::tokens::constant::Type::get_token(
location.clone(),
&"bool".chars().collect::<Vec<char>>()
),
Some((
I_Language_lexer::tokens::token::Token {
lexer::tokens::token::Token {
location: location.clone(),
content: "boolean".to_owned(),
token_type: I_Language_lexer::tokens::token::TokenType::Type(
I_Language_lexer::tokens::constant::Type::Boolean
token_type: lexer::tokens::token::TokenType::Type(
lexer::tokens::constant::Type::Boolean
),
},
4,
))
);
assert_eq!(
I_Language_lexer::tokens::constant::Type::get_token(
lexer::tokens::constant::Type::get_token(
location.clone(),
&"boolean".chars().collect::<Vec<char>>()
),
Some((
I_Language_lexer::tokens::token::Token {
lexer::tokens::token::Token {
location: location.clone(),
content: "boolean".to_owned(),
token_type: I_Language_lexer::tokens::token::TokenType::Type(
I_Language_lexer::tokens::constant::Type::Boolean
token_type: lexer::tokens::token::TokenType::Type(
lexer::tokens::constant::Type::Boolean
),
},
7,
))
);
assert_eq!(
I_Language_lexer::tokens::constant::Type::get_token(
lexer::tokens::constant::Type::get_token(
location.clone(),
&"/".chars().collect::<Vec<char>>()
),
Expand Down
Loading

0 comments on commit e64fe41

Please sign in to comment.