pub trait BlockVisitor: HasDiagnostics + Sized {
// Provided methods
fn line_number(&mut self, n: u32, span: Span) { ... }
fn comment(&mut self, value: &str, span: Span) { ... }
fn program_number(&mut self, number: u32, span: Span) { ... }
fn program_delimiter(&mut self, _span: Span) { ... }
fn word_address(&mut self, _letter: char, _value: Value<'_>, _span: Span) { ... }
fn start_general_code(
&mut self,
number: Number,
) -> ControlFlow<impl CommandVisitor + '_> { ... }
fn start_miscellaneous_code(
&mut self,
number: Number,
) -> ControlFlow<impl CommandVisitor + '_> { ... }
fn start_tool_change_code(
&mut self,
number: Number,
) -> ControlFlow<impl CommandVisitor + '_> { ... }
fn end_line(self, span: Span) { ... }
}Expand description
Visitor for a single block (line) of g-code.
The parser creates a block visitor from ProgramVisitor::start_block and
then calls the methods below in order. Terminals (line number, comment,
program number) are reported with a single call; each G/M/O/T command on the
line is entered via one of the start_*_code methods, which return a
CommandVisitor for that command. When the line ends, the parser calls
end_line, consuming this visitor.
§Call order
- Optional:
line_number,comment,program_number(each at most once per block, in any order depending on source). - Zero or more commands:
start_general_code,start_miscellaneous_code,start_tool_change_code, each returning aCommandVisitorthat receives arguments thenCommandVisitor::end_command. - Exactly once:
end_line.
Provided Methods§
Sourcefn line_number(&mut self, n: u32, span: Span)
fn line_number(&mut self, n: u32, span: Span)
Optional N line number (e.g. N100). Called at most once per block.
Sourcefn comment(&mut self, value: &str, span: Span)
fn comment(&mut self, value: &str, span: Span)
Comment content (excluding parentheses). Called for each comment on the line.
Sourcefn program_number(&mut self, number: u32, span: Span)
fn program_number(&mut self, number: u32, span: Span)
Optional O program number (e.g. O0001). Called at most once per block.
Sourcefn program_delimiter(&mut self, _span: Span)
fn program_delimiter(&mut self, _span: Span)
Program delimiter % (RS-274 / ISO 6983). Called once per % token.
Sourcefn word_address(&mut self, _letter: char, _value: Value<'_>, _span: Span)
fn word_address(&mut self, _letter: char, _value: Value<'_>, _span: Span)
Modal bare word address (e.g. X5.0, S12000 at block level without a G/M/T prefix).
Sourcefn start_general_code(
&mut self,
number: Number,
) -> ControlFlow<impl CommandVisitor + '_>
fn start_general_code( &mut self, number: Number, ) -> ControlFlow<impl CommandVisitor + '_>
Start of a G (general) command. Return a CommandVisitor to handle
this command, or use the default to ignore it.
Sourcefn start_miscellaneous_code(
&mut self,
number: Number,
) -> ControlFlow<impl CommandVisitor + '_>
fn start_miscellaneous_code( &mut self, number: Number, ) -> ControlFlow<impl CommandVisitor + '_>
Start of an M (miscellaneous) command. Return a CommandVisitor to handle
this command, or use the default to ignore it.
Sourcefn start_tool_change_code(
&mut self,
number: Number,
) -> ControlFlow<impl CommandVisitor + '_>
fn start_tool_change_code( &mut self, number: Number, ) -> ControlFlow<impl CommandVisitor + '_>
Start of a T (tool change) command. Return a CommandVisitor to handle
this command, or use the default to ignore it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.