knitout_interpreter.knitout_language.knitout_actions module

Actions for reducing in Knitout Parser

knitout_interpreter.knitout_language.knitout_actions.comment(_, __, content)[source]

Extracts the content of a comment.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • content (str | None) – The content of the comment.

Returns:

The content of the comment.

Return type:

str | None

knitout_interpreter.knitout_language.knitout_actions.code_line(_, __, c, com)[source]

Creates a knitout line with optional comment.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • c (Knitout_Line | None) – The knitout line to execute, if any.

  • com (str | None) – The comment to append to the knitout line.

Returns:

The knitout line created or None if no values are given.

Return type:

Knitout_Line | None

knitout_interpreter.knitout_language.knitout_actions.magic_string(_, __, v)[source]

Creates a knitout version line.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • v (int) – Version number.

Returns:

The version line knitout line.

Return type:

Knitout_Version_Line

knitout_interpreter.knitout_language.knitout_actions.header_line(_, __, h_op)[source]

Returns a header line operation.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • h_op (Knitout_Header_Line) – Operation on the line.

Returns:

The header operation.

Return type:

Knitout_Header_Line

knitout_interpreter.knitout_language.knitout_actions.machine_op(_, __, m)[source]

Creates a machine header line.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • m (str) – The machine name as a string.

Returns:

The machine declaration operation.

Return type:

Machine_Header_Line

knitout_interpreter.knitout_language.knitout_actions.gauge_op(_, __, g)[source]

Creates a gauge header line.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • g (int) – Gauge value.

Returns:

Gauge_Declaration.

Return type:

Gauge_Header_Line

knitout_interpreter.knitout_language.knitout_actions.yarn_op(_, __, cid, plies, weight, color)[source]

Creates a yarn header line.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • cid (int) – The carrier to assign the yarn too.

  • plies (int) – Plies in the yarn.

  • weight (int) – Weight of the yarn.

  • color (str) – The yarn color.

Returns:

Yarn declaration.

Return type:

Yarn_Header_Line

knitout_interpreter.knitout_language.knitout_actions.carriers_op(_, __, CS)[source]

Creates a carriers header line.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • CS (Yarn_Carrier_Set) – The carriers that are available.

Returns:

Carrier declaration.

Return type:

Carriers_Header_Line

knitout_interpreter.knitout_language.knitout_actions.position_op(_, __, p)[source]

Creates a position header line.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • p (str) – The position of operations.

Returns:

The position declaration.

Return type:

Position_Header_Line

knitout_interpreter.knitout_language.knitout_actions.in_op(_, __, c)[source]

Creates an in instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • c (int) – The carrier to bring in.

Returns:

In operation on a carrier set.

Return type:

In_Instruction

knitout_interpreter.knitout_language.knitout_actions.inhook_op(_, __, c)[source]

Creates an inhook instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • c (int) – The carrier to hook in.

Returns:

Inhook operation on carrier set.

Return type:

Inhook_Instruction

knitout_interpreter.knitout_language.knitout_actions.releasehook_op(_, __, c)[source]

Creates a releasehook instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • c (int) – Carrier set.

Returns:

Releasehook operation on carrier set.

Return type:

Releasehook_Instruction

knitout_interpreter.knitout_language.knitout_actions.out_op(_, __, c)[source]

Creates an out instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • c (int) – Carrier set.

Returns:

Out operation on the carrier set.

Return type:

Out_Instruction

knitout_interpreter.knitout_language.knitout_actions.outhook_op(_, __, c)[source]

Creates an outhook instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • c (int) – Carrier set.

Returns:

Outhook operation on the carrier set.

Return type:

Outhook_Instruction

knitout_interpreter.knitout_language.knitout_actions.rack_op(_, __, R)[source]

Creates a rack instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • R (float) – Rack value.

Returns:

Rack operation.

Return type:

Rack_Instruction

