knit_script.knit_script_interpreter.statements package
Knit Script Interpreter Statements Package
This package contains all statement types for the Knit Script interpreter. Statements are executable language constructs that perform actions or control program flow but do not return values (unlike expressions).
Statement Categories
- Core Language Statements:
Statement: Base class for all statements. Expression_Statement: Wrapper for evaluating expressions as statements. Code_Block: Executes multiple statements in a new scope.
- Assignment and Variables:
Assignment: Assigns values to variables in local or global scope. Variable_Declaration: Declares variables in current or global scope. With_Statement: Sets variables temporarily within a statement block.
- Control Flow:
If_Statement: Conditional execution with if-else branches. While_Statement: Loop execution while condition is true. For_Each_Statement: Iteration over iterable collections. Try_Catch_Statement: Exception handling with try-catch blocks.
- Function Management:
Function_Declaration: Declares user-defined functions. Function_Signature: Function object for parameter binding and execution. Return_Statement: Returns values from functions and exits function scope.
- Module System:
Import_Statement: Imports Python modules and knit script files.
- Machine Operations:
In_Direction_Statement: Executes needle instructions in specified direction. Carriage_Pass_Specification: Manages collections of needle operations. Drop_Pass: Specialized pass for dropping stitches. Push_Statement: Modifies layer positions of needles in stacking hierarchy. Swap_Statement: Swaps stitch layers between needles. Xfer_Pass_Statement: Executes transfer operations with racking control.
- Carrier and Yarn Management:
Cut_Statement: Cuts yarn carriers. Release_Statement: Releases yarn inserting hook. Remove_Statement: Removes carriers from bed without cutting.
- Output and Debugging:
Print: Prints to console and adds comments to knitout. Pause_Statement: Pauses machine execution. Assertion: Tests conditions with optional error messages.
Architecture
All statement classes inherit from the base Statement class and implement the execute() method to define their behavior. Statements operate within a Knit_Script_Context that provides access to: - Variable scopes (local, global, machine) - Machine state and operations - Knitout instruction generation - Parser and execution environment
The statement system integrates closely with the expression system, scope management, and machine simulation components.
Submodules
- knit_script.knit_script_interpreter.statements.Assertion module
- knit_script.knit_script_interpreter.statements.Carriage_Pass_Specification module
Carriage_Pass_SpecificationCarriage_Pass_Specification._source_statementCarriage_Pass_Specification._to_slidersCarriage_Pass_Specification._rackingCarriage_Pass_Specification._target_bedCarriage_Pass_Specification._has_dropsCarriage_Pass_Specification._drop_passCarriage_Pass_Specification._needle_to_instructionCarriage_Pass_Specification._directionCarriage_Pass_Specification._instruction_typesCarriage_Pass_Specification._knitting_passCarriage_Pass_Specification._require_secondCarriage_Pass_Specification.__init__()Carriage_Pass_Specification.write_knitout()
- knit_script.knit_script_interpreter.statements.Drop_Pass module
- knit_script.knit_script_interpreter.statements.Import_Statement module
Import_StatementImport_Statement.srcImport_Statement.aliasImport_Statement.__init__()Import_Statement.source_stringImport_Statement.source_ks_fileImport_Statement.alias_nameImport_Statement.execute()Import_Statement.__class_getitem__()Import_Statement.__init_subclass__()Import_Statement.file_nameImport_Statement.line_numberImport_Statement.local_pathImport_Statement.locationImport_Statement.location_strImport_Statement.position_contextImport_Statement.pre_scope_action()
- knit_script.knit_script_interpreter.statements.Print module
- knit_script.knit_script_interpreter.statements.Push_Statement module
Push_StatementPush_Statement._needlesPush_Statement._push_valPush_Statement.__init__()Push_Statement.execute()Push_Statement.__class_getitem__()Push_Statement.__init_subclass__()Push_Statement.file_namePush_Statement.line_numberPush_Statement.local_pathPush_Statement.locationPush_Statement.location_strPush_Statement.position_context
- knit_script.knit_script_interpreter.statements.Statement module
- knit_script.knit_script_interpreter.statements.Swap_Statement module
Swap_StatementSwap_Statement._needlesSwap_Statement._layerSwap_Statement._sheetSwap_Statement.__init__()Swap_Statement.__class_getitem__()Swap_Statement.__init_subclass__()Swap_Statement.file_nameSwap_Statement.line_numberSwap_Statement.local_pathSwap_Statement.locationSwap_Statement.location_strSwap_Statement.position_contextSwap_Statement.execute()
- knit_script.knit_script_interpreter.statements.Variable_Declaration module
Variable_DeclarationVariable_Declaration._is_globalVariable_Declaration._assignmentVariable_Declaration.__init__()Variable_Declaration.execute()Variable_Declaration.__class_getitem__()Variable_Declaration.__init_subclass__()Variable_Declaration.file_nameVariable_Declaration.line_numberVariable_Declaration.local_pathVariable_Declaration.locationVariable_Declaration.location_strVariable_Declaration.position_context
- knit_script.knit_script_interpreter.statements.With_Statement module
With_StatementWith_Statement._assignmentsWith_Statement.__init__()With_Statement.pre_scope_action()With_Statement.__class_getitem__()With_Statement.__init_subclass__()With_Statement.execute()With_Statement.file_nameWith_Statement.line_numberWith_Statement.local_pathWith_Statement.locationWith_Statement.location_strWith_Statement.position_context
- knit_script.knit_script_interpreter.statements.assignment module
- knit_script.knit_script_interpreter.statements.branch_statements module
If_StatementIf_Statement._conditionIf_Statement._true_statementIf_Statement._false_statementIf_Statement.__init__()If_Statement.execute()If_Statement.__class_getitem__()If_Statement.__init_subclass__()If_Statement.file_nameIf_Statement.line_numberIf_Statement.local_pathIf_Statement.locationIf_Statement.location_strIf_Statement.position_context
- knit_script.knit_script_interpreter.statements.carrier_statements module
Cut_StatementRelease_StatementRelease_Statement.__init__()Release_Statement.execute()Release_Statement.__class_getitem__()Release_Statement.__init_subclass__()Release_Statement.file_nameRelease_Statement.line_numberRelease_Statement.local_pathRelease_Statement.locationRelease_Statement.location_strRelease_Statement.position_context
Remove_StatementRemove_Statement._carriersRemove_Statement.__init__()Remove_Statement.execute()Remove_Statement.__class_getitem__()Remove_Statement.__init_subclass__()Remove_Statement.file_nameRemove_Statement.line_numberRemove_Statement.local_pathRemove_Statement.locationRemove_Statement.location_strRemove_Statement.position_context
- knit_script.knit_script_interpreter.statements.code_block_statements module
- knit_script.knit_script_interpreter.statements.control_loop_statements module
While_StatementWhile_Statement._conditionWhile_Statement._statementWhile_Statement.__init__()While_Statement.execute()While_Statement.__str__()While_Statement.__repr__()While_Statement.__class_getitem__()While_Statement.__init_subclass__()While_Statement.file_nameWhile_Statement.line_numberWhile_Statement.local_pathWhile_Statement.locationWhile_Statement.location_strWhile_Statement.position_context
For_Each_StatementFor_Each_Statement._variablesFor_Each_Statement.var_nameFor_Each_Statement._iter_expressionFor_Each_Statement._statementFor_Each_Statement.__init__()For_Each_Statement.__class_getitem__()For_Each_Statement.__init_subclass__()For_Each_Statement.execute()For_Each_Statement.file_nameFor_Each_Statement.line_numberFor_Each_Statement.local_pathFor_Each_Statement.locationFor_Each_Statement.location_strFor_Each_Statement.position_context
- knit_script.knit_script_interpreter.statements.express_statement module
Expression_StatementExpression_Statement.__init__()Expression_Statement.expressionExpression_Statement.execute()Expression_Statement.__class_getitem__()Expression_Statement.__init_subclass__()Expression_Statement.file_nameExpression_Statement.line_numberExpression_Statement.local_pathExpression_Statement.locationExpression_Statement.location_strExpression_Statement.position_context
- knit_script.knit_script_interpreter.statements.function_dec_statement module
Function_SignatureFunction_DeclarationFunction_Declaration._func_nameFunction_Declaration._argsFunction_Declaration._kwargsFunction_Declaration._bodyFunction_Declaration.__init__()Function_Declaration.execute()Function_Declaration.__class_getitem__()Function_Declaration.__init_subclass__()Function_Declaration.file_nameFunction_Declaration.line_numberFunction_Declaration.local_pathFunction_Declaration.locationFunction_Declaration.location_strFunction_Declaration.position_context
- knit_script.knit_script_interpreter.statements.in_direction_statement module
In_Direction_StatementIn_Direction_Statement._directionIn_Direction_Statement._instructionsIn_Direction_Statement.__init__()In_Direction_Statement.execute()In_Direction_Statement.__class_getitem__()In_Direction_Statement.__init_subclass__()In_Direction_Statement.file_nameIn_Direction_Statement.line_numberIn_Direction_Statement.local_pathIn_Direction_Statement.locationIn_Direction_Statement.location_strIn_Direction_Statement.position_context
- knit_script.knit_script_interpreter.statements.instruction_statements module
- knit_script.knit_script_interpreter.statements.return_statement module
Return_StatementReturn_Statement._expressionReturn_Statement.__init__()Return_Statement.execute()Return_Statement.__class_getitem__()Return_Statement.__init_subclass__()Return_Statement.file_nameReturn_Statement.line_numberReturn_Statement.local_pathReturn_Statement.locationReturn_Statement.location_strReturn_Statement.position_context
- knit_script.knit_script_interpreter.statements.scoped_statement module
Scoped_StatementScoped_Statement.__init__()Scoped_Statement.pre_scope_action()Scoped_Statement.execute()Scoped_Statement.__class_getitem__()Scoped_Statement.__init_subclass__()Scoped_Statement.file_nameScoped_Statement.line_numberScoped_Statement.local_pathScoped_Statement.locationScoped_Statement.location_strScoped_Statement.position_context
- knit_script.knit_script_interpreter.statements.try_catch_statements module
Try_Catch_StatementTry_Catch_Statement._try_statementTry_Catch_Statement._catch_statementTry_Catch_Statement._errorsTry_Catch_Statement.__init__()Try_Catch_Statement.execute()Try_Catch_Statement.__class_getitem__()Try_Catch_Statement.__init_subclass__()Try_Catch_Statement.file_nameTry_Catch_Statement.line_numberTry_Catch_Statement.local_pathTry_Catch_Statement.locationTry_Catch_Statement.location_strTry_Catch_Statement.position_context
- knit_script.knit_script_interpreter.statements.xfer_pass_statement module
Xfer_Pass_StatementXfer_Pass_Statement._is_slidersXfer_Pass_Statement._bedXfer_Pass_Statement._rackingXfer_Pass_Statement._needlesXfer_Pass_Statement.__init__()Xfer_Pass_Statement.execute()Xfer_Pass_Statement.__class_getitem__()Xfer_Pass_Statement.__init_subclass__()Xfer_Pass_Statement.file_nameXfer_Pass_Statement.line_numberXfer_Pass_Statement.local_pathXfer_Pass_Statement.locationXfer_Pass_Statement.location_strXfer_Pass_Statement.position_context