Skip to content

Commit 20fa6c5

Browse files
committed
removed unnecessary fields
1 parent b189ef8 commit 20fa6c5

12 files changed

Lines changed: 704 additions & 96 deletions

File tree

crates/parser/src/ast.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ pub enum Expr {
183183
target: Option<Box<Expr>>,
184184
name: Box<Expr>,
185185
args: Vec<Expr>,
186-
returned_type: Option<Type>,
187186
},
188187

189188
StructInit {
@@ -195,7 +194,6 @@ pub enum Expr {
195194
left: Box<Expr>,
196195
right: Box<Expr>,
197196
op: Operation,
198-
return_type: Type,
199197
},
200198
Break,
201199
Continue,
@@ -215,7 +213,7 @@ impl Display for Expr {
215213
#[derive(Clone, Debug, PartialEq)]
216214
pub struct Symbol {
217215
pub typ: Type,
218-
pub is_pointer: bool,
216+
pub is_mutable: bool,
219217
pub is_used: bool,
220218
pub is_changed: bool,
221219
}

crates/parser/src/binary_op.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ fn parse_binary_op_with_precedence(
8787
target: None,
8888
name: Box::new(left),
8989
args,
90-
returned_type: Some(Type::Void),
9190
});
9291
}
9392
loop {
@@ -156,7 +155,6 @@ fn parse_binary_op_with_precedence(
156155
left: Box::new(left),
157156
right: Box::new(right),
158157
op,
159-
return_type: Type::Any,
160158
};
161159
}
162160

crates/parser/src/expressions.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ pub fn parse_single_expr(tokens: &mut Tokens) -> Result<Expr, ParserError> {
214214
left: Box::new(Expr::Number(-1)),
215215
right: Box::new(Expr::VariableRef { name, symbol }),
216216
op: crate::ast::Operation::Multiply,
217-
return_type: Type::Integer,
218217
}),
219218
_ => return Err(ParserError::UnexpectedEOF),
220219
}

