Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6705b6c
add type inferer
jonasstrehle Oct 31, 2025
3153820
:art: enhance type inference and expression handling with structural …
jonasstrehle Nov 1, 2025
49b4274
remove option from rich ast
jonasstrehle Nov 1, 2025
7ca60bb
refactor: type inference functions to use RichAst directly
jonasstrehle Nov 1, 2025
01a4ee5
test: add structural type inference for integer literals
jonasstrehle Nov 1, 2025
7e1f1da
feat: add type annotation handling to TypeExpression and update Spann…
jonasstrehle Nov 1, 2025
65e640e
feat: enhance type inference by adding variable declaration handling …
jonasstrehle Nov 1, 2025
b27284a
feat: add support for binary operations and variable declarations wit…
jonasstrehle Nov 1, 2025
07b1c0b
feat: enhance variable handling by adding variable access and updatin…
jonasstrehle Nov 1, 2025
1b81456
docs: enhance type inference
jonasstrehle Nov 1, 2025
d6868a4
refactor: rename type inferer to type inference
jonasstrehle Nov 1, 2025
bf48a38
refactor: rename type_inferer module to type_inference
jonasstrehle Nov 1, 2025
7d30642
refactor: replace direct type annotation setting with mark_type function
jonasstrehle Nov 1, 2025
cd18b08
fmt
jonasstrehle Nov 1, 2025
52a389c
feat: add visit_type_declaration method for handling type declarations
jonasstrehle Nov 1, 2025
2e9b945
feat: add visit methods for union, intersection, and structural map t…
jonasstrehle Nov 1, 2025
a3239f3
feat: add visit method for structural list type in TypeInference
jonasstrehle Nov 1, 2025
c51e9f6
refactor: remove unused span parameter from visit methods in TypeInfe…
jonasstrehle Nov 1, 2025
f78f7a8
feat: update error handling to use core library types and add clippy …
jonasstrehle Nov 6, 2025
cfd1f20
disable visitor?
jonasstrehle Nov 6, 2025
dee3003
feat: enhance type inference with detailed error handling and variabl…
jonasstrehle Nov 6, 2025
4dfb128
feat: fix hoisting (WIP)
jonasstrehle Nov 6, 2025
ca0ba14
feat: implement hoisting for top-level type declarations in precompiler
jonasstrehle Nov 6, 2025
ea245e9
refactor: migrate type inference tests (WIP)
jonasstrehle Nov 6, 2025
6dfbad9
refactor: migrate type inference tests (WIP)
jonasstrehle Nov 6, 2025
9655740
refactor: migrate type inference tests (WIP)
jonasstrehle Nov 6, 2025
a52c141
feat: add unit type to TypeContainer and update expression visitor logic
jonasstrehle Nov 6, 2025
1037f8b
refactor: reorganize imports in error.rs for clarity
jonasstrehle Nov 6, 2025
bc8463a
refactor: remove unused type_inference module from mod.rs
jonasstrehle Nov 6, 2025
61cd5a7
refactor: remove type_inference module to streamline codebase
jonasstrehle Nov 6, 2025
acbcc69
feat: enhance type inference with error handling options and refactor…
jonasstrehle Nov 6, 2025
86856ae
fmt
jonasstrehle Nov 6, 2025
25cb4a0
feat: add detailed error message for InvalidDerefType in TypeError enum
jonasstrehle Nov 6, 2025
c54674f
feat: enhance type inference with additional expression types and err…
jonasstrehle Nov 6, 2025
65cbd93
feat: add SetTypeRecurseChildNodes and SetTypeSkipChildren actions to…
jonasstrehle Nov 6, 2025
35449e1
feat: refine error handling in TypeInference by adjusting VisitAction…
jonasstrehle Nov 6, 2025
34e13e4
feat: implement function type inference (WIP)
jonasstrehle Nov 9, 2025
3c43a23
feat: implement function type inference (WIP)
jonasstrehle Nov 9, 2025
79c38b4
rename structual type to typealias
jonasstrehle Nov 9, 2025
bf2a7e1
feat: Fix structual vs nominal type precompilation (WIP)
jonasstrehle Nov 9, 2025
403f31b
feat: Fix structual vs nominal type precompilation and type inference
jonasstrehle Nov 9, 2025
7a2ae85
test cleanup
jonasstrehle Nov 9, 2025
2f84561
fmt
jonasstrehle Nov 9, 2025
487d3b0
fix: test for type inference
jonasstrehle Nov 9, 2025
a931148
remove println
jonasstrehle Nov 9, 2025
fbc8cd5
feat: Add support for incoming and outgoing block interceptors in ComHub
jonasstrehle Nov 9, 2025
4588006
feat: Add support for incoming and outgoing block interceptors in ComHub
jonasstrehle Nov 9, 2025
12ca689
add box import
benStre Nov 9, 2025
085328d
rename r#type
benStre Nov 9, 2025
8ac80d2
:art: fmt
benStre Nov 9, 2025
9c2509a
:art: fmt
benStre Nov 9, 2025
1597784
:art: switch kind and name
benStre Nov 9, 2025
bebe88b
add todo
benStre Nov 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions benches/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#![feature(custom_test_frameworks)]
#![feature(thread_local)]
#![test_runner(criterion::runner)]
#![allow(clippy::std_instead_of_alloc)]
#![allow(clippy::alloc_instead_of_core)]
#![allow(clippy::std_instead_of_core)]

