The input to the PuzzleMuncher consists of a single description file given as the sole (normal) command-line argument to the program. The programmer MAY also provide additional command-line arguments (optionally with the gnu.getopt package) at her or his discretion. Any such additional options MUST be documented in the user documentation for PuzzleMuncher.
The input file is given by the following BNF grammar. The program MAY assume that all input data is standard, 7-bit ASCII; deviations from this MAY be treated as RECOVERABLE or UNRECOVERABLE ERRORs or silently ignored. The start symbol of this grammar is FILE.
FILE := ( CONTROLPUZZLEDEF )*
CONTROL := ( OUTFILE![]()
LOGFILE![]()
ERRFILE![]()
RESULTS![]()
STATS![]()
SEARCH-CTRL![]()
"Run"![]()
"Reset" )
OUTFILE := "OutFile" "=" FILESPEC
LOGFILE := "LogFile" "=" FILESPEC
ERRFILE := "ErrFile" "=" FILESPEC
FILESPEC := "\"" PATH? DIR-OR-FILENAME "\""
PATH := "/"? ( DIR-OR-FILENAME "/" )+
DIR-OR-FILENAME := [a-zA-Z0-9._-]+
RESULTS := ( "SolnPathLen""StatePath"
"MoveSeq" )
STATS := ( "NodesOpened"![]()
"OpenListMaxLen"![]()
"NodesClosed"![]()
"NumReopened"![]()
"OpenClosedRatio" )
SEARCH-CTRL := ( OPENLIST-BOUNDTOTALNODES-BOUND
TIME-BOUND )
OPENLIST-BOUND := "OpenListBound" "=" POS-INTEGER
TOTALNODES-BOUND := "TotalNodesBound" "=" POS-INTEGER
TIME-BOUND := "TimeBound" "=" POS-INTEGER
PUZZLEDEF := "Puzzle"
( MCPUZZLE![]()
SPPUZZLE![]()
N2KPUZZLE )
MCPUZZLE := "MissionariesAndCannibals" "(" HNAME ")"
"=" "{"
"InitialState" "=" MCSTATE
"GoalState" "=" MCSTATE
"BoatCapacity" "=" POS-INTEGER
"}"
MCSTATE := "{"
"WEST" "BANK" ":" BANKSPEC
"EAST" "BANK" ":" BANKSPEC
"BOAT" "is" "on" ( "EAST""WEST" ) "BANK"
"}"
BANKSPEC := NON-NEG-INTEGER "Cannibals" "and"
NON-NEG-INTEGER "Missionaries"
SPPUZZLE := "ShortestPaths" "(" HNAME ")"
"=" "{"
"Cities" "=" CITYLIST
"Distances" "=" DISTLIST
"StartCity" "=" CITYNAME
"GoalCity" "=" CITYNAME
"}"
CITYLIST := "(" ( CITYNAME ( "," CITYNAME )* )? ")"
DISTLIST := "(" ( DISTPAIR ( "," DISTPAIR )* )? ")"
DISTPAIR := CITYNAME "->" CITYNAME "=" NON-NEG-INTEGER
CITYNAME := [A-Z][a-zA-Z]+
N2KPUZZLE := "NToTheKPuzzle" "(" HNAME ")"
"=" "{"
"StartState" "=" NKPUZSTATE
"GoalState" "=" NKPUZSTATE
"}"
NKPUZSTATE := "[" ( NUMLIST![]()
NKPUZSTATE ( "," NKPUZSTATE )* )
"]"
NUMLIST := NON-NEG-INTEGER ( ","NON-NEG-INTEGER )*
HNAME := [a-zA-Z]+
POS-INTEGER := [1-9][0-9]+
NON-NEG-INTEGER := [0-9]+
This grammar is case sensitive so that, for example,
"OpenListBound" does not match "openlistbound".
Tokens are separated by whitespace (as defined by
java.lang.Character.isWhitespace()), though whitespace is
otherwise ignored by the grammar.
A SYNTAX ERROR in the input data file MAY be treated as a RECOVERABLE or UNRECOVERABLE ERROR.
The designer MAY implement additional syntax if desired, for example, to support additional PUZZLE types, or additional RESULTS, STATS, or SEARCH-CTRL mechanisms. All such additional syntax (and the corresponding semantic extensions) MUST be documented in the appropriate API and user documentation.