From 52f0a5b8f100fcee88a9db58947abbb347a588f2 Mon Sep 17 00:00:00 2001 From: Giulio Agostini Date: Sat, 11 Jul 2026 18:01:40 +0200 Subject: [PATCH] Wip: struct parsign --- README.org | 16 +++++++++++----- src/frontend/parser.rs | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.org b/README.org index 2d8d302..1ed1e56 100755 --- a/README.org +++ b/README.org @@ -17,21 +17,27 @@ Cosa :: struct{ field1: Number } #+end_src -*** TODO update lexert +*** TODO update lexer *** TODO update ast *** TODO update parser ** TODO implement partial function ... #+begin_src rlox -cosa := make(Cosa, feld1: 42) +cosa := Cosa{feld1: 42} function :: fn(self:Cosa, b: Number) -> Number res := function(cosa,44) #+end_src -*** TODO ... to undericlty create method +*** TODO ... to undirectly create method #+begin_src rlox -res := cosa.function(44) +res := cosa.function(44); #+end_src *** TODO ... to make pipeline #+begin_src rlox -res := cosa |> function(44) +res := cosa |> function(44); #+end_src ** TODO Understand what is a type system +** TODO implement struct method: +#+begin_src rlox +Cosa.new :: fn(field1: Number):Self #+begin_src do + return Self{ field1 }; +end; +#+end_src diff --git a/src/frontend/parser.rs b/src/frontend/parser.rs index c9bc811..a42c62b 100755 --- a/src/frontend/parser.rs +++ b/src/frontend/parser.rs @@ -2,7 +2,7 @@ use crate::{ common::{ ast::{AstNode, Expr}, base_value::{BaseValue, LoxFunction, Struct}, - lox_result::{LoxResult, parse_error, runtime_error}, + lox_result::{parse_error, runtime_error, LoxResult}, types::Type, }, frontend::{ @@ -409,7 +409,7 @@ impl Parser { let expr = self.or_and()?; if self.peek().token_type == TokenType::Equal { self.advance(); // consume '=' - // Right-associative: `a = b = c` parses as `a = (b = c)`. + // Right-associative: `a = b = c` parses as `a = (b = c)`. let value = self.assignment()?; let combined_slice = SourceSlice::from_positions( expr.source_slice.source_id,