From 28d9af4a8c75ed15e0b0042d834ae197290dd086 Mon Sep 17 00:00:00 2001 From: ec798 Date: Sat, 5 Oct 2024 21:42:08 -0400 Subject: [PATCH 1/6] inital pathing for debugger --- interp/src/debugger/debugger_core.rs | 21 ++++++++++++- .../src/flatten/structures/environment/env.rs | 6 ++++ .../structures/environment/program_counter.rs | 31 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/interp/src/debugger/debugger_core.rs b/interp/src/debugger/debugger_core.rs index 6b34dc8ef7..ebc5b12003 100644 --- a/interp/src/debugger/debugger_core.rs +++ b/interp/src/debugger/debugger_core.rs @@ -220,6 +220,22 @@ impl + Clone> Debugger { Ok(()) } + // Print executing points + pub fn print_executing(&self) { + let env = self.interpreter.env(); + let ctx = self.program_context.as_ref(); + + let mut pc_iterable = env.pc_iter(); + + // For now we do all control points: + let mut item = pc_iterable.next(); + while item.is_some() { + let control_point = item.unwrap(); + println!("{}", control_point.string_path(ctx)); + item = pc_iterable.next(); + } + } + // so on and so forth /// The main loop of the debugger. This function is the entry point for the @@ -281,7 +297,10 @@ impl + Clone> Debugger { }; match comm { - Command::Step(n) => self.do_step(n)?, + Command::Step(n) => { + self.print_executing(); + self.do_step(n)? + } Command::StepOver(target) => { self.do_step_over(target)?; } diff --git a/interp/src/flatten/structures/environment/env.rs b/interp/src/flatten/structures/environment/env.rs index 98e3c96bea..2fbfd58fbc 100644 --- a/interp/src/flatten/structures/environment/env.rs +++ b/interp/src/flatten/structures/environment/env.rs @@ -46,6 +46,7 @@ use owo_colors::OwoColorize; use slog::warn; use std::fmt::Debug; use std::fmt::Write; +use std::slice::Iter; pub type PortMap = IndexedMap; @@ -284,6 +285,11 @@ impl + Clone> Environment { pub fn ctx(&self) -> &Context { self.ctx.as_ref() } + + pub fn pc_iter(&self) -> Iter<'_, ControlPoint> { + self.pc.iter() + } + /// Returns the full name and port list of each cell in the context pub fn iter_cells( &self, diff --git a/interp/src/flatten/structures/environment/program_counter.rs b/interp/src/flatten/structures/environment/program_counter.rs index 7b1e52f95d..7ef947bb2a 100644 --- a/interp/src/flatten/structures/environment/program_counter.rs +++ b/interp/src/flatten/structures/environment/program_counter.rs @@ -56,6 +56,37 @@ impl ControlPoint { false } } + + /// Returns a string showing the path from the root node to input node. + /// How to get context? + pub fn string_path(&self, ctx: &Context) -> String { + // Does it matter if it takes ownership? + let path = SearchPath::find_path_from_root(self.control_node_idx, ctx); + let control_map = &ctx.primary.control; + let mut string_path = String::from("main::"); + let mut first = true; + for search_node in path.path { + // The control_idx should exist in the map, so we shouldn't worry about it + // exploding. + let seperator = if first { "" } else { "_" }; + first = false; + + let control_idx = search_node.node; + let control_node = control_map.get(control_idx).unwrap(); + let control_type = match control_node { + ControlNode::Empty(_) => "empty", + ControlNode::Enable(_) => "enable", + ControlNode::Seq(_) => "seq", + ControlNode::Par(_) => "par", + ControlNode::If(_) => "if", + ControlNode::While(_) => "while", + ControlNode::Repeat(_) => "repeat", + ControlNode::Invoke(_) => "invoke", + }; + string_path = string_path + seperator + control_type; + } + string_path + } } #[derive(Debug, Clone)] From 17fed18954d41c4369428cfb0daf9ae30e113751 Mon Sep 17 00:00:00 2001 From: ec798 Date: Mon, 4 Nov 2024 23:30:43 -0500 Subject: [PATCH 2/6] Finished implementing print node command for debugger --- .../src/debugger/commands/command_parser.rs | 17 +++-- interp/src/debugger/commands/commands.pest | 3 +- interp/src/debugger/commands/core.rs | 9 ++- interp/src/debugger/debugger_core.rs | 36 ++++------- .../src/flatten/structures/environment/env.rs | 16 +++++ .../structures/environment/program_counter.rs | 63 ++++++++++++++----- 6 files changed, 98 insertions(+), 46 deletions(-) diff --git a/interp/src/debugger/commands/command_parser.rs b/interp/src/debugger/commands/command_parser.rs index cd512c5a17..9cf336a3ad 100644 --- a/interp/src/debugger/commands/command_parser.rs +++ b/interp/src/debugger/commands/command_parser.rs @@ -1,5 +1,8 @@ -use super::core::{ - Command, ParsedBreakPointID, ParsedGroupName, PrintMode, WatchPosition, +use super::{ + core::{ + Command, ParsedBreakPointID, ParsedGroupName, PrintMode, WatchPosition, + }, + PrintCommand, }; use pest_consume::{match_nodes, Error, Parser}; @@ -20,10 +23,15 @@ impl CommandParser { fn EOI(_input: Node) -> ParseResult<()> { Ok(()) } + fn code_calyx(_input: Node) -> ParseResult<()> { Ok(()) } + fn code_nodes(_input: Node) -> ParseResult<()> { + Ok(()) + } + // ---------------------- fn help(_input: Node) -> ParseResult { @@ -59,8 +67,9 @@ impl CommandParser { fn comm_where(input: Node) -> ParseResult { Ok(match_nodes!(input.into_children(); - [code_calyx(_)] => Command::PrintPC(true), - [] => Command::PrintPC(false), + [code_calyx(_)] => Command::PrintPC(PrintCommand::PrintCalyx), + [code_nodes(_)] => Command::PrintPC(PrintCommand::PrintNodes), + [] => Command::PrintPC(PrintCommand::Normal), )) } diff --git a/interp/src/debugger/commands/commands.pest b/interp/src/debugger/commands/commands.pest index 799971648c..7a1920c680 100644 --- a/interp/src/debugger/commands/commands.pest +++ b/interp/src/debugger/commands/commands.pest @@ -14,6 +14,7 @@ pc_s = { ^"s" } pc_ufx = { ^"u." ~ num } pc_sfx = { ^"s." ~ num } code_calyx = { ^"calyx" } +code_nodes = {^"nodes"} print_code = { "\\" ~ (pc_ufx | pc_sfx | pc_s | pc_un) @@ -67,7 +68,7 @@ disable_watch = { (^"disable-watch " | ^"disw ") ~ brk_id+ } exit = { ^"exit" | ^"quit" } -comm_where = { (^"where" | "pc") ~ (code_calyx)? } +comm_where = { (^"where" | "pc") ~ (code_calyx | code_nodes)? } explain = { ^"explain" } diff --git a/interp/src/debugger/commands/core.rs b/interp/src/debugger/commands/core.rs index 46f86279bb..37148ef8a0 100644 --- a/interp/src/debugger/commands/core.rs +++ b/interp/src/debugger/commands/core.rs @@ -299,6 +299,13 @@ impl From<(Vec, Option, PrintMode)> for PrintTuple { } } +// Different types of printing commands +pub enum PrintCommand { + Normal, + PrintCalyx, + PrintNodes, +} + /// A command that can be sent to the debugger. pub enum Command { /// Advance the execution by a given number of steps (cycles). @@ -345,7 +352,7 @@ pub enum Command { PrintMode, ), /// Print the current program counter - PrintPC(bool), + PrintPC(PrintCommand), /// Show command examples Explain, /// Restart the debugger from the beginning of the execution. Command history, breakpoints, watchpoints, etc. are preserved. diff --git a/interp/src/debugger/debugger_core.rs b/interp/src/debugger/debugger_core.rs index ebc5b12003..9c38678f21 100644 --- a/interp/src/debugger/debugger_core.rs +++ b/interp/src/debugger/debugger_core.rs @@ -5,7 +5,9 @@ use super::{ source::structures::NewSourceMap, }; use crate::{ - debugger::{source::SourceMap, unwrap_error_message}, + debugger::{ + commands::PrintCommand, source::SourceMap, unwrap_error_message, + }, errors::{InterpreterError, InterpreterResult}, flatten::{ flat_ir::prelude::GroupIdx, @@ -220,22 +222,6 @@ impl + Clone> Debugger { Ok(()) } - // Print executing points - pub fn print_executing(&self) { - let env = self.interpreter.env(); - let ctx = self.program_context.as_ref(); - - let mut pc_iterable = env.pc_iter(); - - // For now we do all control points: - let mut item = pc_iterable.next(); - while item.is_some() { - let control_point = item.unwrap(); - println!("{}", control_point.string_path(ctx)); - item = pc_iterable.next(); - } - } - // so on and so forth /// The main loop of the debugger. This function is the entry point for the @@ -297,10 +283,7 @@ impl + Clone> Debugger { }; match comm { - Command::Step(n) => { - self.print_executing(); - self.do_step(n)? - } + Command::Step(n) => self.do_step(n)?, Command::StepOver(target) => { self.do_step_over(target)?; } @@ -379,10 +362,15 @@ impl + Clone> Debugger { Command::InfoWatch => self .debugging_context .print_watchpoints(self.interpreter.env()), - Command::PrintPC(_override_flag) => { - self.interpreter.print_pc(); - } + Command::PrintPC(print_mode) => match print_mode { + PrintCommand::Normal | PrintCommand::PrintCalyx => { + self.interpreter.print_pc(); + } + PrintCommand::PrintNodes => { + self.interpreter.print_pc_string(); + } + }, Command::Explain => { print!("{}", Command::get_explain_string()) } diff --git a/interp/src/flatten/structures/environment/env.rs b/interp/src/flatten/structures/environment/env.rs index 2fbfd58fbc..e116b8aae7 100644 --- a/interp/src/flatten/structures/environment/env.rs +++ b/interp/src/flatten/structures/environment/env.rs @@ -727,6 +727,18 @@ impl + Clone> Environment { } } + pub fn print_pc_string(&self) { + let current_nodes = self.pc.iter(); + let ctx = &self.ctx.as_ref(); + for node in current_nodes { + println!( + "{}: {}", + self.get_full_name(node.comp), + node.string_path(ctx) + ); + } + } + fn get_name_from_cell_and_parent( &self, parent: GlobalCellIdx, @@ -1274,6 +1286,10 @@ impl + Clone> Simulator { self.env.print_pc() } + pub fn print_pc_string(&self) { + self.env.print_pc_string() + } + /// Pins the port with the given name to the given value. This may only be /// used for input ports on the entrypoint component (excluding the go port) /// and will panic if used otherwise. Intended for external use. diff --git a/interp/src/flatten/structures/environment/program_counter.rs b/interp/src/flatten/structures/environment/program_counter.rs index 7ef947bb2a..587d9696e1 100644 --- a/interp/src/flatten/structures/environment/program_counter.rs +++ b/interp/src/flatten/structures/environment/program_counter.rs @@ -63,27 +63,58 @@ impl ControlPoint { // Does it matter if it takes ownership? let path = SearchPath::find_path_from_root(self.control_node_idx, ctx); let control_map = &ctx.primary.control; - let mut string_path = String::from("main::"); - let mut first = true; + let mut string_path = String::from(""); + let mut count = -1; + let mut body = false; + let mut if_branches: HashMap = HashMap::new(); for search_node in path.path { // The control_idx should exist in the map, so we shouldn't worry about it - // exploding. - let seperator = if first { "" } else { "_" }; - first = false; - + // exploding. First SearchNode is root, hence "." let control_idx = search_node.node; let control_node = control_map.get(control_idx).unwrap(); - let control_type = match control_node { - ControlNode::Empty(_) => "empty", - ControlNode::Enable(_) => "enable", - ControlNode::Seq(_) => "seq", - ControlNode::Par(_) => "par", - ControlNode::If(_) => "if", - ControlNode::While(_) => "while", - ControlNode::Repeat(_) => "repeat", - ControlNode::Invoke(_) => "invoke", + match control_node { + // These are terminal nodes + // ControlNode::Empty(_) => "empty", + // ControlNode::Invoke(_) => "invoke", + // ControlNode::Enable(_) => "enable", + + // These have unbounded children + // ControlNode::Seq(_) => "seq", + // ControlNode::Par(_) => "par", + + // Special cases + ControlNode::If(if_node) => { + if_branches.insert(if_node.tbranch(), String::from("t")); + if_branches.insert(if_node.tbranch(), String::from("f")); + } + ControlNode::While(_) => { + body = true; + } + ControlNode::Repeat(_) => { + body = true; + } + _ => {} + }; + // At root, at end to process logic above. + if string_path == String::from("") { + string_path = string_path + "."; + continue; + } + let control_type = if body { + body = false; + count = -1; + "b" + } else { + if if_branches.contains_key(&control_idx) { + let (_, branch) = + if_branches.get_key_value(&control_idx).unwrap(); + branch + } else { + count += 1; + &count.to_string() + } }; - string_path = string_path + seperator + control_type; + string_path = string_path + "-" + control_type; } string_path } From 4654907a4a84ec754aa39e2051ae30f81d426125 Mon Sep 17 00:00:00 2001 From: ec798 Date: Sat, 9 Nov 2024 17:36:52 -0500 Subject: [PATCH 3/6] original parser setup --- interp/src/debugger/commands/core.rs | 7 +++ interp/src/debugger/commands/mod.rs | 1 + interp/src/debugger/commands/path_parser.pest | 11 ++++ interp/src/debugger/commands/path_parser.rs | 63 +++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 interp/src/debugger/commands/path_parser.pest create mode 100644 interp/src/debugger/commands/path_parser.rs diff --git a/interp/src/debugger/commands/core.rs b/interp/src/debugger/commands/core.rs index 37148ef8a0..cb7c82fbfc 100644 --- a/interp/src/debugger/commands/core.rs +++ b/interp/src/debugger/commands/core.rs @@ -298,6 +298,13 @@ impl From<(Vec, Option, PrintMode)> for PrintTuple { PrintTuple(val.0, val.1, val.2) } } +pub enum ParsePath { + Root, + Body, + Offset(u32), + Separator, + End, +} // Different types of printing commands pub enum PrintCommand { diff --git a/interp/src/debugger/commands/mod.rs b/interp/src/debugger/commands/mod.rs index 452108f4ea..19f20de743 100644 --- a/interp/src/debugger/commands/mod.rs +++ b/interp/src/debugger/commands/mod.rs @@ -1,6 +1,7 @@ //! This module contains the structures for the debugger commands pub(crate) mod command_parser; pub mod core; +mod path_parser; pub use command_parser::parse_command; pub use core::Command; diff --git a/interp/src/debugger/commands/path_parser.pest b/interp/src/debugger/commands/path_parser.pest new file mode 100644 index 0000000000..306f4b5ec1 --- /dev/null +++ b/interp/src/debugger/commands/path_parser.pest @@ -0,0 +1,11 @@ +root = { "." } + +seperator = { "-" } + +body = { "b" } + +num = { ASCII_DIGIT+ } + +clause = { seperator ~ (body | num) } + +path = { SOI ~ root ~ clause* ~ EOI } diff --git a/interp/src/debugger/commands/path_parser.rs b/interp/src/debugger/commands/path_parser.rs new file mode 100644 index 0000000000..5b3898e611 --- /dev/null +++ b/interp/src/debugger/commands/path_parser.rs @@ -0,0 +1,63 @@ +use super::core::ParsePath; + +use pest_consume::{match_nodes, Error, Parser}; + +type ParseResult = std::result::Result>; +type Node<'i> = pest_consume::Node<'i, Rule, ()>; + +// include the grammar file so that Cargo knows to rebuild this file on grammar changes +const _GRAMMAR: &str = include_str!("path_parser.pest"); + +#[derive(Parser)] +#[grammar = "debugger/commands/path_parser.pest"] + +pub struct PathParser; + +#[pest_consume::parser] +impl PathParser { + fn EOI(_input: Node) -> ParseResult<()> { + Ok(()) + } + + fn root(_input: Node) -> ParseResult<()> { + Ok(()) + } + + fn body(_input: Node) -> ParseResult<()> { + Ok(()) + } + + fn num(input: Node) -> ParseResult { + input + .as_str() + .parse::() + .map_err(|_| input.error("Expected non-negative number")) + } + + fn clause(input: Node) -> ParseResult { + Ok(match_nodes!(input.into_children(); + [num(n)] => ParsePath::Offset(n), + [body(_)] => ParsePath::Body, + [] => ParsePath::Separator, + )) + } + + fn path(input: Node) -> ParseResult { + Ok(match_nodes!(input.into_children(); + [root(_), EOI(_)] => ParsePath::Root, + [clause(c).., EOI(_)] => c, + [EOI(_)] => ParsePath::End, + )) + } +} + +// Parse the path +pub fn parse_path(input_str: &str) -> Result, Error> { + let mut path_vec = vec![]; + let entries = PathParser::parse(Rule::path, input_str)?; + let entry = entries.single()?; + + path_vec.extend(PathParser::path(entry)); + + Ok(path_vec) +} From 89313737fb5ec66fbffaf09d21e54f65c98fcf40 Mon Sep 17 00:00:00 2001 From: ec798 Date: Tue, 12 Nov 2024 01:31:08 -0500 Subject: [PATCH 4/6] implemented path parser and tests --- interp/src/debugger/commands/core.rs | 29 ++++++- interp/src/debugger/commands/path_parser.pest | 4 +- interp/src/debugger/commands/path_parser.rs | 76 ++++++++++++++++--- 3 files changed, 92 insertions(+), 17 deletions(-) diff --git a/interp/src/debugger/commands/core.rs b/interp/src/debugger/commands/core.rs index cb7c82fbfc..35c2b9cb54 100644 --- a/interp/src/debugger/commands/core.rs +++ b/interp/src/debugger/commands/core.rs @@ -6,6 +6,7 @@ use owo_colors::OwoColorize; use std::{ fmt::{Display, Write}, marker::PhantomData, + vec::IntoIter, }; use crate::{ @@ -298,12 +299,32 @@ impl From<(Vec, Option, PrintMode)> for PrintTuple { PrintTuple(val.0, val.1, val.2) } } -pub enum ParsePath { - Root, + +#[derive(Debug, PartialEq, Clone)] +pub enum ParseNodes { Body, Offset(u32), - Separator, - End, + If(bool), +} +pub struct ParsePath { + nodes: Vec, +} + +impl ParsePath { + pub fn new(nodes: Vec) -> ParsePath { + ParsePath { nodes } + } + + pub fn get_path(&self) -> Vec { + self.nodes.clone() + } + + pub fn from_iter(iter: I) -> ParsePath + where + I: IntoIterator, + { + ParsePath::new(iter.into_iter().collect()) + } } // Different types of printing commands diff --git a/interp/src/debugger/commands/path_parser.pest b/interp/src/debugger/commands/path_parser.pest index 306f4b5ec1..14669eb256 100644 --- a/interp/src/debugger/commands/path_parser.pest +++ b/interp/src/debugger/commands/path_parser.pest @@ -6,6 +6,8 @@ body = { "b" } num = { ASCII_DIGIT+ } -clause = { seperator ~ (body | num) } +branch = {"t" | "f"} + +clause = { seperator ~ (body | num | branch) } path = { SOI ~ root ~ clause* ~ EOI } diff --git a/interp/src/debugger/commands/path_parser.rs b/interp/src/debugger/commands/path_parser.rs index 5b3898e611..856f0ed76f 100644 --- a/interp/src/debugger/commands/path_parser.rs +++ b/interp/src/debugger/commands/path_parser.rs @@ -1,4 +1,4 @@ -use super::core::ParsePath; +use super::{core::ParseNodes, ParsePath}; use pest_consume::{match_nodes, Error, Parser}; @@ -27,6 +27,10 @@ impl PathParser { Ok(()) } + fn seperator(_input: Node) -> ParseResult<()> { + Ok(()) + } + fn num(input: Node) -> ParseResult { input .as_str() @@ -34,30 +38,78 @@ impl PathParser { .map_err(|_| input.error("Expected non-negative number")) } - fn clause(input: Node) -> ParseResult { + fn branch(input: Node) -> ParseResult { + let b = input.as_str(); + let result = if b == "f" { false } else { true }; + Ok(result) + } + + fn clause(input: Node) -> ParseResult { Ok(match_nodes!(input.into_children(); - [num(n)] => ParsePath::Offset(n), - [body(_)] => ParsePath::Body, - [] => ParsePath::Separator, + [seperator(_), num(n)] => ParseNodes::Offset(n), + [seperator(_), body(_)] => ParseNodes::Body, + [seperator(_), branch(b)] => ParseNodes::If(b) )) } fn path(input: Node) -> ParseResult { Ok(match_nodes!(input.into_children(); - [root(_), EOI(_)] => ParsePath::Root, - [clause(c).., EOI(_)] => c, - [EOI(_)] => ParsePath::End, + [root(_), clause(c).., EOI(_)] => ParsePath::from_iter(c), )) } } // Parse the path -pub fn parse_path(input_str: &str) -> Result, Error> { - let mut path_vec = vec![]; +pub fn parse_path(input_str: &str) -> Result> { let entries = PathParser::parse(Rule::path, input_str)?; let entry = entries.single()?; - path_vec.extend(PathParser::path(entry)); + PathParser::path(entry) +} + +#[cfg(test)] +#[test] +fn root() { + let path = parse_path(".").unwrap(); + dbg!(path.get_path()); + assert_eq!(path.get_path(), Vec::new()) +} + +#[test] +fn body() { + let path = parse_path(".-b").unwrap(); + dbg!(path.get_path()); + assert_eq!(path.get_path(), vec![ParseNodes::Body]) +} + +#[test] +fn branch() { + let path = parse_path(".-f").unwrap(); + dbg!(path.get_path()); + assert_eq!(path.get_path(), vec![ParseNodes::If(false)]) +} + +#[test] +fn offset() { + let path = parse_path(".-0-1").unwrap(); + dbg!(path.get_path()); + assert_eq!( + path.get_path(), + vec![ParseNodes::Offset(0), ParseNodes::Offset(1)] + ) +} - Ok(path_vec) +#[test] +fn multiple() { + let path = parse_path(".-0-1-b-t").unwrap(); + dbg!(path.get_path()); + assert_eq!( + path.get_path(), + vec![ + ParseNodes::Offset(0), + ParseNodes::Offset(1), + ParseNodes::Body, + ParseNodes::If(true) + ] + ) } From 760bb010bc95aada66a7185453ca9fea0386979a Mon Sep 17 00:00:00 2001 From: ec798 Date: Mon, 18 Nov 2024 15:26:26 -0500 Subject: [PATCH 5/6] Clippy complaints --- interp/src/debugger/commands/path_parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interp/src/debugger/commands/path_parser.rs b/interp/src/debugger/commands/path_parser.rs index 856f0ed76f..e1c317b7c9 100644 --- a/interp/src/debugger/commands/path_parser.rs +++ b/interp/src/debugger/commands/path_parser.rs @@ -40,7 +40,7 @@ impl PathParser { fn branch(input: Node) -> ParseResult { let b = input.as_str(); - let result = if b == "f" { false } else { true }; + let result = b != "f"; Ok(result) } From adfadb160dc423b0ea78353785e67dca4eab12ef Mon Sep 17 00:00:00 2001 From: ec798 Date: Tue, 26 Nov 2024 08:46:44 -0500 Subject: [PATCH 6/6] revision --- interp/src/debugger/commands/core.rs | 12 ++++++++---- interp/src/debugger/commands/path_parser.pest | 4 ++-- interp/src/debugger/commands/path_parser.rs | 13 +++++++------ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/interp/src/debugger/commands/core.rs b/interp/src/debugger/commands/core.rs index 3d69cf7489..5d5e9689af 100644 --- a/interp/src/debugger/commands/core.rs +++ b/interp/src/debugger/commands/core.rs @@ -299,6 +299,11 @@ impl From<(Vec, Option, PrintMode)> for PrintTuple { } } +/// ParseNodes enum is used to represent what child to traverse with respect to +/// the current ControlIdx. +/// Body defines that we should go into the body of a while or repeat. +/// Offset defines which child to go to. +/// If defines whether we should go to the true or false branch next #[derive(Debug, PartialEq, Clone)] pub enum ParseNodes { Body, @@ -317,11 +322,10 @@ impl ParsePath { pub fn get_path(&self) -> Vec { self.nodes.clone() } +} - pub fn from_iter(iter: I) -> ParsePath - where - I: IntoIterator, - { +impl FromIterator for ParsePath { + fn from_iter>(iter: I) -> Self { ParsePath::new(iter.into_iter().collect()) } } diff --git a/interp/src/debugger/commands/path_parser.pest b/interp/src/debugger/commands/path_parser.pest index 14669eb256..f95eaff145 100644 --- a/interp/src/debugger/commands/path_parser.pest +++ b/interp/src/debugger/commands/path_parser.pest @@ -1,6 +1,6 @@ root = { "." } -seperator = { "-" } +separator = { "-" } body = { "b" } @@ -8,6 +8,6 @@ num = { ASCII_DIGIT+ } branch = {"t" | "f"} -clause = { seperator ~ (body | num | branch) } +clause = { separator ~ (body | num | branch) } path = { SOI ~ root ~ clause* ~ EOI } diff --git a/interp/src/debugger/commands/path_parser.rs b/interp/src/debugger/commands/path_parser.rs index e1c317b7c9..5739da65b9 100644 --- a/interp/src/debugger/commands/path_parser.rs +++ b/interp/src/debugger/commands/path_parser.rs @@ -27,7 +27,7 @@ impl PathParser { Ok(()) } - fn seperator(_input: Node) -> ParseResult<()> { + fn separator(_input: Node) -> ParseResult<()> { Ok(()) } @@ -46,9 +46,9 @@ impl PathParser { fn clause(input: Node) -> ParseResult { Ok(match_nodes!(input.into_children(); - [seperator(_), num(n)] => ParseNodes::Offset(n), - [seperator(_), body(_)] => ParseNodes::Body, - [seperator(_), branch(b)] => ParseNodes::If(b) + [separator(_), num(n)] => ParseNodes::Offset(n), + [separator(_), body(_)] => ParseNodes::Body, + [separator(_), branch(b)] => ParseNodes::If(b) )) } @@ -60,11 +60,12 @@ impl PathParser { } // Parse the path -pub fn parse_path(input_str: &str) -> Result> { +#[allow(dead_code)] +pub fn parse_path(input_str: &str) -> Result>> { let entries = PathParser::parse(Rule::path, input_str)?; let entry = entries.single()?; - PathParser::path(entry) + PathParser::path(entry).map_err(Box::new) } #[cfg(test)]