Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ jobs:
tomato set workspace.dependencies.plotnik-vm.version "$next" Cargo.toml
tomato set workspace.dependencies.plotnik-langs.version "$next" Cargo.toml
tomato set workspace.dependencies.plotnik-lib.version "$next" Cargo.toml
# plotnik-cli has explicit plotnik-langs dep (default-features = false workaround)
# explicit default-features = false overrides need local version bumps too
tomato set dependencies.plotnik-langs.version "$next" crates/plotnik-compiler/Cargo.toml
tomato set dependencies.plotnik-compiler.version "$next" crates/plotnik-lib/Cargo.toml
tomato set dependencies.plotnik-langs.version "$next" crates/plotnik-cli/Cargo.toml
tomato set dependencies.plotnik-lib.version "$next" crates/plotnik-cli/Cargo.toml

- name: Update lockfile
run: cargo check --workspace
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,33 @@ jobs:

- name: Test
run: make test

feature-flags:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6

- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: Using Rust cache
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
with:
cache-all-crates: "true"
cache-on-failure: "true"
prefix-key: v0-rust-stable

- name: No-default-features langs
run: cargo clippy -p plotnik-langs --no-default-features -- -D warnings

- name: No-default-features compiler
run: cargo check -p plotnik-compiler --no-default-features

- name: Single non-default language
run: cargo check -p plotnik --no-default-features --features lang-styx

- name: All-features workspace
run: cargo check --workspace --all-targets --all-features
56 changes: 0 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/plotnik-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ lang-zsh = ["plotnik-langs/lang-zsh"]
clap = { version = "4.5", features = ["derive"] }
plotnik-core.workspace = true
plotnik-langs = { path = "../plotnik-langs", version = "0.3.3", default-features = false }
plotnik-lib.workspace = true
plotnik-lib = { path = "../plotnik-lib", version = "0.3.3", default-features = false }
arborium-tree-sitter = "2.12.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
3 changes: 2 additions & 1 deletion crates/plotnik-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }
[dependencies]
plotnik-bytecode.workspace = true
plotnik-core.workspace = true
plotnik-langs = { workspace = true, optional = true }
plotnik-langs = { path = "../plotnik-langs", version = "0.3.3", default-features = false }
annotate-snippets = "0.12.9"
logos = "0.16.0"
indexmap = "2"
Expand All @@ -27,6 +27,7 @@ regex-syntax = "0.8"

[features]
default = ["plotnik-langs"]
plotnik-langs = ["plotnik-langs/default"]

[dev-dependencies]
insta = { version = "=1.46.1", features = ["yaml"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/plotnik-compiler/src/compile/collapse_up_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use plotnik_bytecode::Nav;

use super::collapse_up::collapse_up;
use super::CompileResult;
use super::collapse_up::collapse_up;
use crate::bytecode::{InstructionIR, Label, MatchIR};

#[test]
Expand Down
12 changes: 8 additions & 4 deletions crates/plotnik-compiler/src/compile/compile_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ fn compile_nested() {
fn compile_large_tagged_alternation() {
// Regression test: alternations with 30+ branches should compile
// by splitting epsilon transitions into a cascade.
shot_bytecode!(r#"
shot_bytecode!(
r#"
Q = [
A0: (identifier) @x0 A1: (identifier) @x1 A2: (identifier) @x2
A3: (identifier) @x3 A4: (identifier) @x4 A5: (identifier) @x5
Expand All @@ -49,7 +50,8 @@ fn compile_large_tagged_alternation() {
A24: (identifier) @x24 A25: (identifier) @x25 A26: (identifier) @x26
A27: (identifier) @x27 A28: (identifier) @x28 A29: (identifier) @x29
]
"#);
"#
);
}

#[test]
Expand All @@ -66,8 +68,10 @@ fn compile_unlabeled_alternation_5_branches_with_captures() {
fn compile_unlabeled_alternation_8_branches_with_captures() {
// Even more extreme: 8 branches means 14 pre-effects per branch (7 nulls + 7 sets).
// This requires 2 cascade steps per branch.
shot_bytecode!(r#"
shot_bytecode!(
r#"
Q = [(identifier) @a (number) @b (string) @c (binary_expression) @d
(call_expression) @e (member_expression) @f (array) @g (object) @h]
"#);
"#
);
}
2 changes: 1 addition & 1 deletion crates/plotnik-compiler/src/compile/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use super::collapse_prefix::collapse_prefix;
use super::collapse_up::collapse_up;
use super::dce::remove_unreachable;
use super::epsilon_elim::eliminate_epsilons;
use super::lower::lower;
use super::error::{CompileError, CompileResult};
use super::lower::lower;
use super::scope::StructScope;
use super::verify::debug_verify_ir_fingerprint;

Expand Down
66 changes: 38 additions & 28 deletions crates/plotnik-compiler/src/compile/lower_tests.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! Unit tests for the lowering pass.

use plotnik_bytecode::{EffectOpcode, Nav, MAX_MATCH_PAYLOAD_SLOTS, MAX_PRE_EFFECTS};
use plotnik_bytecode::{EffectOpcode, MAX_MATCH_PAYLOAD_SLOTS, MAX_PRE_EFFECTS, Nav};

use super::lower::lower;
use super::CompileResult;
use super::lower::lower;
use crate::bytecode::{EffectIR, InstructionIR, Label, MatchIR};

const MAX_POST_EFFECTS: usize = 7;
Expand All @@ -16,10 +16,12 @@ fn make_effect(_idx: u16) -> EffectIR {
#[test]
fn lower_no_overflow_unchanged() {
let mut result = CompileResult {
instructions: vec![MatchIR::at(Label(0))
.pre_effects((0..3).map(make_effect))
.next(Label(1))
.into()],
instructions: vec![
MatchIR::at(Label(0))
.pre_effects((0..3).map(make_effect))
.next(Label(1))
.into(),
],
def_entries: Default::default(),
preamble_entry: Label(0),
};
Expand All @@ -32,11 +34,13 @@ fn lower_no_overflow_unchanged() {
#[test]
fn lower_pre_effects_overflow() {
let mut result = CompileResult {
instructions: vec![MatchIR::at(Label(0))
.nav(Nav::Down)
.pre_effects((0..10).map(make_effect))
.next(Label(1))
.into()],
instructions: vec![
MatchIR::at(Label(0))
.nav(Nav::Down)
.pre_effects((0..10).map(make_effect))
.next(Label(1))
.into(),
],
def_entries: Default::default(),
preamble_entry: Label(0),
};
Expand All @@ -59,11 +63,13 @@ fn lower_pre_effects_overflow() {
#[test]
fn lower_post_effects_overflow() {
let mut result = CompileResult {
instructions: vec![MatchIR::at(Label(0))
.nav(Nav::Down)
.post_effects((0..10).map(make_effect))
.next(Label(1))
.into()],
instructions: vec![
MatchIR::at(Label(0))
.nav(Nav::Down)
.post_effects((0..10).map(make_effect))
.next(Label(1))
.into(),
],
def_entries: Default::default(),
preamble_entry: Label(0),
};
Expand All @@ -89,11 +95,13 @@ fn lower_post_effects_overflow() {
#[test]
fn lower_neg_fields_overflow() {
let mut result = CompileResult {
instructions: vec![MatchIR::at(Label(0))
.nav(Nav::Down)
.neg_fields(0..10)
.next(Label(1))
.into()],
instructions: vec![
MatchIR::at(Label(0))
.nav(Nav::Down)
.neg_fields(0..10)
.next(Label(1))
.into(),
],
def_entries: Default::default(),
preamble_entry: Label(0),
};
Expand Down Expand Up @@ -146,13 +154,15 @@ fn lower_successors_overflow() {
#[test]
fn lower_combined_overflow() {
let mut result = CompileResult {
instructions: vec![MatchIR::at(Label(0))
.nav(Nav::Down)
.pre_effects((0..10).map(make_effect))
.post_effects((0..10).map(make_effect))
.neg_fields(0..10)
.next(Label(1))
.into()],
instructions: vec![
MatchIR::at(Label(0))
.nav(Nav::Down)
.pre_effects((0..10).map(make_effect))
.post_effects((0..10).map(make_effect))
.neg_fields(0..10)
.next(Label(1))
.into(),
],
def_entries: Default::default(),
preamble_entry: Label(0),
};
Expand Down
Loading
Loading