Trait commands::parser::NodeOps
[−]
[src]
pub trait NodeOps {
fn accept<'text>(&self, parser: &mut Parser<'text>, token: Token, node_ref: &Rc<Node>);
fn acceptable(&self, parser: &Parser, node_ref: &Rc<Node>) -> bool;
fn complete<'text>(&self, token: Option<Token<'text>>) -> Completion<'text>;
fn matches(&self, parser: &Parser, token: Token) -> bool;
}The operations that every node must implement.
Required Methods
fn accept<'text>(&self, parser: &mut Parser<'text>, token: Token, node_ref: &Rc<Node>)
Accept this node with the given token as data.
By default, nothing needs to happen for accept.
fn acceptable(&self, parser: &Parser, node_ref: &Rc<Node>) -> bool
Can this node be accepted in the current parser state? By default, a node can be accepted when it hasn't been seen yet.
The node_ref is provided so that implementations have access to
the Rc<Node> value for the node rather than having to rely upon
self which won't be a Node, but the underlying CommandNode
or similar.
fn complete<'text>(&self, token: Option<Token<'text>>) -> Completion<'text>
Given a node and an optional token, provide the completion options.
By default, completion should complete for the name of the given node.
This is the expected behavior for CommandNode,
ParameterNameNode, as well as ParameterNode where the
ParameterKind is Flag.
fn matches(&self, parser: &Parser, token: Token) -> bool
By default, a node matches a token when the name of the
node starts with the token.
This is the expected behavior for CommandNode,
ParameterNameNode, as well as ParameterNode where the
ParameterKind is Flag.
Implementors
impl NodeOps for Nodeimpl NodeOps for RootNodeimpl NodeOps for CommandNodeimpl NodeOps for ParameterNameNodeimpl NodeOps for ParameterNode