Skip to content

Commit 2e702b1

Browse files
authored
Merge pull request #23 from mrLSD/feat/serde
Feat: add Serde as codec feature
2 parents 177e077 + b75703e commit 2e702b1

14 files changed

+876
-18
lines changed

.github/workflows/lints.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- stable
1919

2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2222
with:
2323
fetch-depth: 1
2424
- uses: actions-rs/toolchain@v1
@@ -28,6 +28,8 @@ jobs:
2828
override: true
2929
components: rustfmt, clippy
3030
- name: Format
31-
run: cargo fmt --check
31+
run: cargo fmt --all -- --check
32+
- name: Clippy no-default-features
33+
run: cargo clippy --all --all-targets --no-default-features -- -D warnings
3234
- name: Clippy
33-
run: cargo clippy --all-targets -- -D warnings
35+
run: cargo clippy --all --all-targets --all-features -- -D warnings

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- nightly
1919

2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2222
with:
2323
fetch-depth: 1
2424
- uses: actions-rs/toolchain@v1
@@ -37,9 +37,9 @@ jobs:
3737
~/.cargo/git/db/
3838
key: ${{ runner.os }}-cargo
3939
- name: Build
40-
run: cargo build
40+
run: cargo build --all-features
4141
- name: Test
42-
run: cargo test --all-targets
42+
run: cargo test --all-targets --all-features
4343
env:
4444
CARGO_INCREMENTAL: '0'
4545
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Copt-level=0 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort'

Cargo.toml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "semantic-analyzer"
3-
version = "0.3.2"
3+
version = "0.3.3"
44
authors = ["Evgeny Ukhanov <mrlsd@ya.ru>"]
55
description = "Semantic analyzer library for compilers written in Rust for semantic analysis of programming languages AST"
66
keywords = ["compiler", "semantic-analisis", "semantic-alalyzer", "compiler-design", "semantic"]
@@ -13,9 +13,17 @@ repository = "https://github.com/mrLSD/semantic-analyzer-rs"
1313
[lib]
1414
doctest = false
1515

16-
#[lints.clippy]
17-
#pedantic = "deny"
18-
#nursery = "deny"
16+
# It requieres MSRV: 1.74
17+
# [lints.clippy]
18+
# pedantic = "deny"
19+
# nursery = "deny"
1920

2021
[dependencies]
2122
nom_locate = "4.2"
23+
serde = { version = "1", features = ["derive"], optional = true }
24+
25+
[dev-dependencies]
26+
serde_json = "1"
27+
28+
[features]
29+
codec = ["serde"]

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,31 @@ possibilities of using the results of the `semantic-analyzer-rs` `SemanticStackC
112112
backend, [inkwell](https://github.com/TheDan64/inkwell) as a library for LLVM codegen, and compiled into an executable
113113
program. The source of data is the AST structure itself.
114114

115+
## 📶 Features
116+
117+
Available library rust features:
118+
- `codec` - 💮 enable serialization and deserialization with `Serde`.
119+
This is especially convenient in the process of forming AST, Codegen,
120+
a serialized representation of the `SemanticState`. Another important
121+
nuance is that any library that implements `Serde` can act as a
122+
serializer `codec`. For example formats: `json`, `toml`, `yaml`,
123+
`binary`, and many others that can use `serde` library.
124+
The main entities, which apply the `codec` feature is:
125+
- [x] `AST` ↪️ AST data source can be presented with serialized source.
126+
This is especially useful for designing and testing `Codegen`, AST data
127+
transfer pipeline, and also for use as a data generation source for
128+
AST - any programming language that can generate serialized AST data.
129+
- [x] `State` ↪️ `SematniсState` can be obtained in the form of
130+
serialized data. This is especially convenient for storing state
131+
before code generation with different parameters, post-analysis,
132+
optimizations - which will allow to work with already analyzed
133+
data.
134+
- [x] `SemanticStack` ↪️ contains a set of instructions for `Codegen`.
135+
Representation in serialized form may be convenient for cases: code
136+
generation without repeated semantic analysis, only based on
137+
instructions for the code generator generated by the `semantic analyzer`.
138+
Serialized data represented `SemanticStack` - opens up wide
139+
possibilities for using any third-party code generators and compilers
140+
implemented in any programming language.
141+
115142
## MIT [LICENSE](LICENSE)

0 commit comments

Comments
 (0)