-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7dfc09a
commit 9a8de4e
Showing
13 changed files
with
98 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
```k | ||
module RUST-CONVERSIONS-SYNTAX | ||
imports LIST | ||
imports RUST-REPRESENTATION | ||
syntax PtrListOrError ::= listToPtrList(List) [function, total] | ||
syntax ValueListOrError ::= ptrListToValueList(PtrListOrError, Map) [function, total] | ||
endmodule | ||
module RUST-CONVERSIONS | ||
imports private RUST-CONVERSIONS-SYNTAX | ||
imports private RUST-ERROR-SYNTAX | ||
rule listToPtrList(.List) => .PtrList | ||
rule listToPtrList(ListItem(P:Int) L:List) => concat(ptr(P), listToPtrList(L)) | ||
rule listToPtrList(L:List) => error("Unrecognized element (listToPtrList)", L) | ||
[owise] | ||
rule ptrListToValueList(E:SemanticsError, _:Map) => E | ||
rule ptrListToValueList(.PtrList, _:Map) => .ValueList | ||
rule ptrListToValueList((ptr(P:Int) , Ps:PtrList), M:Map) | ||
=> concat({M[P:Int:KItem]}:>Value, ptrListToValueList(Ps, M:Map)) | ||
requires P:Int:KItem in_keys(M) andBool isValue(M[P:Int:KItem] orDefault 0) | ||
[preserves-definedness] | ||
rule ptrListToValueList(Ps:PtrList, M:Map) | ||
=> error("element not in map or wrong value type (ptrListToValueList)", ListItem(Ps) ListItem(M)) | ||
[owise] | ||
endmodule | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
```k | ||
module RUST-ERROR-SYNTAX | ||
imports RUST-REPRESENTATION | ||
syntax ValueListOrError ::= concat(ValueOrError, ValueListOrError) [function, total] | ||
syntax PtrListOrError ::= concat(Ptr, PtrListOrError) [function, total] | ||
syntax PtrValueOrError ::= wrapPtrValueOrError(Ptr, ValueOrError) [function, total] | ||
endmodule | ||
module RUST-ERROR | ||
imports private RUST-ERROR-SYNTAX | ||
rule concat(P:Ptr, L:PtrList) => P , L | ||
rule concat(_:Ptr, E:SemanticsError) => E | ||
rule concat(V:Value, L:ValueList) => V , L | ||
rule concat(_:Value, E:SemanticsError) => E | ||
rule concat(E:SemanticsError, _:ValueListOrError) => E | ||
rule concat(E:ValueOrError, L:ValueListOrError) | ||
=> error("unexpected branch (concat(ValueOrError, ValueListOrError))", ListItem(E) ListItem(L)) | ||
[owise] | ||
rule wrapPtrValueOrError(P:Ptr, V:Value) => ptrValue(P, V) | ||
rule wrapPtrValueOrError(_:Ptr, E:SemanticsError) => E | ||
endmodule | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
```k | ||
module RUST-STATEMENT-EXPRESSION | ||
imports RUST-REPRESENTATION | ||
imports RUST-SHARED-SYNTAX | ||
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters