Skip to content

Commit 40d5ea1

Browse files
authored
Add vhdl_syntax and vhdl-dump-ast to pipeline (#442)
* Add vhdl_syntax and vhdl-dump-ast to the crates checked in the CI stages * Fix clippy lints and formatting
1 parent c63d6ec commit 40d5ea1

17 files changed

Lines changed: 127 additions & 101 deletions

File tree

.github/workflows/build-test-all.yml

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ jobs:
1616
strategy:
1717
matrix:
1818
crate:
19-
- vhdl_lang
20-
- vhdl_ls
19+
- { name: "vhdl_lang", binary: true }
20+
- { name: "vhdl_ls", binary: true }
21+
- { name: "vhdl_syntax", binary: false }
22+
- { name: "vhdl-dump-ast", binary: false }
2123
target:
2224
- x86_64-unknown-linux-gnu
2325
- x86_64-unknown-linux-musl
@@ -49,11 +51,16 @@ jobs:
4951
uses: dtolnay/rust-toolchain@stable
5052
with:
5153
toolchain: ${{ matrix.rust }}
52-
target: x86_64-unknown-linux-musl
54+
target: ${{ matrix.target }}
5355
components: rustfmt, clippy
5456

55-
- name: Add Apple Silicon Dependencies
56-
run: rustup target add aarch64-apple-darwin
57+
- name: Cache cargo
58+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
59+
with:
60+
path: |
61+
~/.cargo/registry
62+
~/.cargo/git
63+
key: ${{ runner.os }}-${{ matrix.target }}-${{ matrix.rust }}-${{ matrix.crate.name }}-${{ hashFiles('**/Cargo.lock') }}
5764

5865
- uses: awalsh128/cache-apt-pkgs-action@5902b33ae29014e6ca012c5d8025d4346556bd40 # v1.5.0
5966
if: matrix.os == 'ubuntu-latest'
@@ -62,34 +69,34 @@ jobs:
6269
version: 1.0
6370

6471
- name: Build
65-
run: cargo build --manifest-path ${{ matrix.crate }}/Cargo.toml --release --target ${{ matrix.target }}
72+
run: cargo build --manifest-path ${{ matrix.crate.name }}/Cargo.toml --release --target ${{ matrix.target }}
6673

6774
- name: Test
6875
if: matrix.os != 'macos-latest' # There are no free runners for Apple Silicon available at the moment
69-
run: cargo test --manifest-path ${{ matrix.crate }}/Cargo.toml --release --target ${{ matrix.target }}
76+
run: cargo test --manifest-path ${{ matrix.crate.name }}/Cargo.toml --release --target ${{ matrix.target }}
7077

7178
- name: rustfmt
72-
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'stable'
73-
run: cargo fmt --package ${{ matrix.crate }} -- --check
79+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-gnu' && matrix.rust == 'stable' }}
80+
run: cargo fmt --manifest-path ${{ matrix.crate.name }}/Cargo.toml -- --check
7481

7582
- name: clippy
76-
if: matrix.os == 'ubuntu-latest'
77-
run: cargo clippy --package ${{ matrix.crate }} --all-targets --all-features -- -D warnings
83+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-gnu' && matrix.rust == 'stable' }}
84+
run: cargo clippy --manifest-path ${{ matrix.crate.name }}/Cargo.toml --all-targets --all-features -- -D warnings
7885

7986
- name: Assemble
80-
if: matrix.rust == 'stable'
87+
if: ${{ matrix.crate.binary == true && matrix.rust == 'stable' }}
8188
run: |
82-
mkdir ${{ matrix.crate }}-${{ matrix.target }}
83-
mkdir ${{ matrix.crate }}-${{ matrix.target }}/bin
84-
cp -R vhdl_libraries ${{ matrix.crate }}-${{ matrix.target }}
85-
cp target/${{ matrix.target }}/release/${{ matrix.crate }}${{ matrix.ext }} ${{ matrix.crate }}-${{ matrix.target }}/bin
89+
mkdir ${{ matrix.crate.name }}-${{ matrix.target }}
90+
mkdir ${{ matrix.crate.name }}-${{ matrix.target }}/bin
91+
cp -R vhdl_libraries ${{ matrix.crate.name }}-${{ matrix.target }}
92+
cp target/${{ matrix.target }}/release/${{ matrix.crate.name }}${{ matrix.ext }} ${{ matrix.crate.name }}-${{ matrix.target }}/bin
8693
8794
- name: Upload
88-
if: matrix.rust == 'stable'
95+
if: ${{ matrix.crate.binary == true && matrix.rust == 'stable' }}
8996
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
9097
with:
91-
name: ${{ matrix.crate }}-${{ matrix.target }}
92-
path: ${{ matrix.crate }}-${{ matrix.target }}
98+
name: ${{ matrix.crate.name }}-${{ matrix.target }}
99+
path: ${{ matrix.crate.name }}-${{ matrix.target }}
93100

94101
release:
95102
name: Release
@@ -126,7 +133,7 @@ jobs:
126133
version_string=$(~/temp/vhdl_ls-x86_64-unknown-linux-musl/bin/vhdl_ls --version)
127134
if [ "$version_string" != "vhdl_ls $v" ]
128135
then
129-
echo "Version string mismatch (\"$version_string\" != \"vhdl_lang $v\""
136+
echo "Version string mismatch (\"$version_string\" != \"vhdl_ls $v\""
130137
exit 1
131138
else
132139
echo "Version string matched"

vhdl_syntax/examples/linting.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use vhdl_syntax::syntax::EntityDeclarationSyntax;
1111

1212
/// Showcases how one could write a simple linter that checks that the declared name and final name
1313
/// of an entity match.
14-
1514
fn main() {
1615
let vhdl = "\
1716
entity baz is

vhdl_syntax/src/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
//! Provides facilities to format nodes and tokens to encoded strings.
22
3-
pub mod utf8;
43
pub mod latin1;
4+
pub mod utf8;

vhdl_syntax/src/fmt/utf8.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Provides facilities to format nodes and tokens to UTF-8 encoded strings.
2-
//!
2+
//!
33
//! # Important considerations
44
//!
55
//! ## Latin1 encoding
@@ -10,15 +10,15 @@
1010
//! the encoding is simply `[0xE9]`.
1111
//! As a consequence, the round-trip VHDL-file -> parse -> to string is not guaranteed to yield
1212
//! the same result.
13-
//!
14-
//! If you want to format to Latin-1, consider using the [fmt::latin1](crate::fmt::latin1) module.
13+
//!
14+
//! If you want to format to Latin-1, consider using the [fmt::latin1](crate::fmt::latin1) module.
1515
//!
1616
//! ## Comment handling
17-
//!
17+
//!
1818
//! VHDL allows comments to have a different encoding compared to the rest of the file.
1919
//! This implementation assumes `UTF-8` and will replace every invalid UTF-8 sequences
2020
//! with `U+FFFD REPLACEMENT CHARACTER`, which looks like this: �
21-
//!
21+
//!
2222
//! To circumvent the issues from above, the byte-oriented facilities
2323
//! (e.g., [SyntaxNode::write_to], [Token::write_to]) can be used. These always guarantee that the round-trip
2424
//! VHDL-file -> parse -> write will yield the exact same result.

vhdl_syntax/src/parser/productions/attributes.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//
55
// Copyright (c) 2025, Lukas Scheller lukasscheller@icloud.com
66

7-
use crate::match_next_token;
87
use crate::parser::Parser;
98
use crate::syntax::node_kind::NodeKind::*;
109
use crate::tokens::token_kind::Keyword as Kw;

vhdl_syntax/src/parser/productions/concurrent_statement.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl Parser {
193193
_ => {
194194
self.skip();
195195
self.expect_tokens_err([Keyword(Kw::Block)])
196-
},
196+
}
197197
}
198198
}
199199

