knitout_interpreter.knitout_language.Knitout_Parser module — knitout-interpreter 0.0.18 documentation

# knitout_interpreter.knitout_language.Knitout_Parser module

Parser code for accessing Parglare language support

class knitout_interpreter.knitout_language.Knitout_Parser.Knitout_Parser(debug_grammar=False, debug_parser=False, debug_parser_layout=False)

  Bases: `object`

  Parser for reading knitout using the parglare library.

  parse_knitout_to_instructions(pattern, pattern_is_file=False, reset_parser=True, debug_parser=False, debug_parser_layout=False)

    Parse knitout pattern into a list of instruction objects.

    Parameters:

      - pattern (str) – Either a file path or the knitout string to be parsed.

      - pattern_is_file (bool) – If True, treat pattern as a file path. Defaults to False.

      - reset_parser (bool) – Reset parser to have no prior input. Defaults to True.

      - debug_parser (bool) – Enable parser debugging. Defaults to False.

      - debug_parser_layout (bool) – Enable parser layout debugging. Defaults to False.

    Returns:

      List of knitout instructions created by parsing the given pattern.

    Raises:

      parglare.exceptions.ParseError – If there’s an error parsing the knitout code.

    Return type:

      list[Knitout_Line]

knitout_interpreter.knitout_language.Knitout_Parser.parse_knitout(pattern, pattern_is_file=False, debug_parser=False, debug_parser_layout=False)

  Execute the parsing code for the parglare parser.

  This is a convenience function that creates a Knitout_Parser instance and parses the given pattern.

  Parameters:

    - pattern (str) – Either a file path or the knitout string to be parsed.

    - pattern_is_file (bool) – If True, treat pattern as a file path. Defaults to False.

    - debug_parser (bool) – Enable parser debugging. Defaults to False.

    - debug_parser_layout (bool) – Enable parser layout debugging. Defaults to False.

  Returns:

    List of knitout instructions created by parsing the given pattern.

  Raises:

    - parglare.exceptions.ParseError – If there’s an error parsing the knitout code.

    - FileNotFoundError – If the grammar file or input file cannot be found.

  Return type:

    list[Knitout_Line]