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
4 changes: 2 additions & 2 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Validate toolchain
run: |
echo "RUST_VERSION=$(rustc --version | cut -d ' ' -f 2)" >> ${GITHUB_ENV}

- uses: actions/cache@v4
- uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:

steps:
- name: Clone project
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Validate toolchain
shell: bash
run: |
echo "RUST_VERSION=$(rustc --version | cut -d ' ' -f 2)" >> ${GITHUB_ENV}

- uses: actions/cache@v4
- uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
Expand Down
138 changes: 32 additions & 106 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "technique"
version = "0.5.3"
version = "0.5.4"
edition = "2021"
description = "A domain specific language for procedures."
authors = [ "Andrew Cowie" ]
Expand Down
24 changes: 19 additions & 5 deletions src/domain/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,14 @@ impl<'i> Scope<'i> {
/// Returns the tablet pairs if this is a CodeBlock containing a Tablet.
pub fn tablet(&self) -> Option<&[Pair<'i>]> {
match self {
Scope::CodeBlock { expression, .. } => match expression {
Expression::Tablet(pairs) => Some(pairs),
_ => None,
},
Scope::CodeBlock { expressions, .. } => {
if expressions.len() == 1 {
if let Expression::Tablet(pairs) = &expressions[0] {
return Some(pairs);
}
}
None
}
_ => None,
}
}
Expand Down Expand Up @@ -189,7 +193,16 @@ impl<'i> Scope<'i> {
/// Returns the expression of a CodeBlock as readable text.
pub fn expression_text(&self) -> Option<String> {
match self {
Scope::CodeBlock { expression, .. } => Some(render_expression(expression)),
Scope::CodeBlock { expressions, .. } => {
if expressions.is_empty() {
return None;
}
let texts: Vec<String> = expressions
.iter()
.map(render_expression)
.collect();
Some(texts.join("\n"))
}
_ => None,
}
}
Expand Down Expand Up @@ -331,6 +344,7 @@ fn render_expression(expr: &Expression) -> String {
Expression::Number(Numeric::Scientific(q)) => q.to_string(),
Expression::Number(Numeric::Integral(n)) => n.to_string(),
Expression::Tablet(_) => String::new(),
Expression::Separator => String::new(),
}
}

Expand Down
Loading