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
133 commits
Select commit Hold shift + click to select a range
9547e02
work on proper formatter (WIP)
jonasstrehle Oct 16, 2025
4991e1b
work on fmt (WIP)
jonasstrehle Oct 21, 2025
cc490c4
work on fmt (WIP)
jonasstrehle Oct 21, 2025
ae521cc
work on fmt (WIP)
jonasstrehle Oct 21, 2025
5daa6e9
work on fmt (WIP)
jonasstrehle Oct 21, 2025
7b4046a
fix new map / list struct
jonasstrehle Oct 25, 2025
8730b90
add bracketing to ast
jonasstrehle Oct 25, 2025
dadf1ca
work on fmt (WIP)
jonasstrehle Oct 25, 2025
5289fa8
work on fmt (WIP)
jonasstrehle Oct 25, 2025
298e32e
work on op precedence on formatter (WIP)
jonasstrehle Oct 25, 2025
33f8e0f
refactor infix left chain (add logical and / or)
jonasstrehle Oct 25, 2025
f597dc0
rename tokens
jonasstrehle Oct 25, 2025
57a997e
add power to binary operations
jonasstrehle Oct 25, 2025
cd16288
add caret token
jonasstrehle Oct 25, 2025
b986b90
add README for DATEX Formatter with parentheses handling examples
jonasstrehle Oct 25, 2025
d029ddc
refactor operator precedence handling
jonasstrehle Oct 25, 2025
ff283ba
split up options
jonasstrehle Oct 25, 2025
cd32fad
split up bracketing
jonasstrehle Oct 25, 2025
ec119f1
refactor formatting options and context handling for Datex expressions
jonasstrehle Oct 25, 2025
260a662
refactor: enhance bracketing handling and modularize formatting funct…
jonasstrehle Oct 25, 2025
7f90b85
fmt
jonasstrehle Oct 25, 2025
a210f85
fix comment
jonasstrehle Oct 25, 2025
c0e60ff
refactor: enhance datex expression formatting and streamline function…
jonasstrehle Oct 25, 2025
0d9df6f
refactor: streamline bracketing handling and enhance test coverage fo…
jonasstrehle Oct 25, 2025
0d421a9
refactor: clean up formatting functions and improve test coverage for…
jonasstrehle Oct 25, 2025
6e29358
fmt
jonasstrehle Oct 25, 2025
1ccb142
add function declaration to datex expression data
jonasstrehle Oct 25, 2025
c41098c
refactor: update binary operation handling and improve deref assignme…
jonasstrehle Oct 25, 2025
5f19f80
refactor: restructure comparison operation data handling for clarity
jonasstrehle Oct 25, 2025
9517a5d
Refactor binary operation representation in AST
jonasstrehle Oct 25, 2025
2a82f32
Refactor AST representation and improve type inference
jonasstrehle Oct 25, 2025
6c07ad8
refactor: update Conditional representation and improve visitor imple…
jonasstrehle Oct 25, 2025
c9fad16
(WIP) Refactor TypeExpression to TypeExpressionData
jonasstrehle Oct 25, 2025
42767ce
refactor: update ApplyChain and RemoteExecution structures for improv…
jonasstrehle Oct 25, 2025
42a63d4
refactor: rename Variable to VariableAccess and update related implem…
jonasstrehle Oct 26, 2025
b378581
(WIP) refactor: introduce new data structures for type expressions an…
jonasstrehle Oct 26, 2025
901d1cf
(WIP) Implement AST data structures and visitor pattern for type expr…
jonasstrehle Oct 26, 2025
50c848d
(WIP) refactor: reorganize imports and implement Spanned trait for ex…
jonasstrehle Oct 26, 2025
2622a52
(WIP) refactor: update struct visibility and improve import organizat…
jonasstrehle Oct 26, 2025
4bcc41c
(WIP) refactor: add Spanned trait imports across multiple AST files
jonasstrehle Oct 26, 2025
68568c5
(WIP) refactor: update type expression references and improve span ha…
jonasstrehle Oct 26, 2025
21c587f
(WIP) refactor: reorganize imports and update type expression referen…
jonasstrehle Oct 26, 2025
dad5e99
(WIP) refactor: update imports to use data module for expression type…
jonasstrehle Oct 26, 2025
f91bf97
(WIP) refactor: enhance type expression handling and update imports a…
jonasstrehle Oct 26, 2025
86e86f7
(WIP) refactor: update GenericAccess to use Vec<TypeExpression> and a…
jonasstrehle Oct 26, 2025
034d93c
(WIP) refactor: update type expression tests to use new constructors …
jonasstrehle Oct 26, 2025
e0e24a8
refactor: finished type data refactoring
jonasstrehle Oct 26, 2025
21602da
fmt
jonasstrehle Oct 26, 2025
cad5d13
remove tree module
jonasstrehle Oct 26, 2025
2b0360b
add visitor methods for type ast traversal
jonasstrehle Oct 26, 2025
91c6026
refactor: enhance Visit trait with additional visit methods for type …
jonasstrehle Oct 26, 2025
0412b06
docs: add documentation for DatexExpression and TypeExpression structs
jonasstrehle Oct 26, 2025
b67c164
refactor: update visit methods for DatexExpression to handle TypeExpr…
jonasstrehle Oct 26, 2025
67a0a59
refactor: update visit methods in Visitable trait and implementations…
jonasstrehle Oct 26, 2025
54b49a4
refactor: enhance visitor methods for DatexExpression and TypeExpress…
jonasstrehle Oct 26, 2025
c318a98
refactor: enhance Precompiler to support variable resolution and decl…
jonasstrehle Oct 26, 2025
6a573c8
refactor: enhance Precompiler to support variable resolution and assi…
jonasstrehle Oct 26, 2025
d63312a
fmt
jonasstrehle Oct 26, 2025
5bffdfc
refactor: update Precompiler to handle optional metadata and improve …
jonasstrehle Oct 26, 2025
bc4e240
fmt
jonasstrehle Oct 26, 2025
3621ff7
refactor: replace SimpleSpan with Range<usize>
jonasstrehle Oct 27, 2025
c5571e4
fmt
jonasstrehle Oct 27, 2025
b02ded3
work on transformer pattern (WIP)
jonasstrehle Oct 27, 2025
f55e348
work on transformer pattern (WIP)
jonasstrehle Oct 27, 2025
44a0ab7
fmt
jonasstrehle Oct 27, 2025
8928189
feat: add Noop variant to DatexExpressionData for better error recove…
jonasstrehle Oct 27, 2025
5103e87
feat: enhance expression visitor with additional visit methods and ac…
jonasstrehle Oct 27, 2025
0176d86
feat: handle Noop variant in DatexExpressionData for expression visit…
jonasstrehle Oct 27, 2025
8248b10
fmt
jonasstrehle Oct 27, 2025
7ab21a8
feat: update VisitAction enum and ExpressionVisitor trait for improve…
jonasstrehle Oct 27, 2025
255c5c8
refactor: remove visitor_new.rs
jonasstrehle Oct 27, 2025
9f7d13f
feat: enable associated_type_defaults feature in lib.rs
jonasstrehle Oct 27, 2025
9d1b7c0
refactor: remove unused visitor_new module and reorganize visitor str…
jonasstrehle Oct 27, 2025
acd2dc4
feat: add constructor method to TypeExpression for easier instantiation
jonasstrehle Oct 27, 2025
2bf88a1
feat: implement VisitableExpression trait for various expression types
jonasstrehle Oct 27, 2025
2186c42
feat: add TypeExpressionVisitor trait and related methods for type ex…
jonasstrehle Oct 27, 2025
94e5537
feat: implement VisitableTypeExpression trait for various type expres…
jonasstrehle Oct 27, 2025
c9b31e4
fmt
jonasstrehle Oct 27, 2025
0b4e441
add TODO
jonasstrehle Oct 27, 2025
29d77e0
:recycle: separate Visit and VisitMut
benStre Oct 28, 2025
a9b237d
Implement expression and type expression visitor patterns
jonasstrehle Oct 28, 2025
0053a1f
feat: enhance Precompiler with new expression and type declaration vi…
jonasstrehle Oct 28, 2025
1ae770b
fmt
jonasstrehle Oct 28, 2025
10d5df9
refactor: remove deprecated precompiler_new module
jonasstrehle Oct 28, 2025
3d8c9d3
feat: reorganize precompiler structure (sorry)
jonasstrehle Oct 28, 2025
f36b5c6
deprecate old visitor (sorry again)
jonasstrehle Oct 28, 2025
d4c24ce
refactoring ast (WIP)
jonasstrehle Oct 28, 2025
6ca7d0b
refactoring ast (WIP)
jonasstrehle Oct 28, 2025
b973bcb
refactoring ast (WIP)
jonasstrehle Oct 28, 2025
0650143
fmt
jonasstrehle Oct 28, 2025
c113957
Refactor operator enums and restructure imports (WIP)
jonasstrehle Oct 28, 2025
082dbbb
Add ApplyOperation enum and refactor imports across modules (WIP)
jonasstrehle Oct 28, 2025
937cb3c
move ComparisonOperator
jonasstrehle Oct 28, 2025
170dd39
move unary operator
jonasstrehle Oct 28, 2025
f8c51f0
fmt
jonasstrehle Oct 28, 2025
3912585
make grammar mod private
jonasstrehle Oct 28, 2025
f4214f2
Remove unused visit_literal_type method from TypeExpressionVisitor im…
jonasstrehle Oct 28, 2025
9f79c5c
fmt
jonasstrehle Oct 28, 2025
c23f733
fix: add guidelines to CONTRIBUTING.md
jonasstrehle Oct 29, 2025
5f37ce4
docs: update CONTRIBUTING.md with branch naming conventions and testi…
jonasstrehle Oct 29, 2025
ad850a4
feat: refactor variable metadata handling in Precompiler
jonasstrehle Oct 29, 2025
d2499b7
Refactor Expression and Type Expression Visitors to Support Error Han…
jonasstrehle Oct 29, 2025
a2ecdac
feat: enhance error handling in Expression and TypeExpression visitors
jonasstrehle Oct 29, 2025
a1f5ae0
feat: improve error handling in Expression and TypeExpression visitors
jonasstrehle Oct 29, 2025
62f8941
add abort logic to visitor (TBD)
jonasstrehle Oct 29, 2025
4097308
:construction: work on new precompiler
benStre Oct 30, 2025
262fe4d
:construction: work on new precompiler
benStre Oct 30, 2025
020b753
split up variant access for precom
jonasstrehle Oct 30, 2025
1bc4528
fmt
jonasstrehle Oct 30, 2025
884d039
refactor: fix scope stacks for new precompiler
jonasstrehle Oct 30, 2025
36949d9
refactor: update precompiler to use simple error handling and clean u…
jonasstrehle Oct 30, 2025
e33d7cf
fix test without precompiler
jonasstrehle Oct 30, 2025
5d09394
refactor: enhance variant access handling and restructure related types
jonasstrehle Oct 30, 2025
5154de5
refactor: streamline type expression visitor methods for improved cla…
jonasstrehle Oct 30, 2025
f7bc0a9
test: rename and update variant access test for improved clarity
jonasstrehle Oct 30, 2025
1b61cf9
refactor: update type expression handling to include variant access
jonasstrehle Oct 30, 2025
26290e9
refactor: enhance type expression visitor methods for improved clarit…
jonasstrehle Oct 30, 2025
ea8fce7
refactor: update type annotation handling to use variant access for i…
jonasstrehle Oct 30, 2025
7e72871
refactor: improve error handling and add logging for unhandled expres…
jonasstrehle Oct 30, 2025
3ffda98
:construction: cleanup ast, fix deref
benStre Oct 31, 2025
5dc9de6
:bug: fix scope stack
benStre Oct 31, 2025
4ef6568
:wastebasket: cleanup
benStre Oct 31, 2025
4d6d163
:bug: fix precompile methods
benStre Oct 31, 2025
d69f534
:bug: fix binary operation precompiler
benStre Oct 31, 2025
acecb3b
:art: clippy
benStre Oct 31, 2025
4eb4241
:recycle: refactor precompiler
benStre Oct 31, 2025
012a1e3
:bug: handle variable redeclaration errors
benStre Oct 31, 2025
1102e35
:bug: handle variable redeclaration errors
benStre Oct 31, 2025
562071a
:fire: remove final references
benStre Oct 31, 2025
841626f
fmt
jonasstrehle Nov 1, 2025
02af154
remove println
jonasstrehle Nov 1, 2025
0ce78e8
Merge branch 'feat/fmt' of github.com:unyt-org/datex-core into feat/fmt
benStre Nov 1, 2025
ffe3b14
Merge branch 'release/0.0.7' into feat/fmt
benStre Nov 4, 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
89 changes: 67 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
# Contributing to **DATEX Core**
# Contributing to **DATEX Core**

