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

Properly implement expression/statement results #94

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
12 changes: 7 additions & 5 deletions rust-semantics/execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
requires "execution/configuration.md"
requires "execution/block.md"
requires "execution/calls.md"
requires "execution/expression.md"
requires "execution/let.md"
requires "execution/stack.md"
requires "execution/statements.md"
module RUST-EXECUTION
imports RUST-BLOCK
imports RUST-CALLS
imports RUST-LET
imports RUST-STACK
imports RUST-STATEMENTS
imports private RUST-BLOCK
imports private RUST-CALLS
imports private RUST-STATEMENT-EXPRESSION
imports private RUST-LET
imports private RUST-STACK
imports private RUST-STATEMENTS
endmodule
```
14 changes: 14 additions & 0 deletions rust-semantics/execution/expression.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```k
module RUST-STATEMENT-EXPRESSION
imports private RUST-REPRESENTATION
imports private RUST-SHARED-SYNTAX
syntax Instruction ::= "clearValue"
rule E:Expression ; => (E ~> clearValue)
rule (_:PtrValue ~> clearValue) => .K
rule clearValue => .K
endmodule
```
13 changes: 9 additions & 4 deletions rust-semantics/execution/statements.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
```k
module RUST-STATEMENTS
imports RUST-SHARED-SYNTAX
imports private RUST-SHARED-SYNTAX
imports private RUST-VALUE-SYNTAX
rule Nes:NonEmptyStatements E:Expression => Nes ~> E
rule S:Statement Ss:NonEmptyStatements => S ~> Ss
rule .NonEmptyStatements => .K
syntax K ::= statementsToK(NonEmptyStatements) [function, total]
rule statementsToK(.NonEmptyStatements) => .K
rule statementsToK(S:Statement Ss:NonEmptyStatements)
=> S ~> statementsToK(Ss)
rule Nes:NonEmptyStatements E:Expression => statementsToK(Nes) ~> E
rule Ss:NonEmptyStatements => statementsToK(Ss) ~> ptrValue(null, tuple(.ValueList))
endmodule
```
2 changes: 2 additions & 0 deletions rust-semantics/expression.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ requires "expression/conditionals.md"
requires "expression/literals.md"
requires "expression/references.md"
requires "expression/struct.md"
requires "expression/tuple.md"
requires "expression/variables.md"

module RUST-EXPRESSION
Expand All @@ -21,6 +22,7 @@ module RUST-EXPRESSION
imports private RUST-EXPRESSION-REFERENCES
imports private RUST-EXPRESSION-STRUCT
imports private RUST-EXPRESSION-VARIABLES
imports private RUST-EXPRESSION-TUPLE
imports private RUST-INTEGER-OPERATIONS
imports private RUST-BOOL-OPERATIONS
endmodule
Expand Down
2 changes: 2 additions & 0 deletions rust-semantics/expression/casts.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module RUST-CASTS
rule implicitCast(V:Bool, bool) => V
rule implicitCast(tuple(.ValueList) #as V, ():Type) => V
rule implicitCast(struct(T, _) #as V, T) => V
rule implicitCast(struct(T, _) #as V, T < _ >) => V
Expand Down
10 changes: 10 additions & 0 deletions rust-semantics/expression/tuple.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
```k

module RUST-EXPRESSION-TUPLE
imports RUST-REPRESENTATION
imports RUST-VALUE-SYNTAX

rule ():Expression => ptrValue(null, tuple(.ValueList))

endmodule
```
4 changes: 3 additions & 1 deletion tests/execution/if-expressions.5.run
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
new IfExpressions;
call IfExpressions.test_if_no_return
call IfExpressions.test_if_no_return;
return_value;
check_eq ()
Loading