Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field access in PIL #1586

Draft
wants to merge 95 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
bf13c94
StructDeclaration & auxiliary functions (display, children, etc.)
gzanitti May 16, 2024
81694ee
Display, TypeDeclaration, TypeConstructor, etc.
gzanitti May 17, 2024
67bdbc0
Basic struct declaration
gzanitti May 17, 2024
f46673c
Temporarily using SelectedExpression with "$" instead of "*" to avoid…
gzanitti May 17, 2024
582d95c
WIP
gzanitti May 18, 2024
668ed89
Patterns
gzanitti May 20, 2024
b6e4d3f
Functions as struct fields type & test
gzanitti May 20, 2024
f21eeaa
missed clippy deny
gzanitti May 20, 2024
ed196cf
Ellipsis in StructPattern, and missed case in handle_statement
gzanitti May 20, 2024
585ca0c
WIP
gzanitti May 21, 2024
df3aec3
Merge remote-tracking branch 'upstream/main' into structs_in_pil
gzanitti May 28, 2024
877a828
WIP
gzanitti May 29, 2024
8235873
Main merged
gzanitti Jun 11, 2024
4cc6f1c
Main merged
gzanitti Jul 1, 2024
303ffa2
Main marged with new grammar
gzanitti Jul 1, 2024
47022a3
Updated grammar: Conflict with new StructExpression
gzanitti Jul 1, 2024
46e06e4
StructExpression needs to be redefine
gzanitti Jul 1, 2024
81051e9
//StructExpression
gzanitti Jul 1, 2024
fb4e357
//StructExpression
gzanitti Jul 2, 2024
bf8f2de
Temporarily resolving the grammar with X?{ .. }
gzanitti Jul 2, 2024
70bc1fc
Basic type inference (fake grammar)
gzanitti Jul 2, 2024
18fea1a
Fields are going to be a problem :melting_face:
gzanitti Jul 2, 2024
df3abd4
More tests
gzanitti Jul 3, 2024
d2d3992
Merge remote-tracking branch 'upstream/main' into structs_in_pil
gzanitti Jul 3, 2024
0a23ec5
Structs integration
gzanitti Jul 3, 2024
c4d535f
Conflict solved & Struct pattern updated
gzanitti Jul 4, 2024
6290bf8
Test fixed
gzanitti Jul 4, 2024
008a61d
FieldAccess
gzanitti Jul 4, 2024
7d0dbeb
Parsing
gzanitti Jul 5, 2024
08dccea
Progress in type inference & new test
gzanitti Jul 5, 2024
18bd64f
Merge remote-tracking branch 'upstream/main' into structs_in_pil
gzanitti Jul 5, 2024
63056b4
More about type inference
gzanitti Jul 5, 2024
06c7c46
Display
gzanitti Jul 9, 2024
bf142d7
Conflict solved
gzanitti Jul 9, 2024
add43c2
New var when type cannot be infered
gzanitti Jul 9, 2024
15ca14d
Better patterns, but still bugy
gzanitti Jul 9, 2024
9312643
Basic pattern working. Still need to type-check fields
gzanitti Jul 9, 2024
b9bf311
Minor fix, more tests, etc
gzanitti Jul 9, 2024
94aff50
Minor fix
gzanitti Jul 10, 2024
02ba92e
Improvements before separating Pattern & FieldAccess
gzanitti Jul 10, 2024
f089d8a
Improvements before separating Pattern & FieldAccess
gzanitti Jul 10, 2024
73601cd
Conflicts solved
gzanitti Jul 10, 2024
a93ee10
handle_symbol_definition refactor
gzanitti Jul 10, 2024
6ec9af0
Merge remote-tracking branch 'upstream/main' into structs_in_pil
gzanitti Jul 11, 2024
636f70f
Minor change
gzanitti Jul 11, 2024
4ae9915
More on type inference. "Cannot unify types F::S and F::S"
gzanitti Jul 11, 2024
203fbcd
WIP evaluation
gzanitti Jul 11, 2024
560a589
Conflict solved
gzanitti Jul 15, 2024
154c0be
Primer in field access evaluation
gzanitti Jul 15, 2024
3a42a01
Minor fix
gzanitti Jul 15, 2024
6ac9de2
Next step: Pattern evaluation.
gzanitti Jul 15, 2024
f7ec1da
Struct pattern tests (still failling)
gzanitti Jul 15, 2024
220c2b9
Patterns.
gzanitti Jul 16, 2024
4958971
Fix: a value of type [Arc<evaluator::Value<_, T>>] cannot be built fr…
gzanitti Jul 16, 2024
6e30e5c
Merge remote-tracking branch 'upstream/main' into structs_in_pil
gzanitti Jul 16, 2024
be18e8b
Minor fix
gzanitti Jul 16, 2024
cb41a77
FieldAccess in PIL
gzanitti Jul 16, 2024
58174f5
FieldAccess & Patterns moved into their own PRs
gzanitti Jul 16, 2024
9957e5a
Minor fix
gzanitti Jul 16, 2024
80ecddd
Comments removed
gzanitti Jul 16, 2024
944381d
comments removed
gzanitti Jul 16, 2024
d3e62bc
comments removed
gzanitti Jul 16, 2024
b339b79
linter unused var
gzanitti Jul 16, 2024
dfc5821
linter unused var
gzanitti Jul 16, 2024
2701c3c
Missed import
gzanitti Jul 16, 2024
0e4aed5
cargo check not working well
gzanitti Jul 16, 2024
d0ca0f7
Conflict solved
gzanitti Jul 25, 2024
f442d47
Conflicts & new tests organization
gzanitti Jul 29, 2024
2b1b5a4
Conflicts & new tests organization
gzanitti Jul 29, 2024
8b8211b
Minor fix
gzanitti Jul 29, 2024
ff2b7b6
Missed param after merge
gzanitti Jul 29, 2024
89fac56
Main merged
gzanitti Aug 26, 2024
f375e19
More fixes
gzanitti Aug 26, 2024
ca41e60
Path fixed
gzanitti Aug 27, 2024
34c7b11
Main merged
gzanitti Aug 27, 2024
23647c2
path fixed
gzanitti Aug 27, 2024
41a62d9
Error msg
gzanitti Aug 27, 2024
05be960
Minor fixes
gzanitti Aug 28, 2024
00efbf0
Cleaner code
gzanitti Aug 28, 2024
a96d489
Merged new grammar. keyword `with` removed from struct instanciation
gzanitti Aug 29, 2024
9ca8d93
Merged new grammar. keyword `with` removed from struct instanciation
gzanitti Aug 29, 2024
f2c298c
Fixed grammar: removed RestrictedExpression from MatchArm
gzanitti Aug 29, 2024
7317c5f
Fixed grammar: removed RestrictedExpression from MatchArm
gzanitti Aug 29, 2024
e59a4f1
conflicts solved
gzanitti Sep 13, 2024
992c018
children() separation from namedexpressions
gzanitti Sep 13, 2024
9fad753
Grammar (NamedExpression<Box<...>>) and new method not implemented fo…
gzanitti Sep 13, 2024
e809301
missed match arm implemented
gzanitti Sep 13, 2024
612622f
remove parenthesis outside lambda functions in struct tests
gzanitti Sep 13, 2024
7e37b0c
Check and negative tests for wrong field names
gzanitti Sep 13, 2024
3ada7db
More checks and tests
gzanitti Sep 13, 2024
0308859
Fix tests with undefined structs or fields
gzanitti Sep 13, 2024
6bdf680
Minor improvements
gzanitti Sep 13, 2024
754ac64
cleaner statement processor
gzanitti Sep 17, 2024
f7393d6
arc
gzanitti Sep 17, 2024
d5b8983
conflicts
gzanitti Sep 17, 2024
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
Prev Previous commit
Next Next commit
Merged new grammar. keyword with removed from struct instanciation
  • Loading branch information