This document describes the workflow, branch strategy, coding standards, and
quality gates for contributing to
the [`datex-core`](https://github.com/unyt-org/datex-core)Rust crate.
quality gates for contributing to the
[`datex-core`](https://github.com/unyt-org/datex-core) Rust crate.

---

## Workflow & Branch Strategy

| Purpose | Naming Pattern | Example |
| ------------------------------ | --------------------------------- | ----------------------- |
| **Permanent default branch** | `main` | |
| **Permanent default branch** | `main` | - |
| **Milestone / release branch** | `release/<MAJOR>.<MINOR>.<PATCH>` | `release/0.0.4` |
| **Feature branch** | `feature/<slug>` | `feature/tcp-interface` |
| **Bug-fix branch** | `fix/<slug>` | `fix/handshake-timeout` |
| **Maintenance / chore branch** | `chore/<slug>` | `chore/update-deps` |
| **Hotfix branch** | `hotfix/<slug>` | `hotfix/crash-on-start` |

1. **`main` is protected** – direct pushes are disabled.
> Use **lowercase letters** and **hyphens** (`-`) in branch names. Avoid spaces,
> underscores (`_`), or other special characters.

1. The default branch **`main` is protected** – direct pushes are disabled.
2. **All work happens via Pull Requests (PRs).**
3. **Target branch for every PR is the currently-active release branch** (e.g.
`release/0.0.4`).
4. After review & CI success, the feature branch is **squash-merged** into the
release branch.
4. After review & CI success, the feature branch is **merged** into the release
branch.
5. Release branches are merged back to `main` only by a maintainer at version
cut-time.

> **Do not branch from or target `main`** for new work. All development must
> branch from the **latest release branch** (e.g., `release/0.0.4`). The `main`
> branch reflects only published, production-ready code and is not used for
> active development.

---

## Coding Style

- **Edition:** Rust 2024.
- **Edition:** Rust 2024.

- **Formatting:**

Expand All @@ -45,19 +54,19 @@ the [`datex-core`](https://github.com/unyt-org/datex-core) Rust crate.
cargo clippy --features debug
```

_We plan to treat all Clippy warnings as errors in the future._ Suppress a
_We plan to treat more Clippy warnings as errors in the future._ Suppress a
lint only with a line-level `#[allow(lint_name)]` and an explanatory comment.

- **Idioms & Practices:**

- Prefer explicit `use` paths; group imports by crate.
- Enable useful nightly lints in `#![deny(clippy::pedantic, clippy::nursery)]`
where feasible.
- No `unsafe` unless unavoidable - must include a safety comment explaining
- No `unsafe` unless unavoidable must include a safety comment explaining
invariants.
- Public items require rustdoc comments (`///`) with examples where possible.
- Follow **snake\_case** for variables/functions, **CamelCase** for
types/traits, **SCREAMING\_SNAKE\_CASE** for constants.
- Follow **snake_case** for variables/functions, **CamelCase** for
types/traits, **SCREAMING_SNAKE_CASE** for constants.

---

Expand Down Expand Up @@ -103,22 +112,24 @@ the [`datex-core`](https://github.com/unyt-org/datex-core) Rust crate.
- Place Criterion benchmarks in `benches/`.
- Benchmarks must compile and run (CI executes them with `--bench` but does not
time-gate results).
- Performance regressions > 10 % should be called out in the PR description.
- Performance regressions > 10 % should be called out in the PR description.

---

## Continuous Integration Gates

A pull request is **merge-ready** only when:

1. All unit tests pass: `cargo test --all`.
2. All integration tests pass: `cargo test --all --tests`.
1. All unit tests pass: `cargo test --all --features debug`.
2. All integration tests pass: `cargo test --all --tests --features debug`.
3. All benchmarks build: `cargo bench --no-run`.
4. Clippy passes with no errors
5. Rustfmt check passes
4. Clippy passes with no errors.
5. Rustfmt check passes.
6. Checks complete on all supported toolchains (currently stable, beta).

CI will automatically block a PR that fails any step.
> **Note:** CI pipelines are automatically triggered for all PRs targeting
> release branches. PRs to `main` will be rejected unless explicitly opened by a
> maintainer.

---

Expand All @@ -136,21 +147,55 @@ Before requesting review, ensure you have:

---

## How to Make Changes & Open a PR

1. **Always base your work on the latest release branch**, _not_ on `main`. The
`main` branch only tracks finalized releases - new development happens in the
currently active `release/x.y.z` branch.

2. **Creating your branch:**

```bash
git fetch origin
git checkout origin/release/<MAJOR>.<MINOR>.<PATCH> -b feature/<slug>
```

3. **When your feature or fix is ready:**

- Open a Pull Request (PR) targeting the same **release branch** you based
your work on.
- Select the [**"DATEX"**](https://github.com/orgs/unyt-org/projects/12)
project for the PR in GitHub.
- The **maintainers** will assign it to the appropriate **release
milestone**.

4. If your PR cannot be merged cleanly (e.g., due to version conflicts), it may
be retargeted to a later release branch by maintainers.

5. Once approved, your change will be **merged** into the active release branch;
the release branch will later be merged back into `main` during version cut.

---

## Commit & PR Hygiene

- Use **Conventional Commits** style (e.g. `feat: add TCP interface`,
`fix: handle timeout`).
- Keep commit history clean; squash or amend while the PR is open.
- Reference issues in the PR body (e.g. `Closes #42`).
- Reference issues in the PR body (e.g. `fix #42`).

---

## Communication

- Small changes (< 30 LoC) may be approved by one maintainer; larger or
- Small changes (< 30 LoC) may be approved by one maintainer; larger or
architectural changes require two approvals.
- Discuss API-breaking changes in a GitHub Issue before coding.
- Feel free to draft a PR early (`[WIP]`) to get feedback on direction.
- Discuss API-breaking changes in a GitHub
[Issue](https://github.com/unyt-org/datex-core/issues) or
[Discussion](https://github.com/unyt-org/datex-core/discussions) before
coding.
- Feel free to draft a PR early (`[WIP]`) and mark as draft to get feedback on
direction.

---

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ futures-core = "0.3.31"
internment = "0.8.6"
serde-big-array = "0.5.1"
indoc = "2.0.6"
pretty = "0.12.5"


[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
19 changes: 19 additions & 0 deletions src/ast/grammar/assignment_operation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

use crate::ast::DatexParserTrait;
use crate::ast::grammar::utils::whitespace;
use crate::ast::lexer::Token;
use crate::ast::structs::operator::AssignmentOperator;
use chumsky::prelude::*;

pub fn assignment_operation<'a>()
-> impl DatexParserTrait<'a, AssignmentOperator> {
select! {
Token::Assign => AssignmentOperator::Assign,
Token::AddAssign => AssignmentOperator::AddAssign,
Token::SubAssign => AssignmentOperator::SubtractAssign,
Token::MulAssign => AssignmentOperator::MultiplyAssign,
Token::DivAssign => AssignmentOperator::DivideAssign,
Token::ModAssign => AssignmentOperator::ModuloAssign,
}
.padded_by(whitespace())
}
10 changes: 5 additions & 5 deletions src/ast/atom.rs → src/ast/grammar/atom.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::ast::DatexParserTrait;
use crate::ast::decimal::decimal;
use crate::ast::endpoint::endpoint;
use crate::ast::integer::integer;
use crate::ast::literal::literal;
use crate::ast::text::text;
use crate::ast::grammar::decimal::decimal;
use crate::ast::grammar::endpoint::endpoint;
use crate::ast::grammar::integer::integer;
use crate::ast::grammar::literal::literal;
use crate::ast::grammar::text::text;
use chumsky::prelude::*;

pub fn atom<'a>(
Expand Down
117 changes: 117 additions & 0 deletions src/ast/grammar/binary_operation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
use crate::ast::DatexParserTrait;
use crate::ast::grammar::utils::operation;
use crate::ast::lexer::Token;
use crate::ast::spanned::Spanned;
use crate::ast::structs::expression::BinaryOperation;
use crate::ast::structs::operator::BinaryOperator;
use crate::ast::structs::operator::binary::ArithmeticOperator;
use crate::ast::structs::operator::binary::BitwiseOperator;
use crate::ast::structs::operator::binary::LogicalOperator;
use crate::ast::{DatexExpression, DatexExpressionData};
use chumsky::prelude::*;

/// Generic helper for left-associative infix chains
fn infix_left_chain<'a>(
lower: impl DatexParserTrait<'a>,
ops: Vec<(Token, BinaryOperator)>,
) -> impl DatexParserTrait<'a> {
let base = lower.clone();

// Build a choice of operators
let choices = choice(
ops.into_iter()
.map(|(tok, op)| operation(tok).to(op))
.collect::<Vec<_>>(),
);

base.clone()
.foldl(
choices.then(base.clone()).repeated(),
move |lhs, (op, rhs)| binary_op(op)(Box::new(lhs), Box::new(rhs)),
)
.boxed()
}

fn binary_op(
op: BinaryOperator,
) -> impl Fn(Box<DatexExpression>, Box<DatexExpression>) -> DatexExpression + Clone
{
move |lhs, rhs| {
let start = lhs.span.start.min(rhs.span.start);
let end = lhs.span.end.max(rhs.span.end);
let combined_span = start..end;
DatexExpressionData::BinaryOperation(BinaryOperation {
operator: op,
left: lhs,
right: rhs,
r#type: None,
})
.with_span(SimpleSpan::from(combined_span))
}
}
fn product<'a>(atom: impl DatexParserTrait<'a>) -> impl DatexParserTrait<'a> {
infix_left_chain(
atom,
vec![
(Token::Star, ArithmeticOperator::Multiply.into()),
(Token::Slash, ArithmeticOperator::Divide.into()),
],
)
}
fn power<'a>(product: impl DatexParserTrait<'a>) -> impl DatexParserTrait<'a> {
infix_left_chain(
product,
vec![(Token::Caret, ArithmeticOperator::Power.into())],
)
}

fn sum<'a>(prod: impl DatexParserTrait<'a>) -> impl DatexParserTrait<'a> {
infix_left_chain(
prod,
vec![
(Token::Plus, ArithmeticOperator::Add.into()),
(Token::Minus, ArithmeticOperator::Subtract.into()),
],
)
}

