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
13 changes: 3 additions & 10 deletions examples/prototype/ChristmasTurkey.tq
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ roast_turkey(i) : Ingredients -> Turkey
# Roast Turkey

@chef
1. Set oven temperature { <oven>(180 °C) ~ temp }
1. Set oven temperature { oven(180 °C) ~ temp }
2. Place bacon strips onto bird
3. Put bird into oven
4. Set timer for roasting { timer(3 h) ~ t }
4. Set timer for roasting { timer(3 hr) ~ t }
5. Record temperature
{
[
Expand Down Expand Up @@ -179,17 +179,10 @@ Certainly I always hated my Aunt at holidays for making me dry dishes with a
dish towel when they would perfectly well air dry by themselves.

@*
1. Turn off oven { <oven>(0 °C) }
1. Turn off oven { oven(0 °C) }
2. Put knives away { <knives_away> }
3. Turn lights out { <lights_out> }

oven(temp) : Temperature -> ()

# Set oven temperature

@chef
- Set temperature to { "oven at { temp }" }

knives_away :

# Put knives away
Expand Down
30 changes: 28 additions & 2 deletions src/domain/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
//! projecting these into domain-specific models.

use crate::language::{
Attribute, Descriptive, Document, Element, Expression, Paragraph, Procedure, Response, Scope,
Target, Technique,
Attribute, Descriptive, Document, Element, Expression, Pair, Paragraph, Procedure, Response,
Scope, Target, Technique,
};

impl<'i> Document<'i> {
Expand Down Expand Up @@ -136,6 +136,32 @@ impl<'i> Scope<'i> {
}
}

/// Returns an iterator over place names if this is an AttributeBlock.
pub fn places(&self) -> impl Iterator<Item = &'i str> {
match self {
Scope::AttributeBlock { attributes, .. } => attributes
.iter()
.filter_map(|attr| match attr {
Attribute::Place(id) => Some(id.0),
_ => None,
})
.collect::<Vec<_>>()
.into_iter(),
_ => Vec::new().into_iter(),
}
}

/// 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,
},
_ => None,
}
}

/// Returns true if this scope represents a step (dependent or parallel).
pub fn is_step(&self) -> bool {
matches!(
Expand Down
1 change: 1 addition & 0 deletions src/domain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod adapter;
pub mod checklist;
pub mod engine;
pub mod procedure;
pub mod recipe;
pub(crate) mod serialize;
pub mod source;

Expand Down
Loading
Loading