plan_parser.PlanParser

class plan_parser.PlanParser

Bases: object

Parses Fast Downward plan output into structured action sequences.

Fast Downward outputs plans in SAS+ format with actions like: - (pickup-from-table a) - (unstack b c) - (stack-target a b)

This parser extracts these actions and their parameters for execution.

__init__()

Initialize the plan parser.

Methods

__init__()

Initialize the plan parser.

format_action(action_name, params)

Format an action for display.

parse_plan_file(plan_file)

Parse a Fast Downward plan file.

plan_to_string(actions)

Convert a parsed plan to a human-readable string.

validate_plan(actions)

Perform basic validation on a parsed plan.

format_action(action_name, params)

Format an action for display.

Args:

action_name: Name of the action (e.g., ‘stack-target’). params: List of parameter strings.

Returns:

Formatted string representation of the action.

parse_plan_file(plan_file)

Parse a Fast Downward plan file.

Args:

plan_file: Path to sas_plan file generated by Fast Downward.

Returns:

List of (action_name, parameters) tuples. Example: [(‘unstack’, [‘A’, ‘B’]), (‘stack-target’, [‘A’, ‘B’])]

plan_to_string(actions)

Convert a parsed plan to a human-readable string.

Args:

actions: List of (action_name, parameters) tuples.

Returns:

Multi-line string with numbered action sequence.

validate_plan(actions)

Perform basic validation on a parsed plan.

Checks for: - Empty plan - Valid action names - Proper parameter counts for each action

Args:

actions: List of (action_name, parameters) tuples.

Returns:

Tuple of (is_valid, error_message). If valid, error_message is None.