use core::hint::black_box;

use crate::json::{
Expand Down
2 changes: 1 addition & 1 deletion src/ast/grammar/binary_operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn binary_op(
operator: op,
left: lhs,
right: rhs,
r#type: None,
ty: None,
})
.with_span(SimpleSpan::from(combined_span))
}
Expand Down
4 changes: 2 additions & 2 deletions src/ast/grammar/binding.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::ast::error::error::ParseError;
use crate::ast::error::pattern::Pattern;
use crate::ast::grammar::assignment_operation::assignment_operation;
use crate::ast::grammar::r#type::{r#type, type_declaration};
use crate::ast::grammar::r#type::{ty, type_declaration};
use crate::ast::grammar::utils::whitespace;
use crate::ast::lexer::Token;
use crate::ast::spanned::Spanned;
Expand Down Expand Up @@ -91,7 +91,7 @@ pub fn variable_declaration<'a>(
) -> impl DatexParserTrait<'a> {
let type_annotation = just(Token::Colon)
.padded_by(whitespace())
.ignore_then(r#type())
.ignore_then(ty())
.or_not();

let assignment_op = assignment_operation();
Expand Down
6 changes: 3 additions & 3 deletions src/ast/grammar/function.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::ast::grammar::r#type::r#type;
use crate::ast::grammar::r#type::ty;
use crate::ast::grammar::utils::whitespace;
use crate::ast::lexer::Token;
use crate::ast::spanned::Spanned;
Expand All @@ -9,7 +9,7 @@ use chumsky::prelude::*;
fn return_type<'a>() -> impl DatexParserTrait<'a, Option<TypeExpression>> {
just(Token::Arrow)
.padded_by(whitespace())
.ignore_then(r#type().padded_by(whitespace()))
.ignore_then(ty().padded_by(whitespace()))
.or_not()
}

Expand All @@ -26,7 +26,7 @@ fn parameter<'a>() -> impl DatexParserTrait<'a, (String, TypeExpression)> {
.then(
just(Token::Colon)
.padded_by(whitespace())
.ignore_then(r#type().padded_by(whitespace())),
.ignore_then(ty().padded_by(whitespace())),
)
.map(|(name, ty)| (name, ty))
}
Expand Down
30 changes: 17 additions & 13 deletions src/ast/grammar/type.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::stdlib::{str::FromStr, vec};

use crate::ast::spanned::Spanned;
use crate::ast::structs::expression::DatexExpressionData;
use crate::ast::structs::expression::{
DatexExpressionData, TypeDeclarationKind,
};
use crate::ast::structs::r#type::{
FixedSizeList, FunctionType, GenericAccess, Intersection, SliceList,
StructuralList, StructuralMap, TypeExpression, TypeExpressionData,
Expand Down Expand Up @@ -95,7 +97,7 @@
})
}

