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
66 changes: 30 additions & 36 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.4.5"
version = "0.4.6"
edition = "2021"
description = "A domain specific language for procedures."
authors = [ "Andrew Cowie" ]
Expand Down
4 changes: 4 additions & 0 deletions examples/minimal/SimpleList.tq
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1. Open door
2. Through door
3. Close door, accepting that it will make a smug and self-satisified
sigh with the knowledge of a job well done.
22 changes: 20 additions & 2 deletions src/parsing/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ impl<'i> Parser<'i> {
}

// Check if this Technique is a single set of one or more
// top-level Scope::SectionChunk
if is_section(self.source) && procedures.is_empty() {
// top-level Scopes (steps or sections)
if (is_section(self.source) || is_step(self.source)) && procedures.is_empty() {
while !self.is_finished() {
self.trim_whitespace();
if self.is_finished() {
Expand All @@ -269,6 +269,24 @@ impl<'i> Parser<'i> {
self.skip_to_next_line();
}
}
} else if is_step_dependent(self.source) {
match self.read_step_dependent() {
Ok(step) => sections.push(step),
Err(error) => {
self.problems
.push(error);
self.skip_to_next_line();
}
}
} else if is_step_parallel(self.source) {
match self.read_step_parallel() {
Ok(step) => sections.push(step),
Err(error) => {
self.problems
.push(error);
self.skip_to_next_line();
}
}
} else {
self.problems
.push(ParsingError::Unrecognized(self.offset, 0));
Expand Down
12 changes: 8 additions & 4 deletions tests/parsing/samples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ use std::path::Path;

use technique::parsing;

#[test]
fn ensure_parse() {
let dir = Path::new("tests/samples/");

fn check_directory(dir: &Path) {
// Ensure the directory exists
assert!(dir.exists(), "samples directory missing");

let entries = fs::read_dir(dir).expect("Failed to read samples directory");
Expand Down Expand Up @@ -49,3 +47,9 @@ fn ensure_parse() {
);
}
}

#[test]
fn ensure_parse() {
check_directory(Path::new("tests/samples/"));
check_directory(Path::new("examples/minimal/"));
}