Package fr.uga.pddl4j.parser
Class Parser
java.lang.Object
fr.uga.pddl4j.parser.Parser
Implements the
Parser
of the PDD4L library.
A simple example of how to use the parser:
public static void main(String[] args) { if (args.length == 2 && args[0].equals("-p")) { Parser parser = new Parser(); try { parser.parse(args[1]); } catch (FileNotFoundException e) { System.out.println(e.getMessage()); } if (!parser.getErrorManager().isEmpty()) { parser.getErrorManager().printAll(); } } else if (args.length == 4 && args[0].equals("-o") && args[2].equals("-f")) { Parser parser = new Parser(); try { parser.parse(args[1], args[3]); } catch (FileNotFoundException e) { System.out.println(e.getMessage()); } if (!parser.getErrorManager().isEmpty()) { parser.mgr.printAll(); } } else { System.out.println("\nusage of parser:\n"); System.out.println("OPTIONS DESCRIPTIONS\n"); System.out.println("-p <str> path for operator and fact file"); System.out.println("-o <str> operator file name"); System.out.println("-f <str> fact file name\n"); } }To generate the PDDL BNF accepted by the parser use the commande line:
./gradlew jjdocThe BNF description is available in build/doc/PDD4J_BNF.
-
Field Summary
Modifier and TypeFieldDescriptionThe specific symbol total-costs.The specific symbol total-costs. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncall()
This method contains the code called by the main method of the planner when planner are launched from command line.Returns the domain file to parse.Returns the error manager of the parser.Returns the log of the planner.Returns the problem file to parse.static void
The main method of theParser
planner.void
Parses a planning domain and a planning problem from a file.Parses a planning domain and a planning problem from their respective files.void
Parses a planning domain and a planning problem from a file path.Parses a planning domain and a planning problem from their respective files.Parses a planning domain from a specific file.parseDomain(File domain)
Parses a planning domain from a specific file.parseDomain(String domain)
Parses a planning domain from a specific file path.parseDomainAndProblem(File domainAndProblem)
Parses a planning domain and a planning problem from the specified file.parseDomainAndProblem(String domainAndProblem)
Parses a planning domain and a planning problem from the specified file path.void
parseFromStream(InputStream inputDomainAndProblem)
Parses a planning domain and a planning problem from an input stream.void
parseFromStream(InputStream inputDomain, InputStream inputProblem)
Parses a planning domain and a planning problem from two input streams.void
parseFromString(String domainAndProblemString)
Parses a planning domain and a planning problem from their respective string description.void
parseFromString(String domainString, String problemString)
Parses a planning domain and a planning problem from their respective string description.Parses a planning problem from a specific file.parseProblem(File problem)
Parses a planning problem from a specific file.parseProblem(String problem)
Parses a planning problem from a specific file path.void
setDomainFile(File domain)
Sets the domain file to parse.void
setLogLevel(LogLevel log)
Sets the log level of the planner.void
setProblemFile(File problem)
Sets the problem file to parse.
-
Field Details
-
TOTAL_COST
The specific symbol total-costs. -
TOTAL_TIME
The specific symbol total-costs.
-
-
Constructor Details
-
Parser
public Parser()Create a newParser
.
-
-
Method Details
-
setDomainFile
Sets the domain file to parse.- Parameters:
domain
- the domain file to parse.
-
getDomainFile
Returns the domain file to parse.- Returns:
- the domain file to parse.
-
setProblemFile
Sets the problem file to parse.- Parameters:
problem
- the problem file to parse.
-
getProblemFile
Returns the problem file to parse.- Returns:
- the problem file to parse.
-
setLogLevel
Sets the log level of the planner.- Parameters:
log
- the log of the planner.- See Also:
Level
-
getLogLevel
Returns the log of the planner.- Returns:
- the trace level declared of the planner.
- See Also:
Level
-
parseDomain
Parses a planning domain from a specific file path.- Parameters:
domain
- the path to the domain file.- Returns:
- a the pddl domain parsed or null if a lexical error or parser error occurred.
- Throws:
FileNotFoundException
- if the specified domain does not exist.
-
parseDomain
Parses a planning domain from a specific file.- Parameters:
domain
- the file that contains the planning domain.- Returns:
- a the pddl domain parsed or null if a lexical error or parser error occurred.
- Throws:
FileNotFoundException
- if the specified domain file does not exist.
-
parseDomain
Parses a planning domain from a specific file.- Returns:
- the pddl domain parsed or null if a lexical error or parser error occurred.
- Throws:
FileNotFoundException
- if the specified domain file does not exist.
-
parseProblem
Parses a planning problem from a specific file path.- Parameters:
problem
- the path to the planning problem.- Returns:
- a the pddl problem parsed or null if a lexical error or parser error occurred.
- Throws:
FileNotFoundException
- if the specified problem file does not exist.
-
parseProblem
Parses a planning problem from a specific file.- Parameters:
problem
- the file that contains the planning problem.- Returns:
- a the pddl problem parsed or null if a lexical error or parser error occurred.
- Throws:
FileNotFoundException
- if the specified problem file does not exist.
-
parseProblem
Parses a planning problem from a specific file.- Returns:
- the pddl problem parsed or null if a lexical error or parser error occurred.
- Throws:
FileNotFoundException
- if the specified problem file does not exist.
-
parseDomainAndProblem
public DefaultParsedProblem parseDomainAndProblem(String domainAndProblem) throws FileNotFoundExceptionParses a planning domain and a planning problem from the specified file path.- Parameters:
domainAndProblem
- the path to the file that contains the planning domain and problem.- Returns:
- the problem parsed.
- Throws:
FileNotFoundException
- if the specified file does not exist.
-
parseDomainAndProblem
public DefaultParsedProblem parseDomainAndProblem(File domainAndProblem) throws FileNotFoundExceptionParses a planning domain and a planning problem from the specified file.- Parameters:
domainAndProblem
- the file that contains the planning domain and problem.- Returns:
- the problem parsed.
- Throws:
FileNotFoundException
- if the specified file does not exist.
-
parseFromString
Parses a planning domain and a planning problem from their respective string description.- Parameters:
domainString
- the string that contains the planning domains.problemString
- the string that contains the planning problem.- Throws:
IOException
- if an error occurs while parsing.
-
parseFromString
Parses a planning domain and a planning problem from their respective string description.- Parameters:
domainAndProblemString
- the string that contains the domain and planning problem.- Throws:
IOException
- if an error occurs while parsing.
-
parseFromStream
Parses a planning domain and a planning problem from an input stream.- Parameters:
inputDomainAndProblem
- the stream that contains the domain and planning problem.- Throws:
IOException
- if an error occurs while parsing.
-
parseFromStream
Parses a planning domain and a planning problem from two input streams.- Parameters:
inputDomain
- the stream that contains the domain.inputProblem
- the stream that contains the planning problem.- Throws:
IOException
- if an error occurs while parsing.
-
parse
Parses a planning domain and a planning problem from a file path.- Parameters:
domainAndProblem
- the path of the file that contains the planning domain an problem.- Throws:
FileNotFoundException
- if the specified domain or problem file does not exist.
-
parse
Parses a planning domain and a planning problem from a file.- Parameters:
domainAndProblem
- the file that contains the planning domain an problem.- Throws:
FileNotFoundException
- if the specified domain or problem file does not exist.
-
parse
Parses a planning domain and a planning problem from their respective files.- Parameters:
domain
- the path of the file that contains the planning domains.problem
- the path of the file that contains the planning problem.- Returns:
- the problem parsed.
- Throws:
FileNotFoundException
- if the specified domain or problem file does not exist.
-
parse
Parses a planning domain and a planning problem from their respective files.- Parameters:
domain
- the file that contains the planning domains.problem
- the file that contains the planning problem.- Returns:
- the problem parsed or null if an error occurred while parsing domain or problem.
- Throws:
FileNotFoundException
- if the specified domain or problem file does not exist.
-
getErrorManager
Returns the error manager of the parser.- Returns:
- the error manager of the parser.
-
main
The main method of theParser
planner.- Parameters:
args
- the arguments of the command line.
-
call
This method contains the code called by the main method of the planner when planner are launched from command line.
-