pddl

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 3 Imported by: 0

README

pddl

Package pddl parses PDDL (Planning Domain Definition Language) files supporting the :strips, :typing, and :equality requirements, and converts the resulting ASTs into graphplan domain types.

Key Types

  • Adapter -- main entry point; wraps parse + convert in single calls
  • DomainAST -- parsed representation of a PDDL domain
  • ProblemAST -- parsed representation of a PDDL problem

Usage

Create an Adapter, call ParseDomain and ParseProblem:

adapter := pddl.NewAdapter()

domain, err := adapter.ParseDomain(domainPDDL)
if err != nil {
    log.Fatal(err)
}

problem, err := adapter.ParseProblem(problemPDDL, domain)
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Domain: %s (%d operators)\n",
    domain.Name, len(domain.Operators))
fmt.Printf("Problem: %s (%d objects)\n",
    problem.Name, len(problem.Objects))

The returned *graphplan.Domain and *graphplan.Problem can be passed directly to graphplan.Solver.Solve.

See examples/parse_rocket/ for a complete working example.

Documentation

Overview

Package pddl provides a parser for PDDL (Planning Domain Definition Language) files. It supports the STRIPS subset with :typing and :equality requirements, and converts parsed ASTs to graphplan domain types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertDomain

func ConvertDomain(
	ast *DomainAST,
) (*graphplan.Domain, error)

ConvertDomain converts a DomainAST into a graphplan.Domain.

func ConvertProblem

func ConvertProblem(
	ast *ProblemAST,
	domain *graphplan.Domain,
) (*graphplan.Problem, error)

ConvertProblem converts a ProblemAST into a graphplan.Problem, linking it to the given domain.

Types

type ActionAST

type ActionAST struct {
	Name          string
	Params        []TypedList
	Preconditions []LiteralAST
	Effects       []LiteralAST
}

ActionAST is a parsed action schema.

type Adapter

type Adapter struct{}

Adapter wraps the PDDL parse and convert pipeline into single-call methods.

Pattern: Adapter -- translates PDDL parse/convert two-step into single-call interfaces.

func NewAdapter

func NewAdapter() *Adapter

NewAdapter creates a PDDL adapter.

func (*Adapter) ParseDomain

func (*Adapter) ParseDomain(
	input string,
) (*graphplan.Domain, error)

ParseDomain parses a PDDL domain string and converts it to a graphplan.Domain.

func (*Adapter) ParseProblem

func (*Adapter) ParseProblem(
	input string,
	domain *graphplan.Domain,
) (*graphplan.Problem, error)

ParseProblem parses a PDDL problem string and converts it to a graphplan.Problem.

type DomainAST

type DomainAST struct {
	Name         string
	Requirements []string
	Types        []TypedList
	Constants    []TypedList
	Predicates   []PredicateAST
	Actions      []ActionAST
}

DomainAST is the parsed form of a PDDL domain.

func ParseDomain

func ParseDomain(input string) (*DomainAST, error)

ParseDomain parses a PDDL domain definition and returns the corresponding AST.

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer tokenizes PDDL input. It handles comments (;), parentheses, keywords (:keyword), variables (?var), dashes, and bare names.

func NewLexer

func NewLexer(input string) *Lexer

NewLexer creates a lexer for the given PDDL source.

func (*Lexer) Next

func (l *Lexer) Next() Token

Next returns the next token. Returns TokenEOF at end of input.

type LiteralAST

type LiteralAST struct {
	Predicate string
	Args      []string
	Negated   bool
}

LiteralAST is a predicate application, possibly negated.

type ParseError

type ParseError struct {
	Message string
	Line    int
	Col     int
}

ParseError reports a syntax error with position.

func (*ParseError) Error

func (e *ParseError) Error() string

Error implements the error interface.

type PredicateAST

type PredicateAST struct {
	Name   string
	Params []TypedList
}

PredicateAST is a predicate declaration.

type ProblemAST

type ProblemAST struct {
	Name    string
	Domain  string
	Objects []TypedList
	Init    []LiteralAST
	Goal    []LiteralAST
}

ProblemAST is the parsed form of a PDDL problem.

func ParseProblem

func ParseProblem(
	input string,
) (*ProblemAST, error)

ParseProblem parses a PDDL problem definition and returns the corresponding AST.

type Token

type Token struct {
	Text string
	Kind TokenKind
	Line int
	Col  int
}

Token is a lexed PDDL token with source position.

type TokenKind

type TokenKind int

TokenKind identifies the type of a lexical token.

const (
	TokenLParen  TokenKind = iota // (
	TokenRParen                   // )
	TokenDash                     // -
	TokenName                     // name
	TokenVar                      // variable
	TokenKeyword                  // keyword
	TokenEOF                      // eof
)

func (TokenKind) String

func (i TokenKind) String() string

type TypedList

type TypedList struct {
	Type  string
	Names []string
}

TypedList represents "name1 name2 - type" groups.

Directories

Path Synopsis
examples
parse_rocket command
Command parse_rocket parses the rocket PDDL files and prints the resulting domain and problem.
Command parse_rocket parses the rocket PDDL files and prints the resulting domain and problem.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL