Skip to content

Commit

Permalink
Syntax for parsing Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
virgil-serbanuta committed Aug 7, 2024
1 parent 7a085cd commit bf9be40
Show file tree
Hide file tree
Showing 9 changed files with 2,335 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
SEMANTICS_FILES ::= $(shell find rust-semantics/ -type f -name '*')
RUST_KOMPILED ::= .build/rust-kompiled
RUST_TIMESTAMP ::= $(RUST_KOMPILED)/timestamp
SYNTAX_INPUT_DIR ::= tests/syntax
SYNTAX_OUTPUTS_DIR ::= .build/syntax-output

SYNTAX_INPUTS ::= $(wildcard $(SYNTAX_INPUT_DIR)/*.rs)
SYNTAX_OUTPUTS ::= $(patsubst $(SYNTAX_INPUT_DIR)/%.rs,$(SYNTAX_OUTPUTS_DIR)/%.rs-parsed,$(SYNTAX_INPUTS))

.PHONY: clean build test syntax-test

clean:
rm -r .build

build: $(RUST_TIMESTAMP)

test: syntax-test

syntax-test: $(SYNTAX_OUTPUTS)

$(RUST_TIMESTAMP): $(SEMANTICS_FILES)
$$(which kompile) rust-semantics/rust.md -o $(RUST_KOMPILED)

$(SYNTAX_OUTPUTS_DIR)/%.rs-parsed: $(SYNTAX_INPUT_DIR)/%.rs $(RUST_TIMESTAMP)
mkdir -p $(SYNTAX_OUTPUTS_DIR)
kast --definition $(RUST_KOMPILED) $< --sort Crate > $@
8 changes: 8 additions & 0 deletions rust-semantics/rust.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```k
requires "syntax.md"
module RUST
imports RUST-SHARED-SYNTAX
endmodule
```
Loading

0 comments on commit bf9be40

Please sign in to comment.