fn bitwise_and<'a>(
sum: impl DatexParserTrait<'a>,
) -> impl DatexParserTrait<'a> {
infix_left_chain(sum, vec![(Token::Ampersand, BitwiseOperator::And.into())])
}

fn bitwise_or<'a>(
bitwise_and: impl DatexParserTrait<'a>,
) -> impl DatexParserTrait<'a> {
infix_left_chain(
bitwise_and,
vec![(Token::Pipe, BitwiseOperator::Or.into())],
)
}

fn logical_and<'a>(
bitwise_or: impl DatexParserTrait<'a>,
) -> impl DatexParserTrait<'a> {
infix_left_chain(
bitwise_or,
vec![(Token::DoubleAnd, LogicalOperator::And.into())],
)
}

fn logical_or<'a>(
logical_and: impl DatexParserTrait<'a>,
) -> impl DatexParserTrait<'a> {
infix_left_chain(
logical_and,
vec![(Token::DoublePipe, LogicalOperator::Or.into())],
)
}

pub fn binary_operation<'a>(
atom: impl DatexParserTrait<'a>,
) -> impl DatexParserTrait<'a> {
logical_or(logical_and(bitwise_or(bitwise_and(sum(product(power(
atom,
)))))))
}
37 changes: 22 additions & 15 deletions src/ast/binding.rs → src/ast/grammar/binding.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
use crate::ast::assignment_operation::{
AssignmentOperator, assignment_operation,
};
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::utils::whitespace;
use crate::ast::lexer::Token;
use crate::ast::r#type::{r#type, type_declaration};
use crate::ast::utils::whitespace;
use crate::ast::{DatexExpression, DatexExpressionData, DatexParserTrait, ParserRecoverExt};
use crate::ast::spanned::Spanned;
use crate::ast::structs::expression::VariableDeclaration;
use crate::ast::structs::expression::{
DerefAssignment, VariableAssignment, VariableKind,
};
use crate::ast::structs::operator::assignment::AssignmentOperator;
use crate::ast::structs::r#type::TypeExpression;
use crate::ast::{
DatexExpression, DatexExpressionData, DatexParserTrait, ParserRecoverExt,
};
use chumsky::prelude::*;
use datex_core::ast::tree::VariableDeclaration;
use crate::ast::tree::{TypeExpression, VariableAssignment, VariableKind};

pub type VariableId = usize;

fn create_variable_declaration(
name: String,
Expand Down Expand Up @@ -43,7 +46,8 @@ pub fn variable_assignment<'a>(
operator,
name: var_name.to_string(),
expression: Box::new(expr),
}).with_span(e.span())
})
.with_span(e.span())
})
.labelled(Pattern::Declaration)
.as_context()
Expand All @@ -65,13 +69,15 @@ pub fn deref_assignment<'a>(
|(
((deref_count, deref_expression), operator),
assigned_expression,
), e| {
DatexExpressionData::DerefAssignment {
),
e| {
DatexExpressionData::DerefAssignment(DerefAssignment {
operator,
deref_count,
deref_expression: Box::new(deref_expression),
assigned_expression: Box::new(assigned_expression),
}.with_span(e.span())
})
.with_span(e.span())
},
)
// FIXME #369 assignment instead of declaration
Expand Down Expand Up @@ -113,7 +119,8 @@ pub fn variable_declaration<'a>(
expr,
annotation,
kind,
).with_span(e.span()))
)
.with_span(e.span()))
})
.recover_invalid()
.labelled(Pattern::Declaration)
Expand Down
Loading
Loading