knit_script.knit_script_interpreter.statements.carrier_statements module
Statement that cuts a yarn.
This module provides statement classes for managing yarn carrier operations in knit script programs. It includes statements for cutting carriers (permanently removing them), releasing the yarn hook, and removing carriers from the working area without cutting the yarn.
- class Cut_Statement(parser_node, carriers)[source]
Bases:
Statement
Statement for cutting yarn carriers.
Creates outhook operations that cut and remove yarn carriers from the machine permanently. If no carriers are specified, cuts the currently active working carrier. This operation terminates the yarn and removes it from the machine completely.
The cut operation is typically used at the end of knitting sections or when switching between different yarns that should not be connected. Unlike remove operations, cut operations permanently sever the yarn.
- _carriers
List of expressions that evaluate to carriers to cut.
- Type:
- Parameters:
parser_node (
LRStackNode
)carriers (
list
[Expression
])
- __init__(parser_node, carriers)[source]
Initialize a cut statement.
- Parameters:
parser_node (LRStackNode) – The parser node from the abstract syntax tree.
carriers (list[Expression]) – List of expressions that evaluate to carriers to cut. Can be empty to cut the current working carrier.
- __str__()[source]
Return string representation of the cut statement.
- Returns:
A string showing the carriers to be cut.
- Return type:
- __repr__()[source]
Return detailed string representation of the cut statement.
- Returns:
Same as __str__ for this class.
- Return type:
- execute(context)[source]
Execute the cut operation on the specified carriers.
Evaluates all carrier expressions and generates outhook instructions to permanently cut and remove the specified carriers from the machine. If no carriers are specified, cuts the current working carrier.
- Parameters:
context (Knit_Script_Context) – The current execution context of the knit script interpreter.
- Return type:
- property line_number: int
Get the line number of the symbol that generated this statement.
- Returns:
The line number where this element appears in the source file.
- Return type:
- property location: Location
Get the location of this symbol in KnitScript file.
- Returns:
The location of this symbol in the source file, including file name, line number, and position information.
- Return type:
Location
- class Release_Statement(parser_node)[source]
Bases:
Statement
Statement for releasing the yarn inserting hook.
Removes the current carrier from the yarn inserting hook or does nothing if no carrier is currently hooked. This operation releases the yarn from the hook mechanism without cutting or removing the carrier from the machine, allowing it to be manipulated or repositioned.
The release operation is typically used when the yarn hook needs to be cleared for racking operations or other machine movements that require the hook to be free.
- Parameters:
parser_node (
LRStackNode
)
- __init__(parser_node)[source]
Initialize a release statement.
- Parameters:
parser_node (LRStackNode) – The parser node from the abstract syntax tree.
- __str__()[source]
Return string representation of the release statement.
- Returns:
A string indicating this is a release hook operation.
- Return type:
- __repr__()[source]
Return detailed string representation of the release statement.
- Returns:
Same as __str__ for this class.
- Return type:
- execute(context)[source]
Execute the release hook operation.
Checks if there is a currently hooked carrier and generates a releasehook instruction to release it from the yarn inserting hook.
- Parameters:
context (Knit_Script_Context) – The current execution context of the knit script interpreter.
- Return type:
- property line_number: int
Get the line number of the symbol that generated this statement.
- Returns:
The line number where this element appears in the source file.
- Return type:
- property location: Location
Get the location of this symbol in KnitScript file.
- Returns:
The location of this symbol in the source file, including file name, line number, and position information.
- Return type:
Location
- class Remove_Statement(parser_node, carriers)[source]
Bases:
Statement
Statement for removing carriers from bed without cutting.
Equivalent to ‘out’ operations - removes carriers from the needle bed but does not cut the yarn, allowing the carrier to be brought back later with ‘in’ operations. This is useful for temporarily moving carriers out of the way without permanently terminating them.
The remove operation maintains the yarn connection but moves the carrier out of the active working area, making it available for later reactivation when needed.
- _carriers
List of expressions that evaluate to carriers to remove.
- Type:
- Parameters:
parser_node (
LRStackNode
)carriers (
list
[Expression
])
- __init__(parser_node, carriers)[source]
Initialize a remove statement.
- Parameters:
parser_node (LRStackNode) – The parser node from the abstract syntax tree.
carriers (list[Expression]) – List of expressions that evaluate to carriers to remove. Can be empty to remove the current working carrier.
- __str__()[source]
Return string representation of the remove statement.
- Returns:
A string showing the carriers to be removed.
- Return type:
- __repr__()[source]
Return detailed string representation of the remove statement.
- Returns:
Same as __str__ for this class.
- Return type:
- execute(context)[source]
Execute the remove operation on the specified carriers.
Evaluates all carrier expressions and generates out instructions to remove the specified carriers from the working area without cutting them. If no carriers are specified, removes the current working carrier.
- Parameters:
context (Knit_Script_Context) – The current execution context of the knit script interpreter.
- Return type:
- property line_number: int
Get the line number of the symbol that generated this statement.
- Returns:
The line number where this element appears in the source file.
- Return type:
- property location: Location
Get the location of this symbol in KnitScript file.
- Returns:
The location of this symbol in the source file, including file name, line number, and position information.
- Return type:
Location