vhdl_syntax/src/parser/productions/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ pub mod association_lists;
99
pub mod attributes;
1010
pub mod component_declaration;
1111
pub mod composite_types;
12-
pub mod context;
1312
pub mod concurrent_statement;
1413
pub mod configuration_declarations;
14+
pub mod context;
1515
pub mod declarations;
1616
pub mod design;
1717
pub mod entity_declaration;

vhdl_syntax/src/parser/productions/names.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,7 @@ mod tests {
373373

374374
#[test]
375375
fn test_external_name_explicit_relative_multiple_levels() {
376-
insta::assert_snapshot!(name_to_test_text(
377-
"<< signal ^.^.^.dut.gen : std_logic >>"
378-
));
376+
insta::assert_snapshot!(name_to_test_text("<< signal ^.^.^.dut.gen : std_logic >>"));
379377
}
380378

381379
#[test]

vhdl_syntax/src/parser/util.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ impl Parser {
115115
}
116116
}
117117

118-
pub(crate) fn expect_one_of_tokens<const N: usize>(&mut self, kinds: [TokenKind; N]) -> Option<TokenKind> {
118+
pub(crate) fn expect_one_of_tokens<const N: usize>(
119+
&mut self,
120+
kinds: [TokenKind; N],
121+
) -> Option<TokenKind> {
119122
for kind in kinds {
120123
if self.opt_token(kind) {
121124
return Some(kind);
@@ -126,11 +129,17 @@ impl Parser {
126129
}
127130

128131
pub(crate) fn peek_token(&self) -> TokenKind {
129-
self.token_stream.peek(0).map(|tok| tok.kind()).unwrap_or(TokenKind::Eof)
132+
self.token_stream
133+
.peek(0)
134+
.map(|tok| tok.kind())
135+
.unwrap_or(TokenKind::Eof)
130136
}
131137

132138
pub(crate) fn peek_nth_token(&self, n: usize) -> TokenKind {
133-
self.token_stream.peek(n).map(|tok| tok.kind()).unwrap_or(TokenKind::Eof)
139+
self.token_stream
140+
.peek(n)
141+
.map(|tok| tok.kind())
142+
.unwrap_or(TokenKind::Eof)
134143
}
135144

136145
pub(crate) fn next_is(&self, kind: TokenKind) -> bool {

vhdl_syntax/src/serde/flags.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
//! let flags = SerdeFlags::default()
1111
//! .include_trivia(false)
1212
//! .include_loc(true);
13-
//!
13+
//!
1414
//! // Serialized data will not include trivia information
1515
//! assert!(!flags.includes_trivia());
16-
//!
16+
//!
1717
//! // Serialized data will include source location
1818
//! assert!(flags.includes_loc());
1919
//! ```
@@ -31,7 +31,7 @@ impl Default for SerdeFlags {
3131
Self {
3232
include_trivia: true,
3333
include_loc: true,
34-
comment_encoding: "utf-8".into()
34+
comment_encoding: "utf-8".into(),
3535
}
3636
}
3737
}
@@ -61,7 +61,7 @@ impl SerdeFlags {
6161

6262
/// Comments in VHDL can have arbitrary encoding. This flag allows serializers to specify an
6363
/// encoding that is attached to individual comments in the serialized AST.
64-
///
64+
///
6565
/// Currently, this encoding serves merely as an information to consumers.
6666
/// It is not enforced nor is the string actually encoded using the specified value.
6767
/// This may change in the future.

0 commit comments

Comments
 (0)