Skip to content

Commit

Permalink
WIP: support for inlining of methods
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickpeterse committed Oct 5, 2024
1 parent 9f68de6 commit 387fd23
Show file tree
Hide file tree
Showing 37 changed files with 2,323 additions and 582 deletions.
6 changes: 6 additions & 0 deletions ast/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ pub enum TokenKind {
While,
Whitespace,
Extern,
Inline,
}

impl TokenKind {
Expand Down Expand Up @@ -268,6 +269,7 @@ impl TokenKind {
TokenKind::Nil => "the 'nil' keyword",
TokenKind::Replace => "a '=:'",
TokenKind::Extern => "the 'extern' keyword",
TokenKind::Inline => "the 'inline' keyword",
}
}
}
Expand Down Expand Up @@ -335,6 +337,7 @@ impl Token {
| TokenKind::Case
| TokenKind::Enum
| TokenKind::Extern
| TokenKind::Inline
)
}

Expand Down Expand Up @@ -997,6 +1000,7 @@ impl Lexer {
"return" => TokenKind::Return,
"static" => TokenKind::Static,
"extern" => TokenKind::Extern,
"inline" => TokenKind::Inline,
_ => TokenKind::Identifier,
},
7 => match value.as_str() {
Expand Down Expand Up @@ -1337,6 +1341,7 @@ mod tests {
assert!(tok(TokenKind::While, "", 1..=1, 1..=1).is_keyword());
assert!(tok(TokenKind::Recover, "", 1..=1, 1..=1).is_keyword());
assert!(tok(TokenKind::Nil, "", 1..=1, 1..=1).is_keyword());
assert!(tok(TokenKind::Inline, "", 1..=1, 1..=1).is_keyword());
}

#[test]
Expand Down Expand Up @@ -1978,6 +1983,7 @@ mod tests {
assert_token!("return", Return, "return", 1..=1, 1..=6);
assert_token!("static", Static, "static", 1..=1, 1..=6);
assert_token!("extern", Extern, "extern", 1..=1, 1..=6);
assert_token!("inline", Inline, "inline", 1..=1, 1..=6);

assert_token!("builtin", Builtin, "builtin", 1..=1, 1..=7);
assert_token!("recover", Recover, "recover", 1..=1, 1..=7);
Expand Down
1 change: 1 addition & 0 deletions ast/src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ pub enum MethodKind {

#[derive(Debug, PartialEq, Eq)]
pub struct DefineMethod {
pub inline: bool,
pub public: bool,
pub kind: MethodKind,
pub operator: bool,
Expand Down
Loading

0 comments on commit 387fd23

Please sign in to comment.