Skip to content

Commit

Permalink
Merge pull request #28 from kaiserthe13th/module-import-is-use
Browse files Browse the repository at this point in the history
Module import is use
  • Loading branch information
kaiserthe13th authored Feb 5, 2022
2 parents 6012dc4 + e838715 commit 90080bc
Show file tree
Hide file tree
Showing 5 changed files with 355 additions and 8 deletions.
46 changes: 39 additions & 7 deletions src/lexer/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ impl Lexer {
Ok(f) => {
tmp_visited.push(path.display().to_string());
f
},
}
Err(FSErr::IsADir) => {
path.push("giriş.trl");
match read_file(&path) {
Ok(f) => {
tmp_visited.push(path.display().to_string());
f
},
Err(e) => panic!("{:?}", e)
}
Err(e) => panic!("{:?}", e),
}
},
}
};
if !in_vec(&path.display().to_string(), &visited.clone()) {
let mut nl = Lexer::new(source);
Expand Down Expand Up @@ -108,10 +108,42 @@ impl Lexer {
} else {
*visited = tmp_visited;
}
},
_ => panic!("yükle den sonra <yazı> bekleniyordu ancak bulunamadı"),
}
TokenType::ParenL => {
tokens.push(Token::new(
TokenType::InScopeParentL,
next_token.lexeme,
next_token.line,
next_token.col,
next_token.file,
Precedence::Reserved,
));
current += 2;
while current < prog.len() - 1 {
let c = prog.get(current).unwrap().clone();
current += 1;
match c.typ {
TokenType::ParenR => {
tokens.push(Token::new(
TokenType::InScopeParentR,
c.lexeme,
c.line,
c.col,
c.file,
Precedence::Reserved,
));
break;
}
TokenType::Identifier | TokenType::Çarpı | TokenType::İkiNokta => tokens.push(c),
_ => panic!("yükle ('dan sonra tanımlayıcı, `)` veya `*` bekleniyordu ancak bulunamadı. {:?}", c),
}
}
}
_ => {
panic!("yükle den sonra <yazı> veya `(` bekleniyordu ancak bulunamadı")
}
}
},
}
_ => {
tokens.push(c);
current += 1;
Expand Down
12 changes: 12 additions & 0 deletions src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ impl Parser {

for (ip, ptoken) in self.tokens.iter().enumerate() {
match ptoken.typ {
LexTokenType::InScopeParentR => parsed.push(Token::new(
TokenType::InScopeParentR,
ptoken.line,
ptoken.col,
ptoken.file.clone(),
)),
LexTokenType::InScopeParentL => parsed.push(Token::new(
TokenType::InScopeParentL,
ptoken.line,
ptoken.col,
ptoken.file.clone(),
)),
LexTokenType::İkiNokta => parsed.push(Token::new(
TokenType::İkiNokta,
ptoken.line,
Expand Down
Loading

0 comments on commit 90080bc

Please sign in to comment.