pub fn r#type<'a>() -> impl DatexParserTrait<'a, TypeExpression> {
pub fn ty<'a>() -> impl DatexParserTrait<'a, TypeExpression> {
recursive(|ty| {
let paren_group = ty.clone().delimited_by(
just(Token::LeftParen).padded_by(whitespace()),
Expand Down Expand Up @@ -179,7 +181,7 @@
&& n > 0
{
Ok(TypeExpressionData::FixedSizeList(FixedSizeList {
r#type: Box::new(t),
ty: Box::new(t),
size: n,
})
.with_default_span())
Expand Down Expand Up @@ -393,7 +395,7 @@
Some(size) if size > 0 => {
TypeExpressionData::FixedSizeList(
FixedSizeList {
r#type: Box::new(t),
ty: Box::new(t),
size,
},
)
Expand Down Expand Up @@ -478,14 +480,15 @@
.ignore_then(name)
.then(generic)
.then_ignore(just(Token::Assign).padded_by(whitespace()))
.then(r#type())
.then(ty())
.padded_by(whitespace())
.map_with(|((name, generic), expr), e| {
DatexExpressionData::TypeDeclaration(TypeDeclaration {
id: None,
name: name.to_string(),
value: expr,
hoisted: false,
kind: TypeDeclarationKind::Nominal,
})
.with_span(e.span())
})
Expand All @@ -494,17 +497,18 @@
}

pub fn structural_type_definition<'a>() -> impl DatexParserTrait<'a> {
just(Token::Identifier("typedef".to_string()))
just(Token::Identifier("typealias".to_string()))
.padded_by(whitespace())
.ignore_then(select! { Token::Identifier(name) => name })
.then_ignore(just(Token::Assign).padded_by(whitespace()))
.then(r#type())
.then(ty())
.map_with(|(name, expr), e| {
DatexExpressionData::TypeDeclaration(TypeDeclaration {
id: None,
name: name.to_string(),
value: expr,
hoisted: false,
kind: TypeDeclarationKind::Structural,
})
.with_span(e.span())
})
Expand All @@ -521,7 +525,7 @@
just(Token::Identifier("type".to_string()))
.padded_by(whitespace())
.then_ignore(just(Token::LeftParen).padded_by(whitespace()))
.ignore_then(r#type())
.ignore_then(ty())
.padded_by(whitespace())
.then_ignore(just(Token::RightParen).padded_by(whitespace()))
.map_with(|expr, e| DatexExpressionData::Type(expr).with_span(e.span()))
Expand All @@ -536,7 +540,7 @@
InvalidDatexParseResult, ValidDatexParseResult,
};
use crate::ast::structs::expression::{
DatexExpression, DatexExpressionData, Statements,

Check warning on line 543 in src/ast/grammar/type.rs

View workflow job for this annotation

GitHub Actions / Test

unused import: `DatexExpression`
};
use crate::stdlib::{io, str::FromStr};

Expand Down Expand Up @@ -906,7 +910,7 @@
assert_eq!(
val,
TypeExpressionData::FixedSizeList(FixedSizeList {
r#type: Box::new(
ty: Box::new(
TypeExpressionData::Literal("integer".to_owned())
.with_default_span()
),
Expand All @@ -919,7 +923,7 @@
assert_eq!(
val,
TypeExpressionData::FixedSizeList(FixedSizeList {
r#type: Box::new(
ty: Box::new(
TypeExpressionData::Union(Union(vec![
TypeExpressionData::Literal("integer".to_owned())
.with_default_span(),
Expand All @@ -940,7 +944,7 @@
assert_eq!(
val,
TypeExpressionData::FixedSizeList(FixedSizeList {
r#type: Box::new(
ty: Box::new(
TypeExpressionData::Literal("text".to_owned())
.with_default_span()
),
Expand All @@ -953,7 +957,7 @@
assert_eq!(
val,
TypeExpressionData::FixedSizeList(FixedSizeList {
r#type: Box::new(
ty: Box::new(
TypeExpressionData::Literal("text".to_owned())
.with_default_span()
),
Expand All @@ -966,7 +970,7 @@
assert_eq!(
val,
TypeExpressionData::FixedSizeList(FixedSizeList {
r#type: Box::new(
ty: Box::new(
TypeExpressionData::Literal("text".to_owned())
.with_default_span()
),
Expand Down
Loading
Loading