Skip to content

Commit

Permalink
Merge pull request #23 from mrLSD/feat/serde
Browse files Browse the repository at this point in the history
Feat: add Serde as codec feature
  • Loading branch information
mrLSD committed Dec 12, 2023
2 parents 177e077 + b75703e commit 2e702b1
Show file tree
Hide file tree
Showing 14 changed files with 876 additions and 18 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- stable

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
Expand All @@ -28,6 +28,8 @@ jobs:
override: true
components: rustfmt, clippy
- name: Format
run: cargo fmt --check
run: cargo fmt --all -- --check
- name: Clippy no-default-features
run: cargo clippy --all --all-targets --no-default-features -- -D warnings
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
run: cargo clippy --all --all-targets --all-features -- -D warnings
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- nightly

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
Expand All @@ -37,9 +37,9 @@ jobs:
~/.cargo/git/db/
key: ${{ runner.os }}-cargo
- name: Build
run: cargo build
run: cargo build --all-features
- name: Test
run: cargo test --all-targets
run: cargo test --all-targets --all-features
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Copt-level=0 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort'
Expand Down
16 changes: 12 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "semantic-analyzer"
version = "0.3.2"
version = "0.3.3"
authors = ["Evgeny Ukhanov <mrlsd@ya.ru>"]
description = "Semantic analyzer library for compilers written in Rust for semantic analysis of programming languages AST"
keywords = ["compiler", "semantic-analisis", "semantic-alalyzer", "compiler-design", "semantic"]
Expand All @@ -13,9 +13,17 @@ repository = "https://github.com/mrLSD/semantic-analyzer-rs"
[lib]
doctest = false

#[lints.clippy]
#pedantic = "deny"
#nursery = "deny"
# It requieres MSRV: 1.74
# [lints.clippy]
# pedantic = "deny"
# nursery = "deny"

[dependencies]
nom_locate = "4.2"
serde = { version = "1", features = ["derive"], optional = true }

[dev-dependencies]
serde_json = "1"

[features]
codec = ["serde"]
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,31 @@ possibilities of using the results of the `semantic-analyzer-rs` `SemanticStackC
backend, [inkwell](https://github.com/TheDan64/inkwell) as a library for LLVM codegen, and compiled into an executable
program. The source of data is the AST structure itself.

## 📶 Features

Available library rust features:
- `codec` - 💮 enable serialization and deserialization with `Serde`.
This is especially convenient in the process of forming AST, Codegen,
a serialized representation of the `SemanticState`. Another important
nuance is that any library that implements `Serde` can act as a
serializer `codec`. For example formats: `json`, `toml`, `yaml`,
`binary`, and many others that can use `serde` library.
The main entities, which apply the `codec` feature is:
- [x] `AST` ↪️ AST data source can be presented with serialized source.
This is especially useful for designing and testing `Codegen`, AST data
transfer pipeline, and also for use as a data generation source for
AST - any programming language that can generate serialized AST data.
- [x] `State` ↪️ `SematniсState` can be obtained in the form of
serialized data. This is especially convenient for storing state
before code generation with different parameters, post-analysis,
optimizations - which will allow to work with already analyzed
data.
- [x] `SemanticStack` ↪️ contains a set of instructions for `Codegen`.
Representation in serialized form may be convenient for cases: code
generation without repeated semantic analysis, only based on
instructions for the code generator generated by the `semantic analyzer`.
Serialized data represented `SemanticStack` - opens up wide
possibilities for using any third-party code generators and compilers
implemented in any programming language.

## MIT [LICENSE](LICENSE)
Loading

0 comments on commit 2e702b1

Please sign in to comment.