feat: add managed types, source classes and scoped native calls

This commit is contained in:
2026-10-21 01:47:08 +08:00
parent 7c842789c0
commit a970fd7707
48 changed files with 2069 additions and 134 deletions
+9 -3
View File
@@ -1,6 +1,7 @@
use crate::ast::{
Assignment, AstRoot, BinaryOp, Binding, Block, Decl, DeclKind, Expr, ExprKind, Function,
InteractiveInput, Name, Parameter, Program, ReturnStatement, Stmt, StmtKind, UnaryOp,
Assignment, AstRoot, BinaryOp, Binding, Block, Class, Decl, DeclKind, Expr, ExprKind, Function,
InteractiveInput, MemberAssignment, Name, Parameter, Program, ReturnStatement, Stmt, StmtKind,
UnaryOp,
};
use crate::lexer::decode_string;
use crate::{Diagnostic, DiagnosticKind, Span, Token, TokenKind, lex};
@@ -44,7 +45,7 @@ pub fn parse_source_expression(
parse_expression(source.text()).map_err(|error| source.annotate(error))
}
/// Parse one or more basic typed function declarations. This is a syntax
/// Parse one or more typed function or class declarations. This is a syntax
/// operation: type names and name references are retained without resolution.
pub fn parse(source: &str) -> Result<Program, Diagnostic> {
let tokens = lex(source)?;
@@ -93,6 +94,11 @@ enum Suffix {
Call(Vec<Expr>, Span),
}
enum ClassMember {
Field(Parameter),
Method(Function),
}
fn postfix(expression: Expr, suffix: Suffix) -> Expr {
match suffix {
Suffix::Member(name) => Expr {