crates/parser/src/identifier.rs

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,50 +13,50 @@ use tokenizer::{
1313

1414
pub fn parse_identifier(tokens: &mut Tokens, s: String) -> Result<Expr, ParserError> {
1515
match tokens.peek() {
16-
Some(SpannedToken {
17-
token: Token::LParen,
18-
span,
19-
}) => {
20-
tokens.next();
21-
let mut args = Vec::new();
22-
loop {
23-
match tokens.peek() {
24-
Some(SpannedToken {
25-
token: Token::RParen,
26-
..
27-
}) => {
28-
tokens.next();
29-
break;
30-
}
31-
Some(SpannedToken {
32-
token: Token::Comma,
33-
..
34-
}) => {
35-
tokens.next();
36-
}
37-
None => {
38-
return Err(ParserError::RParenNotFound(Token::Eof));
39-
}
40-
_ => {
41-
args.push(parse_single_expr(tokens)?);
42-
}
43-
}
44-
}
45-
Ok(Expr::Call {
46-
target: None,
47-
name: Box::new(Expr::VariableRef {
48-
name: s,
49-
symbol: Some(Symbol {
50-
is_changed: false,
51-
is_pointer: false,
52-
is_used: true,
53-
typ: Type::Function,
54-
}),
55-
}),
56-
args,
57-
returned_type: None,
58-
})
59-
}
16+
// Some(SpannedToken {
17+
// token: Token::LParen,
18+
// span,
19+
// }) => {
20+
// tokens.next();
21+
// let mut args = Vec::new();
22+
// loop {
23+
// match tokens.peek() {
24+
// Some(SpannedToken {
25+
// token: Token::RParen,
26+
// ..
27+
// }) => {
28+
// tokens.next();
29+
// break;
30+
// }
31+
// Some(SpannedToken {
32+
// token: Token::Comma,
33+
// ..
34+
// }) => {
35+
// tokens.next();
36+
// }
37+
// None => {
38+
// return Err(ParserError::RParenNotFound(Token::Eof));
39+
// }
40+
// _ => {
41+
// args.push(parse_single_expr(tokens)?);
42+
// }
43+
// }
44+
// }
45+
// Ok(Expr::Call {
46+
// target: None,
47+
// name: Box::new(Expr::VariableRef {
48+
// name: s,
49+
// symbol: Some(Symbol {
50+
// is_changed: false,
51+
// is_mutable: false,
52+
// is_used: true,
53+
// typ: Type::Function,
54+
// }),
55+
// }),
56+
// args,
57+
// returned_type: None,
58+
// })
59+
// }
6060
Some(SpannedToken {
6161
token: Token::ListStart,
6262
..

crates/parser/src/tests/assignment.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
mod tests {
33
use crate::assign::parse_assign;
44
use crate::ast::{Expr, Operation, Statement};
5-
use crate::binary_op::{parse_expression, parse_statement};
5+
use crate::binary_op::parse_statement;
66
use crate::decl::parse_decl;
77
use crate::shared_ast::{StringEnum, Type};
88
use crate::tests::{TestResult, create_tokens};
99
use std::rc::Rc;
10-
use tokenizer::iterator::{SourceSpan, Tokens};
11-
use tokenizer::tokens::{self, Token};
10+
use tokenizer::tokens::Token;
1211

1312
#[test]
1413
fn test_parse_assign_simple() -> TestResult {
@@ -93,7 +92,6 @@ mod tests {
9392
left: Box::new(Expr::Number(10)),
9493
right: Box::new(Expr::Number(20)),
9594
op: Operation::Add,
96-
return_type: Type::Any
9795
})
9896
}
9997
);

crates/parser/src/tests/binary_op_test.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ fn test_binary_op_print() -> TestResult {
1717
left: Box::new(Expr::Number(2)),
1818
right: Box::new(Expr::Number(2)),
1919
op: Operation::Add,
20-
return_type: Type::Any,
2120
}
2221
);
2322
Ok(())
@@ -40,11 +39,9 @@ fn test_multi_add_binary_op() -> TestResult {
4039
left: Box::new(Expr::Number(2)),
4140
right: Box::new(Expr::Number(2)),
4241
op: Operation::Add,
43-
return_type: Type::Any,
4442
}),
4543
right: Box::new(Expr::Number(4)),
4644
op: Operation::Add,
47-
return_type: Type::Any,
4845
}
4946
);
5047
Ok(())
@@ -76,10 +73,8 @@ fn test_multiply_add_binary_op() -> TestResult {
7673
left: Box::new(Expr::Number(2)),
7774
right: Box::new(Expr::Number(4)),
7875
op: Operation::Multiply,
79-
return_type: Type::Any,
8076
}),
8177
op: Operation::Add,
82-
return_type: Type::Any,
8378
}
8479
);
8580
assert_eq!(
@@ -89,11 +84,9 @@ fn test_multiply_add_binary_op() -> TestResult {
8984
left: Box::new(Expr::Number(2)),
9085
right: Box::new(Expr::Number(2)),
9186
op: Operation::Multiply,
92-
return_type: Type::Any,
9387
}),
9488
right: Box::new(Expr::Number(4)),
9589
op: Operation::Add,
96-
return_type: Type::Any,
9790
}
9891
);
9992
Ok(())
@@ -111,7 +104,6 @@ fn test_equal_binary_op() -> TestResult {
111104
left: Box::new(Expr::Number(2)),
112105
right: Box::new(Expr::Number(2)),
113106
op: Operation::Equal,
114-
return_type: Type::Any,
115107
}
116108
);
117109
assert_eq!(
@@ -120,7 +112,6 @@ fn test_equal_binary_op() -> TestResult {
120112
left: Box::new(Expr::Number(2)),
121113
right: Box::new(Expr::Number(2)),
122114
op: Operation::NotEqual,
123-
return_type: Type::Any,
124115
}
125116
);
126117
Ok(())

0 commit comments

Comments
 (0)