gzanitti committed Aug 29, 2024
commit a96d489bde7acb1ebb445efa74247718af0383b6
2 changes: 1 addition & 1 deletion ast/src/parsed/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ impl<E: Display> Display for StructExpression<E> {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(
f,
"{} with {}",
"{}{}",
self.name,
if self.fields.is_empty() {
"".to_string()
Expand Down
9 changes: 1 addition & 8 deletions parser/src/powdr.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ TermCommon<StructOption>: Box<Expression> = {
MatchExpression,
IfExpression,
BlockExpression,
StructExpression,
<start:@L> "[" <items:ExpressionList> "]" <end:@R> => ctx.to_expr_with_source_ref(ArrayLiteral{items}, start, end),
<start:@L> "(" <head:Expression> "," <tail:ExpressionList> ")" <end:@R> => { let mut list = vec![head]; list.extend(tail); Box::new(Expression::Tuple(ctx.source_ref(start, end), list)) },
<start:@L> "(" ")" <end:@R> => Box::new(Expression::Tuple(ctx.source_ref(start, end), vec![])),
Expand Down Expand Up @@ -674,7 +673,7 @@ IfExpression: Box<Expression> = {
}

StructExpression: Box<Expression> = {
<start:@L> <name:Identifier> "with" "{" <fields:NamedExpressions> "}" <end:@R> => ctx.to_expr_with_source_ref(StructExpression{name, fields}, start, end),
<start:@L> <name:Identifier> "{" <fields:NamedExpressions> "}" <end:@R> => ctx.to_expr_with_source_ref(StructExpression{name, fields}, start, end),
}

BlockExpression: Box<Expression> = {
Expand All @@ -686,12 +685,6 @@ StatementInsideBlock: StatementInsideBlock = {
<Expression> ";" => StatementInsideBlock::Expression(<>),
}


// This rules are placeholder to test the parser. Structs are not implemented yet.
StructExpression: Box<Expression> = {
<start:@L> <name:Identifier> "{" <fields:NamedExpressions> "}" <end:@R> => Box::new(Expression::Tuple(ctx.source_ref(start, end), vec![])),
}

// ---------------------------- Pattern -----------------------------

Pattern: Pattern = {
Expand Down
8 changes: 4 additions & 4 deletions pil-analyzer/tests/parse_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ fn simple_struct() {
x: int,
y: int,
}
let f: int -> Point = (|i| Point with { x: 0, y: i });
let f: int -> Point = (|i| Point{ x: 0, y: i });
let x: Point = f(0);
";
let formatted = analyze_string::<GoldilocksField>(input).to_string();
Expand All @@ -892,9 +892,9 @@ fn struct_constr_var_typed() {
y: int,
}
let v: int -> X = (|i| match i {
1 => X with { x: 1, y: 0 },
2 => X with { x: 2, y: 2 },
_ => X with { x: 0, y: 1 },
1 => X{ x: 1, y: 0 },
2 => X{ x: 2, y: 2 },
_ => X{ x: 0, y: 1 },
});
let x: X = v(1);
";
Expand Down
8 changes: 4 additions & 4 deletions pil-analyzer/tests/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ fn empty_conditional() {
fn simple_struct() {
let input = "
struct Dot { x: int, y: int }
let f: int -> Dot = |i| Dot with {x: 0, y: i};
let f: int -> Dot = |i| Dot{x: 0, y: i};

let x: Dot = f(0);
";
Expand All @@ -591,9 +591,9 @@ fn struct_constr_var_typed() {
let input = "
struct X {x: int, y: int}
let v: int -> X = |i| match i {
1 => X with {x: 1, y: 0},
2 => X with {x: 2, y: 2},
_ => X with {x: 0, y: 1},
1 => X{x: 1, y: 0},
2 => X{x: 2, y: 2},
_ => X{x: 0, y: 1},
};

let x: X = v(1);
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.