Skip to content

Commit

Permalink
Refactor and finish implementing trait preprocessing (#4) (#6)
Browse files Browse the repository at this point in the history
* Rename indexing -> preprocessing

* Refactor trait initialization

* Refactor addMethod

* Function arguments test

* Return type test

---------

Co-authored-by: Virgil <25692529+virgil-serbanuta@users.noreply.github.com>
  • Loading branch information
ACassimiro and virgil-serbanuta authored Aug 22, 2024
1 parent 6f83f7a commit acbff61
Show file tree
Hide file tree
Showing 20 changed files with 322 additions and 267 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.build
.DS_store
tmp
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SEMANTICS_FILES ::= $(shell find rust-semantics/ -type f -name '*')
SEMANTICS_FILES ::= $(shell find rust-semantics/ -type f -a '(' -name '*.md' -or -name '*.k' ')')
RUST_KOMPILED ::= .build/rust-kompiled
RUST_TIMESTAMP ::= $(RUST_KOMPILED)/timestamp
SYNTAX_INPUT_DIR ::= tests/syntax
Expand Down
6 changes: 3 additions & 3 deletions rust-semantics/config.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
```k
module RUST-CONFIGURATION
imports RUST-INDEXING-CONFIGURATION
imports RUST-PREPROCESSING-CONFIGURATION
configuration
<rust>
<crate/>
<preprocessed/>
</rust>
endmodule
module RUST-RUNNING-CONFIGURATION
imports private RUST-INDEXING-SYNTAX
imports private RUST-PREPROCESSING-SYNTAX
imports RUST-CONFIGURATION
configuration
Expand Down
19 changes: 0 additions & 19 deletions rust-semantics/indexing.md

This file was deleted.

32 changes: 0 additions & 32 deletions rust-semantics/indexing/configuration.md

This file was deleted.

35 changes: 0 additions & 35 deletions rust-semantics/indexing/helpers.md

This file was deleted.

119 changes: 0 additions & 119 deletions rust-semantics/indexing/initialization.md

This file was deleted.

46 changes: 0 additions & 46 deletions rust-semantics/indexing/syntax.md

This file was deleted.

19 changes: 19 additions & 0 deletions rust-semantics/preprocessing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```k
requires "preprocessing/crate.md"
requires "preprocessing/configuration.md"
requires "preprocessing/helpers.md"
requires "preprocessing/initialization.md"
requires "preprocessing/syntax.md"
requires "preprocessing/trait.md"
requires "preprocessing/trait-methods.md"
module RUST-PREPROCESSING
imports private CRATE
imports private INITIALIZATION
imports private TRAIT
imports private TRAIT-METHODS
endmodule
```
34 changes: 34 additions & 0 deletions rust-semantics/preprocessing/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
```k
module RUST-PREPROCESSING-CONFIGURATION
imports private RUST-REPRESENTATION
imports private RUST-SHARED-SYNTAX
syntax Identifier ::= "my_identifier" [token]
configuration
<preprocessed>
<constants>
<constant multiplicity="*" type="Map">
<constant-name> my_identifier </constant-name>
<constant-value> tuple(.ValueList) </constant-value>
</constant>
</constants>
<traits>
<trait multiplicity="*" type="Map">
<trait-path> my_identifier:TypePath </trait-path>
<methods>
<method multiplicity="*" type="Map">
<method-name> my_identifier </method-name>
<method-params> .NormalizedFunctionParameterList </method-params>
<method-return-type> ():Type </method-return-type>
<method-implementation> empty:FunctionBodyRepresentation </method-implementation>
</method>
</methods>
</trait>
</traits>
</preprocessed>
endmodule
```
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
module CRATE
imports private LIST
imports private MAP
imports private RUST-INDEXING-PRIVATE-SYNTAX
imports private RUST-INDEXING-SYNTAX
imports private RUST-PREPROCESSING-PRIVATE-SYNTAX
imports private RUST-PREPROCESSING-SYNTAX
imports private RUST-REPRESENTATION
imports private RUST-RUNNING-CONFIGURATION
Expand Down Expand Up @@ -67,11 +67,13 @@ module CRATE
, traitName : Name:Identifier
, traitFunctions: Functions:Map
)
=> crateInitializer
( ... constantNames: keys_list(Constants), constants: Constants
, traitName: Name
, functionNames:keys_list(Functions), functions: Functions
)
=> constantInitializer
( ... constantNames: keys_list(Constants), constants: Constants )
~> traitInitializer(Name)
~> traitMethodInitializer
( ... traitName: Name
, functionNames:keys_list(Functions), functions: Functions
)
endmodule
```
Loading

0 comments on commit acbff61

Please sign in to comment.