nonterminal() constructor function
This commit is contained in:
parent
77e0d639c2
commit
fc7c86be1a
@ -19,6 +19,16 @@ impl CommandTree {
|
|||||||
pub fn term(s: &str, help: Option<&str>) -> CommandTree {
|
pub fn term(s: &str, help: Option<&str>) -> CommandTree {
|
||||||
CommandTree::Terminal {name: s.to_string(), help_msg: help.map(|x| x.to_string()), function: None }
|
CommandTree::Terminal {name: s.to_string(), help_msg: help.map(|x| x.to_string()), function: None }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn nonterm(s: &str, help: Option<&str>, children: Vec<CommandTree>) -> CommandTree {
|
||||||
|
CommandTree::NonTerminal {
|
||||||
|
name: s.to_string(),
|
||||||
|
help_msg: help.map(|x| x.to_string()),
|
||||||
|
children,
|
||||||
|
function: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_cmd(&self) -> &str {
|
pub fn get_cmd(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
CommandTree::Terminal { name, .. } => name.as_str(),
|
CommandTree::Terminal { name, .. } => name.as_str(),
|
||||||
|
@ -137,23 +137,26 @@ impl Repl {
|
|||||||
CommandTree::term("exit", Some("exit the REPL")),
|
CommandTree::term("exit", Some("exit the REPL")),
|
||||||
CommandTree::term("quit", Some("exit the REPL")),
|
CommandTree::term("quit", Some("exit the REPL")),
|
||||||
CommandTree::term("help", Some("Print this help message")),
|
CommandTree::term("help", Some("Print this help message")),
|
||||||
CommandTree::NonTerminal { name: format!("debug"), children: vec![
|
CommandTree::nonterm("debug",
|
||||||
|
Some("show or hide pass debug info for a given pass, or display the names of all passes, or turn timing on/off"),
|
||||||
|
vec![
|
||||||
CommandTree::term("passes", None),
|
CommandTree::term("passes", None),
|
||||||
CommandTree::NonTerminal { name: format!("show"), children: passes_directives.clone(), help_msg: None, function: None },
|
CommandTree::nonterm("show", None, passes_directives.clone()),
|
||||||
CommandTree::NonTerminal{ name: format!("hide"), children: passes_directives.clone(), help_msg: None, function: None},
|
CommandTree::nonterm("hide", None, passes_directives.clone()),
|
||||||
CommandTree::NonTerminal { name: format!("timing"), children: vec![
|
CommandTree::nonterm("timing", None, vec![
|
||||||
CommandTree::term("on", None),
|
CommandTree::term("on", None),
|
||||||
CommandTree::term("off", None),
|
CommandTree::term("off", None),
|
||||||
], help_msg: None, function: None },
|
])
|
||||||
], help_msg: Some(format!("show or hide pass debug info for a given pass, or display the names of all passes, or turn timing on/off")),
|
]
|
||||||
function: None
|
),
|
||||||
},
|
CommandTree::nonterm("lang",
|
||||||
CommandTree::NonTerminal{ name: format!("lang"), children: vec![
|
Some("switch between languages, or go directly to a langauge by name"),
|
||||||
|
vec![
|
||||||
CommandTree::term("next", None),
|
CommandTree::term("next", None),
|
||||||
CommandTree::term("prev", None),
|
CommandTree::term("prev", None),
|
||||||
CommandTree::NonTerminal{ name: format!("go"), children: vec![], help_msg: None, function: None },
|
CommandTree::nonterm("go", None, vec![]),
|
||||||
], help_msg: Some(format!("switch between languages, or go directly to a langauge by name")),
|
]
|
||||||
function: None },
|
),
|
||||||
CommandTree::term("doc", Some("Get language-specific help for an item")),
|
CommandTree::term("doc", Some("Get language-specific help for an item")),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user