knitout_interpreter.knitout_language.knitout_actions.knit_op(_, __, D, N, CS)[source]

Creates a knit instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • D (str) – Direction operates in.

  • N (Needle) – Needle to operate on.

  • CS (Yarn_Carrier_Set) – A carrier set.

Returns:

Knit operation.

Return type:

Knit_Instruction

knitout_interpreter.knitout_language.knitout_actions.tuck_op(_, __, D, N, CS)[source]

Creates a tuck instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • D (str) – Direction operates in.

  • N (Needle) – Needle to operate on.

  • CS (Yarn_Carrier_Set) – A carrier set.

Returns:

Tuck operation.

Return type:

Tuck_Instruction

knitout_interpreter.knitout_language.knitout_actions.miss_op(_, __, D, N, CS)[source]

Creates a miss instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • D (str) – Direction to operate in.

  • N (Needle) – Needle to operate on.

  • CS (Yarn_Carrier_Set) – A carrier set.

Returns:

Miss operation.

Return type:

Miss_Instruction

knitout_interpreter.knitout_language.knitout_actions.kick_op(_, __, D, N, CS)[source]

Creates a kick instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • D (str) – The direction to operate in.

  • N (Needle) – The needle to position the kickback.

  • CS (Yarn_Carrier_Set) – The carrier set to kick.

Returns:

The specified Kick Operation.

Return type:

Kick_Instruction

knitout_interpreter.knitout_language.knitout_actions.split_op(_, __, D, N, N2, CS)[source]

Creates a split instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • D (str) – Direction operates in.

  • N (Needle) – Needle to operate on.

  • N2 (Needle) – Second needle to move to.

  • CS (Yarn_Carrier_Set) – A carrier set.

Returns:

Split operation.

Return type:

Split_Instruction

knitout_interpreter.knitout_language.knitout_actions.drop_op(_, __, N)[source]

Creates a drop instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • N (Needle) – Needle to drop from.

Returns:

Drop operation.

Return type:

Drop_Instruction

knitout_interpreter.knitout_language.knitout_actions.xfer_op(_, __, N, N2)[source]

Creates a transfer instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • N (Needle) – Needle to transfer from.

  • N2 (Needle) – Needle to transfer to.

Returns:

Xfer operation.

Return type:

Xfer_Instruction

knitout_interpreter.knitout_language.knitout_actions.pause_op(_, __)[source]

Creates a pause instruction.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

Returns:

Pause operation.

Return type:

Pause_Instruction

knitout_interpreter.knitout_language.knitout_actions.identifier(_, node)[source]

Returns an identifier string.

Parameters:
  • _ (Any) – The parser element that created this value.

  • node (str) – Identifier string.

Returns:

The identifier string.

Return type:

str

knitout_interpreter.knitout_language.knitout_actions.float_exp(_, node)[source]

Converts a string to a float.

Parameters:
  • _ (Any) – The parser element that created this value.

  • node (str) – Float string.

Returns:

Float conversion.

Return type:

float

knitout_interpreter.knitout_language.knitout_actions.int_exp(_, node)[source]

Converts a string to an integer.

Parameters:
  • _ (Any) – The parser element that created this value.

  • node (str) – Integer string.

Returns:

Integer conversion.

Return type:

int

knitout_interpreter.knitout_language.knitout_actions.needle_id(_, node)[source]

Creates a needle from a string representation.

Parameters:
  • _ (Any) – The parser element that created this value.

  • node (str) – String of the given needle.

Returns:

The Needle represented by this string.

Return type:

Needle

knitout_interpreter.knitout_language.knitout_actions.carrier_set(_, __, carriers)[source]

Creates a yarn carrier set.

Parameters:
  • _ (Any) – The parser element that created this value.

  • __ (Any) – Unused parameter.

  • carriers (list[int]) – Carriers in set.

Returns:

Carrier set.

Return type:

Yarn_Carrier_Set