Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tahadostifam committed Mar 2, 2025
1 parent d2a1281 commit b1c620e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 7 additions & 3 deletions examples/main.cyr
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import std::io;

struct User {
name: string;
}

fn main() {
#arr: i32[4] = [1, 2, 3];
#size = len(arr);
std::io::printf("size: %d\n", size);
#user1 = User {
name: "Taha"
};
}
7 changes: 5 additions & 2 deletions parser/src/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl<'a> Parser<'a> {
} else if self.current_token_is(TokenKind::As) {
self.next_token(); // consume as expression
} else {
panic!("Unexpected behaviour when trying to parse cast_as_expression.");
panic!("Unexpected behavior when trying to parse cast_as_expression.");
}

match self.parse_type_token() {
Expand Down Expand Up @@ -513,6 +513,9 @@ impl<'a> Parser<'a> {
} else {
self.next_token();
let func_call = self.parse_func_call(*object_expr, start)?;
if self.current_token_is(TokenKind::RightParen) {
self.next_token();
}
Ok(Expression::FieldAccessOrMethodCall(vec![FieldAccessOrMethodCall {
method_call: Some(func_call),
field_access: None,
Expand All @@ -532,7 +535,7 @@ impl<'a> Parser<'a> {
field_inits: Vec::new(),
loc: self.current_location(),
}));
}
}

loop {
let field_name = match self.current_token.kind.clone() {
Expand Down

0 comments on commit b1c620e

Please sign in to comment.