diff --git a/Makefile b/Makefile index d58b06c..027d5ce 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ CPPFLAGS = # C compiler -CC := gcc +CC ?= gcc CFLAGS = ${DEPENDFLAGS} %.o : %.c @@ -36,7 +36,7 @@ CFLAGS = ${DEPENDFLAGS} # C++ compiler -CXX := g++ +CXX ?= g++ CXXFLAGS = ${DEPENDFLAGS} -ansi -Wall %.o : %.cc @@ -475,27 +475,27 @@ src/PingusTranslator.o: src/PlanRec.o: -src/Polynomial.o: /usr/include/math.h +src/Polynomial.o: src/Relax.o: src/TIM.o: -src/TimSupport.o: /usr/include/assert.h +src/TimSupport.o: src/TypeStrip.o: src/TypedAnalysis.o: -src/Validator.o: /usr/include/math.h +src/Validator.o: src/dynaMain.o: -src/instantiation.o: /usr/include/assert.h +src/instantiation.o: src/instantiationMain.o: -src/main.o: /usr/include/time.h +src/main.o: src/parse.o: diff --git a/Papers on Val/aaai05.pdf b/Papers on Val/aaai05.pdf new file mode 100644 index 0000000..c77e413 Binary files /dev/null and b/Papers on Val/aaai05.pdf differ diff --git a/Papers on Val/ictai.pdf b/Papers on Val/ictai.pdf new file mode 100644 index 0000000..07c8f39 Binary files /dev/null and b/Papers on Val/ictai.pdf differ diff --git a/VAL.depend b/VAL.depend deleted file mode 100644 index 4de0510..0000000 --- a/VAL.depend +++ /dev/null @@ -1,974 +0,0 @@ -# depslib dependency file v1.0 -1406195218 source:c:\users\derek\downloads\val4301\val\src\action.cpp - "State.h" - "Action.h" - "Plan.h" - "main.h" - "Validator.h" - "Ownership.h" - "Utils.h" - "Proposition.h" - "LaTeXSupport.h" - "RobustAnalyse.h" - - - -1406195222 c:\users\derek\downloads\val4301\val\include\state.h - "Proposition.h" - "FuncExp.h" - "StateObserver.h" - - -1406195221 c:\users\derek\downloads\val4301\val\include\proposition.h - "ptree.h" - - - "Environment.h" - "Ownership.h" - "Polynomial.h" - -1406195221 c:\users\derek\downloads\val4301\val\include\ptree.h - - - - - "sStack.h" - "macros.h" - "parse_error.h" - - -1406195222 c:\users\derek\downloads\val4301\val\include\sstack.h - - -1406195220 c:\users\derek\downloads\val4301\val\include\macros.h - -1406195220 c:\users\derek\downloads\val4301\val\include\parse_error.h - - - - "ptree.h" - -1406195218 c:\users\derek\downloads\val4301\val\include\environment.h - - - -1406195220 c:\users\derek\downloads\val4301\val\include\ownership.h - - "ptree.h" - -1406195221 c:\users\derek\downloads\val4301\val\include\polynomial.h - - - - - -1406195219 c:\users\derek\downloads\val4301\val\include\funcexp.h - - - "ptree.h" - "Environment.h" - "Utils.h" - -1406195222 c:\users\derek\downloads\val4301\val\include\utils.h - - - -1406195222 c:\users\derek\downloads\val4301\val\include\stateobserver.h - -1406195218 c:\users\derek\downloads\val4301\val\include\action.h - "ptree.h" - "Proposition.h" - "main.h" - - - - - - -1406195220 c:\users\derek\downloads\val4301\val\include\main.h - - -1406195221 c:\users\derek\downloads\val4301\val\include\plan.h - - - - - - "ptree.h" - "Exceptions.h" - "main.h" - "Ownership.h" - "Polynomial.h" - "State.h" - -1406195218 c:\users\derek\downloads\val4301\val\include\exceptions.h - - -1406195223 c:\users\derek\downloads\val4301\val\include\validator.h - - - - - "Action.h" - "Plan.h" - "State.h" - "Polynomial.h" - "Events.h" - "typecheck.h" - "RepairAdvice.h" - "TrajectoryConstraints.h" - -1406195218 c:\users\derek\downloads\val4301\val\include\events.h - "ptree.h" - "State.h" - "Action.h" - "Plan.h" - - -1406195222 c:\users\derek\downloads\val4301\val\include\typecheck.h - "ptree.h" - - - -1406195221 c:\users\derek\downloads\val4301\val\include\repairadvice.h - "Action.h" - "State.h" - - -1406195222 c:\users\derek\downloads\val4301\val\include\trajectoryconstraints.h - "ptree.h" - "Proposition.h" - - -1406195219 c:\users\derek\downloads\val4301\val\include\latexsupport.h - - - - "Utils.h" - "main.h" - "Validator.h" - -1406195222 c:\users\derek\downloads\val4301\val\include\robustanalyse.h - - - "ptree.h" - -1406195218 source:c:\users\derek\downloads\val4301\val\src\analysis.cpp - - - - "ptree.h" - "FlexLexer.h" - "Analyser.h" - -1406195219 c:\users\derek\downloads\val4301\val\include\flexlexer.h - - -1406195218 c:\users\derek\downloads\val4301\val\include\analyser.h - - - "ptree.h" - "VisitController.h" - -1406195223 c:\users\derek\downloads\val4301\val\include\visitcontroller.h - "ptree.h" - -1406195218 source:c:\users\derek\downloads\val4301\val\src\causalgraph.cpp - "CausalGraph.h" - "ptree.h" - "VisitController.h" - "TimSupport.h" - "ToFunction.h" - "SASActions.h" - - -1406195218 c:\users\derek\downloads\val4301\val\include\causalgraph.h - - - "ToFunction.h" - -1406195222 c:\users\derek\downloads\val4301\val\include\tofunction.h - - "ptree.h" - "TIM.h" - - - - - -1406195222 c:\users\derek\downloads\val4301\val\include\tim.h - "TimSupport.h" - -1406195222 c:\users\derek\downloads\val4301\val\include\timsupport.h - - - - - - - "TIMUtilities.h" - "TypedAnalyser.h" - -1406195222 c:\users\derek\downloads\val4301\val\include\timutilities.h - - - -1406195222 c:\users\derek\downloads\val4301\val\include\typedanalyser.h - "FuncAnalysis.h" - - - - - "ptree.h" - "VisitController.h" - "typecheck.h" - "Cascader.h" - "FastEnvironment.h" - "Environment.h" - -1406195219 c:\users\derek\downloads\val4301\val\include\funcanalysis.h - - - - - - "VisitController.h" - -1406195218 c:\users\derek\downloads\val4301\val\include\cascader.h - - - -1406195219 c:\users\derek\downloads\val4301\val\include\fastenvironment.h - - - - "ptree.h" - -1406195222 c:\users\derek\downloads\val4301\val\include\sasactions.h - "ToFunction.h" - - - - -1406195218 source:c:\users\derek\downloads\val4301\val\src\commitments.cpp - - "State.h" - "Plan.h" - "Validator.h" - "typecheck.h" - "RobustAnalyse.h" - - - - "ptree.h" - "FlexLexer.h" - "Utils.h" - "LaTeXSupport.h" - "main.h" - "ptree.h" - "TIM.h" - "FuncAnalysis.h" - "AbstractGraph.h" - "CommitmentTracker.h" - "Agents.h" - -1406195218 c:\users\derek\downloads\val4301\val\include\abstractgraph.h - "HowAnalyser.h" - -1406195219 c:\users\derek\downloads\val4301\val\include\howanalyser.h - "ptree.h" - "VisitController.h" - - "TypedAnalyser.h" - "TimSupport.h" - - -1406195218 c:\users\derek\downloads\val4301\val\include\commitmenttracker.h - - - "State.h" - "Plan.h" - "VisitController.h" - "Proposition.h" - "Agents.h" - -1406195218 c:\users\derek\downloads\val4301\val\include\agents.h - "ptree.h" - "Environment.h" - -1406195218 source:c:\users\derek\downloads\val4301\val\src\debugwritecontroller.cpp - - "DebugWriteController.h" - -1406195218 c:\users\derek\downloads\val4301\val\include\debugwritecontroller.h - "WriteController.h" - -1406195223 c:\users\derek\downloads\val4301\val\include\writecontroller.h - "ptree.h" - -1406195218 source:c:\users\derek\downloads\val4301\val\src\environment.cpp - "Environment.h" - -1406195218 source:c:\users\derek\downloads\val4301\val\src\evaluator.cpp - "Evaluator.h" - "TypedAnalyser.h" - "State.h" - "ptree.h" - "instantiation.h" - "InstPropLinker.h" - "Validator.h" - -1406195218 c:\users\derek\downloads\val4301\val\include\evaluator.h - "VisitController.h" - - - - "ptree.h" - "Environment.h" - -1406195219 c:\users\derek\downloads\val4301\val\include\instantiation.h - - - "FastEnvironment.h" - - - "SimpleEval.h" - "TypedAnalyser.h" - -1406195222 c:\users\derek\downloads\val4301\val\include\simpleeval.h - "VisitController.h" - "FastEnvironment.h" - - - - "ptree.h" - -1406195219 c:\users\derek\downloads\val4301\val\include\instproplinker.h - -1406195218 source:c:\users\derek\downloads\val4301\val\src\events.cpp - "Events.h" - "Plan.h" - "Validator.h" - "Action.h" - "RobustAnalyse.h" - -1406195219 source:c:\users\derek\downloads\val4301\val\src\fastenvironment.cpp - "FastEnvironment.h" - -1406195219 source:c:\users\derek\downloads\val4301\val\src\funcexp.cpp - "FuncExp.h" - "State.h" - "random.h" - "main.h" - "RobustAnalyse.h" - -1406195221 c:\users\derek\downloads\val4301\val\include\random.h - - - -1406195219 source:c:\users\derek\downloads\val4301\val\src\latexsupport.cpp - "LaTeXSupport.h" - "ptree.h" - -1406195220 source:c:\users\derek\downloads\val4301\val\src\ownership.cpp - "Ownership.h" - "Validator.h" - "Action.h" - "FuncExp.h" - "Environment.h" - "Proposition.h" - -1406195220 source:c:\users\derek\downloads\val4301\val\src\pddl+.cpp - - - - - "ptree.h" - "parse_error.h" - - - - - - - - - - - "lex.yy.cc" - -1406195219 c:\users\derek\downloads\val4301\val\src\parser\lex.yy.cc - - - - - - - - - - - -1406195221 source:c:\users\derek\downloads\val4301\val\src\plan.cpp - "State.h" - "Plan.h" - "Action.h" - "Validator.h" - "main.h" - "Polynomial.h" - "Exceptions.h" - "ptree.h" - "RobustAnalyse.h" - -1406195221 source:c:\users\derek\downloads\val4301\val\src\polynomial.cpp - - - - "Polynomial.h" - "Exceptions.h" - "Proposition.h" - "main.h" - -1406195221 source:c:\users\derek\downloads\val4301\val\src\prettyprinter.cpp - "PrettyPrinter.h" - "Utils.h" - "ptree.h" - - - "FuncExp.h" - -1406195221 c:\users\derek\downloads\val4301\val\include\prettyprinter.h - "WriteController.h" - -1406195221 source:c:\users\derek\downloads\val4301\val\src\proposition.cpp - - - "Proposition.h" - "State.h" - "Action.h" - "Plan.h" - "Validator.h" - "Exceptions.h" - "Utils.h" - "Polynomial.h" - "Events.h" - "PrettyPrinter.h" - -1406195221 source:c:\users\derek\downloads\val4301\val\src\ptree.cpp - "ptree.h" - "macros.h" - "DebugWriteController.h" - "VisitController.h" - - -1406195221 source:c:\users\derek\downloads\val4301\val\src\random.cpp - "random.h" - -1406195221 source:c:\users\derek\downloads\val4301\val\src\repairadvice.cpp - "RepairAdvice.h" - "Validator.h" - "Utils.h" - -1406195222 source:c:\users\derek\downloads\val4301\val\src\robustanalyse.cpp - "RobustAnalyse.h" - "Utils.h" - "LaTeXSupport.h" - "tDistribution.h" - "random.h" - "Validator.h" - -1406195222 c:\users\derek\downloads\val4301\val\include\tdistribution.h - -1406195222 source:c:\users\derek\downloads\val4301\val\src\simpleeval.cpp - "SimpleEval.h" - "TypedAnalyser.h" - "instantiation.h" - "typecheck.h" - -1406195222 source:c:\users\derek\downloads\val4301\val\src\state.cpp - "State.h" - "Plan.h" - "main.h" - "Validator.h" - "Proposition.h" - "Exceptions.h" - "LaTeXSupport.h" - "RobustAnalyse.h" - - -1406195222 source:c:\users\derek\downloads\val4301\val\src\tim.cpp - "FastEnvironment.h" - "TimSupport.h" - - - - "ptree.h" - "FlexLexer.h" - "TypedAnalyser.h" - "TIM.h" - -1406195222 source:c:\users\derek\downloads\val4301\val\src\timsupport.cpp - "FastEnvironment.h" - "TimSupport.h" - "ptree.h" - "Partitions.h" - - - - -1406195220 c:\users\derek\downloads\val4301\val\include\partitions.h - - - -1406195222 source:c:\users\derek\downloads\val4301\val\src\trajectoryconstraints.cpp - "TrajectoryConstraints.h" - "Proposition.h" - "VisitController.h" - "Validator.h" - -1406195222 source:c:\users\derek\downloads\val4301\val\src\typecheck.cpp - "typecheck.h" - "ptree.h" - - "main.h" - "Exceptions.h" - - -1406195223 source:c:\users\derek\downloads\val4301\val\src\utils.cpp - - - "Polynomial.h" - "Action.h" - "FuncExp.h" - "Utils.h" - -1406195223 source:c:\users\derek\downloads\val4301\val\src\validator.cpp - - - - - "Validator.h" - "Action.h" - "Utils.h" - "typecheck.h" - "Exceptions.h" - "RobustAnalyse.h" - "random.h" - - -1406195220 source:c:\users\derek\downloads\val4301\val\src\main.cpp - - "State.h" - "Plan.h" - "Validator.h" - "typecheck.h" - "RobustAnalyse.h" - - - - - "ptree.h" - "FlexLexer.h" - "Utils.h" - "LaTeXSupport.h" - "main.h" - -1406195220 source:c:\users\derek\downloads\val4301\val\src\parse.cpp - - - - "ptree.h" - "FlexLexer.h" - -1406195222 source:c:\users\derek\downloads\val4301\val\src\typedanalyser.cpp - "TypedAnalyser.h" - -1406195222 source:c:\users\derek\downloads\val4301\val\src\typedanalysis.cpp - - - - "ptree.h" - "FlexLexer.h" - "TypedAnalyser.h" - -1406738413 source:c:\users\derek\downloads\val\src\debugwritecontroller.cpp - - "DebugWriteController.h" - -1406738413 c:\users\derek\downloads\val\include\debugwritecontroller.h - "WriteController.h" - -1406738413 c:\users\derek\downloads\val\include\writecontroller.h - "ptree.h" - -1406738413 c:\users\derek\downloads\val\include\ptree.h - - - - - "sStack.h" - "macros.h" - "parse_error.h" - - -1406738413 c:\users\derek\downloads\val\include\sstack.h - - -1406738413 c:\users\derek\downloads\val\include\macros.h - -1406738413 c:\users\derek\downloads\val\include\parse_error.h - - - - "ptree.h" - -1406738413 source:c:\users\derek\downloads\val\src\funcanalysis.cpp - "FuncAnalysis.h" - - - -1406738413 c:\users\derek\downloads\val\include\funcanalysis.h - - - - - - "VisitController.h" - -1406738413 c:\users\derek\downloads\val\include\visitcontroller.h - "ptree.h" - -1406738413 source:c:\users\derek\downloads\val\src\action.cpp - "State.h" - "Action.h" - "Plan.h" - "main.h" - "Validator.h" - "Ownership.h" - "Utils.h" - "Proposition.h" - "LaTeXSupport.h" - "RobustAnalyse.h" - - - -1406738413 c:\users\derek\downloads\val\include\state.h - "Proposition.h" - "FuncExp.h" - "StateObserver.h" - - -1406738413 c:\users\derek\downloads\val\include\proposition.h - "ptree.h" - - - "Environment.h" - "Ownership.h" - "Polynomial.h" - -1406738413 c:\users\derek\downloads\val\include\environment.h - - - -1406738413 c:\users\derek\downloads\val\include\ownership.h - - "ptree.h" - -1406738413 c:\users\derek\downloads\val\include\polynomial.h - - - - - -1406738413 c:\users\derek\downloads\val\include\funcexp.h - - - "ptree.h" - "Environment.h" - "Utils.h" - -1406738413 c:\users\derek\downloads\val\include\utils.h - - - -1406738413 c:\users\derek\downloads\val\include\stateobserver.h - -1406738413 c:\users\derek\downloads\val\include\action.h - "ptree.h" - "Proposition.h" - "main.h" - - - - - - -1406738413 c:\users\derek\downloads\val\include\main.h - - -1406738413 c:\users\derek\downloads\val\include\plan.h - - - - - - "ptree.h" - "Exceptions.h" - "main.h" - "Ownership.h" - "Polynomial.h" - "State.h" - -1406738413 c:\users\derek\downloads\val\include\exceptions.h - - -1406738413 c:\users\derek\downloads\val\include\validator.h - - - - - "Action.h" - "Plan.h" - "State.h" - "Polynomial.h" - "Events.h" - "typecheck.h" - "RepairAdvice.h" - "TrajectoryConstraints.h" - -1406738413 c:\users\derek\downloads\val\include\events.h - "ptree.h" - "State.h" - "Action.h" - "Plan.h" - - -1406738413 c:\users\derek\downloads\val\include\typecheck.h - "ptree.h" - - - -1406738413 c:\users\derek\downloads\val\include\repairadvice.h - "Action.h" - "State.h" - - -1406738413 c:\users\derek\downloads\val\include\trajectoryconstraints.h - "ptree.h" - "Proposition.h" - - -1406738413 c:\users\derek\downloads\val\include\latexsupport.h - - - - "Utils.h" - "main.h" - "Validator.h" - -1406738413 c:\users\derek\downloads\val\include\robustanalyse.h - - - "ptree.h" - -1406738413 source:c:\users\derek\downloads\val\src\environment.cpp - "Environment.h" - -1406738413 source:c:\users\derek\downloads\val\src\funcexp.cpp - "FuncExp.h" - "State.h" - "random.h" - "main.h" - "RobustAnalyse.h" - -1406738413 c:\users\derek\downloads\val\include\random.h - - - -1406738414 source:c:\users\derek\downloads\val\src\latexsupport.cpp - "LaTeXSupport.h" - "ptree.h" - -1406738414 source:c:\users\derek\downloads\val\src\main.cpp - - "State.h" - "Plan.h" - "Validator.h" - "typecheck.h" - "RobustAnalyse.h" - - - - - "ptree.h" - "FlexLexer.h" - "Utils.h" - "LaTeXSupport.h" - "main.h" - -1406738413 c:\users\derek\downloads\val\include\flexlexer.h - - -1406738414 source:c:\users\derek\downloads\val\src\ownership.cpp - "Ownership.h" - "Validator.h" - "Action.h" - "FuncExp.h" - "Environment.h" - "Proposition.h" - -1406738414 source:c:\users\derek\downloads\val\src\pddl+.cpp - - - - - "ptree.h" - "parse_error.h" - - - - - - - - - - - "lex.yy.cc" - -1406738414 c:\users\derek\downloads\val\src\parser\lex.yy.cc - - - - - - - - - - - -1406738414 source:c:\users\derek\downloads\val\src\plan.cpp - "State.h" - "Plan.h" - "Action.h" - "Validator.h" - "main.h" - "Polynomial.h" - "Exceptions.h" - "ptree.h" - "RobustAnalyse.h" - -1406738414 source:c:\users\derek\downloads\val\src\polynomial.cpp - - - - "Polynomial.h" - "Exceptions.h" - "Proposition.h" - "main.h" - -1406738414 source:c:\users\derek\downloads\val\src\prettyprinter.cpp - "PrettyPrinter.h" - "Utils.h" - "ptree.h" - - - "FuncExp.h" - -1406738413 c:\users\derek\downloads\val\include\prettyprinter.h - "WriteController.h" - -1416685419 source:c:\users\derek\downloads\val\src\proposition.cpp - - - "Proposition.h" - "State.h" - "Action.h" - "Plan.h" - "Validator.h" - "Exceptions.h" - "Utils.h" - "Polynomial.h" - "Events.h" - "PrettyPrinter.h" - -1406738414 source:c:\users\derek\downloads\val\src\ptree.cpp - "ptree.h" - "macros.h" - "DebugWriteController.h" - "VisitController.h" - - -1406738414 source:c:\users\derek\downloads\val\src\random.cpp - "random.h" - -1406738414 source:c:\users\derek\downloads\val\src\repairadvice.cpp - "RepairAdvice.h" - "Validator.h" - "Utils.h" - -1406738414 source:c:\users\derek\downloads\val\src\robustanalyse.cpp - "RobustAnalyse.h" - "Utils.h" - "LaTeXSupport.h" - "tDistribution.h" - "random.h" - "Validator.h" - -1406738413 c:\users\derek\downloads\val\include\tdistribution.h - -1406738414 source:c:\users\derek\downloads\val\src\state.cpp - "State.h" - "Plan.h" - "main.h" - "Validator.h" - "Proposition.h" - "Exceptions.h" - "LaTeXSupport.h" - "RobustAnalyse.h" - - -1406738414 source:c:\users\derek\downloads\val\src\trajectoryconstraints.cpp - "TrajectoryConstraints.h" - "Proposition.h" - "VisitController.h" - "Validator.h" - -1406738414 source:c:\users\derek\downloads\val\src\typecheck.cpp - "typecheck.h" - "ptree.h" - - "main.h" - "Exceptions.h" - - -1406738414 source:c:\users\derek\downloads\val\src\utils.cpp - - - "Polynomial.h" - "Action.h" - "FuncExp.h" - "Utils.h" - -1406738414 source:c:\users\derek\downloads\val\src\validator.cpp - - - - - "Validator.h" - "Action.h" - "Utils.h" - "typecheck.h" - "Exceptions.h" - "RobustAnalyse.h" - "random.h" - - -1416682121 source:c:\users\derek\downloads\val\src\events.cpp - "Events.h" - "Plan.h" - "Validator.h" - "Action.h" - "RobustAnalyse.h" - diff --git a/VAL.layout b/VAL.layout deleted file mode 100644 index c39f1e2..0000000 --- a/VAL.layout +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bin/MacOSExecutables/parser b/bin/MacOSExecutables/parser new file mode 100644 index 0000000..11d98a4 Binary files /dev/null and b/bin/MacOSExecutables/parser differ diff --git a/bin/MacOSExecutables/tan b/bin/MacOSExecutables/tan new file mode 100644 index 0000000..9bbee0e Binary files /dev/null and b/bin/MacOSExecutables/tan differ diff --git a/bin/MacOSExecutables/validate b/bin/MacOSExecutables/validate new file mode 100644 index 0000000..e57dc0a Binary files /dev/null and b/bin/MacOSExecutables/validate differ diff --git a/bin/validate/validate.exe b/bin/validate/validate.exe index 05f651b..f63f534 100644 Binary files a/bin/validate/validate.exe and b/bin/validate/validate.exe differ diff --git a/domainsWithEventsAndProcesses/Coffee/coffeemaking.pddl b/domainsWithEventsAndProcesses/Coffee/coffeemaking.pddl new file mode 100644 index 0000000..736d41e --- /dev/null +++ b/domainsWithEventsAndProcesses/Coffee/coffeemaking.pddl @@ -0,0 +1,79 @@ +(define (domain COFFEE) +(:requirements :typing :durative-actions :fluents :timed-initial-literals :time + :duration-inequalities) + +(:types coffee water) + +(:predicates + (havecoffee ?c - coffee) + (hot ?w - water) + (cold ?w - water) + (madecoffee ?c - coffee ?w - water) + (heating ?w - water) + (cooling ?w - water) + (boiled ?w - water) +) + +(:functions + (temperature ?w - water) + +) + +(:durative-action makecoffee +:parameters (?c - coffee ?w - water) +:duration (>= ?duration 1) +:condition (and + (at start (boiled ?w)) + (over all (>= (temperature ?w) 60)) + (over all (<= (temperature ?w) 80)) + (at start (havecoffee ?c)) + ) +:effect (and (at end (madecoffee ?c ?w)) + ) +) + +(:action heatwater +:parameters (?w - water) +:precondition (and (cold ?w)) +:effect (and (not (cold ?w)) + (heating ?w) + ) +) + +(:process heating +:parameters (?w - water) +:precondition (and (heating ?w) (<= (temperature ?w) 100)) +:effect (increase (temperature ?w) (* #t 2)) +) + +(:event boil +:parameters (?w - water) +:precondition (and (>= (temperature ?w) 100) + (not (boiled ?w))) +:effect (and (boiled ?w)) +) + +(:event stop-heating +:parameters (?w - water) +:precondition (and (>= (temperature ?w) 100) (heating ?w)) +:effect (and (not (heating ?w))) +) + +(:process cooling +:parameters (?w - water) +:precondition (>= (temperature ?w) 18) +:effect (decrease (temperature ?w) (* #t 0.5)) +) + +(:event stop-cooling +:parameters (?w - water) +:precondition (and (<= (temperature ?w) 18) (cooling ?w)) + ;; Assume we are working with a room temperature of + ;; 18 degrees +:effect (and (not (cooling ?w))) +) + + + + +) \ No newline at end of file diff --git a/domainsWithEventsAndProcesses/Coffee/coffeeplan.pddl b/domainsWithEventsAndProcesses/Coffee/coffeeplan.pddl new file mode 100644 index 0000000..d5a5af1 --- /dev/null +++ b/domainsWithEventsAndProcesses/Coffee/coffeeplan.pddl @@ -0,0 +1,2 @@ +0: (heatwater water1) +120: (makecoffee coffee1 water1) [1] \ No newline at end of file diff --git a/domainsWithEventsAndProcesses/Coffee/coffeeproblem.txt b/domainsWithEventsAndProcesses/Coffee/coffeeproblem.txt new file mode 100644 index 0000000..369ce36 --- /dev/null +++ b/domainsWithEventsAndProcesses/Coffee/coffeeproblem.txt @@ -0,0 +1,16 @@ +(define (problem COFFEE1) +(:domain COFFEE) +(:objects + water1 - water + coffee1 - coffee +) + +(:init + (havecoffee coffee1) + (cold water1) + (= (temperature water1) 7) ;; Cold tap water at 7 degrees +) + +(:goal (and (madecoffee coffee1 water1))) + +) \ No newline at end of file diff --git a/domainsWithEventsAndProcesses/Drive/drive-problem.txt b/domainsWithEventsAndProcesses/Drive/drive-problem.txt new file mode 100644 index 0000000..a3ce740 --- /dev/null +++ b/domainsWithEventsAndProcesses/Drive/drive-problem.txt @@ -0,0 +1,17 @@ +(define (problem drive-problem) +(:domain drivedomain) +(:objects + car - vehicle + start - location + end - location +) +(:init + + (at car start) + (= (speed car) 0) + (= (maxspeed car) 10) + (= (traveltime car) 0) + (= (distance start end) 100) +) +(:goal (and (at car end) (>= (traveltime car) 20))) +(:metric minimize (total-time))) diff --git a/domainsWithEventsAndProcesses/Drive/drivedomain.pddl b/domainsWithEventsAndProcesses/Drive/drivedomain.pddl new file mode 100644 index 0000000..e7436f9 --- /dev/null +++ b/domainsWithEventsAndProcesses/Drive/drivedomain.pddl @@ -0,0 +1,29 @@ +(define (domain drivedomain) +(:requirements :fluents :continuous-effects :negative-preconditions :duration-inequalities :time :typing) +(:predicates (at ?v - vehicle ?l - location)) +(:types vehicle location) +(:functions (maxspeed ?v - vehicle) (speed ?v - vehicle) (traveltime ?v - vehicle) (distance ?p ?l - location)) + + +;; Set the accelerator value over time. Uses time as a +;; way of avoiding modelling acceleration as a numeric +;; parameter. + +(:durative-action accelerate +:parameters (?v - vehicle) +:duration (and (<= ?duration (- (maxspeed ?v) (speed ?v)))) +:condition (and ) +:effect (and (at end (increase (speed ?v) ?duration))) +) + +;; Then drive with the accelerator setting. + +(:action drive +:parameters (?v - vehicle ?p ?l - location) +:precondition (and (at ?v ?p) (> (speed ?v) 0)) +:effect (and (at ?v ?l) (not (at ?v ?p)) +(increase (traveltime ?v) (/ (distance ?p ?l) (speed ?v)))) +) + + +) diff --git a/domainsWithEventsAndProcesses/Drive/driveplan.pddl b/domainsWithEventsAndProcesses/Drive/driveplan.pddl new file mode 100644 index 0000000..75863fc --- /dev/null +++ b/domainsWithEventsAndProcesses/Drive/driveplan.pddl @@ -0,0 +1,2 @@ +0: (accelerate car) [5] +5.001: (drive car start end) \ No newline at end of file diff --git a/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/SleepingBeautyWithDelayedAlarm.png b/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/SleepingBeautyWithDelayedAlarm.png new file mode 100644 index 0000000..f7008f2 Binary files /dev/null and b/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/SleepingBeautyWithDelayedAlarm.png differ diff --git a/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeauty-problem.txt b/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeauty-problem.txt new file mode 100644 index 0000000..eb911f5 --- /dev/null +++ b/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeauty-problem.txt @@ -0,0 +1,13 @@ +(define (problem sleepingbeauty-problem) +(:domain sleepingbeauty) +(:objects ) +(:init (= (charge) 0) + (= (resistance) 2) + (= (ringtime) 0) + (windowclosed) + (magnetoperational) + (alarmdisabled) + (deeplyasleep) +) +(:goal (awake)) +(:metric minimize (total-time))) diff --git a/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeauty-problem2.txt b/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeauty-problem2.txt new file mode 100644 index 0000000..93fe52b --- /dev/null +++ b/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeauty-problem2.txt @@ -0,0 +1,15 @@ +(define (problem sleepingbeauty-problem) +(:domain sleepingbeauty) +(:objects ) +(:init (= (charge) 0) + (= (resistance) 2) ;; Resistance of 1 is just small enough to + ;; avoid the rousing event, but smaller than this will + ;; cause the alarm to wake her up! + (= (ringtime) 0) + (windowclosed) + (magnetoperational) + (alarmdisabled) + (deeplyasleep) +) +(:goal (and (freshair) (deeplyasleep))) +(:metric minimize (total-time))) diff --git a/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeauty.pddl b/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeauty.pddl new file mode 100644 index 0000000..c7a8378 --- /dev/null +++ b/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeauty.pddl @@ -0,0 +1,76 @@ +(define (domain sleepingbeauty) +(:requirements :fluents :continuous-effects :negative-preconditions :time) +(:predicates (windowclosed) (windowopen) (magnetoperational) (freshair) (circuit) (alarmdisabled) (alarmenabled) (voltage) (ringing) (almostawake) (deeplyasleep) (awake)) +(:functions (charge) (resistance) (ringtime) ) + +(:action openwindow +:parameters ( ) +:precondition (and (windowclosed) (magnetoperational)) +:effect (and (not (magnetoperational)) (not (windowclosed)) (windowopen) (freshair)) +) + +(:action closewindow +:parameters ( ) +:precondition (and (windowopen) (not (magnetoperational))) +:effect (and (magnetoperational) (not (windowopen)) (windowclosed)) +) + +(:event makecircuit +:parameters ( ) +:precondition (and (not (magnetoperational)) (not (circuit))) +:effect (and (circuit)) +) + +(:event breakcircuit +:parameters ( ) +:precondition (and (magnetoperational) (circuit)) +:effect (and (not (circuit)) (assign (charge) 0)) +) + +(:event alarmtriggered +:parameters ( ) +:precondition (and (circuit) (alarmdisabled) (voltage)) +:effect (and (alarmenabled) (not (alarmdisabled)) (ringing)) +) + +(:event alarmdisabled +:parameters ( ) +:precondition (and (not (circuit)) (alarmenabled) (ringing)) +:effect (and (not (alarmenabled)) (not (ringing)) (alarmdisabled) (assign (ringtime) 0)) +) + + +(:event voltageavailable +:parameters ( ) +:precondition (and (>= (charge) 5) (not (voltage))) +:effect (and (voltage)) +) + + +(:process ring +:parameters ( ) +:precondition (ringing) +:effect (and (increase (ringtime) (* #t 1))) +) + +(:event rouseprincess +:parameters ( ) +:precondition (and (ringing) (>= (ringtime) 0.001) (deeplyasleep)) +:effect (and (almostawake) (not (deeplyasleep))) +) + +(:action kiss +:parameters ( ) +:precondition (almostawake) +:effect (and (awake) (not (almostawake))) +) + +(:process chargecapacitor +:parameters ( ) +:precondition (and (circuit) (not (voltage))) +:effect (and (increase (charge) (* #t (/ 1 (resistance))))) + ;assuming capacitance is chosen to make this linear + ;approximation reasonable. +) + +) diff --git a/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeautyplan.pddl b/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeautyplan.pddl new file mode 100644 index 0000000..a1dc519 --- /dev/null +++ b/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeautyplan.pddl @@ -0,0 +1,2 @@ +0: (openwindow) +20.001: (kiss) \ No newline at end of file diff --git a/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeautyplan2.pddl b/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeautyplan2.pddl new file mode 100644 index 0000000..b46a26b --- /dev/null +++ b/domainsWithEventsAndProcesses/Sleeping Beauty with Capacitor/sleepingbeautyplan2.pddl @@ -0,0 +1,2 @@ +0: (openwindow) +9.999: (closewindow) diff --git a/domainsWithEventsAndProcesses/Sleeping Beauty with Magnetic Window Alarm/SleepingBeautyWithAlarm.png b/domainsWithEventsAndProcesses/Sleeping Beauty with Magnetic Window Alarm/SleepingBeautyWithAlarm.png new file mode 100644 index 0000000..4a014dc Binary files /dev/null and b/domainsWithEventsAndProcesses/Sleeping Beauty with Magnetic Window Alarm/SleepingBeautyWithAlarm.png differ diff --git a/domainsWithEventsAndProcesses/Sleeping Beauty with Magnetic Window Alarm/sleepingbeauty-problem.txt b/domainsWithEventsAndProcesses/Sleeping Beauty with Magnetic Window Alarm/sleepingbeauty-problem.txt new file mode 100644 index 0000000..040eadf --- /dev/null +++ b/domainsWithEventsAndProcesses/Sleeping Beauty with Magnetic Window Alarm/sleepingbeauty-problem.txt @@ -0,0 +1,11 @@ +(define (problem sleepingbeauty-problem) +(:domain sleepingbeauty) +(:objects ) +(:init (= (ringtime) 0) + (windowclosed) + (magnetoperational) + (alarmdisabled) + (deeplyasleep) +) +(:goal (awake)) +(:metric minimize (total-time))) diff --git a/domainsWithEventsAndProcesses/Sleeping Beauty with Magnetic Window Alarm/sleepingbeauty.pddl b/domainsWithEventsAndProcesses/Sleeping Beauty with Magnetic Window Alarm/sleepingbeauty.pddl new file mode 100644 index 0000000..e6bc559 --- /dev/null +++ b/domainsWithEventsAndProcesses/Sleeping Beauty with Magnetic Window Alarm/sleepingbeauty.pddl @@ -0,0 +1,69 @@ +(define (domain sleepingbeauty2) +(:requirements :fluents :continuous-effects :negative-preconditions :time) +(:predicates (windowclosed) (windowopen) (magnetoperational) (freshair) (circuit) (alarmdisabled) (alarmenabled) (voltage) (ringing) (almostawake) (deeplyasleep) (awake) ) +(:functions (ringtime) ) + +(:action openwindow +:parameters ( ) +:precondition (and (windowclosed) (magnetoperational)) +:effect (and (not (magnetoperational)) (not (windowclosed)) (windowopen) (freshair)) + ;; Having fresh air is a possible goal which forces + ;; the window to be opened. +) + +(:action closewindow +:parameters ( ) +:precondition (and (windowopen) (not (magnetoperational))) +:effect (and (magnetoperational) (not (windowopen)) (windowclosed)) +) + +(:event makecircuit +:parameters ( ) +:precondition (and (not (magnetoperational)) (not (circuit))) +:effect (and (circuit)) +) + +(:event alarmtriggered +:parameters ( ) +:precondition (and (circuit) (alarmdisabled) ) +:effect (and (not (alarmdisabled)) (ringing) ) +) + +(:event breakcircuit +:parameters ( ) +:precondition (and (magnetoperational) (circuit)) +:effect (and (not (circuit))) +) + + +(:event alarmterminated +:parameters ( ) +:precondition (and (ringing) (not (circuit))) +:effect (and (not (ringing)) (alarmdisabled)) +) + + +(:process ring +:parameters ( ) +:precondition (ringing) +:effect (and (increase (ringtime) (* #t 1))) +) + +(:event rouseprincess +:parameters ( ) +:precondition (and (ringing) (>= (ringtime) 0.001) + ;; If this time delay is longer then it is possible to + ;; open the window and close it before Sleeping Beauty + ;; wakes up, but otherwise giving her fresh air will + ;; rouse her (because of the alarm). + (deeplyasleep)) +:effect (and (almostawake) (not (deeplyasleep))) +) + +(:action kiss +:parameters ( ) +:precondition (almostawake) +:effect (and (awake) (not (almostawake))) +) + +) diff --git a/domainsWithEventsAndProcesses/Sleeping Beauty with Magnetic Window Alarm/sleepingbeautyplan.pddl b/domainsWithEventsAndProcesses/Sleeping Beauty with Magnetic Window Alarm/sleepingbeautyplan.pddl new file mode 100644 index 0000000..e9bd6c0 --- /dev/null +++ b/domainsWithEventsAndProcesses/Sleeping Beauty with Magnetic Window Alarm/sleepingbeautyplan.pddl @@ -0,0 +1,2 @@ +0: (openwindow) +0.002: (kiss) diff --git a/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/ValTalk.pdf b/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/ValTalk.pdf new file mode 100644 index 0000000..ee82d81 Binary files /dev/null and b/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/ValTalk.pdf differ diff --git a/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/tank-domain.pddl b/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/tank-domain.pddl new file mode 100644 index 0000000..5aa0d6f --- /dev/null +++ b/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/tank-domain.pddl @@ -0,0 +1,24 @@ +(define (domain tank-domain) +(:requirements :fluents :durative-actions :duration-inequalities :negative-preconditions) +(:predicates (draining ?t) (filling ?b)) +(:functions (volume ?t) (drain-time ?t) (flow-constant ?t) (capacity ?b) (sqrtvolinit ?t) (sqrtvol ?t)) + +(:durative-action fill-bucket +:parameters (?b ?t) +:duration (<= ?duration (/ (sqrtvolinit ?t) (flow-constant ?t))) +:condition (and (over all (<= (volume ?b) (capacity ?b))) + (at start (not (draining ?t))) + (at start (not (filling ?b)))) +:effect (and (at start (assign (drain-time ?t) 0)) + (at start (assign (sqrtvol ?t) (sqrtvolinit ?t))) + (at start (draining ?t)) + (at start (filling ?b)) + (increase (drain-time ?t) (* #t 1)) + (decrease (volume ?t) (* #t (* (* 2 (flow-constant ?t)) + (- (sqrtvolinit ?t) (* (flow-constant ?t) (drain-time ?t)))))) + (decrease (sqrtvol ?t) (* #t (flow-constant ?t))) + (increase (volume ?b) (* #t (* (* 2 (flow-constant ?t)) + (- (sqrtvolinit ?t) (* (flow-constant ?t) (drain-time ?t)))))) + (at end (assign (sqrtvolinit ?t) (sqrtvol ?t))) + (at end (not (draining ?t))) + (at end (not (filling ?b)))))) diff --git a/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/tank-problem.pddl b/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/tank-problem.pddl new file mode 100644 index 0000000..8b948bd --- /dev/null +++ b/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/tank-problem.pddl @@ -0,0 +1,13 @@ +(define (problem tank-problem) +(:domain tank-domain) +(:objects tank1 tank2 bucket) +(:init (= (volume bucket) 0) + (= (capacity bucket) 60) + (= (volume tank1) 100) + (= (sqrtvolinit tank1) 10) + (= (flow-constant tank1) 0.8) + (= (volume tank2) 64) + (= (sqrtvolinit tank2) 8) + (= (flow-constant tank2) 1)) +(:goal (> (volume bucket) (- (capacity bucket) 2))) +(:metric minimize (total-time))) diff --git a/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/tankplan.pddl b/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/tankplan.pddl new file mode 100644 index 0000000..9dfed13 --- /dev/null +++ b/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/tankplan.pddl @@ -0,0 +1,2 @@ +0.0: (fill-bucket bucket tank1) [2.6] +2.61: (fill-bucket bucket tank2) [1.5] \ No newline at end of file diff --git a/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/twotanks.pdf b/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/twotanks.pdf new file mode 100644 index 0000000..9ffe830 Binary files /dev/null and b/domainsWithEventsAndProcesses/Tanks and a Bucket (Toricelli's formula)/twotanks.pdf differ diff --git a/domainsWithEventsAndProcesses/VendingMachine/Vendingmachine.pdf b/domainsWithEventsAndProcesses/VendingMachine/Vendingmachine.pdf new file mode 100644 index 0000000..6bf7c3c Binary files /dev/null and b/domainsWithEventsAndProcesses/VendingMachine/Vendingmachine.pdf differ diff --git a/domainsWithEventsAndProcesses/VendingMachine/vendingmachine-problem.txt b/domainsWithEventsAndProcesses/VendingMachine/vendingmachine-problem.txt new file mode 100644 index 0000000..48fbeb3 --- /dev/null +++ b/domainsWithEventsAndProcesses/VendingMachine/vendingmachine-problem.txt @@ -0,0 +1,14 @@ +(define (problem vendingmachine-problem) +(:domain vendingmachine) +(:objects ) +(:init (= (vel) 0) + (= (acc) 0) + (= (dist) 0) + (lightsensorstatus) + (= (lightsensorposn) 1) + (= (trayposition) 2) + (= (counted) 0) + (slotopen) +) +(:goal (and (= (counted) 3) (finished))) +(:metric minimize (total-time))) diff --git a/domainsWithEventsAndProcesses/VendingMachine/vendingmachine.pddl b/domainsWithEventsAndProcesses/VendingMachine/vendingmachine.pddl new file mode 100644 index 0000000..0e7289b --- /dev/null +++ b/domainsWithEventsAndProcesses/VendingMachine/vendingmachine.pddl @@ -0,0 +1,47 @@ +(define (domain vending-machine) +(:requirements :fluents :continuous-effects :time) +(:predicates (slotopen) (coinfalling) (newcoin) (finished) (lightsensorstatus) (counterstatus)) +(:functions (acc) (vel) (dist) (lightsensorposn) (trayposition) (counted)) + +(:action entercoin +:parameters ( ) +:precondition (and (slotopen) (lightsensorstatus)) +:effect (and (not (slotopen)) (coinfalling) (newcoin) + (increase (acc) 1)) +) + +(:process falling +:parameters ( ) +:precondition (coinfalling) +:effect (and (increase (dist) (* #t (vel))) + (increase (vel) (* #t (acc)))) +) + +(:event lightsensoroff +:parameters ( ) +:precondition (and (>= (dist) lightsensorposn) (lightsensorstatus) (newcoin)) +:effect (and (not (lightsensorstatus)) + (counterstatus)) +) + +(:event lightsensoron +:parameters ( ) +:precondition (and (not (lightsensorstatus)) (counterstatus) + (> (dist) lightsensorposn)) +:effect (and (lightsensorstatus) (not (counterstatus)) + (not (newcoin)) (increase (counted) 1)) +) + +(:event received +:parameters ( ) +:precondition (and (>= (dist) trayposition) (not (newcoin)) (coinfalling)) +:effect (and (not (coinfalling)) (assign (dist) 0) + (assign (vel) 0) (assign (acc) 0) (slotopen)) +) + +(:action stop +:parameters ( ) +:precondition (and (> (counted) 0) (slotopen)) +:effect (finished) +) +) \ No newline at end of file diff --git a/domainsWithEventsAndProcesses/VendingMachine/vendingmachineplan.pddl b/domainsWithEventsAndProcesses/VendingMachine/vendingmachineplan.pddl new file mode 100644 index 0000000..a34f68c --- /dev/null +++ b/domainsWithEventsAndProcesses/VendingMachine/vendingmachineplan.pddl @@ -0,0 +1,4 @@ +0: (entercoin) +2.001: (entercoin) +4.001: (entercoin) +6.001: (stop) \ No newline at end of file diff --git a/include/Action.h b/include/Action.h index 089e5e3..76ad20d 100644 --- a/include/Action.h +++ b/include/Action.h @@ -65,8 +65,8 @@ class State; class Ownership; class EffectsRecord; class Validator; -class ExecutionContext; -class ActiveCtsEffects; +struct ExecutionContext; +struct ActiveCtsEffects; class StartAction; class EndAction; @@ -125,8 +125,8 @@ class Action { }; }; - friend class FAEhandler; - friend class ActiveCtsEffects; + friend struct FAEhandler; + friend struct ActiveCtsEffects; public: Action(Validator * v,const operator_ * a,const const_symbol_list* bs); @@ -220,12 +220,9 @@ class CondCommunicationAction : public Action { const Proposition * initPre; conj_goal * gli; const Proposition * invPre; - goal * gle; // Will actually be a conj_goal *, but it's not important. effect_lists * els; - effect_lists * ele; - Environment * vars; public: CondCommunicationAction(Validator * v,const durative_action * a,const const_symbol_list * bs, diff --git a/include/Environment.h b/include/Environment.h index 1553f21..f3ab41b 100644 --- a/include/Environment.h +++ b/include/Environment.h @@ -24,120 +24,120 @@ * ************************************************************************/ -/*----------------------------------------------------------------------------- - VAL - The Automatic Plan Validator for PDDL+ - - $Date: 2009-02-05 10:50:12 $ - $Revision: 1.2 $ - - Maria Fox, Richard Howey and Derek Long - PDDL+ and VAL - Stephen Cresswell - PDDL Parser - - maria.fox@cis.strath.ac.uk - derek.long@cis.strath.ac.uk - stephen.cresswell@cis.strath.ac.uk - richard.howey@cis.strath.ac.uk - - By releasing this code we imply no warranty as to its reliability - and its use is entirely at your own risk. - - Strathclyde Planning Group - http://planning.cis.strath.ac.uk - ----------------------------------------------------------------------------*/ -#include -#include - -namespace VAL { - -class var_symbol; -class const_symbol; -class Validator; - -}; - -//#undef vector -//#undef map - -using std::map; -using std::vector; - -#ifndef __MYENVIRONMENT -#define __MYENVIRONMENT - - -//#define vector std::vector - -namespace VAL { - -template bool operator != (T & t1,T & t2) {return ! (t1==t2);}; - -struct Environment : public map { - static map > copies; - - double duration; - - Environment * copy(Validator * v) const - { - Environment * e = new Environment(*this); - copies[v].push_back(e); - //cout << "Copy of "<::iterator i = copies[v].begin();i != copies[v].end();++i) - delete *i; - copies[v].clear(); - - //cout << "Deleting the copies of enviroments here!\\\\\n"; - }; -}; - -template -struct EnvironmentParameterIterator { - Environment * env; - TI pi; - - EnvironmentParameterIterator(Environment * f,TI p) : - env(f), pi(p) {}; - -// Having to cast the const is not good...currently we are forced to do it in order -// to interact with Cascader, but should look at fixing it. - const_symbol * operator*() - { - if(const_symbol * s = const_cast(dynamic_cast(*pi))) - { - return s; - }; - return const_cast((*env)[dynamic_cast(*pi)]); - }; - - EnvironmentParameterIterator & operator++() - { - ++pi; - return *this; - }; - - bool operator==(const EnvironmentParameterIterator & li) const - { - return pi==li.pi; - }; - - bool operator!=(const EnvironmentParameterIterator & li) const - { - return pi!=li.pi; - }; -}; - -template -EnvironmentParameterIterator makeIterator(Environment * f,TI p) -{ - return EnvironmentParameterIterator(f,p); -}; - - -}; - -#endif +/*----------------------------------------------------------------------------- + VAL - The Automatic Plan Validator for PDDL+ + + $Date: 2009-02-05 10:50:12 $ + $Revision: 1.2 $ + + Maria Fox, Richard Howey and Derek Long - PDDL+ and VAL + Stephen Cresswell - PDDL Parser + + maria.fox@cis.strath.ac.uk + derek.long@cis.strath.ac.uk + stephen.cresswell@cis.strath.ac.uk + richard.howey@cis.strath.ac.uk + + By releasing this code we imply no warranty as to its reliability + and its use is entirely at your own risk. + + Strathclyde Planning Group + http://planning.cis.strath.ac.uk + ----------------------------------------------------------------------------*/ +#include +#include + +namespace VAL { + +class var_symbol; +class const_symbol; +class Validator; + +}; + +//#undef vector +//#undef map + +using std::map; +using std::vector; + +#ifndef __MYENVIRONMENT +#define __MYENVIRONMENT + + +//#define vector std::vector + +namespace VAL { + +template bool operator != (T & t1,T & t2) {return ! (t1==t2);}; + +struct Environment : public map { + static map > copies; + + double duration; + + Environment * copy(Validator * v) const + { + Environment * e = new Environment(*this); + copies[v].push_back(e); + //cout << "Copy of "<::iterator i = copies[v].begin();i != copies[v].end();++i) + delete *i; + copies[v].clear(); + + //cout << "Deleting the copies of enviroments here!\\\\\n"; + }; +}; + +template +struct EnvironmentParameterIterator { + Environment * env; + TI pi; + + EnvironmentParameterIterator(Environment * f,TI p) : + env(f), pi(p) {}; + +// Having to cast the const is not good...currently we are forced to do it in order +// to interact with Cascader, but should look at fixing it. + const_symbol * operator*() + { + if(const_symbol * s = const_cast(dynamic_cast(*pi))) + { + return s; + }; + return const_cast((*env)[dynamic_cast(*pi)]); + }; + + EnvironmentParameterIterator & operator++() + { + ++pi; + return *this; + }; + + bool operator==(const EnvironmentParameterIterator & li) const + { + return pi==li.pi; + }; + + bool operator!=(const EnvironmentParameterIterator & li) const + { + return pi!=li.pi; + }; +}; + +template +EnvironmentParameterIterator makeIterator(Environment * f,TI p) +{ + return EnvironmentParameterIterator(f,p); +}; + + +}; + +#endif diff --git a/include/Ownership.h b/include/Ownership.h index 4cf1266..84b5241 100644 --- a/include/Ownership.h +++ b/include/Ownership.h @@ -55,7 +55,7 @@ namespace VAL { class Validator; class Action; class FuncExp; -class Environment; +struct Environment; class SimpleProposition; class expression; diff --git a/include/Plan.h b/include/Plan.h index 802108f..4e375bc 100644 --- a/include/Plan.h +++ b/include/Plan.h @@ -74,7 +74,7 @@ class Action; class InvariantAction; class CtsEffectAction; class CondCommunicationAction; -class ExecutionContext; +struct ExecutionContext; class Update { @@ -137,8 +137,8 @@ class Happening { bool afterPlan; public: - friend class ExecutionContext; - friend class ActiveCtsEffects; + friend struct ExecutionContext; + friend struct ActiveCtsEffects; private: template struct select2nd { diff --git a/include/Proposition.h b/include/Proposition.h index 48a2002..0cee0ac 100644 --- a/include/Proposition.h +++ b/include/Proposition.h @@ -70,7 +70,7 @@ class Action; -class ActiveCtsEffects; +struct ActiveCtsEffects; class DerivedGoal; class AdviceProposition; @@ -298,11 +298,10 @@ class Comparison : public Proposition { class ConjGoal : public Proposition { private: - const conj_goal * cg; const vector gs; public: ConjGoal(const conj_goal * c,const vector & g,const Environment & bs) : - Proposition(bs), cg(c), gs(g) + Proposition(bs), gs(g) {}; bool evaluate(const State *,vector = vector()) const; Intervals getIntervals(const State* s) const; @@ -328,11 +327,10 @@ class ConjGoal : public Proposition { class DisjGoal : public Proposition { private: - const disj_goal * dg; const vector gs; public: DisjGoal(const disj_goal * d,const vector & g,const Environment & bs) : - Proposition(bs), dg(d), gs(g) + Proposition(bs), gs(g) {}; bool evaluate(const State *,vector = vector()) const; Intervals getIntervals(const State* s) const; @@ -357,13 +355,12 @@ class DisjGoal : public Proposition { class ImplyGoal : public Proposition { private: - const imply_goal * ig; const Proposition * ant; const Proposition * cons; public: ImplyGoal(const imply_goal * i,const Proposition * a,const Proposition * c, const Environment & bs) : - Proposition(bs), ig(i), ant(a), cons(c) + Proposition(bs), ant(a), cons(c) {}; bool evaluate(const State *,vector = vector()) const; Intervals getIntervals(const State* s) const; @@ -386,11 +383,10 @@ class ImplyGoal : public Proposition { class NegGoal : public Proposition { private: - const neg_goal * ng; const Proposition * p; public: NegGoal(const neg_goal * n,const Proposition * pp,const Environment & bs) : - Proposition(bs), ng(n), p(pp) + Proposition(bs), p(pp) {}; bool evaluate(const State *,vector = vector()) const; Intervals getIntervals(const State* s) const; diff --git a/include/TypedAnalyser.h b/include/TypedAnalyser.h index 21d19a8..0fac6bd 100644 --- a/include/TypedAnalyser.h +++ b/include/TypedAnalyser.h @@ -62,7 +62,7 @@ extern TypeChecker * theTC; class holding_pred_symbol; class extended_pred_symbol; -class Environment; +struct Environment; class Associater; void cwrite(const parameter_symbol * p,ostream & o); diff --git a/include/ptree.h b/include/ptree.h index 9fd380a..9aaf696 100644 --- a/include/ptree.h +++ b/include/ptree.h @@ -149,8 +149,8 @@ class parse_category; class var_symbol_table_stack; class analysis; -class WriteController; -class VisitController; +struct WriteController; +struct VisitController; class class_def; class class_symbol; diff --git a/obj/validate/src/Action.o b/obj/validate/src/Action.o index 761ac50..301c7a3 100644 Binary files a/obj/validate/src/Action.o and b/obj/validate/src/Action.o differ diff --git a/obj/validate/src/Events.o b/obj/validate/src/Events.o index 33d8a3c..dcdb4a3 100644 Binary files a/obj/validate/src/Events.o and b/obj/validate/src/Events.o differ diff --git a/obj/validate/src/Plan.o b/obj/validate/src/Plan.o index 80c2b13..6d95b86 100644 Binary files a/obj/validate/src/Plan.o and b/obj/validate/src/Plan.o differ diff --git a/obj/validate/src/Polynomial.o b/obj/validate/src/Polynomial.o index f31bea6..a2f05d9 100644 Binary files a/obj/validate/src/Polynomial.o and b/obj/validate/src/Polynomial.o differ diff --git a/obj/validate/src/Proposition.o b/obj/validate/src/Proposition.o index ec6819c..6facb3e 100644 Binary files a/obj/validate/src/Proposition.o and b/obj/validate/src/Proposition.o differ diff --git a/obj/validate/src/pddl+.o b/obj/validate/src/pddl+.o index 04669d4..5e0bb3d 100644 Binary files a/obj/validate/src/pddl+.o and b/obj/validate/src/pddl+.o differ diff --git a/src/Action.cpp b/src/Action.cpp index 19aad72..6b75d4c 100644 --- a/src/Action.cpp +++ b/src/Action.cpp @@ -754,8 +754,7 @@ CondCommunicationAction::CondCommunicationAction(Validator * v,const durative_ac initPre(gs->empty()?0:vld->pf.buildProposition(gls,bindings)), gli(new conj_goal(const_cast(gi))), invPre(gi->empty()?0:vld->pf.buildProposition(gli,bindings)), - gle(act->precondition), - els(es), ele(el), vars(0) {}; + els(es) {}; CondCommunicationAction::CondCommunicationAction(Validator * v,const durative_action * a,const const_symbol_list * bs, @@ -767,8 +766,7 @@ CondCommunicationAction::CondCommunicationAction(Validator * v,const durative_ac // initPre(gs->empty()?0:vld->pf.buildProposition(gls,bindings)), gli(new conj_goal(const_cast(gi))), // invPre(gi->empty()?0:vld->pf.buildProposition(gli,bindings)), - gle(act->precondition), - els(es), ele(el), vars(vs) + els(es) { cout << "I have a real forall CCA to build for variables: "; diff --git a/src/Events.cpp b/src/Events.cpp deleted file mode 100644 index 77e9b78..0000000 --- a/src/Events.cpp +++ /dev/null @@ -1,2023 +0,0 @@ -/************************************************************************ - * Copyright 2008, Strathclyde Planning Group, - * Department of Computer and Information Sciences, - * University of Strathclyde, Glasgow, UK - * http://planning.cis.strath.ac.uk/ - * - * Maria Fox, Richard Howey and Derek Long - VAL - * Stephen Cresswell - PDDL Parser - * - * This file is part of VAL, the PDDL validator. - * - * VAL is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * VAL is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with VAL. If not, see . - * - ************************************************************************/ - -/*----------------------------------------------------------------------------- - VAL - The Automatic Plan Validator for PDDL+ - - $Date: 2009-02-05 10:50:12 $ - $Revision: 1.2 $ - - Maria Fox, Richard Howey and Derek Long - PDDL+ and VAL - Stephen Cresswell - PDDL Parser - - maria.fox@cis.strath.ac.uk - derek.long@cis.strath.ac.uk - stephen.cresswell@cis.strath.ac.uk - richard.howey@cis.strath.ac.uk - - By releasing this code we imply no warranty as to its reliability - and its use is entirely at your own risk. - - Strathclyde Planning Group - http://planning.cis.strath.ac.uk - ----------------------------------------------------------------------------*/ - - #include "Events.h" - #include "Plan.h" - #include "Validator.h" - #include "Action.h" - #include "RobustAnalyse.h" - -namespace VAL { - -Events::Events(const operator_list * ops) : ungroundEvents(), ungroundProcesses(), - triggeredEvents(), triggeredProcesses(), untriggeredProcesses(), activeProcesses(), eventsForMutexCheck(), oldTriggeredEvents(), lastHappeningTime(0), ctsEventTriggered(false) //, noevents(0) -{ - - for(operator_list::const_iterator i = ops->begin();i != ops->end();++i) - { - if(event * e = dynamic_cast(*i)) - { - ungroundEvents.push_back(e); - } - else if(process * p = dynamic_cast(*i)) - { - ungroundProcesses.push_back(p); - }; - }; - - - }; - -Events::~Events() -{ - ungroundEvents.clear(); - triggeredEvents.clear(); - ungroundProcesses.clear(); - triggeredProcesses.clear(); - for(vector::iterator i = oldTriggeredEvents.begin(); i != oldTriggeredEvents.end(); ++i) - delete *i; - - for(map >::iterator j = activeProcesses.begin(); j != activeProcesses.end(); ++j) - {j->second.first->destroy(); delete j->second.second;}; - - activeProcesses.clear(); -}; - -string Events::getName(operator_ * op,const_symbol_list * csl) const -{ - string eventName = "("+op->name->getName(); - for(const_symbol_list::iterator cs = csl->begin(); cs != csl->end(); ++cs) - { - eventName += " "+(*cs)->getName(); - }; - - return eventName +")"; - -}; - -bool Events::isTriggered(event * eve,const_symbol_list * csl) const -{ - string eventName = eve->name->getName(); - for(const_symbol_list::iterator cs = csl->begin(); cs != csl->end(); ++cs) - { - eventName += (*cs)->getName(); - }; - - set::const_iterator i = triggeredEvents.find(eventName); - - if(i != triggeredEvents.end()) - { - eventName = "(" + eve->name->getName(); - for(const_symbol_list::iterator cs = csl->begin(); cs != csl->end(); ++cs) - { - eventName += " "+(*cs)->getName(); - }; - eventName += ")"; - - if(LaTeX) - { - *report << "\\errorr{Attempt to trigger event \\exprn{"<getName0(); - - set::const_iterator i = triggeredEvents.find(eventName); - - if(i != triggeredEvents.end()) - { - if(LaTeX) - { - *report << "\\errorr{Attempt to trigger event \\exprn{"<<*act<<"} twice}\\\\\n"; - } - else if(Verbose) *report << "Attempt to trigger event "<<*act<<" twice\n"; - - return true; - }; - - return false; -}; - -bool Events::isProcessTriggered(const StartAction * sa) const -{ - set::iterator i = triggeredProcesses.find(sa); - - return (i != triggeredProcesses.end()); -}; - -bool Events::isProcessActive(process * pro,const_symbol_list * csl) const -{ - string processName = pro->name->getName(); - for(const_symbol_list::iterator cs = csl->begin(); cs != csl->end(); ++cs) - { - processName += (*cs)->getName(); - }; - - for(map >::const_iterator i = activeProcesses.begin(); i != activeProcesses.end(); ++i) - { - if(processName == i->first->getName0()) - { - return true; - }; - - }; - - return false; - -}; - -bool Events::isProcessUntriggered(process * pro,const_symbol_list * csl) const -{ - string processName = pro->name->getName(); - for(const_symbol_list::iterator cs = csl->begin(); cs != csl->end(); ++cs) - { - processName += (*cs)->getName(); - }; - - set::iterator i = untriggeredProcesses.find(processName); - - return (i != untriggeredProcesses.end()); -}; - -void deleteParameters(vector & vcsl) -{ - for(vector::iterator p = vcsl.begin(); p != vcsl.end(); ++p) - delete *p; -}; - -const vector removeRepeatedParameters(const vector & vcsl) -{ - vector listOfParameters; - - set parameterLists; - for(vector::const_iterator i = vcsl.begin(); i != vcsl.end(); ++i) - { - string eventName; - for(const_symbol_list::iterator cs = (*i)->begin(); cs != (*i)->end(); ++cs) - { - eventName += (*cs)->getName(); - }; - - set::const_iterator pl = parameterLists.find(eventName); - if(pl == parameterLists.end()) - { - listOfParameters.push_back(*i); - parameterLists.insert(eventName); - } - else - delete *i; - }; - - return listOfParameters; -}; - -const_symbol_list * newBlankConstSymbolList(var_symbol_list * parameters,Validator * v) -{ - //create blank list of parameters, ie every parameter is undefined - const_symbol_list * blankcsl = new const_symbol_list(); - for(var_symbol_list::const_iterator i = parameters->begin(); i != parameters->end(); ++i) - { - const_symbol * cs = 0; //v->getAnalysis()->const_tab.symbol_get(""); - blankcsl->push_back(cs); - }; - - return blankcsl; -}; - -const EndAction * addEndProcess(vector & processes,const StartAction * sa,const_symbol_list * csl,Validator * v) -{ - //create end action to end the process - const operator_ * pro = sa->getAction(); - action * dae = new safeaction(pro->name,pro->parameters,new conj_goal(new goal_list()),new effect_lists(),pro->symtab); - const EndAction * endAct = new EndAction(v,dae,csl,sa,0,new goal_list()); - processes.push_back(endAct); - return endAct; -}; - -void Events::updateHappeningTime(double t) -{ - if(lastHappeningTime != t) - { - triggeredEvents.clear(); //to check for events being triggered twice at the same time point - triggeredProcesses.clear(); //to ensure a process is not triggered and untriggered at same time point due to rounding errors - untriggeredProcesses.clear(); //to ensure a processes is not untriggered and then retriggered at the same time point due to rounding when triggering processes by discrete change! - }; - lastHappeningTime = t; - -}; - -void Events::updateEventsForMutexCheck(Validator * v) -{ - eventsForMutexCheck.clear(); - vector listOfParameters0; - vector listOfParameters00; - set svs; - vector listOfParameters; - - for(vector::iterator e = ungroundEvents.begin(); e != ungroundEvents.end(); ++e) - { - listOfParameters0 = getParametersCts((*e)->precondition,*e,v,false,true); - listOfParameters00 = removeRepeatedParameters(listOfParameters0); - svs = getVariables(*e); - listOfParameters = defineUndefinedParameters(listOfParameters00,*e,v,svs); - - //add events to a event happening - for(vector::iterator p = listOfParameters.begin(); p != listOfParameters.end(); ++p) - { - const Action * anAction = new Action(v,*e,*p); - eventsForMutexCheck.push_back(anAction); - oldTriggeredEvents.push_back(anAction); - }; //end of looping thro' parameters - - deleteParameters(listOfParameters); - - }; -}; - -//trigger processes and events before the first happening in the plan -bool Events::triggerInitialEvents(Validator * v,double firstHappeningTime) -{ - if(!hasEvents()) return true; - - bool isOK = true; - ActiveCtsEffects * ace = v->getActiveCtsEffects(); - ace->clearCtsEffects(); //clear cts effect given by the first happening - - //check for events and processes in the intitial state - isOK = triggerDiscreteEvents(v,true); - - //update values before the first happening of the plan! - if(ace->hasCtsEffects() && (isOK || ContinueAnyway)) //if processes have been activated in the intitial state then there may be events to trigger and we need to update values before the first happening - { - ace->setTime(firstHappeningTime); - ace->setLocalUpdateTime(firstHappeningTime); - isOK = triggerEventsOnInterval(v,true) && isOK; - - if(isOK || ContinueAnyway) - { - //execute cts update happening - if(firstHappeningTime != 0) - { - if(Verbose) *report << "\n"; - ace->setLocalUpdateTime(firstHappeningTime - v->getState().getTime()); - const Happening * updateHap = ace->getCtsEffectUpdate(); - updateHap->adjustActiveCtsEffects(*ace); - isOK = v->executeHappening(updateHap) && isOK; - ace->ctsEffectsProcessed = false; ace->addActiveFEs();//update cts effects - }; - }; - - }; - - v->adjustActiveCtsEffects(ace); - return isOK; -}; - -bool Events::triggerEventsOnInterval(Validator * v,bool init) -{ - bool isOK = true; - - - do - { - isOK = triggerDiscreteEvents(v,init) && isOK; if(!isOK && !ContinueAnyway) return false; - - isOK = triggerContinuousEvents(v,init) && isOK; if(!isOK && !ContinueAnyway) return false; - - }while(ctsEventTriggered); - - return isOK; -}; - -bool checkPreconditionsAreNotSatisfied(const State * s,const vector & events) -{ - for(vector::const_iterator i = events.begin(); i != events.end(); ++i) - { -// cout << "Checking a precondition for "<< *i << "\n"; - if((*i)->getPrecondition()->evaluate(s)) - { - if(LaTeX) *report << "\\> Event "<<*i<<" does not falsify its precondition!\\\\\n"; - else if(Verbose) cout << "Event "<<*i<<" does not falsify its precondition!\n"; - - return false; - }; - - - }; - - return true; -}; - -//trigger events given by discrete change -bool Events::triggerDiscreteEvents(Validator * v,bool init) -{ - if(EventPNEJuddering) JudderPNEs = true; - double theCurrentTime = v->getState().getTime(); - updateHappeningTime(theCurrentTime); - bool isOK = true; - - vector listOfParameters; - int numberofEvents = 0; - //trigger events: build up list of events to be triggered then add to a happening and execute the happening - //then test for more events - bool eventTriggered; - do{ - eventTriggered = false; - vector acts; - - for(vector::iterator e = ungroundEvents.begin(); e != ungroundEvents.end(); ++e) - { - - if(!init || (theCurrentTime != 0)) - { - listOfParameters = getParametersDiscreteFinal((*e)->precondition,*e,v->getState()); - } - else - { - listOfParameters = getParametersDiscreteInitialFinal((*e)->precondition,*e,v); - - if(!listOfParameters.empty()) - { - *report << "Event preconditions are not permitted to be satisfied in the initial state!\n"; - if(!ContinueAnyway) return false; - isOK = false; - }; - }; - - //add events to a event happening and remove repetitions - for(vector::iterator p = listOfParameters.begin(); p != listOfParameters.end(); ++p) - { - if(isTriggered(*e,*p)) isOK = false; - else - { - const Action * anAction = new Action(v,*e,*p); //include precondition to check for mutex events? yes - acts.push_back(anAction); - triggeredEvents.insert(anAction->getName0()); - oldTriggeredEvents.push_back(anAction); - }; - - }; //end of looping thro' parameters - - deleteParameters(listOfParameters); - - }; //end of looping thro' events - - //apply events as a happening to the state - if(acts.size() != 0 && (isOK || ContinueAnyway)) - { - if(numberofEvents > 1) - { - *report << "Event cascades of this nature are not yet handled robustly!\n"; - if(!ContinueAnyway) return false; - isOK = false; - }; - - if(Verbose) cout << "\n"; - Happening * eventHappening = new Happening(v,acts,true); - isOK = v->executeHappening(eventHappening) && isOK; - isOK = checkPreconditionsAreNotSatisfied(&(v->getState()),acts) && isOK; - eventHappening->clearActions(); delete eventHappening; - if(!isOK && !ContinueAnyway) return false; - eventTriggered = true; - numberofEvents = acts.size(); - - }; - - isOK = triggerDiscreteProcesses(v) && isOK; - - }while(eventTriggered); //if events were triggered this may result in more events triggering - - eventsForMutexCheck.clear(); - - - if(EventPNEJuddering) JudderPNEs = false; - return isOK; -}; - -const StartAction * newStartProcessAction(process* pro, const_symbol_list* csl,Validator * v) -{ - effect_lists * elc = new effect_lists(); - - for(pc_list::const_iterator i = pro->effects->timed_effects.begin(); - i != pro->effects->timed_effects.end();++i) - { - if((*i)->ts == E_CONTINUOUS) - { - insert_effects(elc,(*i)->effs); - }; - }; - - //create a StartAction here - action * das = new safeaction(pro->name,pro->parameters,new conj_goal(new goal_list()),new effect_lists(),pro->symtab); - return new StartAction(v,das,csl,new conj_goal(new goal_list()),elc,0.0,new goal_list(),vector(),vector()); - -}; - -const EndAction * newEndProcess(const StartAction * sa,const_symbol_list * csl,Validator * v) -{ - //create end action to end the process - const operator_ * pro = sa->getAction(); - action * dae = new safeaction(pro->name,pro->parameters,new conj_goal(new goal_list()),new effect_lists(),pro->symtab); - const EndAction * endAct = new EndAction(v,dae,csl,sa,0,new goal_list()); - return endAct; -}; - -//trigger processes given by discrete change -bool Events::triggerDiscreteProcesses(Validator * v) -{ - if(EventPNEJuddering) JudderPNEs = true; - bool isOK = true; - vector processes; - double time = v->getState().getTime(); - - //find processes that are ended - if(time > 0) - { - vector eraseElements; - for(map >::iterator ap = activeProcesses.begin(); - ap != activeProcesses.end() ; ++ap) - { - const_cast(ap->second.first)->resetCtsFunctions(); //ensure we are checking the precondition at a point not on an interval - - if(!(ap->second.first->evaluate(&v->getState())) && !(isProcessTriggered(ap->first))) - { - const EndAction * endAct = addEndProcess(processes,ap->first,ap->second.second,v); - oldTriggeredEvents.push_back(endAct); - ap->second.first->destroy(); delete ap->second.second; eraseElements.push_back(ap->first); - untriggeredProcesses.insert(ap->first->getName0()); - }; - }; - - for(vector::iterator ee = eraseElements.begin(); ee != eraseElements.end(); ++ee) - activeProcesses.erase(*ee); - }; - - for(vector::const_iterator p = ungroundProcesses.begin(); p != ungroundProcesses.end(); ++p) - { - //for every process check if it could be triggered in the initial state or later on - //get list of parameters (may be empty) - vector listOfParameters; - if(time == 0.0) - { - listOfParameters = getParametersDiscreteInitialFinal((*p)->precondition,*p,v); - } - else - { - listOfParameters = getParametersDiscreteFinal((*p)->precondition,*p,v->getState()); //need to check for all changes after the event cascade, this is the best way, only consider the process if something has changed - }; - //cout << "Process " << (*p)->name->getName() << " with " << listOfParameters.size() << "\n"; - - //add processes to an event happening and remove repetitions - for(vector::iterator pa = listOfParameters.begin(); pa != listOfParameters.end(); ++pa) - { - if(!isProcessActive(*p,*pa) /*&& !isProcessUntriggered(*p,*pa)*/) //no need to check if it has not been untriggered, because above we now check that the process is triggered by something that has changed - { - const StartAction * sa = newStartProcessAction(*p,*pa,v); - processes.push_back(sa); - //only add the precondition to the list of triggered processes, as we already know it to be satisfied when applied - const Proposition * prop = v->pf.buildProposition((*p)->precondition,*(buildBindings(*p,**pa).copy(v))); - activeProcesses[sa] = make_pair(prop,*pa); - oldTriggeredEvents.push_back(sa); - triggeredProcesses.insert(sa); - //cout << "Triggered " << *sa << "\n"; - } - else - delete *pa; - - }; //end of looping thro' parameters - - - }; //end of looping thro' processes - - //apply processes as a happening to the state - if(processes.size() != 0) - { - if(Verbose) cout << "\n"; - ActiveCtsEffects * ace = v->getActiveCtsEffects(); - Happening * eventHappening = new Happening(v,processes,true); - eventHappening->adjustActiveCtsEffects(*ace); - isOK = v->executeHappening(eventHappening); - eventHappening->clearActions(); delete eventHappening; - if(!isOK && !ContinueAnyway) return false; - - }; - - if(EventPNEJuddering) JudderPNEs = false; - return isOK; -}; - -const vector getParametersDiscreteInitialFinal(goal * g,operator_ * op,Validator * v) -{ - vector aParameterList; - const_symbol_list * blankcsl = newBlankConstSymbolList(op->parameters,v); - aParameterList.push_back(blankcsl); - const vector listOfParameters0 = getParametersList(g,op,v,aParameterList,false,true); - delete blankcsl; - const vector listOfParameters00 = removeRepeatedParameters(listOfParameters0); - const set svs = getVariables(op); - return defineUndefinedParameters(listOfParameters00,op,v,svs); -}; - -const vector getParametersDiscreteFinal(goal * g,operator_ * op, const State & s) -{ - //get list of parameters (may be empty) - const vector listOfParameters0 = getParametersDiscrete(g,op,s); - const vector listOfParameters00 = removeRepeatedParameters(listOfParameters0); - const set svs = getVariables(op); - return defineUndefinedParameters(listOfParameters00,op,s.getValidator(),svs); -}; - -const vector getParametersCtsFinal(goal * g,operator_ * op,Validator * v) -{ - const vector listOfParameters0 = getParametersCts(g,op,v,false,false); - const vector listOfParameters00 = removeRepeatedParameters(listOfParameters0); - const set svs = getVariables(op); - return defineUndefinedParameters(listOfParameters00,op,v,svs); -}; - -//trigger events given by ctsly changing PNEs -bool Events::triggerContinuousEvents(Validator * v,bool init) -{ - if(!init && v->isLastHappening()) return true; - if(EventPNEJuddering) JudderPNEs = true; - ctsEventTriggered = false; - ActiveCtsEffects * ace = v->getActiveCtsEffects(); - ExecutionContext * ec = v->getExecutionContext(); - vector listOfParameters; - - double currentTime = v->getState().getTime(); - double nextTime; - if(!init) nextTime = v->getNextHappeningTime(); else nextTime = v->getCurrentHappeningTime(); - double localTime = nextTime - currentTime; - if(localTime == 0) return true; - - bool isOK = true; - vector acts; - vector processes; - - ace->setLocalUpdateTime(localTime); //set value of LocalUpdateTime - time since last regular happening - - //process cts effects, build polys etc, conditional cts effects handled here also - - if(TestingPNERobustness) ace->addActiveFEs(true); - else ace->addActiveFEs(); - - - if(!ace->hasCtsEffects()) return true; - - //get parameters for all events that may be triggered due to cts effects - for(vector::iterator e = ungroundEvents.begin(); e != ungroundEvents.end(); ++e) - { - listOfParameters = getParametersCtsFinal((*e)->precondition,*e,v); - - for(vector::iterator p = listOfParameters.begin(); p != listOfParameters.end(); ++p) - { - const Action * anAction = new Action(v,*e,*p); - const_cast(anAction->getPrecondition())->setUpComparisons(ace); - acts.push_back(anAction); - };//end of loop thro' parameters - - deleteParameters(listOfParameters); - }; - - //find out when events are first triggered, if at all - vector > ctsTriggeredEvents; - Intervals eventIntervals; - for(vector::iterator e = acts.begin(); e != acts.end(); ++e) - { - try - { - eventIntervals = (*e)->getPrecondition()->getIntervals(&(v->getState())); - } - catch(BadAccessError & e) - { - //if a PNE is not defined, then no problem, the event is simply not triggered - }; - - if(!eventIntervals.intervals.empty()) - { - ctsTriggeredEvents.push_back(make_pair(*e, eventIntervals.intervals.begin()->first));//intervals are constructed left to right so this is the minimum point - } - else - delete *e; - - }; - - //get start time for processes to trigger - add to list of actions - map > startProcesses; - for(vector::iterator pro = ungroundProcesses.begin(); pro != ungroundProcesses.end(); ++pro) - { - listOfParameters = getParametersCtsFinal((*pro)->precondition,*pro,v); - - for(vector::iterator p = listOfParameters.begin(); p != listOfParameters.end(); ++p) - { - if(!isProcessActive(*pro,*p) /*&& !isProcessUntriggered(*pro,*p)*/) - { - //create a StartAction here - const StartAction * sa = newStartProcessAction(*pro,*p,v); - const Proposition * prop = v->pf.buildProposition((*pro)->precondition,*(buildBindings(*pro,**p).copy(v))); - const_cast(prop)->setUpComparisons(ace); - eventIntervals = prop->getIntervals(&(v->getState())); - - if(!eventIntervals.intervals.empty()) - { - intervalEnd startTime = make_pair(-1,true); - - //do not trigger a process on an isolated point - for(vector< pair >::const_iterator ei = eventIntervals.intervals.begin(); ei != eventIntervals.intervals.end();++ei) - { - if(ei->first.first != ei->second.first) - { - startTime = ei->first; break; - }; - }; - - if(startTime.first != -1) - { - ctsTriggeredEvents.push_back(make_pair(sa, startTime));//intervals are constructed left to right so this is the minimum point - startProcesses[sa] = make_pair(prop,new const_symbol_list(**p)); - }; - } - else - { - delete sa; - prop->destroy(); - }; - }; - }; - - deleteParameters(listOfParameters); - }; - - map endStartMap; - //find processes that could be ended - for(map >::iterator ap = activeProcesses.begin(); ap != activeProcesses.end() ; ++ap) - { - const_cast(ap->second.first)->setUpComparisons(ace); - Intervals eventIntervals0 = ap->second.first->getIntervals(&(v->getState())); - eventIntervals = setComplement(eventIntervals0,localTime); - if(!(eventIntervals.intervals.empty())) - { - const EndAction * endAct = newEndProcess(ap->first,ap->second.second,v); - endStartMap[endAct] = ap->first; - - intervalEnd startTime = make_pair(-1,true); - - //do not untrigger a process on an isolated point - for(vector< pair >::const_iterator ei = eventIntervals.intervals.begin(); ei != eventIntervals.intervals.end();++ei) - { - if(ei->first.first != ei->second.first) - { - startTime = ei->first; break; - }; - }; - - if((startTime.first != -1) && isProcessTriggered(ap->first)) - { - ctsTriggeredEvents.push_back(make_pair(endAct, startTime)); - }; - }; - }; - - vector eventsToTrigger; - CoScalar eventTriggerTime = 0; - //extract the first group of events to be triggered (including processes) - for(vector >::iterator i = ctsTriggeredEvents.begin(); i != ctsTriggeredEvents.end(); ++i) - { - if(eventsToTrigger.empty()) - { - eventTriggerTime = i->second.first; - eventsToTrigger.push_back(i->first); - } - else if(i->second.first == eventTriggerTime) - { - eventsToTrigger.push_back(i->first); - } - else if(i->second.first < eventTriggerTime) - { - eventTriggerTime = i->second.first; - for(vector::iterator k = eventsToTrigger.begin(); k != eventsToTrigger.end(); ++k) delete *k; - eventsToTrigger.clear(); - eventsToTrigger.push_back(i->first); - } - else - delete i->first; - - }; - - //trigger events - Happening * eventHappening; - updateHappeningTime(eventTriggerTime + currentTime); - bool triggerEventsExist = !eventsToTrigger.empty(); - - //remember the no loops rule, i.e. an event cannot be triggered more than once at a given time point, only the same time point as last trigger - //loop thro' events check if they have already been triggered (unless a process) - if(triggerEventsExist) - { - for(vector::const_iterator j = eventsToTrigger.begin(); j != eventsToTrigger.end(); ++j) - if(isTriggered(*j)) - { - if(!ContinueAnyway) return false; - isOK = false; - }; - }; - - if(triggerEventsExist && isOK) - { - ctsEventTriggered = true; - - ace->setTime(eventTriggerTime + currentTime); //same time as event trigger time - ace->setLocalUpdateTime(eventTriggerTime); - - if(eventTriggerTime != 0) - { - //execute invariant happening - ec->setActiveCtsEffects(ace); - ec->setTime(eventTriggerTime + currentTime); //same time as event trigger time - if(ec->hasInvariants()) {if(Verbose) cout << "\n"; isOK = v->executeHappening(ec->getInvariants()) && isOK;}; - ec->setTime(nextTime); //same time as event trigger time - - //execute cts update happening - if(Verbose) cout << "\n"; - isOK = v->executeHappening(ace->getCtsEffectUpdate()) && isOK; - }; - - //execute event happening - if(Verbose) cout << "\n"; - eventHappening = new Happening(v,eventsToTrigger,eventTriggerTime + currentTime,true); - eventHappening->adjustContext(*ec); - eventHappening->adjustActiveCtsEffects(*ace); //update cts effects for interval after event happening - isOK = v->executeHappeningCtsEvent(eventHappening) && isOK; - - lastHappeningTime = eventTriggerTime + currentTime; - vector triggeredStartProcesses; - vector triggeredEndProcesses; - vector events; - - //add to list of triggered events - for(vector::const_iterator j = eventsToTrigger.begin(); j != eventsToTrigger.end(); ++j) - { - (*j)->addTriggeredEvents(events,oldTriggeredEvents,triggeredStartProcesses,triggeredEndProcesses); - }; - - //check triggered events have falsified their preconditions and add to list of triggered events - isOK = checkPreconditionsAreNotSatisfied(&(v->getState()),events) && isOK; - for(vector::const_iterator te = events.begin(); te != events.end(); ++te) triggeredEvents.insert((*te)->getName0()); - - //add triggered processes to list of triggered processes - for(vector::const_iterator trs = triggeredStartProcesses.begin(); trs != triggeredStartProcesses.end(); ++trs) - { - pair propcsl = startProcesses[*trs]; - activeProcesses[*trs] = make_pair(propcsl.first,propcsl.second); - triggeredProcesses.insert(*trs); - startProcesses.erase(*trs); - }; - - //delete unused startProcesses' props and csls - for(map >::iterator sp = startProcesses.begin(); sp != startProcesses.end(); ++sp) - { - sp->second.first->destroy(); delete sp->second.first; - }; - - //remove untriggered processes from list of triggered processes - for(vector::const_iterator trs = triggeredEndProcesses.begin(); trs != triggeredEndProcesses.end(); ++trs) - { - const StartAction * stAction = endStartMap[*trs]; - map >::iterator ap = activeProcesses.find(stAction); - if(ap != activeProcesses.end()) - { - ap->second.first->destroy(); delete ap->second.second; - activeProcesses.erase(ap); - untriggeredProcesses.insert(stAction->getName0()); - }; - - }; - - eventHappening->clearActions(); delete eventHappening; - - //ready for triggering discrete events - ace->setTime(nextTime); - ace->setEventTime(eventTriggerTime + currentTime); - } - else - for(vector::iterator k = eventsToTrigger.begin(); k != eventsToTrigger.end(); ++k) delete *k; - - - - if(EventPNEJuddering) JudderPNEs = false; - return isOK; -}; - -//for discretly triggered events -const vector getParametersDiscrete(goal * g,operator_ * op, const State & s,bool neg) -{ - vector listOfparameters; - - ///Comparison - if(const comparison * comp = dynamic_cast(g)) - { - //get list of PNEs, then make list of parameter lists from them - set pnes; - getPNEs(comp->getLHS(),pnes); - getPNEs(comp->getRHS(),pnes); - - set changedPNEs = s.getChangedPNEs(); - - for(set::iterator pne = pnes.begin(); pne != pnes.end(); ++pne) - { - //has pne changed since last happening - for(set::const_iterator fe = changedPNEs.begin(); fe != changedPNEs.end(); ++fe) - { - if(((*fe)->getName() == (*pne)->getFunction()->getName()) - && (*fe)->checkConstantsMatch((*pne)->getArgs())) //+check consts match! - { - const_symbol_list* parametersForEvent = new const_symbol_list(); - - for(var_symbol_list::iterator j = op->parameters->begin(); j != op->parameters->end(); ++j) - { - string para = getParameter(*fe,*j,*pne); - - const_symbol * cs = para==""?0:s.getValidator()->getAnalysis()->const_tab.symbol_get(para); - - parametersForEvent->push_back(cs); - - }; //end of filling in parameters - - //ground out undefineds here to produce list of parameter lists - //check the comp holds for each parameter list! use only parameters used in comp - set svs = getVariables(comp); - listOfparameters = defineUndefinedParametersPropVar(parametersForEvent,op,s.getValidator(),g,false,neg,svs); - - }; - - };//end of loop for checking if pne could be a changed fe - - }; //end of looping thro' pnes in expression - - return listOfparameters; - }; - - //Literal - if(const simple_goal * sg = dynamic_cast(g)) - { - //handle derived predicates first! - string literalName = sg->getProp()->head->getName(); - vector aParameterList; - if(s.getValidator()->getDerivRules()->isDerivedPred(literalName)) - { - aParameterList.push_back(newBlankConstSymbolList(op->parameters,s.getValidator())); - return getParametersList(g,op,s.getValidator(),aParameterList,neg,true); - }; - - //check if literal is one that has changed since last happening - //if so fill in parameters with one from a simple prop - set changedLiterals = s.getChangedLiterals(); - for(set::const_iterator sp = changedLiterals.begin(); sp != changedLiterals.end(); ++sp) - { - if( ((*sp)->getPropName() == literalName) && ((!neg && s.evaluate(*sp)) || (neg && !s.evaluate(*sp))) - && (*sp)->checkConstantsMatch(sg->getProp()->args) ) - { - const_symbol_list* parametersForEvent = new const_symbol_list(); - - //fill in parameters for event - for(var_symbol_list::iterator j = op->parameters->begin(); j != op->parameters->end(); ++j) - { - string para = getParameter(*sp,*j,sg); - const_symbol * cs = para==""?0:s.getValidator()->getAnalysis()->const_tab.symbol_get(para); - - parametersForEvent->push_back(cs); - }; //end of filling in parameters - - listOfparameters.push_back(parametersForEvent); - }; - - }; - - return listOfparameters; - }; - - //Negation - if(dynamic_cast(g)) - { - return getParametersDiscrete(const_cast(dynamic_cast(g)->getGoal()),op,s,!neg); - }; - - //Other - listOfparameters = getParameters(g,op,s.getValidator(),true,neg); - - return listOfparameters; -}; - -goal * newQfiedGoal(const qfied_goal * qg,operator_ * op,Validator * v) -{ - //get list of instansigated parameters for the qfied prop, so for forall(?z ?y), we have a grounded list for every z? and ?y - set svs = getVariables(qg); - vector constantsList = defineUndefinedParameters(newBlankConstSymbolList(const_cast(qg->getVars()),v),const_cast(qg->getVars()),v,svs); - - //now create a conjunction or disjunction with the qfied variables substituted - map newvars; - goal_list* theGoals = new goal_list(); - - for(vector::iterator k = constantsList.begin(); k != constantsList.end(); ++k) - { - const goal * aGoal = copyGoal(qg->getGoal()); - - //define mapping of parameter symbol to constant - const_symbol_list::iterator consList = (*k)->begin(); - for(var_symbol_list::const_iterator i = qg->getVars()->begin(); i != qg->getVars()->end(); ++i) - { - newvars[const_cast(*i)] = *consList; - consList++; - }; - //add conjunct/disjunct with qfied variables substituted - changeVars(const_cast(aGoal),newvars); - theGoals->push_back(const_cast(aGoal)); - }; - - deleteParameters(constantsList); - - goal * goalToCheck; - if(qg->getQuantifier()==E_FORALL) - { - goalToCheck = new conj_goal(theGoals); - } - else - { - goalToCheck = new disj_goal(theGoals); - }; - - return goalToCheck; -}; - -//for ctsly triggered events -const vector getParametersCts(goal * g,operator_ * op,Validator * v,bool neg,bool atAPoint) -{ - vector listOfparameters; - vector alistOfparameters; - - ///Comparison - if(const comparison * comp = dynamic_cast(g)) - { - //get list of PNEs, then make list of parameter lists from them - set pnes; - getPNEs(comp->getLHS(),pnes); - getPNEs(comp->getRHS(),pnes); - - for(set::iterator pne = pnes.begin(); pne != pnes.end(); ++pne) - { - //loop thro' ctsly changing PNEs - for(map::const_iterator fe = v->getActiveCtsEffects()->activeFEs.begin(); fe != v->getActiveCtsEffects()->activeFEs.end(); ++fe) - { - if(fe->first->getName() == (*pne)->getFunction()->getName() - && fe->first->checkConstantsMatch((*pne)->getArgs())) - { - const_symbol_list* parametersForEvent = new const_symbol_list(); - - //fill in parameters for event - for(var_symbol_list::iterator j = op->parameters->begin(); j != op->parameters->end(); ++j) - { - string para = getParameter(fe->first,*j,*pne); - const_symbol * cs = para==""?0:v->getAnalysis()->const_tab.symbol_get(para); - - parametersForEvent->push_back(cs); - }; //end of filling in parameters - - //any undefined parameters will be ground out and checked later, unless we are checking at a point for mutex checks with actions at the same time. - if(!atAPoint) listOfparameters.push_back(parametersForEvent); - else - { - set svs = getVariables(comp); - alistOfparameters = defineUndefinedParametersPropVar(parametersForEvent,op,v,g,false,neg,svs,true); - - for(vector::const_iterator l = alistOfparameters.begin(); l != alistOfparameters.end(); ++l) - listOfparameters.push_back(*l); - }; - - }; - - };//end of loop for checking if pne could be a changed fe - - }; //end of looping thro' pnes in expression - - return listOfparameters; - }; - - - //Literal - if(dynamic_cast(g)) - { - //return an empty list, literals do not change ctsly, so cannot trigger a event by cts activity - return listOfparameters; - }; - - //Negation - if(dynamic_cast(g)) - { - return getParametersCts(const_cast(dynamic_cast(g)->getGoal()),op,v,!neg,atAPoint); - }; - - //Others - listOfparameters = getParameters(g,op,v,false,neg,atAPoint); - - return listOfparameters; -}; - -//for both discrete and cts -const vector getParameters(goal * g,operator_ * op,Validator * v,bool discrete,bool neg,bool atAPoint) -{ - vector listOfparameters; - - ///Conjunction - if((!neg && (dynamic_cast(g))) || (neg && (dynamic_cast(g)))) - { - const goal_list* goalList; - if(dynamic_cast(g)) - { - goalList = dynamic_cast(g)->getGoals(); - } - else - { - goalList = dynamic_cast(g)->getGoals(); - }; - - //loop thro' conjuncts - //get all parameters from each - for(pc_list::const_iterator i = goalList->begin(); i != goalList->end(); ++i) - { - - vector someParameters; - if(discrete) someParameters = getParametersDiscrete(*i,op,v->getState(),neg); - else someParameters = getParametersCts(*i,op,v,neg,atAPoint); - - - //whittle down the list of parameters depending if they satisfy the rest of the conjunction - vector alistOfparameters; - if(!someParameters.empty()) alistOfparameters = getParametersList(g,op,v,someParameters,neg,discrete,atAPoint); - deleteParameters(someParameters); - - for(vector::const_iterator l = alistOfparameters.begin(); l != alistOfparameters.end(); ++l) - listOfparameters.push_back(*l); - - - }; - - return listOfparameters; - }; - - ///Disjunction - if((!neg && (dynamic_cast(g))) || (neg && (dynamic_cast(g)))) - { - const goal_list* goalList; - if(dynamic_cast(g)) - { - goalList = dynamic_cast(g)->getGoals(); - } - else - { - goalList = dynamic_cast(g)->getGoals(); - }; - //loop thro' disjuncts - for(pc_list::const_iterator i = goalList->begin(); i != goalList->end(); ++i) - { - vector someParameters; - if(discrete) someParameters = getParametersDiscrete(*i,op,v->getState(),neg); - else someParameters = getParametersCts(*i,op,v,neg,atAPoint); - - for(vector::const_iterator l = someParameters.begin(); l != someParameters.end(); ++l) - listOfparameters.push_back(*l); - //All remaining undefineds are given by existing objects and could be anything since - //remaining disjuncts need not be satisfied - thus leave as undefined - }; - - return listOfparameters; - }; - - - if(const qfied_goal* qg = dynamic_cast(g)) - { - goal * goalToCheck = newQfiedGoal(qg,op,v); - - if(discrete) listOfparameters = getParametersDiscrete(goalToCheck,op,v->getState(),neg); - else listOfparameters = getParametersCts(goalToCheck,op,v,neg,atAPoint); - - delete goalToCheck; - - return listOfparameters; - }; - - if(const imply_goal * ig = dynamic_cast(g)) - { - neg_goal * ng = new neg_goal(const_cast(ig->getAntecedent())); - goal_list * gl = new goal_list();; - goal * agoal = new goal(*const_cast(ig->getConsequent())); - gl->push_back(ng); - gl->push_back(agoal); - disj_goal * goalToCheck = new disj_goal(gl); - - if(discrete) listOfparameters = getParametersDiscrete(goalToCheck,op,v->getState(),neg); - else listOfparameters = getParametersCts(goalToCheck,op,v,neg,atAPoint); - gl->clear(); - ng->destroy(); - delete agoal; - delete goalToCheck; - - - return listOfparameters; - }; - - return listOfparameters; -}; - -void unionVariables(set & svs1,set & svs2) -{ - - for(set::const_iterator i = svs2.begin(); i != svs2.end(); ++i) - { - svs1.insert(*i); - }; - -}; - -//does the goal contain a negation or a comparsion? -bool containsNegationComp(goal * g,bool neg) -{ - - if(dynamic_cast(g)) - { - return true; - }; - - if(const conj_goal * cg = dynamic_cast(g)) - { - for(pc_list::const_iterator i = cg->getGoals()->begin(); i != cg->getGoals()->end(); ++i) - { - if(containsNegationComp(*i,neg)) return true; - }; - return false; - }; - - - if(const disj_goal * dg = dynamic_cast(g)) - { - for(pc_list::const_iterator i = dg->getGoals()->begin(); i != dg->getGoals()->end(); ++i) - { - if(containsNegationComp(*i,neg)) return true; - }; - return false; - }; - - if(const neg_goal * ng = dynamic_cast(g)) - { - return containsNegationComp(const_cast(ng->getGoal()),!neg); - }; - - - if(const imply_goal * ig = dynamic_cast(g)) - { - - return containsNegationComp(const_cast(ig->getAntecedent()),neg) || - containsNegationComp(const_cast(ig->getConsequent()),neg); - }; - - if(dynamic_cast(g)) - { - return neg; - }; - - if(const qfied_goal * qg = dynamic_cast(g)) - { - return containsNegationComp(const_cast(qg->getGoal()),neg); - }; - - return false; -}; - -const vector getCopyCSL(const vector & lop) -{ - vector listOfparameters; - - for(vector::const_iterator p = lop.begin(); p != lop.end(); ++p) - { - listOfparameters.push_back(new const_symbol_list(**p)); - }; - - return listOfparameters; -}; - -//find the list of parameters lists that satisfy g from the given list of parameter lists lop (psi as in paper) -const vector getParametersList(goal * g,operator_ * op,Validator * v,const vector & lop,bool neg,bool discrete,bool atAPoint) -{ - vector listOfparameters; - - ///Comparison - if(const comparison * comp = dynamic_cast(g)) - { - //if checking for ctsly triggered events we need to assume any comps with ctsly changing pnes are true - //at this stage. The comps are checked later, so do not do any checking here, it is done later (which will also include any comps with no ctsly changing PNEs that may be given here) - if(!discrete && !atAPoint) - { - //get list of PNEs, then make list of parameter lists from them - set pnes; - getPNEs(comp->getLHS(),pnes); - getPNEs(comp->getRHS(),pnes); - bool hasCtsPNE = false; - - for(set::iterator pne = pnes.begin(); pne != pnes.end(); ++pne) - { - //loop thro' ctsly changing PNEs - for(map::const_iterator fe = v->getActiveCtsEffects()->activeFEs.begin(); fe != v->getActiveCtsEffects()->activeFEs.end(); ++fe) - { - if(fe->first->getName() == (*pne)->getFunction()->getName()) - { - hasCtsPNE = true; - }; - - };//end of loop for checking if pne could be a changed fe - - }; //end of looping thro' pnes in expression - - //return copy of lop - if(hasCtsPNE) - { - return getCopyCSL(lop); - }; - }; - - //get list of unique parameters from g - set svs = getVariables(comp->getLHS()); - set svs2 =getVariables(comp->getRHS()); - unionVariables(svs,svs2); - - //dont want to delete lop - vector someParameters; - for(vector::const_iterator p = lop.begin(); p != lop.end(); ++p) - { - someParameters.push_back(new const_symbol_list(**p)); - }; - vector listOfparameters = defineUndefinedParametersPropVar(someParameters,op,v,g,false,neg,svs,atAPoint); - - return listOfparameters; - }; - - //Literal - if(const simple_goal * sg = dynamic_cast(g)) - { - - //look in state, look up all simple props that are true with this name. Get a list of constant symbols - //corresponding to the true literals. Create a list of partially ground parameters from these and lop - string literalName = sg->getProp()->head->getName(); - bool isDerivedPred = v->getDerivRules()->isDerivedPred(literalName); - - LogicalState logState = v->getState().getLogicalState(); - if(!neg && !isDerivedPred) - { - for(LogicalState::const_iterator i = logState.begin(); i != logState.end(); ++i) - { - if(i->second && (i->first->getPropName() == literalName)) - { - if(i->first->checkParametersConstantsMatch(sg->getProp()->args)) - { - addToListOfParameters(listOfparameters,lop,i->first->getConstants(op->parameters,sg->getProp()->args,v)); - } - }; - }; - } - else - { - //old style method for negations and derived predicates - set svs = getVariables(sg); - vector someParameters; - for(vector::const_iterator p = lop.begin(); p != lop.end(); ++p) - { - someParameters.push_back(new const_symbol_list(**p)); - }; - listOfparameters = defineUndefinedParametersPropVar(someParameters,op,v,g,isDerivedPred,neg,svs); - - }; - return listOfparameters; - }; - - //Negation - if(dynamic_cast(g)) - { - return getParametersList(const_cast(dynamic_cast(g)->getGoal()),op,v,lop,!neg,discrete,atAPoint); - }; - - ///Conjunction - if((!neg && (dynamic_cast(g))) || (neg && (dynamic_cast(g)))) - { - const goal_list* goalList; - if(dynamic_cast(g)) - { - goalList = dynamic_cast(g)->getGoals(); - } - else - { - goalList = dynamic_cast(g)->getGoals(); - }; - - if(goalList->empty()) return getCopyCSL(lop); - - vector aListOfparameters; - vector aListOfparametersTemp; - for(vector::const_iterator p = lop.begin(); p != lop.end(); ++p) aListOfparametersTemp.push_back(new const_symbol_list(**p)); - - - vector negCompGoals; //do negative ones (and comparisons) later as these often cause a lot of work, try to reduce list first - //loop thro' conjuncts - for(pc_list::const_iterator i = goalList->begin(); i != goalList->end(); ++i) - { - if(containsNegationComp(*i,neg)) negCompGoals.push_back(*i); - else - { - //get the list of parameters for each conjunct and then pass on list for next conjunct - if(!aListOfparametersTemp.empty()) - { - aListOfparameters = getParametersList(*i,op,v,aListOfparametersTemp,neg,discrete,atAPoint);//cout << " size of temp = "<::const_iterator j = negCompGoals.begin(); j != negCompGoals.end(); ++j) - { - if(!aListOfparametersTemp.empty()) - { - aListOfparameters = getParametersList(*j,op,v,aListOfparametersTemp,neg,discrete,atAPoint);//cout << " size of temp = "<(g))) || (neg && (dynamic_cast(g)))) - { - const goal_list* goalList; - if(dynamic_cast(g)) - { - goalList = dynamic_cast(g)->getGoals(); - } - else - { - goalList = dynamic_cast(g)->getGoals(); - }; - //loop thro' disjuncts - for(pc_list::const_iterator i = goalList->begin(); i != goalList->end(); ++i) - { - vector someParameters; - someParameters = getParametersList(*i,op,v,lop,neg,discrete,atAPoint); - for(vector::iterator j = someParameters.begin(); j != someParameters.end(); ++j) - listOfparameters.push_back(*j); - - //All remaining undefineds are given by existing objects and could be anything since - //remaining disjuncts need not be satisfied - thus leave as undefined - }; - - return listOfparameters; - }; - - - if(const qfied_goal* qg = dynamic_cast(g)) - { - goal * goalToCheck = newQfiedGoal(qg,op,v); - - listOfparameters = getParametersList(goalToCheck,op,v,lop,neg,discrete,atAPoint); - - delete goalToCheck; - - return listOfparameters; - }; - - if(const imply_goal * ig = dynamic_cast(g)) - { - neg_goal * ng = new neg_goal(const_cast(ig->getAntecedent())); - goal_list * gl = new goal_list();; - goal * agoal = new goal(*const_cast(ig->getConsequent())); - gl->push_back(ng); - gl->push_back(agoal); - disj_goal * goalToCheck = new disj_goal(gl); - - listOfparameters = getParametersList(goalToCheck,op,v,lop,neg,discrete,atAPoint); - gl->clear(); - ng->destroy(); - delete agoal; - delete goalToCheck; - - return listOfparameters; - }; - - return listOfparameters; -}; - - //find vs in the simple_goal parameters, map this to the parameter instantigation in sp -string getParameter(const SimpleProposition * sp,var_symbol * vs,const simple_goal * sg) -{ - string parameterName = ""; - int parameterNo = 1; - parameter_symbol_list::iterator p = sg->getProp()->args->begin(); - for(; p != sg->getProp()->args->end(); ++p) - { - if(vs == *p) break; - ++parameterNo; - }; - - if( p != sg->getProp()->args->end()) - { - parameterName = sp->getParameter(parameterNo); - }; - - return parameterName; -}; - -//find vs in the func_term parameters, map this to the parameter instantigation in fe -string getParameter(const FuncExp * fe,var_symbol * vs,const func_term * pne) -{ - string parameterName = ""; - int parameterNo = 1; - parameter_symbol_list * psl = const_cast(pne->getArgs()); - parameter_symbol_list::iterator p = psl->begin(); - for(; p != psl->end(); ++p) - { - if(vs == *p) break; - ++parameterNo; - }; - - if( p != psl->end()) - { - parameterName = fe->getParameter(parameterNo); - }; - - return parameterName; -}; - -bool undefinedParameterExists(const_symbol_list * csl) -{ - - for(const_symbol_list::iterator cs = csl->begin(); cs != csl->end(); ++cs) - { - if(!(*cs)) return true; - }; - - return false; -}; - -const set getVariables(const expression * e) -{ - set theVariables; - - if(dynamic_cast(e)) - { - const binary_expression * be = dynamic_cast(e); - theVariables = getVariables(be->getLHS()); - set svs2 =getVariables(be->getRHS()); - unionVariables(theVariables,svs2); - return theVariables; - }; - - if(dynamic_cast(e)) - { - const uminus_expression * ue = dynamic_cast(e); - theVariables = getVariables(ue->getExpr()); - return theVariables; - }; - - if(const func_term * fe = dynamic_cast(e)) - { - parameter_symbol_list *param_list = const_cast(fe->getArgs()); - - for(parameter_symbol_list::iterator i = param_list->begin(); i != param_list->end();++i) - { - if(dynamic_cast(*i)) - { - theVariables.insert(const_cast(dynamic_cast(*i))); - }; - }; - }; - - return theVariables; -}; - -const set getVariables(const simple_goal * sg) -{ - set theVariables; - - for(parameter_symbol_list::iterator i = sg->getProp()->args->begin(); i != sg->getProp()->args->end();++i) - { - if(dynamic_cast(*i)) - { - theVariables.insert(const_cast(dynamic_cast(*i))); - }; - }; - - return theVariables; -}; - -const set getVariables(const qfied_goal * qg) -{ - set theVariables; - - for(var_symbol_list::const_iterator i = qg->getVars()->begin(); i != qg->getVars()->end();++i) - { - theVariables.insert(const_cast(*i)); - }; - - return theVariables; -}; - -const set getVariables(const operator_ * op) -{ - set theVariables; - - for(var_symbol_list::const_iterator i = op->parameters->begin(); i != op->parameters->end();++i) - { - theVariables.insert(*i); - }; - - return theVariables; -}; - -//fill in parameters in lop with those in csl and return results, discard csl also -void addToListOfParameters(vector & vcsl,const vector & lop,const_symbol_list * csl) -{ - - bool satisfied; - - for(vector::const_iterator i = lop.begin(); i != lop.end(); ++i) - { - const_symbol_list * aConstList = new const_symbol_list(**i); - - satisfied = true; - const_symbol_list::const_iterator j = csl->begin(); - const_symbol_list::iterator l = aConstList->begin(); - for(const_symbol_list::const_iterator k = (*i)->begin(); k != (*i)->end(); ++k) - { - if((*j)) - { - if(!(*k)) - *l = *j; - else if(*l != *j) - satisfied = false; //the literal(or other) is not satisfied by previously defined parameters so not add to list of parameters - }; - - ++j; ++l; - }; - - if(satisfied) vcsl.push_back(aConstList); - else delete aConstList; - - - }; - - delete csl; - - //test - /* cout << " results\n"; - for(vector::const_iterator k = vcsl.begin(); k != vcsl.end() ; ++k) - { - for(const_symbol_list::iterator l = (*k)->begin(); l != (*k)->end(); ++l) - { - cout << (*l)->getName(); - - }; - cout <<"\n"; - }; */ - //end test - - -}; - -//for function below -bool isInList(const set & svs, var_symbol * vs) -{ - set::const_iterator i = svs.find(vs); - return (i != svs.end()); -}; - -//returns new set of parameter lists based on csl, only defines undefined variables if they are in svs -const vector defineUndefinedParameters(const_symbol_list * csl,var_symbol_list* variables,Validator * vld,const set & svs) -{ - map definedLists; - vector finalDefinedLists; - - if(csl->size() == 0 || !undefinedParameterExists(csl)) - { - finalDefinedLists.push_back(new const_symbol_list(*csl)); delete csl; - - return finalDefinedLists; - }; - - definedLists[1] = new const_symbol_list(*csl); - const_symbol_list* considerList = definedLists[1]; - unsigned int definedListNoConsider = 0; - unsigned int definedListNoAdd = 1; - - //loop thro definedLists until every parameter is ground, adding to definedLists when grounding a variable and other undefineds remain - - int paraNumber; - int paraNumber0; - bool remainingParasDefined; - - do{ - ++definedListNoConsider; - map::iterator dl = definedLists.find(definedListNoConsider); - if(dl == definedLists.end()) break; - considerList = dl->second; - - //choose the first undefined parameter - const_symbol_list::iterator cs = considerList->begin(); - var_symbol_list::iterator vs = variables->begin(); paraNumber = 1; - for(; cs != considerList->end(); ++cs) - { - if(!(*cs) && isInList(svs,*vs)) break; - ++vs; ++paraNumber; - }; - - if(cs == considerList->end()) {delete considerList; break;}; - - //are remaining parameters defined in list? - remainingParasDefined = true; var_symbol_list::iterator vs0 = variables->begin(); paraNumber0 = 1; - for(const_symbol_list::iterator cs0 = considerList->begin(); cs0 != considerList->end(); ++cs0) - { - if((!(*cs0)) && isInList(svs,*vs0) && (paraNumber0 > paraNumber)) remainingParasDefined = false; - ++vs0; ++paraNumber0; - }; - - //define the parameter for every possibility and add to list of definedLists - //cout << "Seeking range for " << **vs << "\n"; - vector vals = vld->range(*vs); - //cout << "Got\n"; - for(vector::const_iterator obj = vals.begin(); obj != vals.end(); ++obj) - { - const_symbol_list* parameters = new const_symbol_list(*considerList); - - const_symbol_list::iterator j = parameters->begin(); - for(int k = 1 ; k < paraNumber; ++k) {++j;}; - *j = *obj; - - if(!remainingParasDefined) definedLists[++definedListNoAdd] = parameters; - else finalDefinedLists.push_back(parameters); - }; - - delete considerList; //delete each consider list - }while(true);//end of looping thro defined lists, for given parameter, move to next parameter if considered parameter set was last in list when chosen - - /* - if(finalDefinedLists.empty()) - { - finalDefinedLists.push_back(new const_symbol_list(*csl)); - }; - */ - //test - /* cout << finalDefinedLists.size() << " results\n"; - - for(vector::const_iterator k = finalDefinedLists.begin(); k != finalDefinedLists.end() ; ++k) - { - for(const_symbol_list::iterator l = (*k)->begin(); l != (*k)->end(); ++l) - { - cout << (*l)->getName(); - - }; - cout <<"\n"; - }; //end test - */ - - delete csl; - return finalDefinedLists; -}; - - -const vector defineUndefinedParameters(const vector & vcsl,operator_ * op,Validator * vld,const set & svs) -{ - vector definedLists; - vector someDefinedLists; - - for(vector::const_iterator csl = vcsl.begin(); csl != vcsl.end(); ++csl) - { - someDefinedLists = defineUndefinedParameters(*csl,op->parameters,vld,svs); - - for(vector::const_iterator i = someDefinedLists.begin(); i != someDefinedLists.end(); ++i) - definedLists.push_back(*i); - - }; - - return definedLists; -}; - -//return parameter lists such that they satisfy the goal g, also delete reject candidate parameter lists! -const vector checkParametersProp(const vector & vcsl,operator_ * op,Validator * vld,goal * g,bool neg,bool dp,bool compError) -{ - vector definedLists; - - for(vector::const_iterator gp = vcsl.begin(); gp != vcsl.end(); ++gp) - { - bool propSatisfied; - if(dynamic_cast(g) && !dp) - { - const Proposition * prop = vld->pf.buildProposition(g,*(buildBindings(op,**gp).copy(vld))); - propSatisfied = prop->evaluate(&vld->getState()); - prop->destroy(); - } - else - { - const Proposition * prop = vld->pf.buildProposition(g,*(buildBindings(op,**gp).copy(vld))); - try - { - if(compError) propSatisfied = prop->evaluateAtPointWithinError(&vld->getState()); - else propSatisfied = prop->evaluate(&vld->getState()); - } - catch(BadAccessError & e) - { - if(!neg) propSatisfied = false; - else propSatisfied = true; //if a PNE is not defined, then no problem, the event is simply not triggered - }; - prop->destroy(); - }; - - if((propSatisfied && !neg) || (!propSatisfied && neg) ) - { - definedLists.push_back(*gp); - } - else - delete *gp; - - }; - - return definedLists; -}; - - -//define undefined parameters in csl (but only if in svs!) and ensure they satisfy the goal of the event -const vector defineUndefinedParametersPropVar(const_symbol_list * csl,operator_ * op,Validator * vld,goal * g,bool dp,bool neg,const set & svs,bool compError) -{ - vector groundListOfParameters; - - //if there are variables to ground then ground 'em! - if(!svs.empty()) groundListOfParameters = defineUndefinedParameters(csl,op->parameters,vld,svs); - else - { - groundListOfParameters.push_back(new const_symbol_list(*csl)); - delete csl; - }; - - return checkParametersProp(groundListOfParameters,op,vld,g,neg,dp,compError); -}; - -const vector defineUndefinedParametersPropVar(const vector & vcsl,operator_ * op,Validator * vld,goal * g,bool dp,bool neg,const set & svs,bool compError) -{ - vector definedLists; - vector someDefinedLists; - - for(vector::const_iterator csl = vcsl.begin(); csl != vcsl.end(); ++csl) - { - someDefinedLists = defineUndefinedParametersPropVar(*csl,op,vld,g,dp,neg,svs,compError); - - for(vector::const_iterator i = someDefinedLists.begin(); i != someDefinedLists.end(); ++i) - definedLists.push_back(*i); - }; - - return definedLists; -}; - -//get pnes in expression e -void getPNEs(const expression * e,set & pnes) -{ - - if(const func_term * fexpression = dynamic_cast(e)) - { - pnes.insert(fexpression); - return; - }; - - - if(const binary_expression * bexp = dynamic_cast(e)) - { - getPNEs(bexp->getLHS(),pnes); - getPNEs(bexp->getRHS(),pnes); - return; - }; - - if(const uminus_expression * uexp = dynamic_cast(e)) - { - getPNEs(uexp->getExpr(),pnes); - }; - - -}; - -//copy a goal including all subgoals -const goal * copyGoal(const goal * g) -{ - - if(dynamic_cast(g)) - { - const goal * ng = (dynamic_cast(g))->getGoal(); - - return new neg_goal(const_cast(copyGoal(ng))); - }; - - if(dynamic_cast(g)) - { - const imply_goal * ig = dynamic_cast(g); - - neg_goal * ng = new neg_goal(const_cast(copyGoal(ig->getAntecedent()))); - goal_list * gl = new goal_list();; - goal * agoal = const_cast(copyGoal(ig->getConsequent())); - gl->push_back(ng); - gl->push_back(agoal); - const disj_goal * dg = new disj_goal(gl); - - return copyGoal(dg); - }; - - if(dynamic_cast(g)) - { - const conj_goal * cg = dynamic_cast(g); - goal_list * gl = new goal_list(); - for(pc_list::const_iterator i = cg->getGoals()->begin(); i != cg->getGoals()->end(); ++i) - { - gl->push_back(const_cast(copyGoal(*i))); - }; - return new conj_goal(gl); - }; - - - if(dynamic_cast(g)) - { - const disj_goal * dg = dynamic_cast(g); - goal_list * gl = new goal_list(); - for(pc_list::const_iterator i = dg->getGoals()->begin(); i != dg->getGoals()->end(); ++i) - { - gl->push_back(const_cast(copyGoal(*i))); - }; - const disj_goal * d_goal = new disj_goal(gl); - - return d_goal; - }; - - - if(dynamic_cast(g)) - { - const qfied_goal * qg = dynamic_cast(g); - - const qfied_goal * ans; - var_symbol_table * sym_tab = new var_symbol_table(); - for(map::const_iterator i = qg->getSymTab()->begin(); i != qg->getSymTab()->end(); ++i) - { - sym_tab->symbol_put(i->first); - }; - - if(qg->getQuantifier() == E_EXISTS) - ans = new qfied_goal(E_EXISTS,new var_symbol_list(*const_cast(qg->getVars())), - const_cast(copyGoal(const_cast(qg->getGoal()))),sym_tab); - else - ans = new qfied_goal(E_FORALL,new var_symbol_list(*const_cast(qg->getVars())), - const_cast(copyGoal(const_cast(qg->getGoal()))),sym_tab); - - return ans; - }; - - if(dynamic_cast(g)) - { - const simple_goal * sg = dynamic_cast(g); - parameter_symbol_list* newpsl = new parameter_symbol_list(); - for(parameter_symbol_list::iterator i = sg->getProp()->args->begin();i != sg->getProp()->args->end();++i) - { - newpsl->push_back(*i); - }; - const proposition * prop = new proposition(sg->getProp()->head,newpsl); - const simple_goal * sim_goal = new simple_goal(const_cast(prop),sg->getPolarity()); - - return sim_goal; - }; - - if(dynamic_cast(g)) - { - const comparison * comp = dynamic_cast(g); - const expression * e1 = copyExpression(comp->getLHS()); //copy - const expression * e2 = copyExpression(comp->getRHS()); - - return new comparison(comp->getOp(),const_cast(e1),const_cast(e2)); - }; - - return g; -}; - -const expression * copyExpression(const expression * e) -{ - - if(const div_expression * fexpression = dynamic_cast(e)) - { - return new div_expression(const_cast(copyExpression(fexpression->getLHS())),const_cast(copyExpression(fexpression->getRHS()))); - }; - - if(const minus_expression * fexpression = dynamic_cast(e)) - { - return new minus_expression(const_cast(copyExpression(fexpression->getLHS())),const_cast(copyExpression(fexpression->getRHS()))); - }; - - if(const mul_expression * fexpression = dynamic_cast(e)) - { - return new mul_expression(const_cast(copyExpression(fexpression->getLHS())),const_cast(copyExpression(fexpression->getRHS()))); - }; - - if(const plus_expression * fexpression = dynamic_cast(e)) - { - return new plus_expression(const_cast(copyExpression(fexpression->getLHS())),const_cast(copyExpression(fexpression->getRHS()))); - }; - - if(const int_expression * fexpression = dynamic_cast(e)) - { - int aNumber = int(fexpression->double_value()); - return new int_expression(aNumber); - }; - - if(const float_expression * fexpression = dynamic_cast(e)) - { - NumScalar aNumber = fexpression->double_value(); - return new float_expression(aNumber); - }; - - if(const uminus_expression * fexpression = dynamic_cast(e)) - { - return new uminus_expression(const_cast(copyExpression(fexpression->getExpr()))); - }; - - if(const func_term * fexpression = dynamic_cast(e)) - { - parameter_symbol_list* newpsl = new parameter_symbol_list(); - for(parameter_symbol_list::const_iterator i = fexpression->getArgs()->begin();i != fexpression->getArgs()->end();++i) - { - newpsl->push_back(*i); - }; - - return new func_term(const_cast(fexpression->getFunction()),newpsl); - }; - - if(dynamic_cast(e)) - { - return e; - }; - - return e; -}; - -}; diff --git a/src/Plan.cpp b/src/Plan.cpp index ee4e5b8..35c4e75 100644 --- a/src/Plan.cpp +++ b/src/Plan.cpp @@ -1291,7 +1291,7 @@ const CtsFunction * ActiveCtsEffects::buildNumericalSoln(const ActiveFE * afe) vector > discharge; pair,const Environment *> exprn; bool exprnDefined = false; - const FuncExp * fexp = 0; + //const FuncExp * fexp = 0; // this was assigned to, but never used for(vector,const Environment *> >::const_iterator i = afe->exprns.begin(); i != afe->exprns.end(); ++i) { @@ -1319,21 +1319,21 @@ const CtsFunction * ActiveCtsEffects::buildNumericalSoln(const ActiveFE * afe) if(const func_term * fexpression = dynamic_cast(rateExprn)) { - fexp = vld->fef.buildFuncExp(fexpression,*exprn.second); + /*fexp =*/ vld->fef.buildFuncExp(fexpression,*exprn.second); } else if(const mul_expression * me = dynamic_cast(rateExprn)) { if(afe->appearsInEprsn(this,me->getLHS(),exprn.second)) { - constExprn = me->getRHS(); fexp = afe->fe; + constExprn = me->getRHS();// fexp = afe->fe; FEExprn = me->getLHS(); } else if(afe->appearsInEprsn(this,me->getRHS(),exprn.second)) { - constExprn = me->getLHS(); fexp = afe->fe; + constExprn = me->getLHS();// fexp = afe->fe; FEExprn = me->getRHS(); } else @@ -1421,7 +1421,7 @@ const CtsFunction * ActiveCtsEffects::buildNumericalSoln(const ActiveFE * afe) throw dee; }; - fexp = fexp; +// fexp = fexp; // why was this line of code here? const BatteryCharge * newBatteryCharge = new BatteryCharge(new Polynomial(bPoly),mValue,discharge,0, localUpdateTime,afe->fe->evaluate(&(vld->getState())),accuracy); diff --git a/src/Polynomial.cpp b/src/Polynomial.cpp index d861915..0608db9 100644 --- a/src/Polynomial.cpp +++ b/src/Polynomial.cpp @@ -60,7 +60,7 @@ using std::cout; //#define map std::map namespace VAL { - + ostream & operator <<(ostream & o,const Intervals & i) { i.write(o); @@ -289,7 +289,7 @@ cout <<"Blown on terms...\n"; ApproxPolyError ape; throw ape; }; - + for(unsigned int i = 2; i <= noTerms; ++i) { powPoly = (powPoly*(*poly))/i; //powPoly = poly^i @@ -320,7 +320,7 @@ vector Exponential::getRoots(CoScalar t) const void checkNum(CoScalar num) { if( (2 * num == num && num != 0) || (!( num == num)) ) - { + { NumError ne; throw ne; }; @@ -567,9 +567,13 @@ bool Polynomial::operator==(const Polynomial & p) const { if(getDegree() != p.getDegree()) return false; - for(unsigned int i = getDegree(); i >= 0; --i) + for(unsigned int i = getDegree(); ; --i) { if(getCoeff(i) != p.getCoeff(i)) return false; + + if (i == 0) { + break; + } }; return true; @@ -637,7 +641,7 @@ CoScalar newtonsMethod(const Polynomial & p,CoScalar startPt,CoScalar accuracy) lastApproxRoot = approxRoot; - + }; if(i == limit) @@ -672,7 +676,7 @@ vector Polynomial::getRoots(CoScalar t) const if( root > 0 && root < t) roots.push_back( root ); } else if(testPoly.getDegree() == 2) - { + { CoScalar a = testPoly.getCoeff(2); CoScalar b = testPoly.getCoeff(1); CoScalar c = testPoly.getCoeff(0); @@ -711,7 +715,7 @@ vector Polynomial::getRoots(CoScalar t) const if(*i > 0.01) roots.push_back(*i); //tolerance value }; copyRoots.clear(); - + return roots; }; @@ -979,7 +983,7 @@ Polynomial mapPkc(const Polynomial & p,CoScalar k,CoScalar c) aPoly.setCoeff(j, pow(2,(deg-i)*k) * p.getCoeff(i) * pow(c,i-j)*choose(i,j)); };*/ - + for(unsigned int j = i; ; --j) { @@ -1008,12 +1012,12 @@ int sign(CoScalar a) }; unsigned int descartesBound(const Polynomial & p) -{ - Polynomial testPoly = mapTc(mapR(p),1); +{ + Polynomial testPoly = mapTc(mapR(p),1); //testPoly.removeSmallCoeffs(); //may be dodgey- remove? if(!testPoly.checkPolynomialCoeffs()) - { + { PolyRootError pre; throw pre; }; @@ -1115,7 +1119,7 @@ CoScalar findRootUsingNewtonsMethod(const Polynomial & p,CoScalar intStart, CoSc { theRoot = newtonsMethod(p,(intEnd-intStart)*(pow(0.5,step) + j*pow(0.5,step+1))+intStart,accuracy); }; - + if(theRoot <= intStart || theRoot >= intEnd) theRoot = -1; step++; }; @@ -1125,7 +1129,7 @@ CoScalar findRootUsingNewtonsMethod(const Polynomial & p,CoScalar intStart, CoSc PolyRootError pre; throw pre; }; - + return theRoot; }; @@ -1150,7 +1154,7 @@ pair >,vector > descartesAlg(cons //get new node, (front of list) map >::iterator i = searchTree.find(treeIter); if(i == searchTree.end()) break; - + testPoly = mapPkc(p,i->second.first,i->second.second); desBnd = descartesBound(testPoly); @@ -1158,10 +1162,10 @@ pair >,vector > descartesAlg(cons intStart = ((i->second.second) / (pow(2,i->second.first))); intEnd = ((i->second.second + 1) / (pow(2,i->second.first))); - + addToTree = false; if(desBnd == 1) - { + { if( (accuracy == 0) || ( (intEnd - intStart) < accuracy) ) { isol.push_back(make_pair(make_pair(intStart,false),make_pair(intEnd,false))); @@ -1169,10 +1173,10 @@ pair >,vector > descartesAlg(cons else { CoScalar theRoot = findRootUsingNewtonsMethod(testPoly,intStart,intEnd,accuracy); - exact.push_back(theRoot); + exact.push_back(theRoot); //addToTree = true; //use this to use descartesAlg to find roots }; - + } else if(desBnd > 1) { @@ -1248,7 +1252,7 @@ pair >,vector > Polynomial::isola bool Polynomial::rootsExist(CoScalar t) const { if(getDegree() < 3) {if(getRoots(t).size() > 0) return true; else return false;}; - + pair >,vector > isolExact; bool ans = false; @@ -1269,7 +1273,7 @@ Intervals getIntervalsFromRoots(vector roots, const CtsFunction * ctsF { Intervals theAns; std::sort(roots.begin(),roots.end()); - + pair startPt,endPt; if(roots.size() == 0) @@ -1293,7 +1297,7 @@ Intervals getIntervalsFromRoots(vector roots, const CtsFunction * ctsF { intStat = ctsFtn->evaluate((*i)/2.0) > 0; }; - + if(intStat) { startPt = make_pair(0,true); @@ -1337,7 +1341,7 @@ Intervals getIntervalsFromRoots(vector roots, const CtsFunction * ctsF //cout << " \\\\ \\> The poly $"<<*this<<"$ is satisfied on "<getComparison()->getOp() == E_GREATER) || (comp->getComparison()->getOp() == E_LESS); - vector roots = comp->getRootsForIntervals(s,t); - theAns = getIntervalsFromRoots(roots,this,t,strict); + vector roots = comp->getRootsForIntervals(s,t); + theAns = getIntervalsFromRoots(roots,this,t,strict); return theAns; }; @@ -1376,44 +1380,44 @@ Intervals Exponential::getIntervals(const Comparison * comp, const State* s,CoSc //return getApproxPoly(t).getIntervals(comp,s,t); Intervals theAns; // pair startPt,endPt; - + bool rootsExist; bool strict = (comp->getComparison()->getOp() == E_GREATER) || (comp->getComparison()->getOp() == E_LESS); //bool greater = (comp->getComparison()->getOp() == E_GREATER) || (comp->getComparison()->getOp() == E_GREATEQ); if(comp->getComparison()->getOp() == E_EQUALS) { - if(K == 0 && offSet - c == 0) theAns.intervals.push_back(make_pair( make_pair(0,true) , make_pair(t, true))); + if(K == 0 && offSet - c == 0) theAns.intervals.push_back(make_pair( make_pair(0,true) , make_pair(t, true))); return theAns; }; - + vector roots; if( ((offSet - c)/K) <= 0 ) rootsExist = false; else { Polynomial aPoly = *poly - log((offSet -c)/K); - + try{roots = aPoly.getRoots(t);} catch(PolyRootError & pre){throw pre;}; - - rootsExist = (roots.size() > 0); + + rootsExist = (roots.size() > 0); }; - + if(!rootsExist) { if(comp->evaluateAtPoint(s)) //no roots so is either satisfied or not over whole interval - so just evaluate one pt { - theAns.intervals.push_back(make_pair( make_pair(0,true) , make_pair(t, true))); + theAns.intervals.push_back(make_pair( make_pair(0,true) , make_pair(t, true))); }; return theAns; }; - + //if(greater) //{ const Exponential * aExp = new Exponential(K,new Polynomial(*poly),c-offSet); theAns = getIntervalsFromRoots(roots,aExp,t,strict); - delete aExp; + delete aExp; /* } else { @@ -1428,10 +1432,10 @@ Intervals Exponential::getIntervals(const Comparison * comp, const State* s,CoSc Intervals NumericalSolution::getIntervals(const Comparison * comp, const State* s,CoScalar t) const { Intervals theAns; - + bool strict = (comp->getComparison()->getOp() == E_GREATER) || (comp->getComparison()->getOp() == E_LESS); bool greater = (comp->getComparison()->getOp() == E_GREATER) || (comp->getComparison()->getOp() == E_GREATEQ); - + pair startPt,endPt; //determine if starting satisfied or not Intervals aInt; @@ -1439,62 +1443,62 @@ Intervals NumericalSolution::getIntervals(const Comparison * comp, const State* //initial interval comparison is satisfied on if((j->second > offSet && greater) || (j->second < offSet && !greater)) - { + { startPt = make_pair(0,true); CoScalar lastPoint = j->second; double lastTime = j->first; bool positive = j->second > offSet; //record sign of last non-zero point j++; - + while( j != points.end()) - { + { if((positive && j->second < offSet) || (!positive && j->second > offSet) || (j->second == offSet && strict) ) break; - + if(j->second < offSet) positive = false; else if(j->second > offSet) positive = true; - + lastPoint = j->second; lastTime = j->first; j++; }; - + double endPoint; if(j != points.end()) endPoint = lastTime+(j->first - lastTime)*(fabs(lastPoint)/(fabs(lastPoint) + fabs(j->second))); else {endPoint = lastTime; strict = false;}; - + endPt = make_pair(endPoint,!strict); aInt.intervals.push_back(make_pair(startPt,endPt)); - theAns = setUnion(theAns,aInt); + theAns = setUnion(theAns,aInt); } else if(j->second == offSet && !strict) { startPt = make_pair(0,true); - CoScalar lastPoint = j->second; + //CoScalar lastPoint = j->second; // set but never used double lastTime = j->first; j++; - lastPoint = lastPoint; +// lastPoint = lastPoint; // why was this line of code here? while( j != points.end()) { if( j->second != offSet) break; - lastPoint = j->second; + //lastPoint = j->second; lastTime = j->first; j++; }; endPt = make_pair(lastTime,!strict); aInt.intervals.push_back(make_pair(startPt,endPt)); - theAns = setUnion(theAns,aInt); + theAns = setUnion(theAns,aInt); }; - + //define other intervals now, when the points change sign the interval end points are formed, //care is needed for values that are zero depending on if comparison is strict - bool startPointDefined = false; + bool startPointDefined = false; while(j != points.end()) { //point at j is not satisfied to begin with - startPointDefined = false; + startPointDefined = false; Intervals aInt; //firstly find starting point if(j->second == offSet && strict) @@ -1508,20 +1512,20 @@ Intervals NumericalSolution::getIntervals(const Comparison * comp, const State* startPointDefined = true; }; }; - - - + + + if(!startPointDefined) - { + { CoScalar lastPoint = j->second; double lastTime = j->first; bool positive = j->second > offSet; //record sign of last non-zero point - + while( j != points.end()) { if((positive && j->second < offSet) || (!positive && j->second > offSet) || (j->second == offSet && strict) ) { - startPointDefined = true; + startPointDefined = true; break; }; @@ -1532,12 +1536,12 @@ Intervals NumericalSolution::getIntervals(const Comparison * comp, const State* lastTime = j->first; j++; }; - + if(startPointDefined) startPt = make_pair(lastTime + (j->first - lastTime)*(fabs(lastPoint)/(fabs(lastPoint) + fabs(j->second))),!(strict)); - - + + }; - + //find the end point now if(startPointDefined) { @@ -1546,32 +1550,32 @@ Intervals NumericalSolution::getIntervals(const Comparison * comp, const State* double theEndPoint; bool positive = j->second > offSet; //record sign of last non-zero point j++; - + while(true) { if( j == points.end() ) {theEndPoint = lastTime; strict = false; break;}; if((positive && j->second < offSet) || (!positive && j->second > offSet) || (j->second == offSet && strict) ) { theEndPoint = lastTime + (j->first - lastTime)*(fabs(lastPoint)/(fabs(lastPoint) + fabs(j->second))); - break; + break; }; if(j->second < offSet) positive = false; else if(j->second > offSet) positive = true; - + lastPoint = j->second; lastTime = j->first; - j++; + j++; }; endPt = make_pair(theEndPoint,!(strict)); aInt.intervals.push_back(make_pair(startPt,endPt)); - theAns = setUnion(theAns,aInt); + theAns = setUnion(theAns,aInt); }; }; - + return theAns; }; @@ -1605,9 +1609,9 @@ bool Polynomial::checkInvariant(const Comparison * comp, const State* s,CoScalar return false; }; - if( (degree == 1)) + if(degree == 1) { - cout << "WE HAVE " << evaluate(0) << " AND " << evaluate(t) << "\n"; +// cout << "WE HAVE " << evaluate(0) << " AND " << evaluate(t) << "\n"; if( (evaluate(0) > - accuracy) && (evaluate(t) > - accuracy)) { return true; @@ -1632,7 +1636,7 @@ bool Polynomial::checkInvariant(const Comparison * comp, const State* s,CoScalar if(!rtsExist) return evaluate(t/2.0) > 0; return !rtsExist; }; - + pair >,vector > isolExact = removeRepeatedRoots().isolateRoots(t); vector >::iterator ints = isolExact.first.begin(); @@ -1689,7 +1693,7 @@ bool Polynomial::checkInvariant(const Comparison * comp, const State* s,CoScalar }; return false; - + }; @@ -1706,7 +1710,7 @@ bool Exponential::rootsExist(CoScalar t) const //on open interval (0,t) return (roots.size() > 0); }; - + }; bool Exponential::checkInvariant(const Comparison * comp, const State* s,CoScalar t,bool rhsIntervalOpen) const @@ -1739,7 +1743,7 @@ bool Exponential::checkInvariant(const Comparison * comp, const State* s,CoScala bool rtsExist = rootsExist(t); if(!rtsExist) return evaluate(t/2.0)-offSet > 0; return !rtsExist; - }; + }; vector roots; if( ((offSet - c)/K) <= 0 ) return true; @@ -1779,29 +1783,29 @@ map::const_iterator j = points.begin(); if( (greater && (j->second - offSet < 0)) || (!greater && (j->second - offSet > 0)) ) return false; - + for( ; j != points.end(); ) { ++j; if( j->first == t) break; if( ((greater && (j->second - offSet < 0)) || (j->second - offSet <= 0 && !strict)) || ((!greater && (j->second - offSet > 0)) || (j->second - offSet >= 0 && !strict))) return false; - + }; //check end point if(j != points.end()) -{ +{ if( ((greater && (j->second - offSet < 0)) || (j->second - offSet <= 0 && !strict && !rhsIntervalOpen)) || ((!greater && (j->second - offSet > 0)) || (j->second - offSet >= 0 && !strict && !rhsIntervalOpen))) return false; }; - + return true; }; - + //build points using Runge Kutta Fehlberg method void NumericalSolution::buildPoints(CoScalar a0,CoScalar b0,CoScalar y,CoScalar accuracy) -{ +{ CoScalar a2 = 1.0/4.0; CoScalar b2 = 1.0/4.0; CoScalar a3 = 3.0/8.0; @@ -1840,10 +1844,10 @@ void NumericalSolution::buildPoints(CoScalar a0,CoScalar b0,CoScalar y,CoScalar CoScalar t = a0; CoScalar br = b0 - 0.00001*fabs(b0); CoScalar err, ynew,s; - + //points.push_back(make_pair(double(a0),double(y))); //initial point points[double(a0)] = y; - + while(t < b0) { @@ -1857,7 +1861,7 @@ void NumericalSolution::buildPoints(CoScalar a0,CoScalar b0,CoScalar y,CoScalar err = fabs(r1*k1 + r3*k3 + r4*k4 + r5*k5 + r6*k6); ynew = y + n1*k1 + n3*k3 + n4*k4 + n5*k5; - + if( err < accuracy || h < 2* hmin) { if(t + h > br) @@ -1882,30 +1886,30 @@ void NumericalSolution::buildPoints(CoScalar a0,CoScalar b0,CoScalar y,CoScalar if(s > 4.0) s = 4.0; h = s*h; - + if(h>hmax) h = hmax; else if(h < hmin) h = hmin; - + //if(maxPoints == points.size()) break; }; - - - - + + + + }; CoScalar BatteryCharge::evaluateDiff(CoScalar t,CoScalar y) { - CoScalar dis = 0; + CoScalar dis = 0; for(vector >::const_iterator i = discharge.begin(); i != discharge.end(); ++i) { if(i->second) dis += (*i).first->evaluate(t); else dis -= (*i).first->evaluate(t); }; - + return ((poly->evaluate(t))* (m - y)) + dis; -}; +}; void BatteryCharge::write(ostream & o) const { @@ -1934,7 +1938,7 @@ vector NumericalSolution::getRoots(CoScalar t) const vector roots; NumError ne; throw ne; - return roots; + return roots; }; Polynomial NumericalSolution::getApproxPoly(CoScalar endInt) const @@ -1943,7 +1947,7 @@ Polynomial NumericalSolution::getApproxPoly(CoScalar endInt) const ApproxPolyError ape; throw ape; - + poly.setCoeff(0,1); return poly; }; @@ -1951,16 +1955,16 @@ Polynomial NumericalSolution::getApproxPoly(CoScalar endInt) const pair >,vector > NumericalSolution::isolateRoots(CoScalar t,CoScalar accuracy) const { pair >,vector > isol; - + NumError ne; throw ne; - return isol; + return isol; }; CoScalar NumericalSolution::evaluate(CoScalar t) const { - CoScalar ans =0; + CoScalar ans =0; map::const_iterator j = points.find(t); if(j != points.end()) return j->second; //else interpolate @@ -1971,28 +1975,28 @@ CoScalar NumericalSolution::evaluate(CoScalar t) const ++i; //should only ever evaluate the end point which will be found above so the stuff below is OK for( ; i != points.end(); ++i) - { + { if( t <= i->first && t >= lastTime) { - + ans = lastPoint + ((i->second - lastPoint)/(i->first - lastTime))*(t - lastTime); - + return ans; }; lastTime = i->first; lastPoint = i->second; }; - + return ans; - + }; bool NumericalSolution::isLinear() const { if(points.size() > 2) return false; - return true; + return true; }; }; diff --git a/src/State.cpp b/src/State.cpp index 46204b8..6e4e745 100644 --- a/src/State.cpp +++ b/src/State.cpp @@ -24,462 +24,462 @@ * ************************************************************************/ -/*----------------------------------------------------------------------------- - VAL - The Automatic Plan Validator for PDDL+ - - $Date: 2009-02-05 10:50:23 $ - $Revision: 1.2 $ - - Maria Fox, Richard Howey and Derek Long - PDDL+ and VAL - Stephen Cresswell - PDDL Parser - - maria.fox@cis.strath.ac.uk - derek.long@cis.strath.ac.uk - stephen.cresswell@cis.strath.ac.uk - richard.howey@cis.strath.ac.uk - - By releasing this code we imply no warranty as to its reliability - and its use is entirely at your own risk. - - Strathclyde Planning Group - http://planning.cis.strath.ac.uk - ----------------------------------------------------------------------------*/ -#include "State.h" -#include "Plan.h" -#include "main.h" -#include "Validator.h" -#include "Proposition.h" -#include "Exceptions.h" -#include "LaTeXSupport.h" -#include "RobustAnalyse.h" - -#include - -using std::stringstream; -using std::cerr; -//#define list std::list -//#define map std::map - -namespace VAL { - -vector State::sos; - -void State::setNew(const effect_lists * is) -{ - logState.clear(); - feValue.clear(); - changedPNEs.clear(); - - for(list::const_iterator i = is->add_effects.begin(); - i != is->add_effects.end();++i) - { - logState[vld->pf.buildLiteral(*i)] = true; - }; - - for(pc_list::const_iterator i1 = is->assign_effects.begin(); - i1 != is->assign_effects.end();++i1) - { - const FuncExp * fe = vld->fef.buildFuncExp((*i1)->getFTerm()); -// DPL 2/2/06: Need to remember which PNEs changed in order to trigger -// processes properly in the initial state. - changedPNEs.insert(fe); - FEScalar feNewValue = dynamic_cast((*i1)->getExpr())->double_value(); - - feValue[fe] = feNewValue; - - //setup initial value for LaTeX graph - if(LaTeX) - { - FEGraph * feg = getValidator()->getGraph(fe); - - //setup initial value if nec - if( (feg->initialTime == -1) ) - { - feg->initialTime = time; - feg->initialValue = feNewValue; - }; - }; - - }; -}; - -State::State(Validator * const v,const effect_lists* is) : - tolerance(v->getTolerance()), vld(v), time(0.0) -{ - setNew(is); -}; - -bool State::evaluate(const SimpleProposition * p) const -{ - LogicalState::const_iterator i = logState.find(p); - if(i != logState.end()) - { - return i->second; - } - else - { - return false; - }; -}; - -FEScalar State::evaluateFE(const FuncExp * fe) const -{ - NumericalState::const_iterator i = feValue.find(fe); - if(i!=feValue.end()) - { - return i->second; - } - else - { - /* cerr << "Attempt to access undefined expression: " << *fe << "\n"; - if(LaTeX) - { - *report << "\\error{Attempt to access undefined expression: " << *fe << "}\n"; - }; - */ - // Throw? Yes ! - //exit(0); - - - BadAccessError bae; - throw bae; - }; -}; - -FEScalar State::evaluate(const expression * e,const Environment & bs) const -{ - if(dynamic_cast(e)) - { - return evaluate(dynamic_cast(e)->getLHS(),bs) / - evaluate(dynamic_cast(e)->getRHS(),bs); - }; - - if(dynamic_cast(e)) - { - return evaluate(dynamic_cast(e)->getLHS(),bs) - - evaluate(dynamic_cast(e)->getRHS(),bs); - }; - - - - if(dynamic_cast(e)) - { - return evaluate(dynamic_cast(e)->getLHS(),bs) * - evaluate(dynamic_cast(e)->getRHS(),bs); - }; - - if(dynamic_cast(e)) - { - return evaluate(dynamic_cast(e)->getLHS(),bs) + - evaluate(dynamic_cast(e)->getRHS(),bs); - }; - - if(dynamic_cast(e)) - { - return dynamic_cast(e)->double_value(); - }; - - if(dynamic_cast(e)) - { - return -(evaluate(dynamic_cast(e)->getExpr(),bs)); - }; - - if(dynamic_cast(e)) - { - const FuncExp * fexp = vld->fef.buildFuncExp(dynamic_cast(e),bs); - return fexp->evaluate(this); - //if(feValue.find(fexp) != feValue.end()) - //return feValue.find(fexp)->second; - /* - if(LaTeX) - { - *report << "\\error{Attempt to access undefined expression: " << *fexp << "}\n"; - } - else if(Verbose) cout << "Attempt to inspect undefined value: " << *fexp << "\n"; - */ - //BadAccessError bae; - //throw bae; - }; - - if(const special_val_expr * sp = dynamic_cast(e)) - { - if(sp->getKind() == E_TOTAL_TIME) - { - if(vld->durativePlan()) return time; - return vld->simpleLength(); - }; - - if(sp->getKind() == E_DURATION_VAR) - { - return bs.duration; - }; - - if(sp->getKind() == E_HASHT) - - { - if(LaTeX) - *report << "The use of \\#t is not valid in this context!\n"; - else if(Verbose) - cout << "The use of #t is not valid in this context!\n"; - SyntaxTooComplex stc; - throw stc; - } - - }; - - if(const violation_term * vt = dynamic_cast(e)) - { - return vld->violationsFor(vt->getName()); - }; - - UnrecognisedCondition uc; - throw uc; -}; - -bool -State::progress(const Happening * h) -{ - DerivedGoal::resetLists(this); - resetChanged(); - - if(TestingPNERobustness) JudderPNEs = true; - bool canHappen = h->canHappen(this); - - if(canHappen || ContinueAnyway) - { - time = h->getTime(); - - if(TestingPNERobustness) JudderPNEs = false; - return h->applyTo(this) && canHappen; - } - else - { - return false; - }; -}; - -bool -State::progressCtsEvent(const Happening * h) -{ - DerivedGoal::resetLists(this); - resetChanged(); - - if(TestingPNERobustness) JudderPNEs = true; - bool canHappen = h->canHappen(this); - - if(canHappen || ContinueAnyway) - { - time = h->getTime(); - if(TestingPNERobustness) JudderPNEs = false; - return h->applyTo(this) && canHappen; - } - else - { - return false; - }; -}; - -void -State::add(const SimpleProposition * a) -{ - if(LaTeX) - *report << " \\> \\adding{"<<*a<<"}\\\\\n"; - else if(Verbose) - cout << "Adding " << *a << "\n"; - - - logState[a] = true; -}; - -void -State::del(const SimpleProposition * a) -{ - if(LaTeX) - *report << " \\> \\deleting{"<<*a<<"}\\\\\n"; - else if(Verbose) - cout << "Deleting " << *a << "\n"; - logState[a] = false; - -}; - -void -State::addChange(const SimpleProposition * a) -{ - if(LaTeX) - *report << " \\> \\adding{"<<*a<<"}\\\\\n"; - else if(Verbose) - cout << "Adding " << *a << "\n"; - - if(!(logState[a])) changedLiterals.insert(a); - logState[a] = true; -}; - -void -State::delChange(const SimpleProposition * a) -{ - if(LaTeX) - *report << " \\> \\deleting{"<<*a<<"}\\\\\n"; - else if(Verbose) - cout << "Deleting " << *a << "\n"; - - if(logState[a]) changedLiterals.insert(a); - logState[a] = false; -}; - -void -State::updateChange(const FuncExp * fe,assign_op aop,FEScalar value) -{ - FEScalar initialValue = feValue[fe]; - - update(fe,aop,value); - - if(feValue[fe] != initialValue) changedPNEs.insert(fe); - -}; - -State & State::operator=(const State & s) -{ - logState = s.logState; - feValue = s.feValue; - time = s.time; - changedLiterals = s.changedLiterals; - changedPNEs = s.changedPNEs; - - return *this; -}; - -void -State::update(const FuncExp * fe,assign_op aop,FEScalar value) -{ - bool setInitialValue = false; - FEGraph * feg = 0; - - if(LaTeX) - { - feg = getValidator()->getGraph(fe); - - //setup initial value if nec - if( (feg->initialTime == -1) ) - { - map::const_iterator i = feValue.find(fe); - - - if(i != feValue.end()) - { - feg->initialTime = 0; - feg->initialValue = fe->evaluate(this); - } - else - { - feg->initialTime = time; - setInitialValue = true; - - }; - - - }; - - - }; - - - - if(Verbose && !LaTeX) *report << "Updating " << *fe << " (" << feValue[fe] << ") by " << value << " "; - - FEScalar feValueInt = feValue[fe]; - - switch(aop) - { - case E_ASSIGN: - if(LaTeX) - { - *report << " \\> \\assignment{"<<*fe<<"}{"< \\assignmentcts{"<<*fe<<"}{"< \\increase{"<<*fe<<"}{"< \\decrease{"<<*fe<<"}{"< \\scaleup{"<<*fe<<"}{"< \\scaledown{"<<*fe<<"}{"<initialValue = feValueInt; - }; - - - if( (feValueInt != feValue[fe]) || setInitialValue ) - { - //check value is already defined, may be communitive updates at the same time - map >::iterator j = feg->discons.find(time); - - if(j == feg->discons.end()) - { - feg->discons[time] = make_pair(feValueInt,feValue[fe]); - feg->happenings.insert(time); - } - else - { - j->second.second = feValue[fe]; - }; - - }; - - - - - - }; - - return; - -}; - -}; - - - +/*----------------------------------------------------------------------------- + VAL - The Automatic Plan Validator for PDDL+ + + $Date: 2009-02-05 10:50:23 $ + $Revision: 1.2 $ + + Maria Fox, Richard Howey and Derek Long - PDDL+ and VAL + Stephen Cresswell - PDDL Parser + + maria.fox@cis.strath.ac.uk + derek.long@cis.strath.ac.uk + stephen.cresswell@cis.strath.ac.uk + richard.howey@cis.strath.ac.uk + + By releasing this code we imply no warranty as to its reliability + and its use is entirely at your own risk. + + Strathclyde Planning Group + http://planning.cis.strath.ac.uk + ----------------------------------------------------------------------------*/ +#include "State.h" +#include "Plan.h" +#include "main.h" +#include "Validator.h" +#include "Proposition.h" +#include "Exceptions.h" +#include "LaTeXSupport.h" +#include "RobustAnalyse.h" + +#include + +using std::stringstream; +using std::cerr; +//#define list std::list +//#define map std::map + +namespace VAL { + +vector State::sos; + +void State::setNew(const effect_lists * is) +{ + logState.clear(); + feValue.clear(); + changedPNEs.clear(); + + for(list::const_iterator i = is->add_effects.begin(); + i != is->add_effects.end();++i) + { + logState[vld->pf.buildLiteral(*i)] = true; + }; + + for(pc_list::const_iterator i1 = is->assign_effects.begin(); + i1 != is->assign_effects.end();++i1) + { + const FuncExp * fe = vld->fef.buildFuncExp((*i1)->getFTerm()); +// DPL 2/2/06: Need to remember which PNEs changed in order to trigger +// processes properly in the initial state. + changedPNEs.insert(fe); + FEScalar feNewValue = dynamic_cast((*i1)->getExpr())->double_value(); + + feValue[fe] = feNewValue; + + //setup initial value for LaTeX graph + if(LaTeX) + { + FEGraph * feg = getValidator()->getGraph(fe); + + //setup initial value if nec + if(feg->initialTime == -1) + { + feg->initialTime = time; + feg->initialValue = feNewValue; + }; + }; + + }; +}; + +State::State(Validator * const v,const effect_lists* is) : + tolerance(v->getTolerance()), vld(v), time(0.0) +{ + setNew(is); +}; + +bool State::evaluate(const SimpleProposition * p) const +{ + LogicalState::const_iterator i = logState.find(p); + if(i != logState.end()) + { + return i->second; + } + else + { + return false; + }; +}; + +FEScalar State::evaluateFE(const FuncExp * fe) const +{ + NumericalState::const_iterator i = feValue.find(fe); + if(i!=feValue.end()) + { + return i->second; + } + else + { + /* cerr << "Attempt to access undefined expression: " << *fe << "\n"; + if(LaTeX) + { + *report << "\\error{Attempt to access undefined expression: " << *fe << "}\n"; + }; + */ + // Throw? Yes ! + //exit(0); + + + BadAccessError bae; + throw bae; + }; +}; + +FEScalar State::evaluate(const expression * e,const Environment & bs) const +{ + if(dynamic_cast(e)) + { + return evaluate(dynamic_cast(e)->getLHS(),bs) / + evaluate(dynamic_cast(e)->getRHS(),bs); + }; + + if(dynamic_cast(e)) + { + return evaluate(dynamic_cast(e)->getLHS(),bs) - + evaluate(dynamic_cast(e)->getRHS(),bs); + }; + + + + if(dynamic_cast(e)) + { + return evaluate(dynamic_cast(e)->getLHS(),bs) * + evaluate(dynamic_cast(e)->getRHS(),bs); + }; + + if(dynamic_cast(e)) + { + return evaluate(dynamic_cast(e)->getLHS(),bs) + + evaluate(dynamic_cast(e)->getRHS(),bs); + }; + + if(dynamic_cast(e)) + { + return dynamic_cast(e)->double_value(); + }; + + if(dynamic_cast(e)) + { + return -(evaluate(dynamic_cast(e)->getExpr(),bs)); + }; + + if(dynamic_cast(e)) + { + const FuncExp * fexp = vld->fef.buildFuncExp(dynamic_cast(e),bs); + return fexp->evaluate(this); + //if(feValue.find(fexp) != feValue.end()) + //return feValue.find(fexp)->second; + /* + if(LaTeX) + { + *report << "\\error{Attempt to access undefined expression: " << *fexp << "}\n"; + } + else if(Verbose) cout << "Attempt to inspect undefined value: " << *fexp << "\n"; + */ + //BadAccessError bae; + //throw bae; + }; + + if(const special_val_expr * sp = dynamic_cast(e)) + { + if(sp->getKind() == E_TOTAL_TIME) + { + if(vld->durativePlan()) return time; + return vld->simpleLength(); + }; + + if(sp->getKind() == E_DURATION_VAR) + { + return bs.duration; + }; + + if(sp->getKind() == E_HASHT) + + { + if(LaTeX) + *report << "The use of \\#t is not valid in this context!\n"; + else if(Verbose) + cout << "The use of #t is not valid in this context!\n"; + SyntaxTooComplex stc; + throw stc; + } + + }; + + if(const violation_term * vt = dynamic_cast(e)) + { + return vld->violationsFor(vt->getName()); + }; + + UnrecognisedCondition uc; + throw uc; +}; + +bool +State::progress(const Happening * h) +{ + DerivedGoal::resetLists(this); + resetChanged(); + + if(TestingPNERobustness) JudderPNEs = true; + bool canHappen = h->canHappen(this); + + if(canHappen || ContinueAnyway) + { + time = h->getTime(); + + if(TestingPNERobustness) JudderPNEs = false; + return h->applyTo(this) && canHappen; + } + else + { + return false; + }; +}; + +bool +State::progressCtsEvent(const Happening * h) +{ + DerivedGoal::resetLists(this); + resetChanged(); + + if(TestingPNERobustness) JudderPNEs = true; + bool canHappen = h->canHappen(this); + + if(canHappen || ContinueAnyway) + { + time = h->getTime(); + if(TestingPNERobustness) JudderPNEs = false; + return h->applyTo(this) && canHappen; + } + else + { + return false; + }; +}; + +void +State::add(const SimpleProposition * a) +{ + if(LaTeX) + *report << " \\> \\adding{"<<*a<<"}\\\\\n"; + else if(Verbose) + cout << "Adding " << *a << "\n"; + + + logState[a] = true; +}; + +void +State::del(const SimpleProposition * a) +{ + if(LaTeX) + *report << " \\> \\deleting{"<<*a<<"}\\\\\n"; + else if(Verbose) + cout << "Deleting " << *a << "\n"; + logState[a] = false; + +}; + +void +State::addChange(const SimpleProposition * a) +{ + if(LaTeX) + *report << " \\> \\adding{"<<*a<<"}\\\\\n"; + else if(Verbose) + cout << "Adding " << *a << "\n"; + + if(!(logState[a])) changedLiterals.insert(a); + logState[a] = true; +}; + +void +State::delChange(const SimpleProposition * a) +{ + if(LaTeX) + *report << " \\> \\deleting{"<<*a<<"}\\\\\n"; + else if(Verbose) + cout << "Deleting " << *a << "\n"; + + if(logState[a]) changedLiterals.insert(a); + logState[a] = false; +}; + +void +State::updateChange(const FuncExp * fe,assign_op aop,FEScalar value) +{ + FEScalar initialValue = feValue[fe]; + + update(fe,aop,value); + + if(feValue[fe] != initialValue) changedPNEs.insert(fe); + +}; + +State & State::operator=(const State & s) +{ + logState = s.logState; + feValue = s.feValue; + time = s.time; + changedLiterals = s.changedLiterals; + changedPNEs = s.changedPNEs; + + return *this; +}; + +void +State::update(const FuncExp * fe,assign_op aop,FEScalar value) +{ + bool setInitialValue = false; + FEGraph * feg = 0; + + if(LaTeX) + { + feg = getValidator()->getGraph(fe); + + //setup initial value if nec + if(feg->initialTime == -1) + { + map::const_iterator i = feValue.find(fe); + + + if(i != feValue.end()) + { + feg->initialTime = 0; + feg->initialValue = fe->evaluate(this); + } + else + { + feg->initialTime = time; + setInitialValue = true; + + }; + + + }; + + + }; + + + + if(Verbose && !LaTeX) *report << "Updating " << *fe << " (" << feValue[fe] << ") by " << value << " "; + + FEScalar feValueInt = feValue[fe]; + + switch(aop) + { + case E_ASSIGN: + if(LaTeX) + { + *report << " \\> \\assignment{"<<*fe<<"}{"< \\assignmentcts{"<<*fe<<"}{"< \\increase{"<<*fe<<"}{"< \\decrease{"<<*fe<<"}{"< \\scaleup{"<<*fe<<"}{"< \\scaledown{"<<*fe<<"}{"<initialValue = feValueInt; + }; + + + if( (feValueInt != feValue[fe]) || setInitialValue ) + { + //check value is already defined, may be communitive updates at the same time + map >::iterator j = feg->discons.find(time); + + if(j == feg->discons.end()) + { + feg->discons[time] = make_pair(feValueInt,feValue[fe]); + feg->happenings.insert(time); + } + else + { + j->second.second = feValue[fe]; + }; + + }; + + + + + + }; + + return; + +}; + +}; + + + diff --git a/src/pddl+.cpp b/src/pddl+.cpp deleted file mode 100644 index 4c6c090..0000000 --- a/src/pddl+.cpp +++ /dev/null @@ -1,5256 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ - -/* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.4.3" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - - - -/* Copy the first part of user declarations. */ - -/* Line 189 of yacc.c */ -#line 17 "src/Parser/pddl+.yacc" - -/* -Error reporting: -Intention is to provide error token on most bracket expressions, -so synchronisation can occur on next CLOSE_BRAC. -Hence error should be generated for innermost expression containing error. -Expressions which cause errors return a NULL values, and parser -always attempts to carry on. -This won't behave so well if CLOSE_BRAC is missing. - -Naming conventions: -Generally, the names should be similar to the PDDL2.1 spec. -During development, they have also been based on older PDDL specs, -older PDDL+ and TIM parsers, and this shows in places. - -All the names of fields in the semantic value type begin with t_ -Corresponding categories in the grammar begin with c_ -Corresponding classes have no prefix. - -PDDL grammar yacc grammar type of corresponding semantic val. - -thing+ c_things thing_list -(thing+) c_thing_list thing_list - -*/ - -#include -#include -#include -#include - -// This is now copied locally to avoid relying on installation -// of flex++. - -//#include "FlexLexer.h" -//#include - -#include "ptree.h" -#include "parse_error.h" - -#define YYDEBUG 1 - -int yyerror(char *); - -#ifndef YY_ -# if YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", ((char *)msgid)) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) ((char *) msgid) -# endif -#endif - -extern int yylex(); - -using namespace VAL; - - - -/* Line 189 of yacc.c */ -#line 135 "src/pddl+.cpp" - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - OPEN_BRAC = 258, - CLOSE_BRAC = 259, - MODULES = 260, - OPEN_SQ = 261, - CLOSE_SQ = 262, - DOT = 263, - CLASSES = 264, - CLASS = 265, - DEFINE = 266, - PDDLDOMAIN = 267, - REQS = 268, - EQUALITY = 269, - STRIPS = 270, - ADL = 271, - NEGATIVE_PRECONDITIONS = 272, - TYPING = 273, - DISJUNCTIVE_PRECONDS = 274, - EXT_PRECS = 275, - UNIV_PRECS = 276, - QUANT_PRECS = 277, - COND_EFFS = 278, - FLUENTS = 279, - OBJECTFLUENTS = 280, - NUMERICFLUENTS = 281, - ACTIONCOSTS = 282, - TIME = 283, - DURATIVE_ACTIONS = 284, - DURATION_INEQUALITIES = 285, - CONTINUOUS_EFFECTS = 286, - DERIVED_PREDICATES = 287, - TIMED_INITIAL_LITERALS = 288, - PREFERENCES = 289, - CONSTRAINTS = 290, - ACTION = 291, - PROCESS = 292, - EVENT = 293, - DURATIVE_ACTION = 294, - DERIVED = 295, - CONSTANTS = 296, - PREDS = 297, - FUNCTIONS = 298, - TYPES = 299, - ARGS = 300, - PRE = 301, - CONDITION = 302, - PREFERENCE = 303, - START_PRE = 304, - END_PRE = 305, - EFFECTS = 306, - INITIAL_EFFECT = 307, - FINAL_EFFECT = 308, - INVARIANT = 309, - DURATION = 310, - AT_START = 311, - AT_END = 312, - OVER_ALL = 313, - AND = 314, - OR = 315, - EXISTS = 316, - FORALL = 317, - IMPLY = 318, - NOT = 319, - WHEN = 320, - WHENEVER = 321, - EITHER = 322, - PROBLEM = 323, - FORDOMAIN = 324, - INITIALLY = 325, - OBJECTS = 326, - GOALS = 327, - EQ = 328, - LENGTH = 329, - SERIAL = 330, - PARALLEL = 331, - METRIC = 332, - MINIMIZE = 333, - MAXIMIZE = 334, - HASHT = 335, - DURATION_VAR = 336, - TOTAL_TIME = 337, - INCREASE = 338, - DECREASE = 339, - SCALE_UP = 340, - SCALE_DOWN = 341, - ASSIGN = 342, - GREATER = 343, - GREATEQ = 344, - LESS = 345, - LESSEQ = 346, - Q = 347, - COLON = 348, - NUMBER = 349, - ALWAYS = 350, - SOMETIME = 351, - WITHIN = 352, - ATMOSTONCE = 353, - SOMETIMEAFTER = 354, - SOMETIMEBEFORE = 355, - ALWAYSWITHIN = 356, - HOLDDURING = 357, - HOLDAFTER = 358, - ISVIOLATED = 359, - BOGUS = 360, - NAME = 361, - FUNCTION_SYMBOL = 362, - INTVAL = 363, - FLOATVAL = 364, - AT_TIME = 365, - PLUS = 366, - HYPHEN = 367, - DIV = 368, - MUL = 369, - UMINUS = 370 - }; -#endif - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -{ - -/* Line 214 of yacc.c */ -#line 79 "src/Parser/pddl+.yacc" - - parse_category* t_parse_category; - - effect_lists* t_effect_lists; - effect* t_effect; - simple_effect* t_simple_effect; - cond_effect* t_cond_effect; - forall_effect* t_forall_effect; - timed_effect* t_timed_effect; - - quantifier t_quantifier; - metric_spec* t_metric; - optimization t_optimization; - - symbol* t_symbol; - var_symbol* t_var_symbol; - pddl_type* t_type; - pred_symbol* t_pred_symbol; - func_symbol* t_func_symbol; - const_symbol* t_const_symbol; - class_symbol* t_class; - - parameter_symbol_list* t_parameter_symbol_list; - var_symbol_list* t_var_symbol_list; - const_symbol_list* t_const_symbol_list; - pddl_type_list* t_type_list; - - proposition* t_proposition; - pred_decl* t_pred_decl; - pred_decl_list* t_pred_decl_list; - func_decl* t_func_decl; - func_decl_list* t_func_decl_list; - - goal* t_goal; - con_goal * t_con_goal; - goal_list* t_goal_list; - - func_term* t_func_term; - assignment* t_assignment; - expression* t_expression; - num_expression* t_num_expression; - assign_op t_assign_op; - comparison_op t_comparison_op; - - structure_def* t_structure_def; - structure_store* t_structure_store; - - action* t_action_def; - event* t_event_def; - process* t_process_def; - durative_action* t_durative_action_def; - derivation_rule* t_derivation_rule; - - problem* t_problem; - length_spec* t_length_spec; - - domain* t_domain; - - pddl_req_flag t_pddl_req_flag; - - plan* t_plan; - plan_step* t_step; - - int ival; - double fval; - - char* cp; - int t_dummy; - - var_symbol_table * vtab; - - class_def * t_class_def; - // classes_list* t_classes; - - - - -/* Line 214 of yacc.c */ -#line 364 "src/pddl+.cpp" -} YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif - - -/* Copy the second part of user declarations. */ - - -/* Line 264 of yacc.c */ -#line 376 "src/pddl+.cpp" - -#ifdef short -# undef short -#endif - -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; -#endif - -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; -#else -typedef short int yytype_int8; -#endif - -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short int yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif -#endif - -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) -#else -# define YYUSE(e) /* empty */ -#endif - -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) -#else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int yyi) -#else -static int -YYID (yyi) - int yyi; -#endif -{ - return yyi; -} -#endif - -#if ! defined yyoverflow || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined _STDLIB_H \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 17 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 967 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 116 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 129 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 350 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 810 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 370 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, - 115 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint16 yyprhs[] = -{ - 0, 0, 3, 5, 7, 9, 15, 20, 23, 26, - 29, 32, 35, 38, 41, 43, 48, 50, 52, 57, - 60, 61, 66, 71, 74, 75, 78, 80, 85, 89, - 91, 93, 95, 97, 100, 101, 107, 111, 114, 115, - 117, 122, 127, 129, 133, 134, 139, 144, 146, 149, - 150, 153, 154, 159, 164, 166, 169, 173, 174, 176, - 178, 180, 182, 187, 189, 191, 194, 195, 198, 199, - 206, 209, 212, 215, 216, 221, 224, 227, 230, 231, - 233, 235, 237, 239, 241, 246, 248, 250, 252, 254, - 257, 260, 263, 264, 269, 274, 279, 287, 293, 299, - 301, 303, 306, 307, 312, 317, 323, 329, 333, 339, - 345, 349, 354, 362, 368, 370, 373, 374, 379, 381, - 383, 385, 387, 390, 393, 396, 397, 403, 409, 415, - 421, 427, 433, 439, 444, 447, 448, 450, 453, 455, - 457, 463, 469, 475, 481, 486, 493, 503, 513, 515, - 517, 519, 521, 524, 525, 530, 532, 537, 539, 547, - 553, 559, 565, 571, 577, 583, 588, 594, 600, 606, - 612, 614, 616, 622, 628, 630, 632, 634, 639, 644, - 646, 653, 658, 663, 665, 667, 669, 671, 673, 675, - 677, 682, 690, 694, 697, 702, 708, 713, 721, 723, - 728, 734, 739, 747, 750, 752, 757, 763, 765, 768, - 770, 775, 783, 788, 793, 798, 804, 809, 815, 821, - 828, 835, 841, 843, 848, 853, 858, 864, 872, 880, - 886, 889, 891, 894, 896, 898, 900, 905, 910, 915, - 920, 925, 930, 935, 940, 945, 950, 955, 958, 960, - 962, 964, 966, 968, 970, 972, 978, 980, 986, 999, - 1004, 1017, 1022, 1035, 1040, 1052, 1057, 1061, 1065, 1066, - 1068, 1073, 1076, 1077, 1082, 1087, 1092, 1098, 1103, 1105, - 1107, 1109, 1111, 1113, 1115, 1117, 1119, 1121, 1123, 1125, - 1127, 1129, 1131, 1133, 1135, 1137, 1139, 1141, 1143, 1145, - 1147, 1149, 1151, 1153, 1158, 1163, 1176, 1182, 1185, 1188, - 1191, 1194, 1197, 1200, 1203, 1204, 1209, 1214, 1216, 1221, - 1227, 1232, 1240, 1246, 1252, 1254, 1256, 1260, 1262, 1264, - 1266, 1271, 1275, 1279, 1283, 1287, 1291, 1293, 1296, 1298, - 1301, 1304, 1308, 1312, 1313, 1317, 1319, 1324, 1326, 1331, - 1333 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int16 yyrhs[] = -{ - 117, 0, -1, 118, -1, 227, -1, 240, -1, 3, - 11, 120, 119, 4, -1, 3, 11, 120, 1, -1, - 125, 119, -1, 226, 119, -1, 225, 119, -1, 206, - 119, -1, 207, 119, -1, 208, 119, -1, 123, 119, - -1, 210, -1, 3, 12, 106, 4, -1, 106, -1, - 106, -1, 3, 9, 124, 4, -1, 121, 124, -1, - -1, 3, 13, 126, 4, -1, 3, 13, 1, 4, - -1, 126, 224, -1, -1, 128, 127, -1, 128, -1, - 3, 129, 136, 4, -1, 3, 1, 4, -1, 106, - -1, 73, -1, 106, -1, 106, -1, 132, 133, -1, - -1, 3, 135, 136, 4, 134, -1, 3, 1, 4, - -1, 112, 94, -1, -1, 106, -1, 137, 112, 149, - 136, -1, 137, 112, 147, 136, -1, 137, -1, 92, - 143, 137, -1, -1, 140, 112, 149, 138, -1, 140, - 112, 147, 138, -1, 140, -1, 145, 139, -1, -1, - 146, 140, -1, -1, 150, 112, 149, 141, -1, 150, - 112, 147, 141, -1, 150, -1, 142, 145, -1, 142, - 92, 144, -1, -1, 106, -1, 106, -1, 106, -1, - 106, -1, 3, 67, 151, 4, -1, 106, -1, 106, - -1, 150, 148, -1, -1, 151, 149, -1, -1, 152, - 3, 73, 188, 187, 4, -1, 152, 181, -1, 152, - 180, -1, 152, 153, -1, -1, 3, 110, 152, 4, - -1, 156, 154, -1, 183, 154, -1, 182, 154, -1, - -1, 159, -1, 179, -1, 178, -1, 183, -1, 182, - -1, 3, 59, 158, 4, -1, 157, -1, 178, -1, - 179, -1, 184, -1, 158, 178, -1, 158, 179, -1, - 158, 184, -1, -1, 3, 59, 154, 4, -1, 3, - 59, 1, 4, -1, 3, 59, 161, 4, -1, 3, - 201, 3, 136, 4, 160, 4, -1, 3, 65, 220, - 160, 4, -1, 3, 66, 198, 164, 4, -1, 162, - -1, 184, -1, 161, 160, -1, -1, 3, 56, 166, - 4, -1, 3, 57, 166, 4, -1, 3, 83, 188, - 186, 4, -1, 3, 84, 188, 186, 4, -1, 3, - 1, 4, -1, 3, 83, 188, 186, 4, -1, 3, - 84, 188, 186, 4, -1, 3, 1, 4, -1, 3, - 59, 165, 4, -1, 3, 201, 3, 136, 4, 164, - 4, -1, 3, 66, 198, 164, 4, -1, 163, -1, - 165, 164, -1, -1, 3, 59, 168, 4, -1, 167, - -1, 178, -1, 179, -1, 169, -1, 168, 178, -1, - 168, 179, -1, 168, 169, -1, -1, 3, 87, 188, - 172, 4, -1, 3, 83, 188, 172, 4, -1, 3, - 84, 188, 172, 4, -1, 3, 85, 188, 172, 4, - -1, 3, 86, 188, 172, 4, -1, 3, 83, 188, - 186, 4, -1, 3, 84, 188, 186, 4, -1, 3, - 59, 171, 4, -1, 171, 170, -1, -1, 173, -1, - 92, 81, -1, 187, -1, 188, -1, 3, 111, 172, - 172, 4, -1, 3, 112, 172, 172, 4, -1, 3, - 114, 172, 172, 4, -1, 3, 113, 172, 172, 4, - -1, 3, 59, 177, 4, -1, 3, 175, 92, 81, - 176, 4, -1, 3, 56, 3, 175, 92, 81, 176, - 4, 4, -1, 3, 57, 3, 175, 92, 81, 176, - 4, 4, -1, 91, -1, 89, -1, 73, -1, 185, - -1, 177, 174, -1, -1, 3, 64, 203, 4, -1, - 203, -1, 3, 64, 205, 4, -1, 205, -1, 3, - 201, 3, 136, 4, 155, 4, -1, 3, 65, 198, - 154, 4, -1, 3, 87, 188, 185, 4, -1, 3, - 83, 188, 185, 4, -1, 3, 84, 188, 185, 4, - -1, 3, 85, 188, 185, 4, -1, 3, 86, 188, - 185, 4, -1, 3, 112, 185, 4, -1, 3, 111, - 185, 185, 4, -1, 3, 112, 185, 185, 4, -1, - 3, 114, 185, 185, 4, -1, 3, 113, 185, 185, - 4, -1, 187, -1, 188, -1, 3, 114, 80, 185, - 4, -1, 3, 114, 185, 80, 4, -1, 80, -1, - 108, -1, 109, -1, 3, 107, 142, 4, -1, 3, - 106, 142, 4, -1, 107, -1, 3, 122, 8, 107, - 142, 4, -1, 3, 107, 142, 4, -1, 3, 106, - 142, 4, -1, 107, -1, 88, -1, 89, -1, 90, - -1, 91, -1, 73, -1, 195, -1, 3, 59, 199, - 4, -1, 3, 201, 3, 136, 4, 191, 4, -1, - 3, 59, 4, -1, 3, 4, -1, 3, 48, 197, - 4, -1, 3, 48, 106, 197, 4, -1, 3, 59, - 194, 4, -1, 3, 201, 3, 136, 4, 193, 4, - -1, 197, -1, 3, 48, 197, 4, -1, 3, 48, - 106, 197, 4, -1, 3, 59, 194, 4, -1, 3, - 201, 3, 136, 4, 193, 4, -1, 194, 192, -1, - 192, -1, 3, 48, 198, 4, -1, 3, 48, 106, - 198, 4, -1, 198, -1, 196, 197, -1, 197, -1, - 3, 59, 196, 4, -1, 3, 201, 3, 136, 4, - 197, 4, -1, 3, 57, 198, 4, -1, 3, 95, - 198, 4, -1, 3, 96, 198, 4, -1, 3, 97, - 187, 198, 4, -1, 3, 98, 198, 4, -1, 3, - 99, 198, 198, 4, -1, 3, 100, 198, 198, 4, - -1, 3, 101, 187, 198, 198, 4, -1, 3, 102, - 187, 187, 198, 4, -1, 3, 103, 187, 198, 4, - -1, 203, -1, 3, 64, 198, 4, -1, 3, 59, - 200, 4, -1, 3, 60, 200, 4, -1, 3, 63, - 198, 198, 4, -1, 3, 201, 3, 136, 4, 198, - 4, -1, 3, 202, 3, 136, 4, 198, 4, -1, - 3, 190, 185, 185, 4, -1, 199, 191, -1, 191, - -1, 200, 198, -1, 198, -1, 62, -1, 61, -1, - 3, 130, 142, 4, -1, 3, 130, 136, 4, -1, - 3, 131, 142, 4, -1, 3, 42, 127, 4, -1, - 3, 42, 1, 4, -1, 3, 43, 132, 4, -1, - 3, 43, 1, 4, -1, 3, 35, 197, 4, -1, - 3, 35, 1, 4, -1, 3, 35, 192, 4, -1, - 3, 35, 1, 4, -1, 210, 211, -1, 211, -1, - 215, -1, 216, -1, 217, -1, 218, -1, 214, -1, - 212, -1, 3, 10, 122, 207, 4, -1, 40, -1, - 3, 213, 204, 198, 4, -1, 3, 36, 106, 223, - 3, 136, 4, 46, 191, 51, 155, 4, -1, 3, - 36, 1, 4, -1, 3, 38, 106, 223, 3, 136, - 4, 46, 198, 51, 155, 4, -1, 3, 38, 1, - 4, -1, 3, 37, 106, 223, 3, 136, 4, 46, - 198, 51, 170, 4, -1, 3, 37, 1, 4, -1, - 3, 39, 106, 223, 3, 136, 4, 55, 174, 219, - 4, -1, 3, 39, 1, 4, -1, 219, 51, 160, - -1, 219, 47, 220, -1, -1, 222, -1, 3, 59, - 221, 4, -1, 221, 220, -1, -1, 3, 56, 198, - 4, -1, 3, 57, 198, 4, -1, 3, 58, 198, - 4, -1, 3, 48, 106, 222, 4, -1, 3, 48, - 222, 4, -1, 45, -1, 14, -1, 15, -1, 18, - -1, 17, -1, 19, -1, 20, -1, 21, -1, 23, - -1, 24, -1, 29, -1, 28, -1, 27, -1, 25, - -1, 26, -1, 5, -1, 16, -1, 22, -1, 30, - -1, 31, -1, 32, -1, 33, -1, 34, -1, 35, - -1, 106, -1, 3, 41, 138, 4, -1, 3, 44, - 141, 4, -1, 3, 11, 3, 68, 106, 4, 3, - 69, 106, 4, 228, 4, -1, 3, 11, 3, 68, - 1, -1, 125, 228, -1, 229, 228, -1, 230, 228, - -1, 232, 228, -1, 209, 228, -1, 233, 228, -1, - 234, 228, -1, -1, 3, 71, 138, 4, -1, 3, - 70, 152, 4, -1, 72, -1, 3, 231, 191, 4, - -1, 3, 77, 235, 236, 4, -1, 3, 77, 1, - 4, -1, 3, 74, 75, 108, 76, 108, 4, -1, - 3, 74, 75, 108, 4, -1, 3, 74, 76, 108, - 4, -1, 78, -1, 79, -1, 3, 237, 4, -1, - 189, -1, 187, -1, 82, -1, 3, 104, 106, 4, - -1, 3, 82, 4, -1, 111, 236, 238, -1, 112, - 236, 236, -1, 114, 236, 239, -1, 113, 236, 236, - -1, 236, -1, 236, 238, -1, 236, -1, 236, 239, - -1, 241, 240, -1, 28, 109, 240, -1, 28, 108, - 240, -1, -1, 244, 93, 242, -1, 242, -1, 243, - 6, 244, 7, -1, 243, -1, 3, 106, 139, 4, - -1, 109, -1, 108, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 260, 260, 261, 262, 266, 272, 279, 280, 281, - 282, 284, 286, 288, 289, 292, 296, 299, 301, 303, - 304, 308, 315, 322, 323, 328, 330, 335, 337, 345, - 353, 355, 363, 368, 370, 374, 376, 383, 383, 386, - 399, 408, 417, 429, 431, 437, 446, 456, 461, 462, - 466, 467, 475, 482, 491, 497, 499, 501, 508, 514, - 518, 522, 526, 531, 538, 543, 545, 549, 551, 555, - 568, 570, 572, 575, 579, 585, 586, 588, 590, 599, - 600, 601, 602, 603, 607, 608, 612, 614, 616, 623, - 624, 625, 627, 631, 633, 641, 643, 651, 656, 661, - 664, 671, 672, 676, 678, 680, 684, 688, 694, 698, - 702, 708, 710, 718, 723, 729, 730, 734, 735, 739, - 741, 743, 750, 751, 752, 754, 759, 761, 763, 765, - 767, 772, 778, 784, 789, 790, 794, 795, 797, 798, - 802, 804, 806, 808, 813, 815, 818, 821, 827, 828, - 829, 837, 841, 844, 848, 853, 860, 865, 870, 875, - 880, 882, 884, 886, 888, 893, 895, 897, 899, 901, - 903, 904, 908, 910, 912, 918, 919, 922, 925, 927, - 930, 947, 949, 951, 957, 958, 959, 960, 961, 973, - 980, 982, 986, 987, 991, 993, 995, 997, 1001, 1006, - 1008, 1010, 1012, 1019, 1021, 1026, 1028, 1032, 1037, 1039, - 1044, 1046, 1049, 1051, 1053, 1055, 1057, 1059, 1061, 1063, - 1065, 1067, 1072, 1074, 1078, 1080, 1083, 1086, 1089, 1092, - 1098, 1100, 1105, 1107, 1117, 1124, 1131, 1136, 1141, 1146, - 1148, 1155, 1157, 1164, 1166, 1173, 1175, 1182, 1183, 1187, - 1188, 1189, 1190, 1191, 1192, 1195, 1204, 1210, 1219, 1230, - 1237, 1248, 1254, 1264, 1270, 1285, 1292, 1294, 1296, 1300, - 1302, 1307, 1310, 1314, 1316, 1318, 1320, 1325, 1330, 1335, - 1336, 1338, 1339, 1341, 1343, 1344, 1345, 1346, 1347, 1349, - 1352, 1355, 1356, 1357, 1359, 1368, 1371, 1374, 1376, 1378, - 1380, 1382, 1384, 1390, 1394, 1399, 1411, 1418, 1419, 1420, - 1421, 1422, 1424, 1426, 1427, 1430, 1433, 1436, 1439, 1443, - 1445, 1452, 1455, 1459, 1466, 1467, 1472, 1473, 1474, 1475, - 1476, 1478, 1482, 1483, 1484, 1485, 1489, 1490, 1495, 1496, - 1502, 1505, 1507, 1510, 1514, 1518, 1524, 1528, 1534, 1542, - 1543 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "OPEN_BRAC", "CLOSE_BRAC", "MODULES", - "OPEN_SQ", "CLOSE_SQ", "DOT", "CLASSES", "CLASS", "DEFINE", "PDDLDOMAIN", - "REQS", "EQUALITY", "STRIPS", "ADL", "NEGATIVE_PRECONDITIONS", "TYPING", - "DISJUNCTIVE_PRECONDS", "EXT_PRECS", "UNIV_PRECS", "QUANT_PRECS", - "COND_EFFS", "FLUENTS", "OBJECTFLUENTS", "NUMERICFLUENTS", "ACTIONCOSTS", - "TIME", "DURATIVE_ACTIONS", "DURATION_INEQUALITIES", - "CONTINUOUS_EFFECTS", "DERIVED_PREDICATES", "TIMED_INITIAL_LITERALS", - "PREFERENCES", "CONSTRAINTS", "ACTION", "PROCESS", "EVENT", - "DURATIVE_ACTION", "DERIVED", "CONSTANTS", "PREDS", "FUNCTIONS", "TYPES", - "ARGS", "PRE", "CONDITION", "PREFERENCE", "START_PRE", "END_PRE", - "EFFECTS", "INITIAL_EFFECT", "FINAL_EFFECT", "INVARIANT", "DURATION", - "AT_START", "AT_END", "OVER_ALL", "AND", "OR", "EXISTS", "FORALL", - "IMPLY", "NOT", "WHEN", "WHENEVER", "EITHER", "PROBLEM", "FORDOMAIN", - "INITIALLY", "OBJECTS", "GOALS", "EQ", "LENGTH", "SERIAL", "PARALLEL", - "METRIC", "MINIMIZE", "MAXIMIZE", "HASHT", "DURATION_VAR", "TOTAL_TIME", - "INCREASE", "DECREASE", "SCALE_UP", "SCALE_DOWN", "ASSIGN", "GREATER", - "GREATEQ", "LESS", "LESSEQ", "Q", "COLON", "NUMBER", "ALWAYS", - "SOMETIME", "WITHIN", "ATMOSTONCE", "SOMETIMEAFTER", "SOMETIMEBEFORE", - "ALWAYSWITHIN", "HOLDDURING", "HOLDAFTER", "ISVIOLATED", "BOGUS", "NAME", - "FUNCTION_SYMBOL", "INTVAL", "FLOATVAL", "AT_TIME", "PLUS", "HYPHEN", - "DIV", "MUL", "UMINUS", "$accept", "mystartsymbol", "c_domain", - "c_preamble", "c_domain_name", "c_new_class", "c_class", "c_classes", - "c_class_seq", "c_domain_require_def", "c_reqs", "c_pred_decls", - "c_pred_decl", "c_new_pred_symbol", "c_pred_symbol", - "c_init_pred_symbol", "c_func_decls", "c_func_decl", "c_ntype", - "c_new_func_symbol", "c_typed_var_list", "c_var_symbol_list", - "c_typed_consts", "c_const_symbols", "c_new_const_symbols", - "c_typed_types", "c_parameter_symbols", "c_declaration_var_symbol", - "c_var_symbol", "c_const_symbol", "c_new_const_symbol", "c_either_type", - "c_new_primitive_type", "c_primitive_type", "c_new_primitive_types", - "c_primitive_types", "c_init_els", "c_timed_initial_literal", - "c_effects", "c_effect", "c_a_effect", "c_p_effect", "c_p_effects", - "c_conj_effect", "c_da_effect", "c_da_effects", "c_timed_effect", - "c_cts_only_timed_effect", "c_da_cts_only_effect", - "c_da_cts_only_effects", "c_a_effect_da", "c_p_effect_da", - "c_p_effects_da", "c_f_assign_da", "c_proc_effect", "c_proc_effects", - "c_f_exp_da", "c_binary_expr_da", "c_duration_constraint", "c_d_op", - "c_d_value", "c_duration_constraints", "c_neg_simple_effect", - "c_pos_simple_effect", "c_init_neg_simple_effect", - "c_init_pos_simple_effect", "c_forall_effect", "c_cond_effect", - "c_assignment", "c_f_exp", "c_f_exp_t", "c_number", "c_f_head", - "c_ground_f_head", "c_comparison_op", "c_pre_goal_descriptor", - "c_pref_con_goal", "c_pref_goal", "c_pref_con_goal_list", - "c_pref_goal_descriptor", "c_constraint_goal_list", "c_constraint_goal", - "c_goal_descriptor", "c_pre_goal_descriptor_list", "c_goal_list", - "c_forall", "c_exists", "c_proposition", "c_derived_proposition", - "c_init_proposition", "c_predicates", "c_functions_def", - "c_constraints_def", "c_constraints_probdef", "c_structure_defs", - "c_structure_def", "c_class_def", "c_rule_head", "c_derivation_rule", - "c_action_def", "c_event_def", "c_process_def", "c_durative_action_def", - "c_da_def_body", "c_da_gd", "c_da_gds", "c_timed_gd", "c_args_head", - "c_require_key", "c_domain_constants", "c_type_names", "c_problem", - "c_problem_body", "c_objects", "c_initial_state", "c_goals", - "c_goal_spec", "c_metric_spec", "c_length_spec", "c_optimization", - "c_ground_f_exp", "c_binary_ground_f_exp", "c_binary_ground_f_pexps", - "c_binary_ground_f_mexps", "c_plan", "c_step_t_d", "c_step_d", "c_step", - "c_float", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, - 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, - 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, - 365, 366, 367, 368, 369, 370 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 116, 117, 117, 117, 118, 118, 119, 119, 119, - 119, 119, 119, 119, 119, 120, 121, 122, 123, 124, - 124, 125, 125, 126, 126, 127, 127, 128, 128, 129, - 130, 130, 131, 132, 132, 133, 133, 134, 134, 135, - 136, 136, 136, 137, 137, 138, 138, 138, 139, 139, - 140, 140, 141, 141, 141, 142, 142, 142, 143, 144, - 145, 146, 147, 148, 149, 150, 150, 151, 151, 152, - 152, 152, 152, 152, 153, 154, 154, 154, 154, 155, - 155, 155, 155, 155, 156, 156, 157, 157, 157, 158, - 158, 158, 158, 159, 159, 160, 160, 160, 160, 160, - 160, 161, 161, 162, 162, 162, 162, 162, 163, 163, - 163, 164, 164, 164, 164, 165, 165, 166, 166, 167, - 167, 167, 168, 168, 168, 168, 169, 169, 169, 169, - 169, 170, 170, 170, 171, 171, 172, 172, 172, 172, - 173, 173, 173, 173, 174, 174, 174, 174, 175, 175, - 175, 176, 177, 177, 178, 179, 180, 181, 182, 183, - 184, 184, 184, 184, 184, 185, 185, 185, 185, 185, - 185, 185, 186, 186, 186, 187, 187, 188, 188, 188, - 188, 189, 189, 189, 190, 190, 190, 190, 190, 191, - 191, 191, 191, 191, 192, 192, 192, 192, 192, 193, - 193, 193, 193, 194, 194, 195, 195, 195, 196, 196, - 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, - 197, 197, 198, 198, 198, 198, 198, 198, 198, 198, - 199, 199, 200, 200, 201, 202, 203, 204, 205, 206, - 206, 207, 207, 208, 208, 209, 209, 210, 210, 211, - 211, 211, 211, 211, 211, 212, 213, 214, 215, 215, - 216, 216, 217, 217, 218, 218, 219, 219, 219, 220, - 220, 221, 221, 222, 222, 222, 222, 222, 223, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 225, 226, 227, 227, 228, 228, 228, - 228, 228, 228, 228, 228, 229, 230, 231, 232, 233, - 233, 234, 234, 234, 235, 235, 236, 236, 236, 236, - 236, 236, 237, 237, 237, 237, 238, 238, 239, 239, - 240, 240, 240, 240, 241, 241, 242, 242, 243, 244, - 244 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 1, 1, 1, 5, 4, 2, 2, 2, - 2, 2, 2, 2, 1, 4, 1, 1, 4, 2, - 0, 4, 4, 2, 0, 2, 1, 4, 3, 1, - 1, 1, 1, 2, 0, 5, 3, 2, 0, 1, - 4, 4, 1, 3, 0, 4, 4, 1, 2, 0, - 2, 0, 4, 4, 1, 2, 3, 0, 1, 1, - 1, 1, 4, 1, 1, 2, 0, 2, 0, 6, - 2, 2, 2, 0, 4, 2, 2, 2, 0, 1, - 1, 1, 1, 1, 4, 1, 1, 1, 1, 2, - 2, 2, 0, 4, 4, 4, 7, 5, 5, 1, - 1, 2, 0, 4, 4, 5, 5, 3, 5, 5, - 3, 4, 7, 5, 1, 2, 0, 4, 1, 1, - 1, 1, 2, 2, 2, 0, 5, 5, 5, 5, - 5, 5, 5, 4, 2, 0, 1, 2, 1, 1, - 5, 5, 5, 5, 4, 6, 9, 9, 1, 1, - 1, 1, 2, 0, 4, 1, 4, 1, 7, 5, - 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, - 1, 1, 5, 5, 1, 1, 1, 4, 4, 1, - 6, 4, 4, 1, 1, 1, 1, 1, 1, 1, - 4, 7, 3, 2, 4, 5, 4, 7, 1, 4, - 5, 4, 7, 2, 1, 4, 5, 1, 2, 1, - 4, 7, 4, 4, 4, 5, 4, 5, 5, 6, - 6, 5, 1, 4, 4, 4, 5, 7, 7, 5, - 2, 1, 2, 1, 1, 1, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 2, 1, 1, - 1, 1, 1, 1, 1, 5, 1, 5, 12, 4, - 12, 4, 12, 4, 11, 4, 3, 3, 0, 1, - 4, 2, 0, 4, 4, 4, 5, 4, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 4, 4, 12, 5, 2, 2, 2, - 2, 2, 2, 2, 0, 4, 4, 1, 4, 5, - 4, 7, 5, 5, 1, 1, 3, 1, 1, 1, - 4, 3, 3, 3, 3, 3, 1, 2, 1, 2, - 2, 3, 3, 0, 3, 1, 4, 1, 4, 1, - 1 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint16 yydefact[] = -{ - 343, 0, 0, 350, 349, 0, 2, 3, 4, 343, - 345, 347, 0, 0, 49, 343, 343, 1, 0, 340, - 0, 0, 0, 0, 60, 0, 49, 342, 341, 0, - 344, 0, 0, 6, 0, 0, 0, 0, 0, 0, - 0, 14, 248, 254, 253, 249, 250, 251, 252, 0, - 0, 348, 48, 346, 0, 306, 0, 20, 0, 0, - 0, 0, 0, 0, 0, 256, 51, 0, 0, 66, - 0, 5, 13, 7, 10, 11, 12, 0, 247, 9, - 8, 15, 0, 16, 20, 0, 17, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 61, 0, 47, 51, 0, 0, 0, 26, 0, - 0, 0, 54, 0, 0, 0, 19, 18, 0, 0, - 22, 21, 293, 279, 280, 294, 282, 281, 283, 284, - 285, 295, 286, 287, 291, 292, 290, 289, 288, 296, - 297, 298, 299, 300, 301, 302, 23, 244, 0, 0, - 234, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 243, 259, 278, 0, 263, 0, 261, 0, 265, - 0, 303, 0, 50, 240, 0, 29, 44, 239, 25, - 242, 0, 241, 33, 304, 63, 0, 65, 30, 31, - 44, 0, 0, 222, 0, 255, 0, 0, 209, 0, - 0, 175, 176, 0, 0, 0, 0, 0, 0, 0, - 44, 44, 44, 44, 44, 0, 64, 51, 51, 28, - 0, 0, 42, 0, 39, 44, 66, 66, 0, 0, - 0, 235, 0, 0, 188, 184, 185, 186, 187, 57, - 0, 0, 0, 257, 0, 212, 210, 208, 213, 214, - 0, 216, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 68, 46, 45, 58, 44, 27, 0, 36, - 0, 53, 52, 237, 233, 0, 0, 0, 0, 0, - 0, 179, 0, 170, 171, 44, 44, 314, 215, 217, - 218, 0, 0, 221, 0, 0, 0, 0, 0, 0, - 43, 44, 44, 38, 224, 232, 225, 0, 223, 236, - 0, 55, 57, 57, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 314, 314, 0, 314, 314, 314, 314, - 314, 219, 220, 0, 0, 0, 0, 0, 62, 67, - 41, 40, 0, 35, 226, 59, 56, 0, 0, 0, - 0, 0, 0, 0, 229, 0, 0, 0, 73, 51, - 317, 0, 0, 0, 307, 311, 305, 308, 309, 310, - 312, 313, 211, 0, 0, 189, 207, 0, 0, 0, - 268, 37, 178, 177, 0, 165, 0, 0, 0, 57, - 0, 0, 0, 0, 0, 198, 0, 0, 0, 0, - 0, 324, 325, 0, 0, 193, 0, 0, 0, 0, - 0, 0, 0, 0, 153, 150, 149, 148, 0, 0, - 166, 167, 169, 168, 0, 227, 228, 246, 0, 0, - 0, 245, 0, 316, 72, 71, 70, 157, 315, 0, - 0, 320, 0, 329, 183, 328, 327, 0, 318, 0, - 0, 192, 231, 207, 0, 44, 0, 0, 79, 81, - 80, 83, 82, 155, 0, 0, 0, 0, 0, 0, - 0, 264, 0, 0, 180, 0, 0, 204, 0, 198, - 44, 0, 0, 32, 73, 57, 322, 0, 323, 0, - 0, 57, 57, 0, 0, 0, 0, 0, 319, 0, - 205, 190, 230, 0, 0, 0, 0, 0, 258, 135, - 0, 0, 262, 260, 0, 0, 144, 152, 0, 0, - 267, 269, 0, 266, 99, 100, 0, 194, 196, 203, - 0, 0, 0, 0, 0, 0, 0, 0, 331, 0, - 0, 0, 0, 0, 0, 0, 326, 206, 0, 0, - 0, 0, 78, 85, 86, 87, 78, 78, 88, 0, - 0, 78, 44, 0, 0, 0, 0, 0, 0, 151, - 0, 0, 0, 0, 272, 0, 0, 0, 102, 0, - 0, 0, 0, 0, 0, 0, 0, 195, 0, 156, - 0, 74, 238, 321, 330, 182, 181, 336, 332, 333, - 335, 338, 334, 0, 0, 94, 92, 0, 0, 93, - 75, 77, 76, 154, 0, 0, 133, 134, 0, 174, - 0, 0, 0, 0, 145, 0, 0, 0, 0, 0, - 0, 0, 107, 0, 0, 118, 121, 119, 120, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 44, 0, - 0, 69, 337, 339, 191, 0, 0, 0, 159, 0, - 0, 131, 132, 0, 0, 0, 277, 273, 274, 275, - 270, 271, 125, 0, 0, 0, 0, 0, 103, 104, - 95, 101, 0, 0, 114, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 197, 0, - 84, 89, 90, 91, 0, 0, 0, 0, 0, 276, - 0, 0, 0, 0, 0, 0, 97, 0, 116, 0, - 0, 0, 0, 98, 0, 161, 105, 162, 106, 163, - 164, 160, 0, 0, 0, 0, 44, 158, 0, 0, - 146, 147, 0, 117, 124, 122, 123, 0, 0, 0, - 136, 138, 139, 0, 0, 0, 0, 110, 0, 0, - 0, 0, 44, 0, 0, 0, 199, 201, 0, 172, - 173, 0, 0, 0, 0, 137, 127, 128, 129, 130, - 126, 111, 115, 0, 0, 0, 0, 96, 200, 0, - 0, 0, 0, 0, 113, 108, 109, 0, 0, 0, - 0, 0, 0, 0, 202, 140, 141, 143, 142, 112 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - -1, 5, 6, 35, 23, 84, 318, 36, 85, 37, - 89, 107, 108, 177, 239, 485, 110, 183, 343, 225, - 221, 222, 102, 25, 103, 111, 279, 266, 346, 311, - 104, 217, 187, 218, 112, 299, 396, 434, 551, 457, - 552, 553, 655, 458, 523, 640, 524, 684, 685, 758, - 634, 635, 710, 636, 465, 563, 749, 750, 380, 418, - 568, 469, 554, 555, 435, 436, 556, 557, 558, 569, - 620, 283, 284, 446, 240, 374, 477, 650, 478, 375, - 197, 333, 376, 454, 275, 507, 242, 193, 114, 437, - 38, 39, 40, 324, 41, 42, 43, 70, 44, 45, - 46, 47, 48, 419, 520, 631, 521, 164, 146, 49, - 50, 7, 325, 326, 327, 363, 328, 329, 330, 403, - 597, 497, 598, 602, 8, 9, 10, 11, 12 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -688 -static const yytype_int16 yypact[] = -{ - 48, 63, 121, -688, -688, 38, -688, -688, -688, 176, - -688, 62, -20, 80, -21, 176, 176, -688, -14, -688, - 131, 251, 11, 57, -688, 231, -21, -688, -688, 261, - -688, 177, 8, -688, 720, 268, 286, 286, 286, 286, - 286, 290, -688, -688, -688, -688, -688, -688, -688, 286, - 286, -688, -688, -688, 294, -688, 299, 203, 206, 495, - 274, 20, 25, 56, 79, -688, 209, 329, 369, -688, - 320, -688, -688, -688, -688, -688, -688, 702, -688, -688, - -688, -688, 324, -688, 203, 330, -688, 336, 341, 628, - 363, 624, 376, 398, 366, 409, 366, 412, 366, 416, - 366, -688, 474, 354, 209, 484, 104, 486, 504, 494, - 244, 527, -37, -25, 532, 469, -688, -688, 497, 539, - -688, -688, -688, -688, -688, -688, -688, -688, -688, -688, - -688, -688, -688, -688, -688, -688, -688, -688, -688, -688, - -688, -688, -688, -688, -688, -688, -688, -688, 532, 542, - -688, 532, 532, 153, 532, 532, 532, 153, 153, 153, - 570, -688, -688, -688, 572, -688, 576, -688, 579, -688, - 592, -688, 19, -688, -688, 599, -688, 514, -688, -688, - -688, 108, -688, -688, -688, -688, 19, -688, -688, -688, - 514, 508, 604, -688, 507, -688, 611, 371, -688, 614, - 623, -688, -688, 532, 633, 532, 532, 532, 153, 532, - 514, 514, 514, 514, 514, 567, -688, 209, 209, -688, - 560, 668, 556, 670, -688, 514, -688, -688, 673, 532, - 532, -688, 532, 532, 135, -688, -688, -688, -688, -688, - 75, 679, 681, -688, 683, -688, -688, -688, -688, -688, - 689, -688, 696, 727, 532, 532, 728, 731, 739, 742, - 748, 749, -688, -688, -688, -688, 514, -688, 19, -688, - 750, -688, -688, -688, -688, 381, 396, 532, 767, 136, - 517, -688, 75, -688, -688, 514, 514, 769, -688, -688, - -688, 770, 773, -688, 542, 740, 741, 747, 718, 86, - -688, 514, 514, 676, -688, -688, -688, 790, -688, -688, - 690, -688, 787, -688, 75, 75, 75, 75, 789, 794, - 795, 796, 462, 769, 769, 797, 769, 769, 769, 769, - 769, -688, -688, 798, 800, 532, 532, 801, -688, -688, - -688, -688, 711, -688, -688, -688, -688, 199, 207, 75, - 59, 75, 75, 699, -688, 532, 532, 353, -688, 209, - -688, 332, 195, 800, -688, -688, -688, -688, -688, -688, - -688, -688, -688, 298, 756, -688, -688, 757, 758, 485, - -688, -688, -688, -688, 806, -688, 807, 808, 809, -688, - 810, 811, 812, 355, 813, -688, 430, 814, 712, 713, - 815, -688, -688, 46, 818, -688, 42, 439, 820, 821, - 822, 821, 823, 824, -688, -688, -688, -688, 736, 37, - -688, -688, -688, -688, 215, -688, -688, -688, 109, 826, - 827, -688, 182, -688, -688, -688, -688, -688, -688, 82, - 828, -688, 498, -688, -688, -688, -688, 829, -688, 532, - 830, -688, -688, -688, 444, 514, 373, 831, -688, -688, - -688, -688, -688, -688, 166, 832, 833, 180, 180, 459, - 759, -688, 835, 836, -688, 542, 837, -688, 468, -688, - 514, 839, 34, -688, -688, -688, -688, 723, -688, 840, - 737, -688, -688, 46, 46, 46, 46, 841, -688, 842, - -688, -688, -688, 843, 418, 845, 532, 846, -688, -688, - 34, 34, -688, -688, 760, 761, -688, -688, 75, 307, - -688, -688, 408, -688, -688, -688, 847, -688, -688, -688, - 850, 744, 851, 370, 153, 477, 230, 852, -688, 853, - 232, 241, 46, 46, 46, 46, -688, -688, 800, 854, - 605, 855, 857, -688, -688, -688, 857, 857, -688, -25, - 858, 857, 514, 483, 58, 58, 780, 782, 860, -688, - 110, 532, 532, 532, -688, 861, 863, 863, -688, 835, - 532, 34, 34, 34, 34, 34, 864, -688, 865, -688, - 866, -688, -688, -688, -688, -688, -688, 46, -688, -688, - -688, 46, -688, 867, 810, -688, -688, 34, 34, -688, - -688, -688, -688, -688, 868, 869, -688, -688, 755, -688, - 870, 871, 75, 75, -688, 292, 873, 874, 875, 876, - 877, 502, -688, 612, 878, -688, -688, -688, -688, 879, - 561, 836, 881, 52, 52, 75, 75, 75, 514, 489, - 882, -688, -688, -688, -688, 574, 75, 75, -688, 821, - 64, -688, -688, 883, 884, 885, -688, -688, -688, -688, - -688, -688, -688, 34, 34, 34, 34, 34, -688, -688, - -688, -688, 886, 269, -688, 887, 669, 888, 889, 890, - 891, 892, 893, 894, 895, 116, 826, 897, -688, 630, - -688, -688, -688, -688, 898, 75, 805, 899, 900, -688, - 590, 99, 99, 99, 99, 99, -688, 901, -688, 532, - 34, 34, 903, -688, 64, -688, -688, -688, -688, -688, - -688, -688, 836, 542, 904, 613, 514, -688, 905, 906, - -688, -688, 664, -688, -688, -688, -688, 678, 834, 907, - -688, -688, -688, 908, 909, 910, 912, -688, 622, 881, - 58, 58, 514, 67, 913, 914, -688, -688, 915, -688, - -688, 99, 99, 99, 99, -688, -688, -688, -688, -688, - -688, -688, -688, 916, 917, 918, 919, -688, -688, 865, - 99, 99, 99, 99, -688, -688, -688, 881, 920, 921, - 922, 923, 924, 925, -688, -688, -688, -688, -688, -688 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = -{ - -688, -688, -688, 729, -688, -688, 819, -688, 817, 378, - -688, 799, -688, -688, 825, -688, -688, -688, -688, -688, - -179, 665, -189, 911, 838, 453, -259, -688, -688, 51, - -688, -139, -688, -172, -688, -688, 446, -688, -151, -407, - -688, -688, -688, -688, -403, -688, -688, -688, -687, -688, - 356, -688, -688, 222, 372, -688, -289, -688, 465, 242, - 122, -688, -399, -396, -688, -688, -393, -392, -446, -216, - -540, -152, -395, -688, -688, -343, -354, 147, 243, -688, - -688, -60, -112, -688, 710, -83, -688, -359, -688, 460, - -688, 856, -688, -688, -688, 926, -688, -688, -688, -688, - -688, -688, -688, -688, -549, -688, -339, 208, -688, -688, - -688, -688, 226, -688, -688, -688, -688, -688, -688, -688, - -344, -688, 347, 344, 249, -688, 927, -688, 929 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -79 -static const yytype_int16 yytable[] = -{ - 92, 203, 192, 394, 466, 207, 208, 209, 160, 55, - 459, 228, 459, 460, 227, 460, 461, 462, 461, 462, - 404, 93, 215, 31, 282, 621, 95, 525, 263, 264, - 641, 257, 258, 259, 260, 261, 196, 533, 17, 199, - 200, 471, 204, 205, 206, 191, 270, 226, 188, 442, - 463, 1, 463, 347, 348, 686, 255, 97, 33, 447, - 34, 618, 280, 385, 452, 26, 319, 280, 20, 185, - 280, 782, 783, 21, 13, 186, 2, 26, 280, 32, - 99, 189, 671, 22, 472, 24, 486, 534, 473, 198, - 338, 250, 14, 252, 253, 254, 302, 256, 349, 350, - 351, 352, 747, 688, 690, 175, 320, 321, 241, 223, - 803, 502, 91, 625, 56, 564, 565, 274, 274, 91, - 277, 278, 340, 341, 529, 216, 94, 339, 443, 301, - 424, 96, 619, 384, 386, 387, 388, 247, 619, -30, - 309, 281, 291, 292, 705, 463, 560, 739, 449, 542, - 543, 544, 545, 444, 201, 202, 3, 4, 487, 281, - 201, 202, 98, 305, 305, 307, 281, 201, 202, 14, - 397, 281, 201, 202, 281, 201, 202, 637, 637, 18, - 638, 638, 281, 201, 202, 100, 643, 644, 645, 646, - 647, 748, 216, 463, 525, 525, 400, 463, 463, 599, - 600, 601, 463, 382, 2, 603, 281, 201, 202, 703, - 176, 383, 656, 657, 224, 475, 626, 463, 463, 474, - 784, 785, 733, 377, 378, 509, 536, -30, 310, 15, - 16, 627, 540, 541, 592, 51, 595, 681, 682, 3, - 4, -30, 24, 390, 391, 596, 481, 181, 182, 510, - 511, 445, 704, 415, 18, 482, 701, 601, 19, 702, - 459, 201, 202, 460, 27, 28, 461, 462, 53, 416, - 717, 417, 71, 401, 402, 90, 503, 91, 711, 712, - 713, 714, 715, 54, 3, 4, 525, 665, 483, 34, - 408, 310, 484, 77, 450, 453, 463, 395, 81, 310, - 463, 530, 405, 82, 166, 24, 168, 310, 170, 83, - 430, 745, 86, 24, 746, 101, 752, 752, 752, 752, - 752, 24, 310, 113, 310, 760, 761, 115, 718, 764, - 105, 150, 106, 310, 117, 719, 24, 499, 24, 118, - 570, 445, 445, 445, 445, 120, 406, 24, 571, 572, - 573, 463, 720, 721, 392, 570, 393, 407, 230, 231, - 150, 232, 233, 571, 572, 573, 574, 147, 476, 479, - 109, 234, -34, -34, 91, 246, 752, 752, 752, 752, - 161, 529, 590, 615, 191, 304, 235, 236, 237, 238, - 445, 445, 445, 445, 561, 752, 752, 752, 752, 191, - 306, 610, 162, 428, 189, 611, 612, 398, 399, 575, - 614, 163, 148, 165, 429, 526, 167, 150, 395, 549, - 169, 550, -78, 753, 754, 755, 756, 687, 689, 691, - 692, 693, 504, 432, 433, 150, 604, 505, 506, 586, - 687, 689, 373, 451, 706, 445, 188, 373, 501, 445, - 151, 152, 153, 154, 155, 156, 157, 158, 159, 628, - 629, 630, 379, 516, 576, 577, 172, 578, 642, 694, - 150, 393, 528, 579, 580, 59, 312, 313, 171, 189, - 432, 591, 790, 791, 792, 793, 464, 616, 174, 738, - 178, 581, 582, 583, 584, 585, 88, 357, 180, -24, - -24, 799, 800, 801, 802, 519, 670, 106, 763, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, 184, 358, 359, 360, 191, 361, 695, 194, 362, - 68, 412, 413, 195, 414, 91, 148, 388, 696, 364, - 365, 150, 367, 368, 369, 370, 371, 768, 415, 751, - 751, 751, 751, 751, 522, 680, 697, 229, 230, 231, - 150, 232, 233, 210, 416, 211, 417, 699, 700, 212, - 489, 234, 213, 786, 151, 152, 153, 154, 155, 156, - 157, 158, 159, 742, 743, 214, 235, 236, 237, 238, - 722, -24, 490, 219, 491, 492, 220, 759, 243, 493, - 494, 495, 496, 244, 189, 245, 393, 767, 248, 751, - 751, 751, 751, 312, 313, 683, 781, 249, 314, 315, - 316, 317, 121, 122, 262, 734, 479, 251, 751, 751, - 751, 751, 123, 124, 125, 126, 127, 128, 129, 130, - 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, - 141, 142, 143, 144, 606, 323, 265, 150, 268, 505, - 506, 672, 267, 765, 269, 395, 505, 273, 188, 271, - 272, 148, 285, 149, 286, 188, 150, 287, 607, 608, - 583, 584, 585, 288, 505, 673, 674, 675, 676, 677, - 289, 323, 323, 188, 323, 323, 323, 323, 323, 514, - 515, 189, 58, 607, 608, 583, 584, 585, 189, 151, - 152, 153, 154, 155, 156, 157, 158, 159, 505, 57, - 58, 290, 293, 59, 145, 294, 189, 188, 61, 62, - 63, 64, 65, 295, 663, 664, 296, 673, 674, 675, - 676, 677, 297, 298, 303, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 72, 73, 74, 75, 76, - 189, 308, 322, 337, 331, 312, 313, 332, 79, 80, - 314, 315, 316, 724, 312, 313, 334, 335, 342, 771, - 772, 773, 774, 336, 344, -17, 345, 353, 354, 355, - 356, 366, 372, 373, 379, 381, 389, 409, 410, 411, - 420, 421, 422, 423, 425, 426, 427, 431, 438, 441, - 439, 440, 448, 455, 456, 464, 467, 468, 470, 393, - 480, 537, 488, 498, 500, 508, 512, 513, 519, 522, - 518, 527, 531, 539, 538, 546, 547, 548, 559, 562, - 483, 587, 566, 567, 588, 589, 593, 594, 605, 609, - 550, 622, 613, 623, 624, 632, 633, 648, 649, 660, - 651, 654, 658, 659, 661, 662, 625, 87, 666, 667, - 668, 669, 678, 679, 683, 739, 698, 707, 708, 709, - 716, 723, 725, 726, 727, 728, 729, 730, 731, 732, - 736, 116, 737, 740, 741, 757, 762, 179, 766, 769, - 770, 776, 777, 778, 779, 775, 780, 787, 788, 789, - 794, 795, 796, 797, 804, 805, 806, 807, 808, 809, - 535, 300, 744, 639, 517, 617, 798, 52, 190, 735, - 276, 532, 173, 119, 652, 653, 0, 0, 30, 29, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 78 -}; - -static const yytype_int16 yycheck[] = -{ - 60, 153, 114, 357, 411, 157, 158, 159, 91, 1, - 409, 190, 411, 409, 186, 411, 409, 409, 411, 411, - 363, 1, 3, 12, 240, 565, 1, 473, 217, 218, - 579, 210, 211, 212, 213, 214, 148, 3, 0, 151, - 152, 4, 154, 155, 156, 3, 225, 186, 73, 3, - 409, 3, 411, 312, 313, 3, 208, 1, 1, 403, - 3, 3, 3, 4, 407, 14, 282, 3, 6, 106, - 3, 758, 759, 93, 11, 112, 28, 26, 3, 68, - 1, 106, 631, 3, 47, 106, 4, 482, 51, 149, - 4, 203, 106, 205, 206, 207, 268, 209, 314, 315, - 316, 317, 3, 643, 644, 1, 285, 286, 191, 1, - 797, 454, 3, 3, 106, 510, 511, 229, 230, 3, - 232, 233, 301, 302, 478, 106, 106, 299, 82, 268, - 389, 106, 80, 349, 350, 351, 352, 197, 80, 4, - 4, 107, 254, 255, 80, 504, 505, 80, 106, 493, - 494, 495, 496, 107, 108, 109, 108, 109, 76, 107, - 108, 109, 106, 275, 276, 277, 107, 108, 109, 106, - 359, 107, 108, 109, 107, 108, 109, 576, 577, 3, - 576, 577, 107, 108, 109, 106, 581, 582, 583, 584, - 585, 92, 106, 552, 640, 641, 1, 556, 557, 543, - 544, 545, 561, 4, 28, 548, 107, 108, 109, 655, - 106, 4, 607, 608, 106, 106, 106, 576, 577, 4, - 760, 761, 106, 335, 336, 59, 485, 92, 92, 108, - 109, 570, 491, 492, 4, 4, 4, 640, 641, 108, - 109, 106, 106, 355, 356, 4, 64, 3, 4, 83, - 84, 403, 659, 73, 3, 73, 655, 601, 9, 655, - 659, 108, 109, 659, 15, 16, 659, 659, 7, 89, - 1, 91, 4, 78, 79, 1, 455, 3, 673, 674, - 675, 676, 677, 106, 108, 109, 732, 626, 106, 3, - 373, 92, 110, 3, 406, 407, 655, 357, 4, 92, - 659, 480, 4, 4, 96, 106, 98, 92, 100, 106, - 393, 710, 106, 106, 710, 106, 711, 712, 713, 714, - 715, 106, 92, 3, 92, 720, 721, 3, 59, 732, - 1, 62, 3, 92, 4, 66, 106, 449, 106, 3, - 48, 493, 494, 495, 496, 4, 48, 106, 56, 57, - 58, 710, 83, 84, 1, 48, 3, 59, 60, 61, - 62, 63, 64, 56, 57, 58, 59, 4, 428, 429, - 1, 73, 3, 4, 3, 4, 771, 772, 773, 774, - 4, 735, 534, 562, 3, 4, 88, 89, 90, 91, - 542, 543, 544, 545, 506, 790, 791, 792, 793, 3, - 4, 552, 4, 48, 106, 556, 557, 75, 76, 1, - 561, 45, 57, 4, 59, 475, 4, 62, 478, 1, - 4, 3, 4, 712, 713, 714, 715, 643, 644, 645, - 646, 647, 59, 3, 4, 62, 548, 64, 65, 522, - 656, 657, 3, 4, 660, 597, 73, 3, 4, 601, - 95, 96, 97, 98, 99, 100, 101, 102, 103, 571, - 572, 573, 3, 4, 56, 57, 112, 59, 580, 648, - 62, 3, 4, 65, 66, 13, 106, 107, 4, 106, - 3, 4, 771, 772, 773, 774, 3, 4, 4, 705, - 4, 83, 84, 85, 86, 87, 1, 35, 4, 4, - 5, 790, 791, 792, 793, 3, 4, 3, 724, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 4, 70, 71, 72, 3, 74, 48, 69, 77, - 43, 56, 57, 4, 59, 3, 57, 763, 59, 323, - 324, 62, 326, 327, 328, 329, 330, 736, 73, 711, - 712, 713, 714, 715, 3, 4, 649, 59, 60, 61, - 62, 63, 64, 3, 89, 3, 91, 3, 4, 3, - 82, 73, 3, 762, 95, 96, 97, 98, 99, 100, - 101, 102, 103, 3, 4, 3, 88, 89, 90, 91, - 683, 106, 104, 4, 106, 107, 92, 719, 4, 111, - 112, 113, 114, 106, 106, 4, 3, 4, 4, 771, - 772, 773, 774, 106, 107, 3, 4, 4, 111, 112, - 113, 114, 4, 5, 67, 695, 696, 4, 790, 791, - 792, 793, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 59, 287, 106, 62, 112, 64, - 65, 59, 4, 733, 4, 735, 64, 4, 73, 226, - 227, 57, 3, 59, 3, 73, 62, 4, 83, 84, - 85, 86, 87, 4, 64, 83, 84, 85, 86, 87, - 4, 323, 324, 73, 326, 327, 328, 329, 330, 467, - 468, 106, 10, 83, 84, 85, 86, 87, 106, 95, - 96, 97, 98, 99, 100, 101, 102, 103, 64, 9, - 10, 4, 4, 13, 106, 4, 106, 73, 36, 37, - 38, 39, 40, 4, 622, 623, 4, 83, 84, 85, - 86, 87, 4, 4, 4, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 36, 37, 38, 39, 40, - 106, 4, 3, 55, 4, 106, 107, 4, 49, 50, - 111, 112, 113, 114, 106, 107, 46, 46, 112, 111, - 112, 113, 114, 46, 4, 8, 106, 8, 4, 4, - 4, 4, 4, 3, 3, 94, 107, 51, 51, 51, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 108, 108, 4, 3, 3, 3, 3, 3, 92, 3, - 3, 108, 4, 4, 4, 4, 4, 4, 3, 3, - 81, 4, 3, 106, 4, 4, 4, 4, 3, 3, - 106, 4, 92, 92, 4, 4, 4, 4, 4, 4, - 3, 81, 4, 81, 4, 4, 3, 3, 3, 114, - 4, 4, 4, 4, 4, 4, 3, 58, 4, 4, - 4, 4, 4, 4, 3, 80, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 3, 84, 4, 4, 4, 4, 3, 108, 4, 4, - 4, 4, 4, 4, 4, 81, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 484, 266, 710, 577, 469, 563, 789, 26, 113, 696, - 230, 481, 104, 87, 597, 601, -1, -1, 21, 20, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 41 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = -{ - 0, 3, 28, 108, 109, 117, 118, 227, 240, 241, - 242, 243, 244, 11, 106, 108, 109, 0, 3, 240, - 6, 93, 3, 120, 106, 139, 145, 240, 240, 244, - 242, 12, 68, 1, 3, 119, 123, 125, 206, 207, - 208, 210, 211, 212, 214, 215, 216, 217, 218, 225, - 226, 4, 139, 7, 106, 1, 106, 9, 10, 13, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 213, 4, 119, 119, 119, 119, 119, 3, 211, 119, - 119, 4, 4, 106, 121, 124, 106, 122, 1, 126, - 1, 3, 197, 1, 106, 1, 106, 1, 106, 1, - 106, 106, 138, 140, 146, 1, 3, 127, 128, 1, - 132, 141, 150, 3, 204, 3, 124, 4, 3, 207, - 4, 4, 5, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 106, 224, 4, 57, 59, - 62, 95, 96, 97, 98, 99, 100, 101, 102, 103, - 201, 4, 4, 45, 223, 4, 223, 4, 223, 4, - 223, 4, 112, 140, 4, 1, 106, 129, 4, 127, - 4, 3, 4, 133, 4, 106, 112, 148, 73, 106, - 130, 3, 198, 203, 69, 4, 198, 196, 197, 198, - 198, 108, 109, 187, 198, 198, 198, 187, 187, 187, - 3, 3, 3, 3, 3, 3, 106, 147, 149, 4, - 92, 136, 137, 1, 106, 135, 147, 149, 136, 59, - 60, 61, 63, 64, 73, 88, 89, 90, 91, 130, - 190, 201, 202, 4, 106, 4, 4, 197, 4, 4, - 198, 4, 198, 198, 198, 187, 198, 136, 136, 136, - 136, 136, 67, 138, 138, 106, 143, 4, 112, 4, - 136, 141, 141, 4, 198, 200, 200, 198, 198, 142, - 3, 107, 185, 187, 188, 3, 3, 4, 4, 4, - 4, 198, 198, 4, 4, 4, 4, 4, 4, 151, - 137, 147, 149, 4, 4, 198, 4, 198, 4, 4, - 92, 145, 106, 107, 111, 112, 113, 114, 122, 185, - 136, 136, 3, 125, 209, 228, 229, 230, 232, 233, - 234, 4, 4, 197, 46, 46, 46, 55, 4, 149, - 136, 136, 112, 134, 4, 106, 144, 142, 142, 185, - 185, 185, 185, 8, 4, 4, 4, 35, 70, 71, - 72, 74, 77, 231, 228, 228, 4, 228, 228, 228, - 228, 228, 4, 3, 191, 195, 198, 198, 198, 3, - 174, 94, 4, 4, 185, 4, 185, 185, 185, 107, - 198, 198, 1, 3, 192, 197, 152, 138, 75, 76, - 1, 78, 79, 235, 191, 4, 48, 59, 201, 51, - 51, 51, 56, 57, 59, 73, 89, 91, 175, 219, - 4, 4, 4, 4, 142, 4, 4, 4, 48, 59, - 201, 4, 3, 4, 153, 180, 181, 205, 4, 108, - 108, 4, 3, 82, 107, 187, 189, 236, 4, 106, - 198, 4, 191, 198, 199, 3, 3, 155, 159, 178, - 179, 182, 183, 203, 3, 170, 155, 3, 3, 177, - 92, 4, 47, 51, 4, 106, 197, 192, 194, 197, - 3, 64, 73, 106, 110, 131, 4, 76, 4, 82, - 104, 106, 107, 111, 112, 113, 114, 237, 4, 198, - 4, 4, 191, 136, 59, 64, 65, 201, 4, 59, - 83, 84, 4, 4, 175, 175, 4, 174, 81, 3, - 220, 222, 3, 160, 162, 184, 197, 4, 4, 192, - 136, 3, 205, 3, 188, 152, 142, 108, 4, 106, - 142, 142, 236, 236, 236, 236, 4, 4, 4, 1, - 3, 154, 156, 157, 178, 179, 182, 183, 184, 3, - 203, 198, 3, 171, 188, 188, 92, 92, 176, 185, - 48, 56, 57, 58, 59, 1, 56, 57, 59, 65, - 66, 83, 84, 85, 86, 87, 201, 4, 4, 4, - 187, 4, 4, 4, 4, 4, 4, 236, 238, 236, - 236, 236, 239, 191, 198, 4, 59, 83, 84, 4, - 154, 154, 154, 4, 154, 136, 4, 170, 3, 80, - 186, 186, 81, 81, 4, 3, 106, 222, 198, 198, - 198, 221, 4, 3, 166, 167, 169, 178, 179, 166, - 161, 220, 198, 188, 188, 188, 188, 188, 3, 3, - 193, 4, 238, 239, 4, 158, 188, 188, 4, 4, - 114, 4, 4, 176, 176, 222, 4, 4, 4, 4, - 4, 220, 59, 83, 84, 85, 86, 87, 4, 4, - 4, 160, 160, 3, 163, 164, 3, 185, 186, 185, - 186, 185, 185, 185, 136, 48, 59, 201, 4, 3, - 4, 178, 179, 184, 155, 80, 185, 4, 4, 4, - 168, 188, 188, 188, 188, 188, 4, 1, 59, 66, - 83, 84, 201, 4, 114, 4, 4, 4, 4, 4, - 4, 4, 4, 106, 197, 194, 3, 4, 185, 80, - 4, 4, 3, 4, 169, 178, 179, 3, 92, 172, - 173, 187, 188, 172, 172, 172, 172, 4, 165, 198, - 188, 188, 3, 185, 160, 197, 4, 4, 136, 4, - 4, 111, 112, 113, 114, 81, 4, 4, 4, 4, - 4, 4, 164, 164, 186, 186, 136, 4, 4, 4, - 172, 172, 172, 172, 4, 4, 4, 4, 193, 172, - 172, 172, 172, 164, 4, 4, 4, 4, 4, 4 -}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ - -#define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) - - -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) -#else -# define YYLEX yylex () -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - if (!yyvaluep) - return; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); -# endif - switch (yytype) - { - default: - break; - } -} - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) -#else -static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule) -#else -static void -yy_reduce_print (yyvsp, yyrule) - YYSTYPE *yyvsp; - int yyrule; -#endif -{ - int yynrhs = yyr2[yyrule]; - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - YYFPRINTF (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, Rule); \ -} while (YYID (0)) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static YYSIZE_T -yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static char * -yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) -{ - int yyn = yypact[yystate]; - - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; - } -} -#endif /* YYERROR_VERBOSE */ - - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - YYUSE (yyvaluep); - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - - default: - break; - } -} - -/* Prevent warnings from -Wmissing-prototypes. */ -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - - -/*-------------------------. -| yyparse or yypush_parse. | -`-------------------------*/ - -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void) -#else -int -yyparse () - -#endif -#endif -{ - - - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - YYSIZE_T yystacksize; - - int yyn; - int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; - yystacksize = YYINITDEPTH; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - yyssp = yyss; - yyvsp = yyvs; - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - if (yystate == YYFINAL) - YYACCEPT; - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - - yystate = yyn; - *++yyvsp = yylval; - - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: - -/* Line 1464 of yacc.c */ -#line 260 "src/Parser/pddl+.yacc" - {top_thing= (yyvsp[(1) - (1)].t_domain); current_analysis->the_domain= (yyvsp[(1) - (1)].t_domain);;} - break; - - case 3: - -/* Line 1464 of yacc.c */ -#line 261 "src/Parser/pddl+.yacc" - {top_thing= (yyvsp[(1) - (1)].t_problem); current_analysis->the_problem= (yyvsp[(1) - (1)].t_problem);;} - break; - - case 4: - -/* Line 1464 of yacc.c */ -#line 262 "src/Parser/pddl+.yacc" - {top_thing= (yyvsp[(1) - (1)].t_plan); ;} - break; - - case 5: - -/* Line 1464 of yacc.c */ -#line 267 "src/Parser/pddl+.yacc" - {(yyval.t_domain)= (yyvsp[(4) - (5)].t_domain); (yyval.t_domain)->name= (yyvsp[(3) - (5)].cp);delete [] (yyvsp[(3) - (5)].cp); - if (types_used && !types_defined) { - yyerrok; log_error(E_FATAL,"Syntax error in domain - no :types section, but types used in definitions."); - } - ;} - break; - - case 6: - -/* Line 1464 of yacc.c */ -#line 273 "src/Parser/pddl+.yacc" - {yyerrok; (yyval.t_domain)=static_cast(NULL); - log_error(E_FATAL,"Syntax error in domain"); ;} - break; - - case 7: - -/* Line 1464 of yacc.c */ -#line 279 "src/Parser/pddl+.yacc" - {(yyval.t_domain)= (yyvsp[(2) - (2)].t_domain); (yyval.t_domain)->req= (yyvsp[(1) - (2)].t_pddl_req_flag);;} - break; - - case 8: - -/* Line 1464 of yacc.c */ -#line 280 "src/Parser/pddl+.yacc" - {types_defined = true; (yyval.t_domain)= (yyvsp[(2) - (2)].t_domain); (yyval.t_domain)->types= (yyvsp[(1) - (2)].t_type_list);;} - break; - - case 9: - -/* Line 1464 of yacc.c */ -#line 281 "src/Parser/pddl+.yacc" - {(yyval.t_domain)= (yyvsp[(2) - (2)].t_domain); (yyval.t_domain)->constants= (yyvsp[(1) - (2)].t_const_symbol_list);;} - break; - - case 10: - -/* Line 1464 of yacc.c */ -#line 282 "src/Parser/pddl+.yacc" - {(yyval.t_domain)= (yyvsp[(2) - (2)].t_domain); - (yyval.t_domain)->predicates= (yyvsp[(1) - (2)].t_pred_decl_list); ;} - break; - - case 11: - -/* Line 1464 of yacc.c */ -#line 284 "src/Parser/pddl+.yacc" - {(yyval.t_domain)= (yyvsp[(2) - (2)].t_domain); - (yyval.t_domain)->functions= (yyvsp[(1) - (2)].t_func_decl_list); ;} - break; - - case 12: - -/* Line 1464 of yacc.c */ -#line 286 "src/Parser/pddl+.yacc" - {(yyval.t_domain)= (yyvsp[(2) - (2)].t_domain); - (yyval.t_domain)->constraints = (yyvsp[(1) - (2)].t_con_goal);;} - break; - - case 13: - -/* Line 1464 of yacc.c */ -#line 288 "src/Parser/pddl+.yacc" - {(yyval.t_domain) = (yyvsp[(2) - (2)].t_domain);;} - break; - - case 14: - -/* Line 1464 of yacc.c */ -#line 289 "src/Parser/pddl+.yacc" - {(yyval.t_domain)= new domain((yyvsp[(1) - (1)].t_structure_store)); ;} - break; - - case 15: - -/* Line 1464 of yacc.c */ -#line 292 "src/Parser/pddl+.yacc" - {(yyval.cp)=(yyvsp[(3) - (4)].cp);;} - break; - - case 16: - -/* Line 1464 of yacc.c */ -#line 296 "src/Parser/pddl+.yacc" - { (yyval.t_class)=current_analysis->classes_tab.new_symbol_put((yyvsp[(1) - (1)].cp)); - delete [] (yyvsp[(1) - (1)].cp); ;} - break; - - case 17: - -/* Line 1464 of yacc.c */ -#line 299 "src/Parser/pddl+.yacc" - { (yyval.t_class) = current_analysis->classes_tab.symbol_get((yyvsp[(1) - (1)].cp)); delete [] (yyvsp[(1) - (1)].cp);;} - break; - - case 18: - -/* Line 1464 of yacc.c */ -#line 301 "src/Parser/pddl+.yacc" - {(yyval.t_dummy) = 0;;} - break; - - case 19: - -/* Line 1464 of yacc.c */ -#line 303 "src/Parser/pddl+.yacc" - {(yyval.t_dummy) = 0;;} - break; - - case 20: - -/* Line 1464 of yacc.c */ -#line 304 "src/Parser/pddl+.yacc" - {(yyval.t_dummy) = 0;;} - break; - - case 21: - -/* Line 1464 of yacc.c */ -#line 309 "src/Parser/pddl+.yacc" - { - // Stash in analysis object --- we need to refer to it during parse - // but domain object is not created yet, - current_analysis->req |= (yyvsp[(3) - (4)].t_pddl_req_flag); - (yyval.t_pddl_req_flag)=(yyvsp[(3) - (4)].t_pddl_req_flag); - ;} - break; - - case 22: - -/* Line 1464 of yacc.c */ -#line 316 "src/Parser/pddl+.yacc" - {yyerrok; - log_error(E_FATAL,"Syntax error in requirements declaration."); - (yyval.t_pddl_req_flag)= 0; ;} - break; - - case 23: - -/* Line 1464 of yacc.c */ -#line 322 "src/Parser/pddl+.yacc" - { (yyval.t_pddl_req_flag)= (yyvsp[(1) - (2)].t_pddl_req_flag) | (yyvsp[(2) - (2)].t_pddl_req_flag); ;} - break; - - case 24: - -/* Line 1464 of yacc.c */ -#line 323 "src/Parser/pddl+.yacc" - { (yyval.t_pddl_req_flag)= 0; ;} - break; - - case 25: - -/* Line 1464 of yacc.c */ -#line 329 "src/Parser/pddl+.yacc" - {(yyval.t_pred_decl_list)=(yyvsp[(2) - (2)].t_pred_decl_list); (yyval.t_pred_decl_list)->push_front((yyvsp[(1) - (2)].t_pred_decl));;} - break; - - case 26: - -/* Line 1464 of yacc.c */ -#line 331 "src/Parser/pddl+.yacc" - { (yyval.t_pred_decl_list)=new pred_decl_list; - (yyval.t_pred_decl_list)->push_front((yyvsp[(1) - (1)].t_pred_decl)); ;} - break; - - case 27: - -/* Line 1464 of yacc.c */ -#line 336 "src/Parser/pddl+.yacc" - {(yyval.t_pred_decl)= new pred_decl((yyvsp[(2) - (4)].t_pred_symbol),(yyvsp[(3) - (4)].t_var_symbol_list),current_analysis->var_tab_stack.pop());;} - break; - - case 28: - -/* Line 1464 of yacc.c */ -#line 338 "src/Parser/pddl+.yacc" - {yyerrok; - // hope someone makes this error someday - log_error(E_FATAL,"Syntax error in predicate declaration."); - (yyval.t_pred_decl)= static_cast(NULL); ;} - break; - - case 29: - -/* Line 1464 of yacc.c */ -#line 346 "src/Parser/pddl+.yacc" - { (yyval.t_pred_symbol)=current_analysis->pred_tab.new_symbol_put((yyvsp[(1) - (1)].cp)); - current_analysis->var_tab_stack.push( - current_analysis->buildPredTab()); - delete [] (yyvsp[(1) - (1)].cp); ;} - break; - - case 30: - -/* Line 1464 of yacc.c */ -#line 353 "src/Parser/pddl+.yacc" - { (yyval.t_pred_symbol)=current_analysis->pred_tab.symbol_ref("="); - requires(E_EQUALITY); ;} - break; - - case 31: - -/* Line 1464 of yacc.c */ -#line 355 "src/Parser/pddl+.yacc" - { (yyval.t_pred_symbol)=current_analysis->pred_tab.symbol_get((yyvsp[(1) - (1)].cp)); delete [] (yyvsp[(1) - (1)].cp); ;} - break; - - case 32: - -/* Line 1464 of yacc.c */ -#line 363 "src/Parser/pddl+.yacc" - { (yyval.t_pred_symbol)=current_analysis->pred_tab.symbol_get((yyvsp[(1) - (1)].cp)); delete [] (yyvsp[(1) - (1)].cp);;} - break; - - case 33: - -/* Line 1464 of yacc.c */ -#line 369 "src/Parser/pddl+.yacc" - {(yyval.t_func_decl_list)=(yyvsp[(1) - (2)].t_func_decl_list); (yyval.t_func_decl_list)->push_back((yyvsp[(2) - (2)].t_func_decl));;} - break; - - case 34: - -/* Line 1464 of yacc.c */ -#line 370 "src/Parser/pddl+.yacc" - { (yyval.t_func_decl_list)=new func_decl_list; ;} - break; - - case 35: - -/* Line 1464 of yacc.c */ -#line 375 "src/Parser/pddl+.yacc" - {(yyval.t_func_decl)= new func_decl((yyvsp[(2) - (5)].t_func_symbol),(yyvsp[(3) - (5)].t_var_symbol_list),current_analysis->var_tab_stack.pop());;} - break; - - case 36: - -/* Line 1464 of yacc.c */ -#line 377 "src/Parser/pddl+.yacc" - {yyerrok; - log_error(E_FATAL,"Syntax error in functor declaration."); - (yyval.t_func_decl)= (int) NULL; ;} - break; - - case 37: - -/* Line 1464 of yacc.c */ -#line 383 "src/Parser/pddl+.yacc" - {(yyval.t_dummy) = (int) NULL;;} - break; - - case 38: - -/* Line 1464 of yacc.c */ -#line 383 "src/Parser/pddl+.yacc" - {(yyval.t_dummy)= (int) NULL;;} - break; - - case 39: - -/* Line 1464 of yacc.c */ -#line 387 "src/Parser/pddl+.yacc" - { (yyval.t_func_symbol)=current_analysis->func_tab.new_symbol_put((yyvsp[(1) - (1)].cp)); - current_analysis->var_tab_stack.push( - current_analysis->buildFuncTab()); - delete [] (yyvsp[(1) - (1)].cp); ;} - break; - - case 40: - -/* Line 1464 of yacc.c */ -#line 400 "src/Parser/pddl+.yacc" - { - (yyval.t_var_symbol_list)= (yyvsp[(1) - (4)].t_var_symbol_list); - (yyval.t_var_symbol_list)->set_types((yyvsp[(3) - (4)].t_type)); /* Set types for variables */ - (yyval.t_var_symbol_list)->splice((yyval.t_var_symbol_list)->end(),*(yyvsp[(4) - (4)].t_var_symbol_list)); /* Join lists */ - delete (yyvsp[(4) - (4)].t_var_symbol_list); /* Delete (now empty) list */ - requires(E_TYPING); - types_used = true; - ;} - break; - - case 41: - -/* Line 1464 of yacc.c */ -#line 409 "src/Parser/pddl+.yacc" - { - (yyval.t_var_symbol_list)= (yyvsp[(1) - (4)].t_var_symbol_list); - (yyval.t_var_symbol_list)->set_either_types((yyvsp[(3) - (4)].t_type_list)); /* Set types for variables */ - (yyval.t_var_symbol_list)->splice((yyval.t_var_symbol_list)->end(),*(yyvsp[(4) - (4)].t_var_symbol_list)); /* Join lists */ - delete (yyvsp[(4) - (4)].t_var_symbol_list); /* Delete (now empty) list */ - requires(E_TYPING); - types_used = true; - ;} - break; - - case 42: - -/* Line 1464 of yacc.c */ -#line 418 "src/Parser/pddl+.yacc" - { - (yyval.t_var_symbol_list)= (yyvsp[(1) - (1)].t_var_symbol_list); - ;} - break; - - case 43: - -/* Line 1464 of yacc.c */ -#line 430 "src/Parser/pddl+.yacc" - {(yyval.t_var_symbol_list)=(yyvsp[(3) - (3)].t_var_symbol_list); (yyvsp[(3) - (3)].t_var_symbol_list)->push_front((yyvsp[(2) - (3)].t_var_symbol)); ;} - break; - - case 44: - -/* Line 1464 of yacc.c */ -#line 431 "src/Parser/pddl+.yacc" - {(yyval.t_var_symbol_list)= new var_symbol_list; ;} - break; - - case 45: - -/* Line 1464 of yacc.c */ -#line 438 "src/Parser/pddl+.yacc" - { - (yyval.t_const_symbol_list)= (yyvsp[(1) - (4)].t_const_symbol_list); - (yyvsp[(1) - (4)].t_const_symbol_list)->set_types((yyvsp[(3) - (4)].t_type)); /* Set types for constants */ - (yyvsp[(1) - (4)].t_const_symbol_list)->splice((yyvsp[(1) - (4)].t_const_symbol_list)->end(),*(yyvsp[(4) - (4)].t_const_symbol_list)); /* Join lists */ - delete (yyvsp[(4) - (4)].t_const_symbol_list); /* Delete (now empty) list */ - requires(E_TYPING); - types_used = true; - ;} - break; - - case 46: - -/* Line 1464 of yacc.c */ -#line 447 "src/Parser/pddl+.yacc" - { - (yyval.t_const_symbol_list)= (yyvsp[(1) - (4)].t_const_symbol_list); - (yyvsp[(1) - (4)].t_const_symbol_list)->set_either_types((yyvsp[(3) - (4)].t_type_list)); - (yyvsp[(1) - (4)].t_const_symbol_list)->splice((yyvsp[(1) - (4)].t_const_symbol_list)->end(),*(yyvsp[(4) - (4)].t_const_symbol_list)); - delete (yyvsp[(4) - (4)].t_const_symbol_list); - requires(E_TYPING); - types_used = true; - ;} - break; - - case 47: - -/* Line 1464 of yacc.c */ -#line 456 "src/Parser/pddl+.yacc" - {(yyval.t_const_symbol_list)= (yyvsp[(1) - (1)].t_const_symbol_list);;} - break; - - case 48: - -/* Line 1464 of yacc.c */ -#line 461 "src/Parser/pddl+.yacc" - {(yyval.t_const_symbol_list)=(yyvsp[(2) - (2)].t_const_symbol_list); (yyvsp[(2) - (2)].t_const_symbol_list)->push_front((yyvsp[(1) - (2)].t_const_symbol));;} - break; - - case 49: - -/* Line 1464 of yacc.c */ -#line 462 "src/Parser/pddl+.yacc" - {(yyval.t_const_symbol_list)=new const_symbol_list;;} - break; - - case 50: - -/* Line 1464 of yacc.c */ -#line 466 "src/Parser/pddl+.yacc" - {(yyval.t_const_symbol_list)=(yyvsp[(2) - (2)].t_const_symbol_list); (yyvsp[(2) - (2)].t_const_symbol_list)->push_front((yyvsp[(1) - (2)].t_const_symbol));;} - break; - - case 51: - -/* Line 1464 of yacc.c */ -#line 467 "src/Parser/pddl+.yacc" - {(yyval.t_const_symbol_list)=new const_symbol_list;;} - break; - - case 52: - -/* Line 1464 of yacc.c */ -#line 476 "src/Parser/pddl+.yacc" - { - (yyval.t_type_list)= (yyvsp[(1) - (4)].t_type_list); - (yyval.t_type_list)->set_types((yyvsp[(3) - (4)].t_type)); /* Set types for constants */ - (yyval.t_type_list)->splice((yyval.t_type_list)->end(),*(yyvsp[(4) - (4)].t_type_list)); /* Join lists */ - delete (yyvsp[(4) - (4)].t_type_list); /* Delete (now empty) list */ - ;} - break; - - case 53: - -/* Line 1464 of yacc.c */ -#line 483 "src/Parser/pddl+.yacc" - { - // This parse needs to be excluded, we think (DPL&MF: 6/9/01) - (yyval.t_type_list)= (yyvsp[(1) - (4)].t_type_list); - (yyval.t_type_list)->set_either_types((yyvsp[(3) - (4)].t_type_list)); - (yyval.t_type_list)->splice((yyvsp[(1) - (4)].t_type_list)->end(),*(yyvsp[(4) - (4)].t_type_list)); - delete (yyvsp[(4) - (4)].t_type_list); - ;} - break; - - case 54: - -/* Line 1464 of yacc.c */ -#line 492 "src/Parser/pddl+.yacc" - { (yyval.t_type_list)= (yyvsp[(1) - (1)].t_type_list); ;} - break; - - case 55: - -/* Line 1464 of yacc.c */ -#line 498 "src/Parser/pddl+.yacc" - {(yyval.t_parameter_symbol_list)=(yyvsp[(1) - (2)].t_parameter_symbol_list); (yyval.t_parameter_symbol_list)->push_back((yyvsp[(2) - (2)].t_const_symbol)); ;} - break; - - case 56: - -/* Line 1464 of yacc.c */ -#line 500 "src/Parser/pddl+.yacc" - {(yyval.t_parameter_symbol_list)=(yyvsp[(1) - (3)].t_parameter_symbol_list); (yyval.t_parameter_symbol_list)->push_back((yyvsp[(3) - (3)].t_var_symbol)); ;} - break; - - case 57: - -/* Line 1464 of yacc.c */ -#line 501 "src/Parser/pddl+.yacc" - {(yyval.t_parameter_symbol_list)= new parameter_symbol_list;;} - break; - - case 58: - -/* Line 1464 of yacc.c */ -#line 508 "src/Parser/pddl+.yacc" - { (yyval.t_var_symbol)= current_analysis->var_tab_stack.top()->symbol_put((yyvsp[(1) - (1)].cp)); delete [] (yyvsp[(1) - (1)].cp); ;} - break; - - case 59: - -/* Line 1464 of yacc.c */ -#line 514 "src/Parser/pddl+.yacc" - { (yyval.t_var_symbol)= current_analysis->var_tab_stack.symbol_get((yyvsp[(1) - (1)].cp)); delete [] (yyvsp[(1) - (1)].cp); ;} - break; - - case 60: - -/* Line 1464 of yacc.c */ -#line 518 "src/Parser/pddl+.yacc" - { (yyval.t_const_symbol)= current_analysis->const_tab.symbol_get((yyvsp[(1) - (1)].cp)); delete [] (yyvsp[(1) - (1)].cp); ;} - break; - - case 61: - -/* Line 1464 of yacc.c */ -#line 522 "src/Parser/pddl+.yacc" - { (yyval.t_const_symbol)= current_analysis->const_tab.new_symbol_put((yyvsp[(1) - (1)].cp)); delete [] (yyvsp[(1) - (1)].cp);;} - break; - - case 62: - -/* Line 1464 of yacc.c */ -#line 527 "src/Parser/pddl+.yacc" - { (yyval.t_type_list)= (yyvsp[(3) - (4)].t_type_list); ;} - break; - - case 63: - -/* Line 1464 of yacc.c */ -#line 532 "src/Parser/pddl+.yacc" - { (yyval.t_type)= current_analysis->pddl_type_tab.symbol_ref((yyvsp[(1) - (1)].cp)); delete [] (yyvsp[(1) - (1)].cp);;} - break; - - case 64: - -/* Line 1464 of yacc.c */ -#line 539 "src/Parser/pddl+.yacc" - { (yyval.t_type)= current_analysis->pddl_type_tab.symbol_ref((yyvsp[(1) - (1)].cp)); delete [] (yyvsp[(1) - (1)].cp);;} - break; - - case 65: - -/* Line 1464 of yacc.c */ -#line 544 "src/Parser/pddl+.yacc" - {(yyval.t_type_list)= (yyvsp[(1) - (2)].t_type_list); (yyval.t_type_list)->push_back((yyvsp[(2) - (2)].t_type));;} - break; - - case 66: - -/* Line 1464 of yacc.c */ -#line 545 "src/Parser/pddl+.yacc" - {(yyval.t_type_list)= new pddl_type_list;;} - break; - - case 67: - -/* Line 1464 of yacc.c */ -#line 550 "src/Parser/pddl+.yacc" - {(yyval.t_type_list)= (yyvsp[(1) - (2)].t_type_list); (yyval.t_type_list)->push_back((yyvsp[(2) - (2)].t_type));;} - break; - - case 68: - -/* Line 1464 of yacc.c */ -#line 551 "src/Parser/pddl+.yacc" - {(yyval.t_type_list)= new pddl_type_list;;} - break; - - case 69: - -/* Line 1464 of yacc.c */ -#line 556 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)=(yyvsp[(1) - (6)].t_effect_lists); - (yyval.t_effect_lists)->assign_effects.push_back(new assignment((yyvsp[(4) - (6)].t_func_term),E_ASSIGN,(yyvsp[(5) - (6)].t_num_expression))); - if((yyvsp[(4) - (6)].t_func_term)->getFunction()->getName()=="total-cost") - { - requires(E_ACTIONCOSTS); - // Should also check that $5 is 0... - } - else - { - requires(E_NFLUENTS); - } - ;} - break; - - case 70: - -/* Line 1464 of yacc.c */ -#line 569 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)=(yyvsp[(1) - (2)].t_effect_lists); (yyval.t_effect_lists)->add_effects.push_back((yyvsp[(2) - (2)].t_simple_effect)); ;} - break; - - case 71: - -/* Line 1464 of yacc.c */ -#line 571 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)=(yyvsp[(1) - (2)].t_effect_lists); (yyval.t_effect_lists)->del_effects.push_back((yyvsp[(2) - (2)].t_simple_effect)); ;} - break; - - case 72: - -/* Line 1464 of yacc.c */ -#line 573 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)=(yyvsp[(1) - (2)].t_effect_lists); (yyval.t_effect_lists)->timed_effects.push_back((yyvsp[(2) - (2)].t_timed_effect)); ;} - break; - - case 73: - -/* Line 1464 of yacc.c */ -#line 575 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)= new effect_lists;;} - break; - - case 74: - -/* Line 1464 of yacc.c */ -#line 580 "src/Parser/pddl+.yacc" - { requires(E_TIMED_INITIAL_LITERALS); - (yyval.t_timed_effect)=new timed_initial_literal((yyvsp[(3) - (4)].t_effect_lists),(yyvsp[(2) - (4)].fval));;} - break; - - case 75: - -/* Line 1464 of yacc.c */ -#line 585 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=(yyvsp[(2) - (2)].t_effect_lists); (yyval.t_effect_lists)->append_effects((yyvsp[(1) - (2)].t_effect_lists)); delete (yyvsp[(1) - (2)].t_effect_lists);;} - break; - - case 76: - -/* Line 1464 of yacc.c */ -#line 586 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=(yyvsp[(2) - (2)].t_effect_lists); (yyval.t_effect_lists)->cond_effects.push_front((yyvsp[(1) - (2)].t_cond_effect)); - requires(E_COND_EFFS);;} - break; - - case 77: - -/* Line 1464 of yacc.c */ -#line 588 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=(yyvsp[(2) - (2)].t_effect_lists); (yyval.t_effect_lists)->forall_effects.push_front((yyvsp[(1) - (2)].t_forall_effect)); - requires(E_COND_EFFS);;} - break; - - case 78: - -/* Line 1464 of yacc.c */ -#line 590 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=new effect_lists(); ;} - break; - - case 79: - -/* Line 1464 of yacc.c */ -#line 599 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)= (yyvsp[(1) - (1)].t_effect_lists);;} - break; - - case 80: - -/* Line 1464 of yacc.c */ -#line 600 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=new effect_lists; (yyval.t_effect_lists)->add_effects.push_front((yyvsp[(1) - (1)].t_simple_effect));;} - break; - - case 81: - -/* Line 1464 of yacc.c */ -#line 601 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=new effect_lists; (yyval.t_effect_lists)->del_effects.push_front((yyvsp[(1) - (1)].t_simple_effect));;} - break; - - case 82: - -/* Line 1464 of yacc.c */ -#line 602 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=new effect_lists; (yyval.t_effect_lists)->cond_effects.push_front((yyvsp[(1) - (1)].t_cond_effect));;} - break; - - case 83: - -/* Line 1464 of yacc.c */ -#line 603 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=new effect_lists; (yyval.t_effect_lists)->forall_effects.push_front((yyvsp[(1) - (1)].t_forall_effect));;} - break; - - case 84: - -/* Line 1464 of yacc.c */ -#line 607 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)= (yyvsp[(3) - (4)].t_effect_lists);;} - break; - - case 85: - -/* Line 1464 of yacc.c */ -#line 608 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)= (yyvsp[(1) - (1)].t_effect_lists);;} - break; - - case 86: - -/* Line 1464 of yacc.c */ -#line 613 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=new effect_lists; (yyval.t_effect_lists)->del_effects.push_front((yyvsp[(1) - (1)].t_simple_effect));;} - break; - - case 87: - -/* Line 1464 of yacc.c */ -#line 615 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=new effect_lists; (yyval.t_effect_lists)->add_effects.push_front((yyvsp[(1) - (1)].t_simple_effect));;} - break; - - case 88: - -/* Line 1464 of yacc.c */ -#line 617 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=new effect_lists; (yyval.t_effect_lists)->assign_effects.push_front((yyvsp[(1) - (1)].t_assignment)); - requires(E_NFLUENTS);;} - break; - - case 89: - -/* Line 1464 of yacc.c */ -#line 623 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)= (yyvsp[(1) - (2)].t_effect_lists); (yyval.t_effect_lists)->del_effects.push_back((yyvsp[(2) - (2)].t_simple_effect));;} - break; - - case 90: - -/* Line 1464 of yacc.c */ -#line 624 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)= (yyvsp[(1) - (2)].t_effect_lists); (yyval.t_effect_lists)->add_effects.push_back((yyvsp[(2) - (2)].t_simple_effect));;} - break; - - case 91: - -/* Line 1464 of yacc.c */ -#line 625 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)= (yyvsp[(1) - (2)].t_effect_lists); (yyval.t_effect_lists)->assign_effects.push_back((yyvsp[(2) - (2)].t_assignment)); - requires(E_NFLUENTS); ;} - break; - - case 92: - -/* Line 1464 of yacc.c */ -#line 627 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)= new effect_lists; ;} - break; - - case 93: - -/* Line 1464 of yacc.c */ -#line 632 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)=(yyvsp[(3) - (4)].t_effect_lists); ;} - break; - - case 94: - -/* Line 1464 of yacc.c */ -#line 634 "src/Parser/pddl+.yacc" - {yyerrok; (yyval.t_effect_lists)=NULL; - log_error(E_FATAL,"Syntax error in (and ...)"); - ;} - break; - - case 95: - -/* Line 1464 of yacc.c */ -#line 642 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)=(yyvsp[(3) - (4)].t_effect_lists); ;} - break; - - case 96: - -/* Line 1464 of yacc.c */ -#line 647 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)= new effect_lists; - (yyval.t_effect_lists)->forall_effects.push_back( - new forall_effect((yyvsp[(6) - (7)].t_effect_lists), (yyvsp[(4) - (7)].t_var_symbol_list), current_analysis->var_tab_stack.pop())); - requires(E_COND_EFFS);;} - break; - - case 97: - -/* Line 1464 of yacc.c */ -#line 652 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)= new effect_lists; - (yyval.t_effect_lists)->cond_effects.push_back( - new cond_effect((yyvsp[(3) - (5)].t_goal),(yyvsp[(4) - (5)].t_effect_lists))); - requires(E_COND_EFFS); ;} - break; - - case 98: - -/* Line 1464 of yacc.c */ -#line 657 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)= new effect_lists; - (yyval.t_effect_lists)->cond_assign_effects.push_back( - new cond_effect((yyvsp[(3) - (5)].t_goal),(yyvsp[(4) - (5)].t_effect_lists))); - requires(E_COND_EFFS); ;} - break; - - case 99: - -/* Line 1464 of yacc.c */ -#line 662 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)=new effect_lists; - (yyval.t_effect_lists)->timed_effects.push_back((yyvsp[(1) - (1)].t_timed_effect)); ;} - break; - - case 100: - -/* Line 1464 of yacc.c */ -#line 665 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)= new effect_lists; - (yyval.t_effect_lists)->assign_effects.push_front((yyvsp[(1) - (1)].t_assignment)); - requires(E_NFLUENTS); ;} - break; - - case 101: - -/* Line 1464 of yacc.c */ -#line 671 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)=(yyvsp[(1) - (2)].t_effect_lists); (yyvsp[(1) - (2)].t_effect_lists)->append_effects((yyvsp[(2) - (2)].t_effect_lists)); delete (yyvsp[(2) - (2)].t_effect_lists); ;} - break; - - case 102: - -/* Line 1464 of yacc.c */ -#line 672 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)= new effect_lists; ;} - break; - - case 103: - -/* Line 1464 of yacc.c */ -#line 677 "src/Parser/pddl+.yacc" - {(yyval.t_timed_effect)=new timed_effect((yyvsp[(3) - (4)].t_effect_lists),E_AT_START);;} - break; - - case 104: - -/* Line 1464 of yacc.c */ -#line 679 "src/Parser/pddl+.yacc" - {(yyval.t_timed_effect)=new timed_effect((yyvsp[(3) - (4)].t_effect_lists),E_AT_END);;} - break; - - case 105: - -/* Line 1464 of yacc.c */ -#line 681 "src/Parser/pddl+.yacc" - {(yyval.t_timed_effect)=new timed_effect(new effect_lists,E_CONTINUOUS); - (yyval.t_timed_effect)->effs->assign_effects.push_front( - new assignment((yyvsp[(3) - (5)].t_func_term),E_INCREASE,(yyvsp[(4) - (5)].t_expression))); ;} - break; - - case 106: - -/* Line 1464 of yacc.c */ -#line 685 "src/Parser/pddl+.yacc" - {(yyval.t_timed_effect)=new timed_effect(new effect_lists,E_CONTINUOUS); - (yyval.t_timed_effect)->effs->assign_effects.push_front( - new assignment((yyvsp[(3) - (5)].t_func_term),E_DECREASE,(yyvsp[(4) - (5)].t_expression))); ;} - break; - - case 107: - -/* Line 1464 of yacc.c */ -#line 689 "src/Parser/pddl+.yacc" - {yyerrok; (yyval.t_timed_effect)=NULL; - log_error(E_FATAL,"Syntax error in timed effect"); ;} - break; - - case 108: - -/* Line 1464 of yacc.c */ -#line 695 "src/Parser/pddl+.yacc" - {(yyval.t_timed_effect)=new timed_effect(new effect_lists,E_CONTINUOUS); - (yyval.t_timed_effect)->effs->assign_effects.push_front( - new assignment((yyvsp[(3) - (5)].t_func_term),E_INCREASE,(yyvsp[(4) - (5)].t_expression))); ;} - break; - - case 109: - -/* Line 1464 of yacc.c */ -#line 699 "src/Parser/pddl+.yacc" - {(yyval.t_timed_effect)=new timed_effect(new effect_lists,E_CONTINUOUS); - (yyval.t_timed_effect)->effs->assign_effects.push_front( - new assignment((yyvsp[(3) - (5)].t_func_term),E_DECREASE,(yyvsp[(4) - (5)].t_expression))); ;} - break; - - case 110: - -/* Line 1464 of yacc.c */ -#line 703 "src/Parser/pddl+.yacc" - {yyerrok; (yyval.t_timed_effect)=NULL; - log_error(E_FATAL,"Syntax error in conditional continuous effect"); ;} - break; - - case 111: - -/* Line 1464 of yacc.c */ -#line 709 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)=(yyvsp[(3) - (4)].t_effect_lists); ;} - break; - - case 112: - -/* Line 1464 of yacc.c */ -#line 714 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)= new effect_lists; - (yyval.t_effect_lists)->forall_effects.push_back( - new forall_effect((yyvsp[(6) - (7)].t_effect_lists), (yyvsp[(4) - (7)].t_var_symbol_list), current_analysis->var_tab_stack.pop())); - requires(E_COND_EFFS);;} - break; - - case 113: - -/* Line 1464 of yacc.c */ -#line 719 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)= new effect_lists; - (yyval.t_effect_lists)->cond_assign_effects.push_back( - new cond_effect((yyvsp[(3) - (5)].t_goal),(yyvsp[(4) - (5)].t_effect_lists))); - requires(E_COND_EFFS); ;} - break; - - case 114: - -/* Line 1464 of yacc.c */ -#line 724 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)=new effect_lists; - (yyval.t_effect_lists)->timed_effects.push_back((yyvsp[(1) - (1)].t_timed_effect)); ;} - break; - - case 115: - -/* Line 1464 of yacc.c */ -#line 729 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)=(yyvsp[(1) - (2)].t_effect_lists); (yyvsp[(1) - (2)].t_effect_lists)->append_effects((yyvsp[(2) - (2)].t_effect_lists)); delete (yyvsp[(2) - (2)].t_effect_lists); ;} - break; - - case 116: - -/* Line 1464 of yacc.c */ -#line 730 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)= new effect_lists; ;} - break; - - case 117: - -/* Line 1464 of yacc.c */ -#line 734 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)= (yyvsp[(3) - (4)].t_effect_lists);;} - break; - - case 118: - -/* Line 1464 of yacc.c */ -#line 735 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)= (yyvsp[(1) - (1)].t_effect_lists);;} - break; - - case 119: - -/* Line 1464 of yacc.c */ -#line 740 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=new effect_lists; (yyval.t_effect_lists)->del_effects.push_front((yyvsp[(1) - (1)].t_simple_effect));;} - break; - - case 120: - -/* Line 1464 of yacc.c */ -#line 742 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=new effect_lists; (yyval.t_effect_lists)->add_effects.push_front((yyvsp[(1) - (1)].t_simple_effect));;} - break; - - case 121: - -/* Line 1464 of yacc.c */ -#line 744 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=new effect_lists; (yyval.t_effect_lists)->assign_effects.push_front((yyvsp[(1) - (1)].t_assignment)); - requires(E_NFLUENTS);;} - break; - - case 122: - -/* Line 1464 of yacc.c */ -#line 750 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)= (yyvsp[(1) - (2)].t_effect_lists); (yyval.t_effect_lists)->del_effects.push_back((yyvsp[(2) - (2)].t_simple_effect));;} - break; - - case 123: - -/* Line 1464 of yacc.c */ -#line 751 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)= (yyvsp[(1) - (2)].t_effect_lists); (yyval.t_effect_lists)->add_effects.push_back((yyvsp[(2) - (2)].t_simple_effect));;} - break; - - case 124: - -/* Line 1464 of yacc.c */ -#line 752 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)= (yyvsp[(1) - (2)].t_effect_lists); (yyval.t_effect_lists)->assign_effects.push_back((yyvsp[(2) - (2)].t_assignment)); - requires(E_NFLUENTS); ;} - break; - - case 125: - -/* Line 1464 of yacc.c */ -#line 754 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)= new effect_lists; ;} - break; - - case 126: - -/* Line 1464 of yacc.c */ -#line 760 "src/Parser/pddl+.yacc" - { (yyval.t_assignment)= new assignment((yyvsp[(3) - (5)].t_func_term),E_ASSIGN,(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 127: - -/* Line 1464 of yacc.c */ -#line 762 "src/Parser/pddl+.yacc" - { (yyval.t_assignment)= new assignment((yyvsp[(3) - (5)].t_func_term),E_INCREASE,(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 128: - -/* Line 1464 of yacc.c */ -#line 764 "src/Parser/pddl+.yacc" - { (yyval.t_assignment)= new assignment((yyvsp[(3) - (5)].t_func_term),E_DECREASE,(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 129: - -/* Line 1464 of yacc.c */ -#line 766 "src/Parser/pddl+.yacc" - { (yyval.t_assignment)= new assignment((yyvsp[(3) - (5)].t_func_term),E_SCALE_UP,(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 130: - -/* Line 1464 of yacc.c */ -#line 768 "src/Parser/pddl+.yacc" - { (yyval.t_assignment)= new assignment((yyvsp[(3) - (5)].t_func_term),E_SCALE_DOWN,(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 131: - -/* Line 1464 of yacc.c */ -#line 773 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=new effect_lists; - timed_effect * te = new timed_effect(new effect_lists,E_CONTINUOUS); - (yyval.t_effect_lists)->timed_effects.push_front(te); - te->effs->assign_effects.push_front( - new assignment((yyvsp[(3) - (5)].t_func_term),E_INCREASE,(yyvsp[(4) - (5)].t_expression))); ;} - break; - - case 132: - -/* Line 1464 of yacc.c */ -#line 779 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=new effect_lists; - timed_effect * te = new timed_effect(new effect_lists,E_CONTINUOUS); - (yyval.t_effect_lists)->timed_effects.push_front(te); - te->effs->assign_effects.push_front( - new assignment((yyvsp[(3) - (5)].t_func_term),E_DECREASE,(yyvsp[(4) - (5)].t_expression))); ;} - break; - - case 133: - -/* Line 1464 of yacc.c */ -#line 785 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists) = (yyvsp[(3) - (4)].t_effect_lists);;} - break; - - case 134: - -/* Line 1464 of yacc.c */ -#line 789 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)=(yyvsp[(1) - (2)].t_effect_lists); (yyvsp[(1) - (2)].t_effect_lists)->append_effects((yyvsp[(2) - (2)].t_effect_lists)); delete (yyvsp[(2) - (2)].t_effect_lists); ;} - break; - - case 135: - -/* Line 1464 of yacc.c */ -#line 790 "src/Parser/pddl+.yacc" - { (yyval.t_effect_lists)= new effect_lists; ;} - break; - - case 136: - -/* Line 1464 of yacc.c */ -#line 794 "src/Parser/pddl+.yacc" - {(yyval.t_expression)= (yyvsp[(1) - (1)].t_expression);;} - break; - - case 137: - -/* Line 1464 of yacc.c */ -#line 795 "src/Parser/pddl+.yacc" - {(yyval.t_expression)= new special_val_expr(E_DURATION_VAR); - requires( E_DURATION_INEQUALITIES );;} - break; - - case 138: - -/* Line 1464 of yacc.c */ -#line 797 "src/Parser/pddl+.yacc" - { (yyval.t_expression)=(yyvsp[(1) - (1)].t_num_expression); ;} - break; - - case 139: - -/* Line 1464 of yacc.c */ -#line 798 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= (yyvsp[(1) - (1)].t_func_term); ;} - break; - - case 140: - -/* Line 1464 of yacc.c */ -#line 803 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new plus_expression((yyvsp[(3) - (5)].t_expression),(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 141: - -/* Line 1464 of yacc.c */ -#line 805 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new minus_expression((yyvsp[(3) - (5)].t_expression),(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 142: - -/* Line 1464 of yacc.c */ -#line 807 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new mul_expression((yyvsp[(3) - (5)].t_expression),(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 143: - -/* Line 1464 of yacc.c */ -#line 809 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new div_expression((yyvsp[(3) - (5)].t_expression),(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 144: - -/* Line 1464 of yacc.c */ -#line 814 "src/Parser/pddl+.yacc" - { (yyval.t_goal)= new conj_goal((yyvsp[(3) - (4)].t_goal_list)); ;} - break; - - case 145: - -/* Line 1464 of yacc.c */ -#line 816 "src/Parser/pddl+.yacc" - { (yyval.t_goal)= new timed_goal(new comparison((yyvsp[(2) - (6)].t_comparison_op), - new special_val_expr(E_DURATION_VAR),(yyvsp[(5) - (6)].t_expression)),E_AT_START); ;} - break; - - case 146: - -/* Line 1464 of yacc.c */ -#line 819 "src/Parser/pddl+.yacc" - { (yyval.t_goal) = new timed_goal(new comparison((yyvsp[(4) - (9)].t_comparison_op), - new special_val_expr(E_DURATION_VAR),(yyvsp[(7) - (9)].t_expression)),E_AT_START);;} - break; - - case 147: - -/* Line 1464 of yacc.c */ -#line 822 "src/Parser/pddl+.yacc" - { (yyval.t_goal) = new timed_goal(new comparison((yyvsp[(4) - (9)].t_comparison_op), - new special_val_expr(E_DURATION_VAR),(yyvsp[(7) - (9)].t_expression)),E_AT_END);;} - break; - - case 148: - -/* Line 1464 of yacc.c */ -#line 827 "src/Parser/pddl+.yacc" - {(yyval.t_comparison_op)= E_LESSEQ; requires(E_DURATION_INEQUALITIES);;} - break; - - case 149: - -/* Line 1464 of yacc.c */ -#line 828 "src/Parser/pddl+.yacc" - {(yyval.t_comparison_op)= E_GREATEQ; requires(E_DURATION_INEQUALITIES);;} - break; - - case 150: - -/* Line 1464 of yacc.c */ -#line 829 "src/Parser/pddl+.yacc" - {(yyval.t_comparison_op)= E_EQUALS; ;} - break; - - case 151: - -/* Line 1464 of yacc.c */ -#line 837 "src/Parser/pddl+.yacc" - {(yyval.t_expression)= (yyvsp[(1) - (1)].t_expression); ;} - break; - - case 152: - -/* Line 1464 of yacc.c */ -#line 842 "src/Parser/pddl+.yacc" - { (yyval.t_goal_list)=(yyvsp[(1) - (2)].t_goal_list); (yyval.t_goal_list)->push_back((yyvsp[(2) - (2)].t_goal)); ;} - break; - - case 153: - -/* Line 1464 of yacc.c */ -#line 844 "src/Parser/pddl+.yacc" - { (yyval.t_goal_list)= new goal_list; ;} - break; - - case 154: - -/* Line 1464 of yacc.c */ -#line 849 "src/Parser/pddl+.yacc" - { (yyval.t_simple_effect)= new simple_effect((yyvsp[(3) - (4)].t_proposition)); ;} - break; - - case 155: - -/* Line 1464 of yacc.c */ -#line 854 "src/Parser/pddl+.yacc" - { (yyval.t_simple_effect)= new simple_effect((yyvsp[(1) - (1)].t_proposition)); ;} - break; - - case 156: - -/* Line 1464 of yacc.c */ -#line 861 "src/Parser/pddl+.yacc" - { (yyval.t_simple_effect)= new simple_effect((yyvsp[(3) - (4)].t_proposition)); ;} - break; - - case 157: - -/* Line 1464 of yacc.c */ -#line 866 "src/Parser/pddl+.yacc" - { (yyval.t_simple_effect)= new simple_effect((yyvsp[(1) - (1)].t_proposition)); ;} - break; - - case 158: - -/* Line 1464 of yacc.c */ -#line 871 "src/Parser/pddl+.yacc" - { (yyval.t_forall_effect)= new forall_effect((yyvsp[(6) - (7)].t_effect_lists), (yyvsp[(4) - (7)].t_var_symbol_list), current_analysis->var_tab_stack.pop());;} - break; - - case 159: - -/* Line 1464 of yacc.c */ -#line 876 "src/Parser/pddl+.yacc" - { (yyval.t_cond_effect)= new cond_effect((yyvsp[(3) - (5)].t_goal),(yyvsp[(4) - (5)].t_effect_lists)); ;} - break; - - case 160: - -/* Line 1464 of yacc.c */ -#line 881 "src/Parser/pddl+.yacc" - { (yyval.t_assignment)= new assignment((yyvsp[(3) - (5)].t_func_term),E_ASSIGN,(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 161: - -/* Line 1464 of yacc.c */ -#line 883 "src/Parser/pddl+.yacc" - { (yyval.t_assignment)= new assignment((yyvsp[(3) - (5)].t_func_term),E_INCREASE,(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 162: - -/* Line 1464 of yacc.c */ -#line 885 "src/Parser/pddl+.yacc" - { (yyval.t_assignment)= new assignment((yyvsp[(3) - (5)].t_func_term),E_DECREASE,(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 163: - -/* Line 1464 of yacc.c */ -#line 887 "src/Parser/pddl+.yacc" - { (yyval.t_assignment)= new assignment((yyvsp[(3) - (5)].t_func_term),E_SCALE_UP,(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 164: - -/* Line 1464 of yacc.c */ -#line 889 "src/Parser/pddl+.yacc" - { (yyval.t_assignment)= new assignment((yyvsp[(3) - (5)].t_func_term),E_SCALE_DOWN,(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 165: - -/* Line 1464 of yacc.c */ -#line 894 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new uminus_expression((yyvsp[(3) - (4)].t_expression)); requires(E_NFLUENTS); ;} - break; - - case 166: - -/* Line 1464 of yacc.c */ -#line 896 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new plus_expression((yyvsp[(3) - (5)].t_expression),(yyvsp[(4) - (5)].t_expression)); requires(E_NFLUENTS); ;} - break; - - case 167: - -/* Line 1464 of yacc.c */ -#line 898 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new minus_expression((yyvsp[(3) - (5)].t_expression),(yyvsp[(4) - (5)].t_expression)); requires(E_NFLUENTS); ;} - break; - - case 168: - -/* Line 1464 of yacc.c */ -#line 900 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new mul_expression((yyvsp[(3) - (5)].t_expression),(yyvsp[(4) - (5)].t_expression)); requires(E_NFLUENTS); ;} - break; - - case 169: - -/* Line 1464 of yacc.c */ -#line 902 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new div_expression((yyvsp[(3) - (5)].t_expression),(yyvsp[(4) - (5)].t_expression)); requires(E_NFLUENTS); ;} - break; - - case 170: - -/* Line 1464 of yacc.c */ -#line 903 "src/Parser/pddl+.yacc" - { (yyval.t_expression)=(yyvsp[(1) - (1)].t_num_expression); ;} - break; - - case 171: - -/* Line 1464 of yacc.c */ -#line 904 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= (yyvsp[(1) - (1)].t_func_term); requires(E_NFLUENTS); ;} - break; - - case 172: - -/* Line 1464 of yacc.c */ -#line 909 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new mul_expression(new special_val_expr(E_HASHT),(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 173: - -/* Line 1464 of yacc.c */ -#line 911 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new mul_expression((yyvsp[(3) - (5)].t_expression), new special_val_expr(E_HASHT)); ;} - break; - - case 174: - -/* Line 1464 of yacc.c */ -#line 913 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new special_val_expr(E_HASHT); ;} - break; - - case 175: - -/* Line 1464 of yacc.c */ -#line 918 "src/Parser/pddl+.yacc" - { (yyval.t_num_expression)=new int_expression((yyvsp[(1) - (1)].ival)); ;} - break; - - case 176: - -/* Line 1464 of yacc.c */ -#line 919 "src/Parser/pddl+.yacc" - { (yyval.t_num_expression)=new float_expression((yyvsp[(1) - (1)].fval)); ;} - break; - - case 177: - -/* Line 1464 of yacc.c */ -#line 923 "src/Parser/pddl+.yacc" - { (yyval.t_func_term)=new func_term( current_analysis->func_tab.symbol_get((yyvsp[(2) - (4)].cp)), (yyvsp[(3) - (4)].t_parameter_symbol_list)); delete [] (yyvsp[(2) - (4)].cp); ;} - break; - - case 178: - -/* Line 1464 of yacc.c */ -#line 926 "src/Parser/pddl+.yacc" - { (yyval.t_func_term)=new func_term( current_analysis->func_tab.symbol_get((yyvsp[(2) - (4)].cp)), (yyvsp[(3) - (4)].t_parameter_symbol_list)); delete [] (yyvsp[(2) - (4)].cp); ;} - break; - - case 179: - -/* Line 1464 of yacc.c */ -#line 928 "src/Parser/pddl+.yacc" - { (yyval.t_func_term)=new func_term( current_analysis->func_tab.symbol_get((yyvsp[(1) - (1)].cp)), - new parameter_symbol_list); delete [] (yyvsp[(1) - (1)].cp);;} - break; - - case 180: - -/* Line 1464 of yacc.c */ -#line 931 "src/Parser/pddl+.yacc" - { (yyval.t_func_term) = new class_func_term( (yyvsp[(2) - (6)].t_class), current_analysis->func_tab.symbol_get((yyvsp[(4) - (6)].cp)), (yyvsp[(5) - (6)].t_parameter_symbol_list)); delete [] (yyvsp[(4) - (6)].cp);;} - break; - - case 181: - -/* Line 1464 of yacc.c */ -#line 948 "src/Parser/pddl+.yacc" - { (yyval.t_func_term)=new func_term( current_analysis->func_tab.symbol_get((yyvsp[(2) - (4)].cp)), (yyvsp[(3) - (4)].t_parameter_symbol_list)); delete [] (yyvsp[(2) - (4)].cp); ;} - break; - - case 182: - -/* Line 1464 of yacc.c */ -#line 950 "src/Parser/pddl+.yacc" - { (yyval.t_func_term)=new func_term( current_analysis->func_tab.symbol_get((yyvsp[(2) - (4)].cp)), (yyvsp[(3) - (4)].t_parameter_symbol_list)); delete [] (yyvsp[(2) - (4)].cp); ;} - break; - - case 183: - -/* Line 1464 of yacc.c */ -#line 952 "src/Parser/pddl+.yacc" - { (yyval.t_func_term)=new func_term( current_analysis->func_tab.symbol_get((yyvsp[(1) - (1)].cp)), - new parameter_symbol_list); delete [] (yyvsp[(1) - (1)].cp);;} - break; - - case 184: - -/* Line 1464 of yacc.c */ -#line 957 "src/Parser/pddl+.yacc" - { (yyval.t_comparison_op)= E_GREATER; ;} - break; - - case 185: - -/* Line 1464 of yacc.c */ -#line 958 "src/Parser/pddl+.yacc" - { (yyval.t_comparison_op)= E_GREATEQ; ;} - break; - - case 186: - -/* Line 1464 of yacc.c */ -#line 959 "src/Parser/pddl+.yacc" - { (yyval.t_comparison_op)= E_LESS; ;} - break; - - case 187: - -/* Line 1464 of yacc.c */ -#line 960 "src/Parser/pddl+.yacc" - { (yyval.t_comparison_op)= E_LESSEQ; ;} - break; - - case 188: - -/* Line 1464 of yacc.c */ -#line 961 "src/Parser/pddl+.yacc" - { (yyval.t_comparison_op)= E_EQUALS; ;} - break; - - case 189: - -/* Line 1464 of yacc.c */ -#line 974 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= (yyvsp[(1) - (1)].t_goal);;} - break; - - case 190: - -/* Line 1464 of yacc.c */ -#line 981 "src/Parser/pddl+.yacc" - {(yyval.t_goal) = new conj_goal((yyvsp[(3) - (4)].t_goal_list));;} - break; - - case 191: - -/* Line 1464 of yacc.c */ -#line 984 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new qfied_goal(E_FORALL,(yyvsp[(4) - (7)].t_var_symbol_list),(yyvsp[(6) - (7)].t_goal),current_analysis->var_tab_stack.pop()); - requires(E_UNIV_PRECS);;} - break; - - case 192: - -/* Line 1464 of yacc.c */ -#line 986 "src/Parser/pddl+.yacc" - {(yyval.t_goal) = new conj_goal(new goal_list);;} - break; - - case 193: - -/* Line 1464 of yacc.c */ -#line 987 "src/Parser/pddl+.yacc" - {(yyval.t_goal) = new conj_goal(new goal_list);;} - break; - - case 194: - -/* Line 1464 of yacc.c */ -#line 992 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new preference((yyvsp[(3) - (4)].t_con_goal));requires(E_PREFERENCES);;} - break; - - case 195: - -/* Line 1464 of yacc.c */ -#line 994 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new preference((yyvsp[(3) - (5)].cp),(yyvsp[(4) - (5)].t_con_goal));requires(E_PREFERENCES);;} - break; - - case 196: - -/* Line 1464 of yacc.c */ -#line 996 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new conj_goal((yyvsp[(3) - (4)].t_goal_list));;} - break; - - case 197: - -/* Line 1464 of yacc.c */ -#line 999 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal)= new qfied_goal(E_FORALL,(yyvsp[(4) - (7)].t_var_symbol_list),(yyvsp[(6) - (7)].t_con_goal),current_analysis->var_tab_stack.pop()); - requires(E_UNIV_PRECS);;} - break; - - case 198: - -/* Line 1464 of yacc.c */ -#line 1002 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = (yyvsp[(1) - (1)].t_con_goal);;} - break; - - case 199: - -/* Line 1464 of yacc.c */ -#line 1007 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new preference((yyvsp[(3) - (4)].t_con_goal));requires(E_PREFERENCES);;} - break; - - case 200: - -/* Line 1464 of yacc.c */ -#line 1009 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new preference((yyvsp[(3) - (5)].cp),(yyvsp[(4) - (5)].t_con_goal));requires(E_PREFERENCES);;} - break; - - case 201: - -/* Line 1464 of yacc.c */ -#line 1011 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new conj_goal((yyvsp[(3) - (4)].t_goal_list));;} - break; - - case 202: - -/* Line 1464 of yacc.c */ -#line 1014 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal)= new qfied_goal(E_FORALL,(yyvsp[(4) - (7)].t_var_symbol_list),(yyvsp[(6) - (7)].t_con_goal),current_analysis->var_tab_stack.pop()); - requires(E_UNIV_PRECS);;} - break; - - case 203: - -/* Line 1464 of yacc.c */ -#line 1020 "src/Parser/pddl+.yacc" - {(yyval.t_goal_list)=(yyvsp[(1) - (2)].t_goal_list); (yyvsp[(1) - (2)].t_goal_list)->push_back((yyvsp[(2) - (2)].t_con_goal));;} - break; - - case 204: - -/* Line 1464 of yacc.c */ -#line 1022 "src/Parser/pddl+.yacc" - {(yyval.t_goal_list)= new goal_list; (yyval.t_goal_list)->push_back((yyvsp[(1) - (1)].t_con_goal));;} - break; - - case 205: - -/* Line 1464 of yacc.c */ -#line 1027 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new preference((yyvsp[(3) - (4)].t_goal)); requires(E_PREFERENCES);;} - break; - - case 206: - -/* Line 1464 of yacc.c */ -#line 1029 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new preference((yyvsp[(3) - (5)].cp),(yyvsp[(4) - (5)].t_goal)); requires(E_PREFERENCES);;} - break; - - case 207: - -/* Line 1464 of yacc.c */ -#line 1033 "src/Parser/pddl+.yacc" - {(yyval.t_goal)=(yyvsp[(1) - (1)].t_goal);;} - break; - - case 208: - -/* Line 1464 of yacc.c */ -#line 1038 "src/Parser/pddl+.yacc" - {(yyval.t_goal_list) = (yyvsp[(1) - (2)].t_goal_list); (yyval.t_goal_list)->push_back((yyvsp[(2) - (2)].t_con_goal));;} - break; - - case 209: - -/* Line 1464 of yacc.c */ -#line 1040 "src/Parser/pddl+.yacc" - {(yyval.t_goal_list) = new goal_list; (yyval.t_goal_list)->push_back((yyvsp[(1) - (1)].t_con_goal));;} - break; - - case 210: - -/* Line 1464 of yacc.c */ -#line 1045 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal)= new conj_goal((yyvsp[(3) - (4)].t_goal_list));;} - break; - - case 211: - -/* Line 1464 of yacc.c */ -#line 1047 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new qfied_goal(E_FORALL,(yyvsp[(4) - (7)].t_var_symbol_list),(yyvsp[(6) - (7)].t_con_goal),current_analysis->var_tab_stack.pop()); - requires(E_UNIV_PRECS);;} - break; - - case 212: - -/* Line 1464 of yacc.c */ -#line 1050 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new constraint_goal(E_ATEND,(yyvsp[(3) - (4)].t_goal));;} - break; - - case 213: - -/* Line 1464 of yacc.c */ -#line 1052 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new constraint_goal(E_ALWAYS,(yyvsp[(3) - (4)].t_goal));;} - break; - - case 214: - -/* Line 1464 of yacc.c */ -#line 1054 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new constraint_goal(E_SOMETIME,(yyvsp[(3) - (4)].t_goal));;} - break; - - case 215: - -/* Line 1464 of yacc.c */ -#line 1056 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new constraint_goal(E_WITHIN,(yyvsp[(4) - (5)].t_goal),NULL,(yyvsp[(3) - (5)].t_num_expression)->double_value(),0.0);delete (yyvsp[(3) - (5)].t_num_expression);;} - break; - - case 216: - -/* Line 1464 of yacc.c */ -#line 1058 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new constraint_goal(E_ATMOSTONCE,(yyvsp[(3) - (4)].t_goal));;} - break; - - case 217: - -/* Line 1464 of yacc.c */ -#line 1060 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new constraint_goal(E_SOMETIMEAFTER,(yyvsp[(4) - (5)].t_goal),(yyvsp[(3) - (5)].t_goal));;} - break; - - case 218: - -/* Line 1464 of yacc.c */ -#line 1062 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new constraint_goal(E_SOMETIMEBEFORE,(yyvsp[(4) - (5)].t_goal),(yyvsp[(3) - (5)].t_goal));;} - break; - - case 219: - -/* Line 1464 of yacc.c */ -#line 1064 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new constraint_goal(E_ALWAYSWITHIN,(yyvsp[(5) - (6)].t_goal),(yyvsp[(4) - (6)].t_goal),(yyvsp[(3) - (6)].t_num_expression)->double_value(),0.0);delete (yyvsp[(3) - (6)].t_num_expression);;} - break; - - case 220: - -/* Line 1464 of yacc.c */ -#line 1066 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new constraint_goal(E_HOLDDURING,(yyvsp[(5) - (6)].t_goal),NULL,(yyvsp[(4) - (6)].t_num_expression)->double_value(),(yyvsp[(3) - (6)].t_num_expression)->double_value());delete (yyvsp[(3) - (6)].t_num_expression);delete (yyvsp[(4) - (6)].t_num_expression);;} - break; - - case 221: - -/* Line 1464 of yacc.c */ -#line 1068 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = new constraint_goal(E_HOLDAFTER,(yyvsp[(4) - (5)].t_goal),NULL,0.0,(yyvsp[(3) - (5)].t_num_expression)->double_value());delete (yyvsp[(3) - (5)].t_num_expression);;} - break; - - case 222: - -/* Line 1464 of yacc.c */ -#line 1073 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new simple_goal((yyvsp[(1) - (1)].t_proposition),E_POS);;} - break; - - case 223: - -/* Line 1464 of yacc.c */ -#line 1075 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new neg_goal((yyvsp[(3) - (4)].t_goal));simple_goal * s = dynamic_cast((yyvsp[(3) - (4)].t_goal)); - if(s && s->getProp()->head->getName()=="=") {requires(E_EQUALITY);} - else{requires(E_NEGATIVE_PRECONDITIONS);};;} - break; - - case 224: - -/* Line 1464 of yacc.c */ -#line 1079 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new conj_goal((yyvsp[(3) - (4)].t_goal_list));;} - break; - - case 225: - -/* Line 1464 of yacc.c */ -#line 1081 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new disj_goal((yyvsp[(3) - (4)].t_goal_list)); - requires(E_DISJUNCTIVE_PRECONDS);;} - break; - - case 226: - -/* Line 1464 of yacc.c */ -#line 1084 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new imply_goal((yyvsp[(3) - (5)].t_goal),(yyvsp[(4) - (5)].t_goal)); - requires(E_DISJUNCTIVE_PRECONDS);;} - break; - - case 227: - -/* Line 1464 of yacc.c */ -#line 1088 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new qfied_goal((yyvsp[(2) - (7)].t_quantifier),(yyvsp[(4) - (7)].t_var_symbol_list),(yyvsp[(6) - (7)].t_goal),current_analysis->var_tab_stack.pop());;} - break; - - case 228: - -/* Line 1464 of yacc.c */ -#line 1091 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new qfied_goal((yyvsp[(2) - (7)].t_quantifier),(yyvsp[(4) - (7)].t_var_symbol_list),(yyvsp[(6) - (7)].t_goal),current_analysis->var_tab_stack.pop());;} - break; - - case 229: - -/* Line 1464 of yacc.c */ -#line 1093 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new comparison((yyvsp[(2) - (5)].t_comparison_op),(yyvsp[(3) - (5)].t_expression),(yyvsp[(4) - (5)].t_expression)); - requires(E_NFLUENTS);;} - break; - - case 230: - -/* Line 1464 of yacc.c */ -#line 1099 "src/Parser/pddl+.yacc" - {(yyval.t_goal_list)=(yyvsp[(1) - (2)].t_goal_list); (yyvsp[(1) - (2)].t_goal_list)->push_back((yyvsp[(2) - (2)].t_goal));;} - break; - - case 231: - -/* Line 1464 of yacc.c */ -#line 1101 "src/Parser/pddl+.yacc" - {(yyval.t_goal_list)= new goal_list; (yyval.t_goal_list)->push_back((yyvsp[(1) - (1)].t_goal));;} - break; - - case 232: - -/* Line 1464 of yacc.c */ -#line 1106 "src/Parser/pddl+.yacc" - {(yyval.t_goal_list)=(yyvsp[(1) - (2)].t_goal_list); (yyvsp[(1) - (2)].t_goal_list)->push_back((yyvsp[(2) - (2)].t_goal));;} - break; - - case 233: - -/* Line 1464 of yacc.c */ -#line 1108 "src/Parser/pddl+.yacc" - {(yyval.t_goal_list)= new goal_list; (yyval.t_goal_list)->push_back((yyvsp[(1) - (1)].t_goal));;} - break; - - case 234: - -/* Line 1464 of yacc.c */ -#line 1118 "src/Parser/pddl+.yacc" - {(yyval.t_quantifier)=E_FORALL; - current_analysis->var_tab_stack.push( - current_analysis->buildForallTab());;} - break; - - case 235: - -/* Line 1464 of yacc.c */ -#line 1125 "src/Parser/pddl+.yacc" - {(yyval.t_quantifier)=E_EXISTS; - current_analysis->var_tab_stack.push( - current_analysis->buildExistsTab());;} - break; - - case 236: - -/* Line 1464 of yacc.c */ -#line 1132 "src/Parser/pddl+.yacc" - {(yyval.t_proposition)=new proposition((yyvsp[(2) - (4)].t_pred_symbol),(yyvsp[(3) - (4)].t_parameter_symbol_list));;} - break; - - case 237: - -/* Line 1464 of yacc.c */ -#line 1137 "src/Parser/pddl+.yacc" - {(yyval.t_proposition) = new proposition((yyvsp[(2) - (4)].t_pred_symbol),(yyvsp[(3) - (4)].t_var_symbol_list));;} - break; - - case 238: - -/* Line 1464 of yacc.c */ -#line 1142 "src/Parser/pddl+.yacc" - {(yyval.t_proposition)=new proposition((yyvsp[(2) - (4)].t_pred_symbol),(yyvsp[(3) - (4)].t_parameter_symbol_list));;} - break; - - case 239: - -/* Line 1464 of yacc.c */ -#line 1147 "src/Parser/pddl+.yacc" - {(yyval.t_pred_decl_list)= (yyvsp[(3) - (4)].t_pred_decl_list);;} - break; - - case 240: - -/* Line 1464 of yacc.c */ -#line 1149 "src/Parser/pddl+.yacc" - {yyerrok; (yyval.t_pred_decl_list)=NULL; - log_error(E_FATAL,"Syntax error in (:predicates ...)"); - ;} - break; - - case 241: - -/* Line 1464 of yacc.c */ -#line 1156 "src/Parser/pddl+.yacc" - {(yyval.t_func_decl_list)= (yyvsp[(3) - (4)].t_func_decl_list);;} - break; - - case 242: - -/* Line 1464 of yacc.c */ -#line 1158 "src/Parser/pddl+.yacc" - {yyerrok; (yyval.t_func_decl_list)=NULL; - log_error(E_FATAL,"Syntax error in (:functions ...)"); - ;} - break; - - case 243: - -/* Line 1464 of yacc.c */ -#line 1165 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = (yyvsp[(3) - (4)].t_con_goal);;} - break; - - case 244: - -/* Line 1464 of yacc.c */ -#line 1167 "src/Parser/pddl+.yacc" - {yyerrok; (yyval.t_con_goal)=NULL; - log_error(E_FATAL,"Syntax error in (:constraints ...)"); - ;} - break; - - case 245: - -/* Line 1464 of yacc.c */ -#line 1174 "src/Parser/pddl+.yacc" - {(yyval.t_con_goal) = (yyvsp[(3) - (4)].t_con_goal);;} - break; - - case 246: - -/* Line 1464 of yacc.c */ -#line 1176 "src/Parser/pddl+.yacc" - {yyerrok; (yyval.t_con_goal)=NULL; - log_error(E_FATAL,"Syntax error in (:constraints ...)"); - ;} - break; - - case 247: - -/* Line 1464 of yacc.c */ -#line 1182 "src/Parser/pddl+.yacc" - { (yyval.t_structure_store)=(yyvsp[(1) - (2)].t_structure_store); (yyval.t_structure_store)->push_back((yyvsp[(2) - (2)].t_structure_def)); ;} - break; - - case 248: - -/* Line 1464 of yacc.c */ -#line 1183 "src/Parser/pddl+.yacc" - { (yyval.t_structure_store)= new structure_store; (yyval.t_structure_store)->push_back((yyvsp[(1) - (1)].t_structure_def)); ;} - break; - - case 249: - -/* Line 1464 of yacc.c */ -#line 1187 "src/Parser/pddl+.yacc" - { (yyval.t_structure_def)= (yyvsp[(1) - (1)].t_action_def); ;} - break; - - case 250: - -/* Line 1464 of yacc.c */ -#line 1188 "src/Parser/pddl+.yacc" - { (yyval.t_structure_def)= (yyvsp[(1) - (1)].t_event_def); requires(E_TIME); ;} - break; - - case 251: - -/* Line 1464 of yacc.c */ -#line 1189 "src/Parser/pddl+.yacc" - { (yyval.t_structure_def)= (yyvsp[(1) - (1)].t_process_def); requires(E_TIME); ;} - break; - - case 252: - -/* Line 1464 of yacc.c */ -#line 1190 "src/Parser/pddl+.yacc" - { (yyval.t_structure_def)= (yyvsp[(1) - (1)].t_durative_action_def); requires(E_DURATIVE_ACTIONS); ;} - break; - - case 253: - -/* Line 1464 of yacc.c */ -#line 1191 "src/Parser/pddl+.yacc" - { (yyval.t_structure_def)= (yyvsp[(1) - (1)].t_derivation_rule); requires(E_DERIVED_PREDICATES);;} - break; - - case 254: - -/* Line 1464 of yacc.c */ -#line 1192 "src/Parser/pddl+.yacc" - { (yyval.t_structure_def) = (yyvsp[(1) - (1)].t_class_def); requires(E_MODULES);;} - break; - - case 255: - -/* Line 1464 of yacc.c */ -#line 1200 "src/Parser/pddl+.yacc" - {(yyval.t_class_def) = new class_def((yyvsp[(3) - (5)].t_class),(yyvsp[(4) - (5)].t_func_decl_list));;} - break; - - case 256: - -/* Line 1464 of yacc.c */ -#line 1204 "src/Parser/pddl+.yacc" - {(yyval.t_dummy)= 0; - current_analysis->var_tab_stack.push( - current_analysis->buildRuleTab());;} - break; - - case 257: - -/* Line 1464 of yacc.c */ -#line 1215 "src/Parser/pddl+.yacc" - {(yyval.t_derivation_rule) = new derivation_rule((yyvsp[(3) - (5)].t_proposition),(yyvsp[(4) - (5)].t_goal),current_analysis->var_tab_stack.pop());;} - break; - - case 258: - -/* Line 1464 of yacc.c */ -#line 1227 "src/Parser/pddl+.yacc" - { (yyval.t_action_def)= current_analysis->buildAction(current_analysis->op_tab.new_symbol_put((yyvsp[(3) - (12)].cp)), - (yyvsp[(6) - (12)].t_var_symbol_list),(yyvsp[(9) - (12)].t_goal),(yyvsp[(11) - (12)].t_effect_lists), - current_analysis->var_tab_stack.pop()); delete [] (yyvsp[(3) - (12)].cp); ;} - break; - - case 259: - -/* Line 1464 of yacc.c */ -#line 1231 "src/Parser/pddl+.yacc" - {yyerrok; - log_error(E_FATAL,"Syntax error in action declaration."); - (yyval.t_action_def)= NULL; ;} - break; - - case 260: - -/* Line 1464 of yacc.c */ -#line 1244 "src/Parser/pddl+.yacc" - {(yyval.t_event_def)= current_analysis->buildEvent(current_analysis->op_tab.new_symbol_put((yyvsp[(3) - (12)].cp)), - (yyvsp[(6) - (12)].t_var_symbol_list),(yyvsp[(9) - (12)].t_goal),(yyvsp[(11) - (12)].t_effect_lists), - current_analysis->var_tab_stack.pop()); delete [] (yyvsp[(3) - (12)].cp);;} - break; - - case 261: - -/* Line 1464 of yacc.c */ -#line 1249 "src/Parser/pddl+.yacc" - {yyerrok; - log_error(E_FATAL,"Syntax error in event declaration."); - (yyval.t_event_def)= NULL; ;} - break; - - case 262: - -/* Line 1464 of yacc.c */ -#line 1261 "src/Parser/pddl+.yacc" - {(yyval.t_process_def)= current_analysis->buildProcess(current_analysis->op_tab.new_symbol_put((yyvsp[(3) - (12)].cp)), - (yyvsp[(6) - (12)].t_var_symbol_list),(yyvsp[(9) - (12)].t_goal),(yyvsp[(11) - (12)].t_effect_lists), - current_analysis->var_tab_stack.pop()); delete [] (yyvsp[(3) - (12)].cp);;} - break; - - case 263: - -/* Line 1464 of yacc.c */ -#line 1265 "src/Parser/pddl+.yacc" - {yyerrok; - log_error(E_FATAL,"Syntax error in process declaration."); - (yyval.t_process_def)= NULL; ;} - break; - - case 264: - -/* Line 1464 of yacc.c */ -#line 1277 "src/Parser/pddl+.yacc" - { (yyval.t_durative_action_def)= (yyvsp[(10) - (11)].t_durative_action_def); - (yyval.t_durative_action_def)->name= current_analysis->op_tab.new_symbol_put((yyvsp[(3) - (11)].cp)); - (yyval.t_durative_action_def)->symtab= current_analysis->var_tab_stack.pop(); - (yyval.t_durative_action_def)->parameters= (yyvsp[(6) - (11)].t_var_symbol_list); - (yyval.t_durative_action_def)->dur_constraint= (yyvsp[(9) - (11)].t_goal); - delete [] (yyvsp[(3) - (11)].cp); - ;} - break; - - case 265: - -/* Line 1464 of yacc.c */ -#line 1286 "src/Parser/pddl+.yacc" - {yyerrok; - log_error(E_FATAL,"Syntax error in durative-action declaration."); - (yyval.t_durative_action_def)= NULL; ;} - break; - - case 266: - -/* Line 1464 of yacc.c */ -#line 1293 "src/Parser/pddl+.yacc" - {(yyval.t_durative_action_def)=(yyvsp[(1) - (3)].t_durative_action_def); (yyval.t_durative_action_def)->effects=(yyvsp[(3) - (3)].t_effect_lists);;} - break; - - case 267: - -/* Line 1464 of yacc.c */ -#line 1295 "src/Parser/pddl+.yacc" - {(yyval.t_durative_action_def)=(yyvsp[(1) - (3)].t_durative_action_def); (yyval.t_durative_action_def)->precondition=(yyvsp[(3) - (3)].t_goal);;} - break; - - case 268: - -/* Line 1464 of yacc.c */ -#line 1296 "src/Parser/pddl+.yacc" - {(yyval.t_durative_action_def)= current_analysis->buildDurativeAction();;} - break; - - case 269: - -/* Line 1464 of yacc.c */ -#line 1301 "src/Parser/pddl+.yacc" - { (yyval.t_goal)=(yyvsp[(1) - (1)].t_goal); ;} - break; - - case 270: - -/* Line 1464 of yacc.c */ -#line 1303 "src/Parser/pddl+.yacc" - { (yyval.t_goal)= new conj_goal((yyvsp[(3) - (4)].t_goal_list)); ;} - break; - - case 271: - -/* Line 1464 of yacc.c */ -#line 1308 "src/Parser/pddl+.yacc" - { (yyval.t_goal_list)=(yyvsp[(1) - (2)].t_goal_list); (yyval.t_goal_list)->push_back((yyvsp[(2) - (2)].t_goal)); ;} - break; - - case 272: - -/* Line 1464 of yacc.c */ -#line 1310 "src/Parser/pddl+.yacc" - { (yyval.t_goal_list)= new goal_list; ;} - break; - - case 273: - -/* Line 1464 of yacc.c */ -#line 1315 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new timed_goal((yyvsp[(3) - (4)].t_goal),E_AT_START);;} - break; - - case 274: - -/* Line 1464 of yacc.c */ -#line 1317 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new timed_goal((yyvsp[(3) - (4)].t_goal),E_AT_END);;} - break; - - case 275: - -/* Line 1464 of yacc.c */ -#line 1319 "src/Parser/pddl+.yacc" - {(yyval.t_goal)= new timed_goal((yyvsp[(3) - (4)].t_goal),E_OVER_ALL);;} - break; - - case 276: - -/* Line 1464 of yacc.c */ -#line 1321 "src/Parser/pddl+.yacc" - {timed_goal * tg = dynamic_cast((yyvsp[(4) - (5)].t_goal)); - (yyval.t_goal) = new timed_goal(new preference((yyvsp[(3) - (5)].cp),tg->clearGoal()),tg->getTime()); - delete tg; - requires(E_PREFERENCES);;} - break; - - case 277: - -/* Line 1464 of yacc.c */ -#line 1326 "src/Parser/pddl+.yacc" - {(yyval.t_goal) = new preference((yyvsp[(3) - (4)].t_goal));requires(E_PREFERENCES);;} - break; - - case 278: - -/* Line 1464 of yacc.c */ -#line 1330 "src/Parser/pddl+.yacc" - {(yyval.t_dummy)= 0; current_analysis->var_tab_stack.push( - current_analysis->buildOpTab());;} - break; - - case 279: - -/* Line 1464 of yacc.c */ -#line 1335 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_EQUALITY;;} - break; - - case 280: - -/* Line 1464 of yacc.c */ -#line 1336 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_STRIPS;;} - break; - - case 281: - -/* Line 1464 of yacc.c */ -#line 1338 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_TYPING;;} - break; - - case 282: - -/* Line 1464 of yacc.c */ -#line 1340 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_NEGATIVE_PRECONDITIONS;;} - break; - - case 283: - -/* Line 1464 of yacc.c */ -#line 1342 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_DISJUNCTIVE_PRECONDS;;} - break; - - case 284: - -/* Line 1464 of yacc.c */ -#line 1343 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_EXT_PRECS;;} - break; - - case 285: - -/* Line 1464 of yacc.c */ -#line 1344 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_UNIV_PRECS;;} - break; - - case 286: - -/* Line 1464 of yacc.c */ -#line 1345 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_COND_EFFS;;} - break; - - case 287: - -/* Line 1464 of yacc.c */ -#line 1346 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_NFLUENTS | E_OFLUENTS;;} - break; - - case 288: - -/* Line 1464 of yacc.c */ -#line 1348 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_DURATIVE_ACTIONS;;} - break; - - case 289: - -/* Line 1464 of yacc.c */ -#line 1349 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_TIME | - E_NFLUENTS | - E_DURATIVE_ACTIONS; ;} - break; - - case 290: - -/* Line 1464 of yacc.c */ -#line 1352 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)=E_ACTIONCOSTS | E_NFLUENTS;;} - break; - - case 291: - -/* Line 1464 of yacc.c */ -#line 1355 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)=E_OFLUENTS;;} - break; - - case 292: - -/* Line 1464 of yacc.c */ -#line 1356 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)=E_NFLUENTS;;} - break; - - case 293: - -/* Line 1464 of yacc.c */ -#line 1357 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)=E_MODULES;;} - break; - - case 294: - -/* Line 1464 of yacc.c */ -#line 1359 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_STRIPS | - E_TYPING | - E_NEGATIVE_PRECONDITIONS | - E_DISJUNCTIVE_PRECONDS | - E_EQUALITY | - E_EXT_PRECS | - E_UNIV_PRECS | - E_COND_EFFS;;} - break; - - case 295: - -/* Line 1464 of yacc.c */ -#line 1368 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_EXT_PRECS | - E_UNIV_PRECS;;} - break; - - case 296: - -/* Line 1464 of yacc.c */ -#line 1372 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_DURATION_INEQUALITIES;;} - break; - - case 297: - -/* Line 1464 of yacc.c */ -#line 1375 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag)= E_CONTINUOUS_EFFECTS;;} - break; - - case 298: - -/* Line 1464 of yacc.c */ -#line 1377 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag) = E_DERIVED_PREDICATES;;} - break; - - case 299: - -/* Line 1464 of yacc.c */ -#line 1379 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag) = E_TIMED_INITIAL_LITERALS;;} - break; - - case 300: - -/* Line 1464 of yacc.c */ -#line 1381 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag) = E_PREFERENCES;;} - break; - - case 301: - -/* Line 1464 of yacc.c */ -#line 1383 "src/Parser/pddl+.yacc" - {(yyval.t_pddl_req_flag) = E_CONSTRAINTS;;} - break; - - case 302: - -/* Line 1464 of yacc.c */ -#line 1385 "src/Parser/pddl+.yacc" - {log_error(E_WARNING,"Unrecognised requirements declaration "); - (yyval.t_pddl_req_flag)= 0; delete [] (yyvsp[(1) - (1)].cp);;} - break; - - case 303: - -/* Line 1464 of yacc.c */ -#line 1391 "src/Parser/pddl+.yacc" - {(yyval.t_const_symbol_list)=(yyvsp[(3) - (4)].t_const_symbol_list);;} - break; - - case 304: - -/* Line 1464 of yacc.c */ -#line 1395 "src/Parser/pddl+.yacc" - {(yyval.t_type_list)=(yyvsp[(3) - (4)].t_type_list); requires(E_TYPING);;} - break; - - case 305: - -/* Line 1464 of yacc.c */ -#line 1405 "src/Parser/pddl+.yacc" - {(yyval.t_problem)=(yyvsp[(11) - (12)].t_problem); (yyval.t_problem)->name = (yyvsp[(5) - (12)].cp); (yyval.t_problem)->domain_name = (yyvsp[(9) - (12)].cp); - if (types_used && !types_defined) { - yyerrok; log_error(E_FATAL,"Syntax error in problem file - types used, but no :types section in domain file."); - } - - ;} - break; - - case 306: - -/* Line 1464 of yacc.c */ -#line 1412 "src/Parser/pddl+.yacc" - {yyerrok; (yyval.t_problem)=NULL; - log_error(E_FATAL,"Syntax error in problem definition."); ;} - break; - - case 307: - -/* Line 1464 of yacc.c */ -#line 1418 "src/Parser/pddl+.yacc" - {(yyval.t_problem)=(yyvsp[(2) - (2)].t_problem); (yyval.t_problem)->req= (yyvsp[(1) - (2)].t_pddl_req_flag);;} - break; - - case 308: - -/* Line 1464 of yacc.c */ -#line 1419 "src/Parser/pddl+.yacc" - {(yyval.t_problem)=(yyvsp[(2) - (2)].t_problem); (yyval.t_problem)->objects= (yyvsp[(1) - (2)].t_const_symbol_list);;} - break; - - case 309: - -/* Line 1464 of yacc.c */ -#line 1420 "src/Parser/pddl+.yacc" - {(yyval.t_problem)=(yyvsp[(2) - (2)].t_problem); (yyval.t_problem)->initial_state= (yyvsp[(1) - (2)].t_effect_lists);;} - break; - - case 310: - -/* Line 1464 of yacc.c */ -#line 1421 "src/Parser/pddl+.yacc" - {(yyval.t_problem)=(yyvsp[(2) - (2)].t_problem); (yyval.t_problem)->the_goal= (yyvsp[(1) - (2)].t_goal);;} - break; - - case 311: - -/* Line 1464 of yacc.c */ -#line 1423 "src/Parser/pddl+.yacc" - {(yyval.t_problem)=(yyvsp[(2) - (2)].t_problem); (yyval.t_problem)->constraints = (yyvsp[(1) - (2)].t_con_goal);;} - break; - - case 312: - -/* Line 1464 of yacc.c */ -#line 1424 "src/Parser/pddl+.yacc" - {(yyval.t_problem)=(yyvsp[(2) - (2)].t_problem); if((yyval.t_problem)->metric == 0) {(yyval.t_problem)->metric= (yyvsp[(1) - (2)].t_metric);} - else {(yyval.t_problem)->metric->add((yyvsp[(1) - (2)].t_metric));};} - break; - - case 313: - -/* Line 1464 of yacc.c */ -#line 1426 "src/Parser/pddl+.yacc" - {(yyval.t_problem)=(yyvsp[(2) - (2)].t_problem); (yyval.t_problem)->length= (yyvsp[(1) - (2)].t_length_spec);;} - break; - - case 314: - -/* Line 1464 of yacc.c */ -#line 1427 "src/Parser/pddl+.yacc" - {(yyval.t_problem)=new problem;;} - break; - - case 315: - -/* Line 1464 of yacc.c */ -#line 1430 "src/Parser/pddl+.yacc" - {(yyval.t_const_symbol_list)=(yyvsp[(3) - (4)].t_const_symbol_list);;} - break; - - case 316: - -/* Line 1464 of yacc.c */ -#line 1433 "src/Parser/pddl+.yacc" - {(yyval.t_effect_lists)=(yyvsp[(3) - (4)].t_effect_lists);;} - break; - - case 317: - -/* Line 1464 of yacc.c */ -#line 1436 "src/Parser/pddl+.yacc" - {(yyval.vtab) = current_analysis->buildOpTab();;} - break; - - case 318: - -/* Line 1464 of yacc.c */ -#line 1439 "src/Parser/pddl+.yacc" - {(yyval.t_goal)=(yyvsp[(3) - (4)].t_goal);delete (yyvsp[(2) - (4)].vtab);;} - break; - - case 319: - -/* Line 1464 of yacc.c */ -#line 1444 "src/Parser/pddl+.yacc" - { (yyval.t_metric)= new metric_spec((yyvsp[(3) - (5)].t_optimization),(yyvsp[(4) - (5)].t_expression)); ;} - break; - - case 320: - -/* Line 1464 of yacc.c */ -#line 1446 "src/Parser/pddl+.yacc" - {yyerrok; - log_error(E_FATAL,"Syntax error in metric declaration."); - (yyval.t_metric)= NULL; ;} - break; - - case 321: - -/* Line 1464 of yacc.c */ -#line 1453 "src/Parser/pddl+.yacc" - {(yyval.t_length_spec)= new length_spec(E_BOTH,(yyvsp[(4) - (7)].ival),(yyvsp[(6) - (7)].ival));;} - break; - - case 322: - -/* Line 1464 of yacc.c */ -#line 1456 "src/Parser/pddl+.yacc" - {(yyval.t_length_spec) = new length_spec(E_SERIAL,(yyvsp[(4) - (5)].ival));;} - break; - - case 323: - -/* Line 1464 of yacc.c */ -#line 1460 "src/Parser/pddl+.yacc" - {(yyval.t_length_spec) = new length_spec(E_PARALLEL,(yyvsp[(4) - (5)].ival));;} - break; - - case 324: - -/* Line 1464 of yacc.c */ -#line 1466 "src/Parser/pddl+.yacc" - {(yyval.t_optimization)= E_MINIMIZE;;} - break; - - case 325: - -/* Line 1464 of yacc.c */ -#line 1467 "src/Parser/pddl+.yacc" - {(yyval.t_optimization)= E_MAXIMIZE;;} - break; - - case 326: - -/* Line 1464 of yacc.c */ -#line 1472 "src/Parser/pddl+.yacc" - {(yyval.t_expression)= (yyvsp[(2) - (3)].t_expression);;} - break; - - case 327: - -/* Line 1464 of yacc.c */ -#line 1473 "src/Parser/pddl+.yacc" - {(yyval.t_expression)= (yyvsp[(1) - (1)].t_func_term);;} - break; - - case 328: - -/* Line 1464 of yacc.c */ -#line 1474 "src/Parser/pddl+.yacc" - {(yyval.t_expression)= (yyvsp[(1) - (1)].t_num_expression);;} - break; - - case 329: - -/* Line 1464 of yacc.c */ -#line 1475 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new special_val_expr(E_TOTAL_TIME); ;} - break; - - case 330: - -/* Line 1464 of yacc.c */ -#line 1477 "src/Parser/pddl+.yacc" - {(yyval.t_expression) = new violation_term((yyvsp[(3) - (4)].cp));;} - break; - - case 331: - -/* Line 1464 of yacc.c */ -#line 1478 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new special_val_expr(E_TOTAL_TIME); ;} - break; - - case 332: - -/* Line 1464 of yacc.c */ -#line 1482 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new plus_expression((yyvsp[(2) - (3)].t_expression),(yyvsp[(3) - (3)].t_expression)); ;} - break; - - case 333: - -/* Line 1464 of yacc.c */ -#line 1483 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new minus_expression((yyvsp[(2) - (3)].t_expression),(yyvsp[(3) - (3)].t_expression)); ;} - break; - - case 334: - -/* Line 1464 of yacc.c */ -#line 1484 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new mul_expression((yyvsp[(2) - (3)].t_expression),(yyvsp[(3) - (3)].t_expression)); ;} - break; - - case 335: - -/* Line 1464 of yacc.c */ -#line 1485 "src/Parser/pddl+.yacc" - { (yyval.t_expression)= new div_expression((yyvsp[(2) - (3)].t_expression),(yyvsp[(3) - (3)].t_expression)); ;} - break; - - case 336: - -/* Line 1464 of yacc.c */ -#line 1489 "src/Parser/pddl+.yacc" - {(yyval.t_expression) = (yyvsp[(1) - (1)].t_expression);;} - break; - - case 337: - -/* Line 1464 of yacc.c */ -#line 1491 "src/Parser/pddl+.yacc" - {(yyval.t_expression) = new plus_expression((yyvsp[(1) - (2)].t_expression),(yyvsp[(2) - (2)].t_expression));;} - break; - - case 338: - -/* Line 1464 of yacc.c */ -#line 1495 "src/Parser/pddl+.yacc" - {(yyval.t_expression) = (yyvsp[(1) - (1)].t_expression);;} - break; - - case 339: - -/* Line 1464 of yacc.c */ -#line 1497 "src/Parser/pddl+.yacc" - {(yyval.t_expression) = new mul_expression((yyvsp[(1) - (2)].t_expression),(yyvsp[(2) - (2)].t_expression));;} - break; - - case 340: - -/* Line 1464 of yacc.c */ -#line 1503 "src/Parser/pddl+.yacc" - {(yyval.t_plan)= (yyvsp[(2) - (2)].t_plan); - (yyval.t_plan)->push_front((yyvsp[(1) - (2)].t_step)); ;} - break; - - case 341: - -/* Line 1464 of yacc.c */ -#line 1506 "src/Parser/pddl+.yacc" - {(yyval.t_plan) = (yyvsp[(3) - (3)].t_plan);(yyval.t_plan)->insertTime((yyvsp[(2) - (3)].fval));;} - break; - - case 342: - -/* Line 1464 of yacc.c */ -#line 1508 "src/Parser/pddl+.yacc" - {(yyval.t_plan) = (yyvsp[(3) - (3)].t_plan);(yyval.t_plan)->insertTime((yyvsp[(2) - (3)].ival));;} - break; - - case 343: - -/* Line 1464 of yacc.c */ -#line 1510 "src/Parser/pddl+.yacc" - {(yyval.t_plan)= new plan;;} - break; - - case 344: - -/* Line 1464 of yacc.c */ -#line 1515 "src/Parser/pddl+.yacc" - {(yyval.t_step)=(yyvsp[(3) - (3)].t_step); - (yyval.t_step)->start_time_given=1; - (yyval.t_step)->start_time=(yyvsp[(1) - (3)].fval);;} - break; - - case 345: - -/* Line 1464 of yacc.c */ -#line 1519 "src/Parser/pddl+.yacc" - {(yyval.t_step)=(yyvsp[(1) - (1)].t_step); - (yyval.t_step)->start_time_given=0;;} - break; - - case 346: - -/* Line 1464 of yacc.c */ -#line 1525 "src/Parser/pddl+.yacc" - {(yyval.t_step)= (yyvsp[(1) - (4)].t_step); - (yyval.t_step)->duration_given=1; - (yyval.t_step)->duration= (yyvsp[(3) - (4)].fval);;} - break; - - case 347: - -/* Line 1464 of yacc.c */ -#line 1529 "src/Parser/pddl+.yacc" - {(yyval.t_step)= (yyvsp[(1) - (1)].t_step); - (yyval.t_step)->duration_given=0;;} - break; - - case 348: - -/* Line 1464 of yacc.c */ -#line 1535 "src/Parser/pddl+.yacc" - {(yyval.t_step)= new plan_step( - current_analysis->op_tab.symbol_get((yyvsp[(2) - (4)].cp)), - (yyvsp[(3) - (4)].t_const_symbol_list)); delete [] (yyvsp[(2) - (4)].cp); - ;} - break; - - case 349: - -/* Line 1464 of yacc.c */ -#line 1542 "src/Parser/pddl+.yacc" - {(yyval.fval)= (yyvsp[(1) - (1)].fval);;} - break; - - case 350: - -/* Line 1464 of yacc.c */ -#line 1543 "src/Parser/pddl+.yacc" - {(yyval.fval)= (float) (yyvsp[(1) - (1)].ival);;} - break; - - - -/* Line 1464 of yacc.c */ -#line 5022 "src/pddl+.cpp" - default: break; - } - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (YY_("syntax error")); -#else - { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } - } -#endif - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; - - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - - yydestruct ("Error: popping", - yystos[yystate], yyvsp); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - *++yyvsp = yylval; - - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#if !defined(yyoverflow) || YYERROR_VERBOSE -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif - /* Make sure YYID is used. */ - return YYID (yyresult); -} - - - -/* Line 1684 of yacc.c */ -#line 1546 "src/Parser/pddl+.yacc" - - -#include -#include -int line_no= 1; -using std::istream; -#include "lex.yy.cc" - -namespace VAL { -extern yyFlexLexer* yfl; -}; - - -int yyerror(char * s) -{ - return 0; -} - -int yylex() -{ - return yfl->yylex(); -} - diff --git a/src/pddl+.yacc b/src/pddl+.yacc new file mode 100644 index 0000000..42c0765 --- /dev/null +++ b/src/pddl+.yacc @@ -0,0 +1,1567 @@ + /* + PDDL2.1 grammar file for bison. + + $Date: 2009-02-11 17:20:39 $ + $Revision: 1.5 $ + + s.n.cresswell@durham.ac.uk + Derek Long + + Srathclyde Planning Group + http://planning.cis.ac.uk + */ + + +%start mystartsymbol + +%{ +/* +Error reporting: +Intention is to provide error token on most bracket expressions, +so synchronisation can occur on next CLOSE_BRAC. +Hence error should be generated for innermost expression containing error. +Expressions which cause errors return a NULL values, and parser +always attempts to carry on. +This won't behave so well if CLOSE_BRAC is missing. + +Naming conventions: +Generally, the names should be similar to the PDDL2.1 spec. +During development, they have also been based on older PDDL specs, +older PDDL+ and TIM parsers, and this shows in places. + +All the names of fields in the semantic value type begin with t_ +Corresponding categories in the grammar begin with c_ +Corresponding classes have no prefix. + +PDDL grammar yacc grammar type of corresponding semantic val. + +thing+ c_things thing_list +(thing+) c_thing_list thing_list + +*/ + +#include +#include +#include +#include + +// This is now copied locally to avoid relying on installation +// of flex++. + +//#include "FlexLexer.h" +//#include + +#include "ptree.h" +#include "parse_error.h" + +#define YYDEBUG 1 + +int yyerror(char *); + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", ((char *)msgid)) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) ((char *) msgid) +# endif +#endif + +extern int yylex(); + +using namespace VAL; + +%} + +%union { + parse_category* t_parse_category; + + effect_lists* t_effect_lists; + effect* t_effect; + simple_effect* t_simple_effect; + cond_effect* t_cond_effect; + forall_effect* t_forall_effect; + timed_effect* t_timed_effect; + + quantifier t_quantifier; + metric_spec* t_metric; + optimization t_optimization; + + symbol* t_symbol; + var_symbol* t_var_symbol; + pddl_type* t_type; + pred_symbol* t_pred_symbol; + func_symbol* t_func_symbol; + const_symbol* t_const_symbol; + class_symbol* t_class; + + parameter_symbol_list* t_parameter_symbol_list; + var_symbol_list* t_var_symbol_list; + const_symbol_list* t_const_symbol_list; + pddl_type_list* t_type_list; + + proposition* t_proposition; + pred_decl* t_pred_decl; + pred_decl_list* t_pred_decl_list; + func_decl* t_func_decl; + func_decl_list* t_func_decl_list; + + goal* t_goal; + con_goal * t_con_goal; + goal_list* t_goal_list; + + func_term* t_func_term; + assignment* t_assignment; + expression* t_expression; + num_expression* t_num_expression; + assign_op t_assign_op; + comparison_op t_comparison_op; + + structure_def* t_structure_def; + structure_store* t_structure_store; + + action* t_action_def; + event* t_event_def; + process* t_process_def; + durative_action* t_durative_action_def; + derivation_rule* t_derivation_rule; + + problem* t_problem; + length_spec* t_length_spec; + + domain* t_domain; + + pddl_req_flag t_pddl_req_flag; + + plan* t_plan; + plan_step* t_step; + + int ival; + double fval; + + char* cp; + int t_dummy; + + var_symbol_table * vtab; + + class_def * t_class_def; + // classes_list* t_classes; + +}; + + +%type c_effects c_conj_effect c_effect c_initial_state + c_a_effect c_p_effects c_p_effect c_da_effect c_da_effects c_da_cts_only_effect c_da_cts_only_effects + c_a_effect_da c_p_effect_da c_p_effects_da + c_init_els c_proc_effect c_proc_effects +%type c_pos_simple_effect c_neg_simple_effect + c_init_pos_simple_effect c_init_neg_simple_effect +%type c_cond_effect +%type c_forall_effect +%type c_timed_effect c_cts_only_timed_effect c_timed_initial_literal + +//%type c_parameter_symbol +%type /* c_type */ c_primitive_type c_new_primitive_type +%type c_pred_symbol c_new_pred_symbol c_init_pred_symbol +%type /* c_func_symbol */ c_new_func_symbol +%type c_const_symbol c_new_const_symbol +%type c_var_symbol c_declaration_var_symbol + +%type c_proposition c_derived_proposition c_init_proposition +%type c_pred_decl +%type c_pred_decls c_predicates +%type c_func_decl +%type c_func_decls c_functions_def + +%type c_parameter_symbols +%type c_var_symbol_list c_typed_var_list +%type c_const_symbols c_new_const_symbols c_typed_consts c_domain_constants c_objects +%type c_primitive_types c_new_primitive_types c_typed_types c_type_names c_either_type + +%type c_goal_descriptor c_pre_goal_descriptor c_pref_goal_descriptor c_goal_spec c_duration_constraint c_da_gd c_timed_gd /* c_f_comp */ +%type c_constraints_def c_constraints_probdef c_constraint_goal c_pref_con_goal c_pref_goal +%type c_goal_list c_pre_goal_descriptor_list c_duration_constraints c_da_gds c_constraint_goal_list c_pref_con_goal_list +%type /*c_quantifier*/ c_forall c_exists + +%type c_f_head /* c_new_f_head */ c_ground_f_head +%type c_assignment c_f_assign_da +%type c_f_exp c_ground_f_exp c_binary_ground_f_exp c_f_exp_da c_f_exp_t c_binary_expr_da c_d_value c_binary_ground_f_pexps c_binary_ground_f_mexps +%type c_number +%type c_comparison_op c_d_op + +%type c_structure_def +%type c_class_def +%type c_action_def +%type c_event_def +%type c_process_def +%type c_durative_action_def c_da_def_body +%type c_derivation_rule +%type c_structure_defs + +%type c_domain_require_def c_require_key c_reqs + +%type c_problem c_problem_body +%type c_length_spec + +%type c_class c_new_class + +%type c_domain c_preamble +%type /*c_action_kind*/ c_args_head c_rule_head c_ntype c_classes c_class_seq + +%type c_optimization +%type c_metric_spec + +%type c_plan +%type c_step c_step_t_d c_step_d + +%type c_domain_name +%type c_float + +%type c_goals; + +%token OPEN_BRAC CLOSE_BRAC MODULES + OPEN_SQ CLOSE_SQ DOT CLASSES CLASS + DEFINE PDDLDOMAIN REQS EQUALITY STRIPS ADL NEGATIVE_PRECONDITIONS + TYPING DISJUNCTIVE_PRECONDS EXT_PRECS UNIV_PRECS QUANT_PRECS COND_EFFS + FLUENTS OBJECTFLUENTS NUMERICFLUENTS ACTIONCOSTS + TIME DURATIVE_ACTIONS DURATION_INEQUALITIES CONTINUOUS_EFFECTS + DERIVED_PREDICATES TIMED_INITIAL_LITERALS PREFERENCES CONSTRAINTS + ACTION PROCESS EVENT DURATIVE_ACTION DERIVED + CONSTANTS PREDS FUNCTIONS TYPES ARGS PRE CONDITION PREFERENCE + START_PRE END_PRE /* Redundant */ + EFFECTS + INITIAL_EFFECT FINAL_EFFECT INVARIANT DURATION /* Redundant */ + AT_START AT_END OVER_ALL + AND OR EXISTS FORALL IMPLY NOT WHEN WHENEVER EITHER + PROBLEM FORDOMAIN INITIALLY + OBJECTS GOALS EQ LENGTH SERIAL PARALLEL METRIC + MINIMIZE MAXIMIZE + HASHT DURATION_VAR TOTAL_TIME + INCREASE DECREASE SCALE_UP SCALE_DOWN ASSIGN + GREATER GREATEQ LESS LESSEQ /* EQUALS */ Q COLON NUMBER + ALWAYS SOMETIME WITHIN ATMOSTONCE SOMETIMEAFTER SOMETIMEBEFORE + ALWAYSWITHIN HOLDDURING HOLDAFTER ISVIOLATED + BOGUS + + +%token NAME FUNCTION_SYMBOL +%token INTVAL +%token FLOATVAL AT_TIME + +%left HYPHEN PLUS +%left MUL DIV +%left UMINUS + +%% +mystartsymbol : + c_domain {top_thing= $1; current_analysis->the_domain= $1;} +| c_problem {top_thing= $1; current_analysis->the_problem= $1;} +| c_plan {top_thing= $1; } +; + +c_domain : + OPEN_BRAC DEFINE c_domain_name c_preamble CLOSE_BRAC + {$$= $4; $$->name= $3;delete [] $3; + if (types_used && !types_defined) { + yyerrok; log_error(E_FATAL,"Syntax error in domain - no :types section, but types used in definitions."); + } + } +| OPEN_BRAC DEFINE c_domain_name error + {yyerrok; $$=static_cast(NULL); + log_error(E_FATAL,"Syntax error in domain"); } // Helpful? +; + +// Assumes operators defns are last, and at least one of them present. +c_preamble : + c_domain_require_def c_preamble {$$= $2; $$->req= $1;} + | c_type_names c_preamble {types_defined = true; $$= $2; $$->types= $1;} + | c_domain_constants c_preamble {$$= $2; $$->constants= $1;} + | c_predicates c_preamble {$$= $2; + $$->predicates= $1; } + | c_functions_def c_preamble {$$= $2; + $$->functions= $1; } + | c_constraints_def c_preamble {$$= $2; + $$->constraints = $1;} + | c_classes c_preamble {$$ = $2;} + | c_structure_defs {$$= new domain($1); } +; + +c_domain_name : OPEN_BRAC PDDLDOMAIN NAME CLOSE_BRAC {$$=$3;} + +; + +c_new_class : NAME { $$=current_analysis->classes_tab.new_symbol_put($1); + delete [] $1; }; + +c_class : NAME { $$ = current_analysis->classes_tab.symbol_get($1); delete [] $1;}; + +c_classes : OPEN_BRAC CLASSES c_class_seq CLOSE_BRAC {$$ = 0;}; + +c_class_seq : c_new_class c_class_seq {$$ = 0;}| +/* empty */ {$$ = 0;} + ; + +c_domain_require_def : + OPEN_BRAC REQS c_reqs CLOSE_BRAC + { + // Stash in analysis object --- we need to refer to it during parse + // but domain object is not created yet, + current_analysis->req |= $3; + $$=$3; + } +| OPEN_BRAC REQS error CLOSE_BRAC + {yyerrok; + log_error(E_FATAL,"Syntax error in requirements declaration."); + $$= 0; } +; + +c_reqs : + c_reqs c_require_key { $$= $1 | $2; } +| /* empty */ { $$= 0; } +; + + +c_pred_decls : + c_pred_decl c_pred_decls + {$$=$2; $$->push_front($1);} +| c_pred_decl + { $$=new pred_decl_list; + $$->push_front($1); }; + +c_pred_decl : + OPEN_BRAC c_new_pred_symbol c_typed_var_list CLOSE_BRAC + {$$= new pred_decl($2,$3,current_analysis->var_tab_stack.pop());} +| OPEN_BRAC error CLOSE_BRAC + {yyerrok; + // hope someone makes this error someday + log_error(E_FATAL,"Syntax error in predicate declaration."); + $$= static_cast(NULL); } +; + +c_new_pred_symbol : + NAME + { $$=current_analysis->pred_tab.new_symbol_put($1); + current_analysis->var_tab_stack.push( + current_analysis->buildPredTab()); + delete [] $1; } +; + +c_pred_symbol : + EQ { $$=current_analysis->pred_tab.symbol_ref("="); + requires(E_EQUALITY); } +| NAME { $$=current_analysis->pred_tab.symbol_get($1); delete [] $1; } +; + + +c_init_pred_symbol : + // We have a different pred_symbol rule for the initial state + // so as to exclude EQ, + // which must be parsed as assignment in initial state. + NAME { $$=current_analysis->pred_tab.symbol_get($1); delete [] $1;} +; + + +c_func_decls : + c_func_decls c_func_decl + {$$=$1; $$->push_back($2);} +| /* empty */ { $$=new func_decl_list; } +; + +c_func_decl : + OPEN_BRAC c_new_func_symbol c_typed_var_list CLOSE_BRAC c_ntype + {$$= new func_decl($2,$3,current_analysis->var_tab_stack.pop());} +| OPEN_BRAC error CLOSE_BRAC + {yyerrok; + log_error(E_FATAL,"Syntax error in functor declaration."); + $$= (int) NULL; } +; + +c_ntype : + HYPHEN NUMBER {$$ = (int) NULL;}| /* empty */ {$$= (int) NULL;}; + +c_new_func_symbol : + NAME + { $$=current_analysis->func_tab.new_symbol_put($1); + current_analysis->var_tab_stack.push( + current_analysis->buildFuncTab()); + delete [] $1; } +; + +//c_func_symbol : +// NAME { $$=current_analysis->func_tab.symbol_get($1); } +//; + +// variables, possibly with types +c_typed_var_list : /* Type specified */ + c_var_symbol_list HYPHEN c_primitive_type c_typed_var_list + { + $$= $1; + $$->set_types($3); /* Set types for variables */ + $$->splice($$->end(),*$4); /* Join lists */ + delete $4; /* Delete (now empty) list */ + requires(E_TYPING); + types_used = true; + } +| c_var_symbol_list HYPHEN c_either_type c_typed_var_list + { + $$= $1; + $$->set_either_types($3); /* Set types for variables */ + $$->splice($$->end(),*$4); /* Join lists */ + delete $4; /* Delete (now empty) list */ + requires(E_TYPING); + types_used = true; + } +| c_var_symbol_list /* No type specified */ + { + $$= $1; + } +; + + + +// a list of variables (excluding type declaration) +// Semantic value is a list of symbols + +c_var_symbol_list : + Q c_declaration_var_symbol c_var_symbol_list + {$$=$3; $3->push_front($2); } +| /* Empty */ {$$= new var_symbol_list; } + ; + +// A list of constants (object names or types), possibly with parent types +c_typed_consts : + /* Type specified */ + c_new_const_symbols HYPHEN c_primitive_type c_typed_consts + { + $$= $1; + $1->set_types($3); /* Set types for constants */ + $1->splice($1->end(),*$4); /* Join lists */ + delete $4; /* Delete (now empty) list */ + requires(E_TYPING); + types_used = true; + } +| c_new_const_symbols HYPHEN c_either_type c_typed_consts + { + $$= $1; + $1->set_either_types($3); + $1->splice($1->end(),*$4); + delete $4; + requires(E_TYPING); + types_used = true; + } +| /* No type specified */ + c_new_const_symbols {$$= $1;} +; + +// A list of object names without parent types +c_const_symbols : + c_const_symbol c_const_symbols {$$=$2; $2->push_front($1);} + | /* Empty */ {$$=new const_symbol_list;} +; + +c_new_const_symbols : + c_new_const_symbol c_new_const_symbols {$$=$2; $2->push_front($1);} + | /* Empty */ {$$=new const_symbol_list;} +; + + +// As above, but for PDDL types +// possibly with parent types +c_typed_types : + // Type specified + c_new_primitive_types HYPHEN c_primitive_type c_typed_types + { + $$= $1; + $$->set_types($3); /* Set types for constants */ + $$->splice($$->end(),*$4); /* Join lists */ + delete $4; /* Delete (now empty) list */ + } +| c_new_primitive_types HYPHEN c_either_type c_typed_types + { + // This parse needs to be excluded, we think (DPL&MF: 6/9/01) + $$= $1; + $$->set_either_types($3); + $$->splice($1->end(),*$4); + delete $4; + } +| // No parent type specified + c_new_primitive_types + { $$= $1; } +; + +// constants or variables (excluding type declaration) +c_parameter_symbols : + c_parameter_symbols c_const_symbol + {$$=$1; $$->push_back($2); } +| c_parameter_symbols Q c_var_symbol + {$$=$1; $$->push_back($3); } +| /* Empty */ {$$= new parameter_symbol_list;} +; + + + // Used in declaration of variable + // - var symbol is added to var table at top of stack +c_declaration_var_symbol : + NAME { $$= current_analysis->var_tab_stack.top()->symbol_put($1); delete [] $1; } +; + + // Used when variable is expected to have already been declared. + // The lookup is an operation on the whole stack of variable tables. +c_var_symbol : + NAME { $$= current_analysis->var_tab_stack.symbol_get($1); delete [] $1; } +; + +c_const_symbol : + NAME { $$= current_analysis->const_tab.symbol_get($1); delete [] $1; } +; + +c_new_const_symbol : + NAME { $$= current_analysis->const_tab.new_symbol_put($1); delete [] $1;} +; + +c_either_type : + OPEN_BRAC EITHER c_primitive_types CLOSE_BRAC + { $$= $3; } +; + +c_new_primitive_type : + NAME + { $$= current_analysis->pddl_type_tab.symbol_ref($1); delete [] $1;} + // We use symbol ref here in order to support multiple declarations of + // a type symbol - this is required for multiple inheritance. +; + +c_primitive_type : + NAME + { $$= current_analysis->pddl_type_tab.symbol_ref($1); delete [] $1;} +; + +c_new_primitive_types : + c_new_primitive_types c_new_primitive_type + {$$= $1; $$->push_back($2);} +| /* empty */ {$$= new pddl_type_list;} +; + +c_primitive_types : + c_primitive_types c_primitive_type + {$$= $1; $$->push_back($2);} +| /* empty */ {$$= new pddl_type_list;} +; + +c_init_els : + c_init_els OPEN_BRAC EQ c_f_head c_number CLOSE_BRAC + { $$=$1; + $$->assign_effects.push_back(new assignment($4,E_ASSIGN,$5)); + if($4->getFunction()->getName()=="total-cost") + { + requires(E_ACTIONCOSTS); + // Should also check that $5 is 0... + } + else + { + requires(E_NFLUENTS); + } + } +| c_init_els c_init_pos_simple_effect + { $$=$1; $$->add_effects.push_back($2); } +| c_init_els c_init_neg_simple_effect + { $$=$1; $$->del_effects.push_back($2); } +| c_init_els c_timed_initial_literal + { $$=$1; $$->timed_effects.push_back($2); } +| /* empty */ + { $$= new effect_lists;} +; + +c_timed_initial_literal : + OPEN_BRAC AT_TIME c_init_els CLOSE_BRAC + { requires(E_TIMED_INITIAL_LITERALS); + $$=new timed_initial_literal($3,$2);} +; + +c_effects : + c_a_effect c_effects {$$=$2; $$->append_effects($1); delete $1;} +| c_cond_effect c_effects {$$=$2; $$->cond_effects.push_front($1); + requires(E_COND_EFFS);} +| c_forall_effect c_effects {$$=$2; $$->forall_effects.push_front($1); + requires(E_COND_EFFS);} +| /* nothing */ {$$=new effect_lists(); } +; + +// Parse a single effect as effect_lists +// Wasteful, but we get the benefit of categorising effect, and +// we will often need the lists when normalising the contained effects. +// e.g. conjunctive effects will immediately collapse into this structure. + +c_effect : + c_conj_effect {$$= $1;} +| c_pos_simple_effect {$$=new effect_lists; $$->add_effects.push_front($1);} +| c_neg_simple_effect {$$=new effect_lists; $$->del_effects.push_front($1);} +| c_cond_effect {$$=new effect_lists; $$->cond_effects.push_front($1);} +| c_forall_effect {$$=new effect_lists; $$->forall_effects.push_front($1);} +; + +c_a_effect : + OPEN_BRAC AND c_p_effects CLOSE_BRAC {$$= $3;} +| c_p_effect {$$= $1;} +; + +c_p_effect : + c_neg_simple_effect + {$$=new effect_lists; $$->del_effects.push_front($1);} +| c_pos_simple_effect + {$$=new effect_lists; $$->add_effects.push_front($1);} +| c_assignment + {$$=new effect_lists; $$->assign_effects.push_front($1); + requires(E_NFLUENTS);} +; + + +c_p_effects : + c_p_effects c_neg_simple_effect {$$= $1; $$->del_effects.push_back($2);} +| c_p_effects c_pos_simple_effect {$$= $1; $$->add_effects.push_back($2);} +| c_p_effects c_assignment {$$= $1; $$->assign_effects.push_back($2); + requires(E_NFLUENTS); } +| /* empty */ { $$= new effect_lists; } +; + +c_conj_effect : + OPEN_BRAC AND c_effects CLOSE_BRAC + { $$=$3; } +| OPEN_BRAC AND error CLOSE_BRAC + {yyerrok; $$=NULL; + log_error(E_FATAL,"Syntax error in (and ...)"); + } +; + + +c_da_effect : + OPEN_BRAC AND c_da_effects CLOSE_BRAC + { $$=$3; } +| OPEN_BRAC c_forall + OPEN_BRAC c_typed_var_list CLOSE_BRAC + c_da_effect + CLOSE_BRAC + { $$= new effect_lists; + $$->forall_effects.push_back( + new forall_effect($6, $4, current_analysis->var_tab_stack.pop())); + requires(E_COND_EFFS);} +| OPEN_BRAC WHEN c_da_gd c_da_effect CLOSE_BRAC + { $$= new effect_lists; + $$->cond_effects.push_back( + new cond_effect($3,$4)); + requires(E_COND_EFFS); } +| OPEN_BRAC WHENEVER c_goal_descriptor c_da_cts_only_effect CLOSE_BRAC + { $$= new effect_lists; + $$->cond_assign_effects.push_back( + new cond_effect($3,$4)); + requires(E_COND_EFFS); } +| c_timed_effect + { $$=new effect_lists; + $$->timed_effects.push_back($1); } +| c_assignment + { $$= new effect_lists; + $$->assign_effects.push_front($1); + requires(E_NFLUENTS); } +; + +c_da_effects : + c_da_effects c_da_effect { $$=$1; $1->append_effects($2); delete $2; } +| /* empty */ { $$= new effect_lists; } +; + +c_timed_effect : + OPEN_BRAC AT_START c_a_effect_da CLOSE_BRAC + {$$=new timed_effect($3,E_AT_START);} +| OPEN_BRAC AT_END c_a_effect_da CLOSE_BRAC + {$$=new timed_effect($3,E_AT_END);} +| OPEN_BRAC INCREASE c_f_head c_f_exp_t CLOSE_BRAC + {$$=new timed_effect(new effect_lists,E_CONTINUOUS); + $$->effs->assign_effects.push_front( + new assignment($3,E_INCREASE,$4)); } +| OPEN_BRAC DECREASE c_f_head c_f_exp_t CLOSE_BRAC + {$$=new timed_effect(new effect_lists,E_CONTINUOUS); + $$->effs->assign_effects.push_front( + new assignment($3,E_DECREASE,$4)); } +| OPEN_BRAC error CLOSE_BRAC + {yyerrok; $$=NULL; + log_error(E_FATAL,"Syntax error in timed effect"); } +; + +c_cts_only_timed_effect : + OPEN_BRAC INCREASE c_f_head c_f_exp_t CLOSE_BRAC + {$$=new timed_effect(new effect_lists,E_CONTINUOUS); + $$->effs->assign_effects.push_front( + new assignment($3,E_INCREASE,$4)); } +| OPEN_BRAC DECREASE c_f_head c_f_exp_t CLOSE_BRAC + {$$=new timed_effect(new effect_lists,E_CONTINUOUS); + $$->effs->assign_effects.push_front( + new assignment($3,E_DECREASE,$4)); } +| OPEN_BRAC error CLOSE_BRAC + {yyerrok; $$=NULL; + log_error(E_FATAL,"Syntax error in conditional continuous effect"); } +; + +c_da_cts_only_effect : + OPEN_BRAC AND c_da_cts_only_effects CLOSE_BRAC + { $$=$3; } +| OPEN_BRAC c_forall + OPEN_BRAC c_typed_var_list CLOSE_BRAC + c_da_cts_only_effect + CLOSE_BRAC + { $$= new effect_lists; + $$->forall_effects.push_back( + new forall_effect($6, $4, current_analysis->var_tab_stack.pop())); + requires(E_COND_EFFS);} +| OPEN_BRAC WHENEVER c_goal_descriptor c_da_cts_only_effect CLOSE_BRAC + { $$= new effect_lists; + $$->cond_assign_effects.push_back( + new cond_effect($3,$4)); + requires(E_COND_EFFS); } +| c_cts_only_timed_effect + { $$=new effect_lists; + $$->timed_effects.push_back($1); } +; + +c_da_cts_only_effects : + c_da_cts_only_effects c_da_cts_only_effect { $$=$1; $1->append_effects($2); delete $2; } +| /* empty */ { $$= new effect_lists; } +; + +c_a_effect_da : + OPEN_BRAC AND c_p_effects_da CLOSE_BRAC {$$= $3;} +| c_p_effect_da {$$= $1;} +; + +c_p_effect_da : + c_neg_simple_effect + {$$=new effect_lists; $$->del_effects.push_front($1);} +| c_pos_simple_effect + {$$=new effect_lists; $$->add_effects.push_front($1);} +| c_f_assign_da + {$$=new effect_lists; $$->assign_effects.push_front($1); + requires(E_NFLUENTS);} +; + + +c_p_effects_da : + c_p_effects_da c_neg_simple_effect {$$= $1; $$->del_effects.push_back($2);} +| c_p_effects_da c_pos_simple_effect {$$= $1; $$->add_effects.push_back($2);} +| c_p_effects_da c_f_assign_da {$$= $1; $$->assign_effects.push_back($2); + requires(E_NFLUENTS); } +| /* empty */ { $$= new effect_lists; } +; + + +c_f_assign_da : + OPEN_BRAC ASSIGN c_f_head c_f_exp_da CLOSE_BRAC + { $$= new assignment($3,E_ASSIGN,$4); } +| OPEN_BRAC INCREASE c_f_head c_f_exp_da CLOSE_BRAC + { $$= new assignment($3,E_INCREASE,$4); } +| OPEN_BRAC DECREASE c_f_head c_f_exp_da CLOSE_BRAC + { $$= new assignment($3,E_DECREASE,$4); } +| OPEN_BRAC SCALE_UP c_f_head c_f_exp_da CLOSE_BRAC + { $$= new assignment($3,E_SCALE_UP,$4); } +| OPEN_BRAC SCALE_DOWN c_f_head c_f_exp_da CLOSE_BRAC + { $$= new assignment($3,E_SCALE_DOWN,$4); } +; + +c_proc_effect : + OPEN_BRAC INCREASE c_f_head c_f_exp_t CLOSE_BRAC + {$$=new effect_lists; + timed_effect * te = new timed_effect(new effect_lists,E_CONTINUOUS); + $$->timed_effects.push_front(te); + te->effs->assign_effects.push_front( + new assignment($3,E_INCREASE,$4)); } +| OPEN_BRAC DECREASE c_f_head c_f_exp_t CLOSE_BRAC + {$$=new effect_lists; + timed_effect * te = new timed_effect(new effect_lists,E_CONTINUOUS); + $$->timed_effects.push_front(te); + te->effs->assign_effects.push_front( + new assignment($3,E_DECREASE,$4)); } +| OPEN_BRAC AND c_proc_effects CLOSE_BRAC + {$$ = $3;} +; + +c_proc_effects : + c_proc_effects c_proc_effect { $$=$1; $1->append_effects($2); delete $2; } +| /* empty */ { $$= new effect_lists; } +; + +c_f_exp_da : + c_binary_expr_da {$$= $1;} +| Q DURATION_VAR {$$= new special_val_expr(E_DURATION_VAR); + requires( E_DURATION_INEQUALITIES );} +| c_number { $$=$1; } +| c_f_head { $$= $1; } +; + +c_binary_expr_da : + OPEN_BRAC PLUS c_f_exp_da c_f_exp_da CLOSE_BRAC + { $$= new plus_expression($3,$4); } +| OPEN_BRAC HYPHEN c_f_exp_da c_f_exp_da CLOSE_BRAC + { $$= new minus_expression($3,$4); } +| OPEN_BRAC MUL c_f_exp_da c_f_exp_da CLOSE_BRAC + { $$= new mul_expression($3,$4); } +| OPEN_BRAC DIV c_f_exp_da c_f_exp_da CLOSE_BRAC + { $$= new div_expression($3,$4); } +; + +c_duration_constraint : + OPEN_BRAC AND c_duration_constraints CLOSE_BRAC + { $$= new conj_goal($3); } +| OPEN_BRAC c_d_op Q DURATION_VAR c_d_value CLOSE_BRAC + { $$= new timed_goal(new comparison($2, + new special_val_expr(E_DURATION_VAR),$5),E_AT_START); } +| OPEN_BRAC AT_START OPEN_BRAC c_d_op Q DURATION_VAR c_d_value CLOSE_BRAC CLOSE_BRAC + { $$ = new timed_goal(new comparison($4, + new special_val_expr(E_DURATION_VAR),$7),E_AT_START);} +| OPEN_BRAC AT_END OPEN_BRAC c_d_op Q DURATION_VAR c_d_value CLOSE_BRAC CLOSE_BRAC + { $$ = new timed_goal(new comparison($4, + new special_val_expr(E_DURATION_VAR),$7),E_AT_END);} +; + +c_d_op : + LESSEQ {$$= E_LESSEQ; requires(E_DURATION_INEQUALITIES);} +| GREATEQ {$$= E_GREATEQ; requires(E_DURATION_INEQUALITIES);} +| EQ {$$= E_EQUALS; } +; + +c_d_value : +// Fix: c_number doesn't apparently require E_FLUENTS +// some needs to be included as separate item. +// c_number {$$= $1;} +//| + c_f_exp {$$= $1; } +; + +c_duration_constraints : + c_duration_constraints c_duration_constraint + { $$=$1; $$->push_back($2); } +| /* empty */ + { $$= new goal_list; } +; + +c_neg_simple_effect : + OPEN_BRAC NOT c_proposition CLOSE_BRAC + { $$= new simple_effect($3); } +; + +c_pos_simple_effect : + c_proposition + { $$= new simple_effect($1); } +; + +/* init versions disallow equality as a predicate */ + +c_init_neg_simple_effect : + OPEN_BRAC NOT c_init_proposition CLOSE_BRAC + { $$= new simple_effect($3); } +; + +c_init_pos_simple_effect : + c_init_proposition + { $$= new simple_effect($1); } +; + +c_forall_effect : +OPEN_BRAC c_forall OPEN_BRAC c_typed_var_list CLOSE_BRAC c_effect CLOSE_BRAC + { $$= new forall_effect($6, $4, current_analysis->var_tab_stack.pop());} +; + +c_cond_effect : + OPEN_BRAC WHEN c_goal_descriptor c_effects CLOSE_BRAC + { $$= new cond_effect($3,$4); } +; + +c_assignment : + OPEN_BRAC ASSIGN c_f_head c_f_exp CLOSE_BRAC + { $$= new assignment($3,E_ASSIGN,$4); } +| OPEN_BRAC INCREASE c_f_head c_f_exp CLOSE_BRAC + { $$= new assignment($3,E_INCREASE,$4); } +| OPEN_BRAC DECREASE c_f_head c_f_exp CLOSE_BRAC + { $$= new assignment($3,E_DECREASE,$4); } +| OPEN_BRAC SCALE_UP c_f_head c_f_exp CLOSE_BRAC + { $$= new assignment($3,E_SCALE_UP,$4); } +| OPEN_BRAC SCALE_DOWN c_f_head c_f_exp CLOSE_BRAC + { $$= new assignment($3,E_SCALE_DOWN,$4); } +; + +c_f_exp : + OPEN_BRAC HYPHEN c_f_exp CLOSE_BRAC %prec UMINUS + { $$= new uminus_expression($3); requires(E_NFLUENTS); } +| OPEN_BRAC PLUS c_f_exp c_f_exp CLOSE_BRAC + { $$= new plus_expression($3,$4); requires(E_NFLUENTS); } +| OPEN_BRAC HYPHEN c_f_exp c_f_exp CLOSE_BRAC + { $$= new minus_expression($3,$4); requires(E_NFLUENTS); } +| OPEN_BRAC MUL c_f_exp c_f_exp CLOSE_BRAC + { $$= new mul_expression($3,$4); requires(E_NFLUENTS); } +| OPEN_BRAC DIV c_f_exp c_f_exp CLOSE_BRAC + { $$= new div_expression($3,$4); requires(E_NFLUENTS); } +| c_number { $$=$1; } +| c_f_head { $$= $1; requires(E_NFLUENTS); } +; + +c_f_exp_t : + OPEN_BRAC MUL HASHT c_f_exp CLOSE_BRAC + { $$= new mul_expression(new special_val_expr(E_HASHT),$4); } +| OPEN_BRAC MUL c_f_exp HASHT CLOSE_BRAC + { $$= new mul_expression($3, new special_val_expr(E_HASHT)); } +| HASHT + { $$= new special_val_expr(E_HASHT); } +; + + +c_number : + INTVAL { $$=new int_expression($1); } +| FLOATVAL { $$=new float_expression($1); }; + +c_f_head : + OPEN_BRAC FUNCTION_SYMBOL c_parameter_symbols CLOSE_BRAC + { $$=new func_term( current_analysis->func_tab.symbol_get($2), $3); delete [] $2; } + // "Undeclared function symbol" case +| OPEN_BRAC NAME c_parameter_symbols CLOSE_BRAC + { $$=new func_term( current_analysis->func_tab.symbol_get($2), $3); delete [] $2; } +| FUNCTION_SYMBOL + { $$=new func_term( current_analysis->func_tab.symbol_get($1), + new parameter_symbol_list); delete [] $1;} +| OPEN_BRAC c_class DOT FUNCTION_SYMBOL c_parameter_symbols CLOSE_BRAC + { $$ = new class_func_term( $2, current_analysis->func_tab.symbol_get($4), $5); delete [] $4;} +; + +// c_new_f_head : +// OPEN_BRAC NAME c_parameter_symbol_list CLOSE_BRAC +// { $$=new func_term( current_analysis->func_tab.symbol_put($2), $3); } +// | NAME +// { $$=new func_term( current_analysis->func_tab.symbol_put($1), +// new parameter_symbol_list); } +// ; + +c_ground_f_head : + /* Fix: Should restrict to constants, as in: */ + /* NAME c_const_symbols */ + /* ... but don't want to return a thing of type const list */ + + OPEN_BRAC FUNCTION_SYMBOL c_parameter_symbols CLOSE_BRAC + { $$=new func_term( current_analysis->func_tab.symbol_get($2), $3); delete [] $2; } +| OPEN_BRAC NAME c_parameter_symbols CLOSE_BRAC + { $$=new func_term( current_analysis->func_tab.symbol_get($2), $3); delete [] $2; } +| FUNCTION_SYMBOL + { $$=new func_term( current_analysis->func_tab.symbol_get($1), + new parameter_symbol_list); delete [] $1;} +; + +c_comparison_op : + GREATER { $$= E_GREATER; } + | GREATEQ { $$= E_GREATEQ; } + | LESS { $$= E_LESS; } + | LESSEQ { $$= E_LESSEQ; } + | EQ { $$= E_EQUALS; } +; + +//c_f_comp : +// OPEN_BRAC c_comparison_op c_f_exp c_f_exp CLOSE_BRAC + +// Goals + +// FIX: PDDL BNF distinguishes between -ve literals and general -ve goals. +// (different reqs) + +c_pre_goal_descriptor : + c_pref_goal_descriptor + {$$= $1;} +/*| c_goal_descriptor + {$$=$1;} +; + +*/ +| OPEN_BRAC AND c_pre_goal_descriptor_list CLOSE_BRAC + {$$ = new conj_goal($3);} +| OPEN_BRAC c_forall OPEN_BRAC c_typed_var_list CLOSE_BRAC + c_pre_goal_descriptor CLOSE_BRAC + {$$= new qfied_goal(E_FORALL,$4,$6,current_analysis->var_tab_stack.pop()); + requires(E_UNIV_PRECS);} + | OPEN_BRAC AND CLOSE_BRAC {$$ = new conj_goal(new goal_list);} + | OPEN_BRAC CLOSE_BRAC {$$ = new conj_goal(new goal_list);} +; + +c_pref_con_goal : + OPEN_BRAC PREFERENCE c_constraint_goal CLOSE_BRAC + {$$ = new preference($3);requires(E_PREFERENCES);} +| OPEN_BRAC PREFERENCE NAME c_constraint_goal CLOSE_BRAC + {$$ = new preference($3,$4);requires(E_PREFERENCES);} +| OPEN_BRAC AND c_pref_con_goal_list CLOSE_BRAC + {$$ = new conj_goal($3);} +| OPEN_BRAC c_forall OPEN_BRAC c_typed_var_list CLOSE_BRAC + c_pref_goal CLOSE_BRAC + {$$= new qfied_goal(E_FORALL,$4,$6,current_analysis->var_tab_stack.pop()); + requires(E_UNIV_PRECS);} +| c_constraint_goal + {$$ = $1;} +; + +c_pref_goal : + OPEN_BRAC PREFERENCE c_constraint_goal CLOSE_BRAC + {$$ = new preference($3);requires(E_PREFERENCES);} +| OPEN_BRAC PREFERENCE NAME c_constraint_goal CLOSE_BRAC + {$$ = new preference($3,$4);requires(E_PREFERENCES);} +| OPEN_BRAC AND c_pref_con_goal_list CLOSE_BRAC + {$$ = new conj_goal($3);} +| OPEN_BRAC c_forall OPEN_BRAC c_typed_var_list CLOSE_BRAC + c_pref_goal CLOSE_BRAC + {$$= new qfied_goal(E_FORALL,$4,$6,current_analysis->var_tab_stack.pop()); + requires(E_UNIV_PRECS);} +; + +c_pref_con_goal_list : + c_pref_con_goal_list c_pref_con_goal + {$$=$1; $1->push_back($2);} +| c_pref_con_goal + {$$= new goal_list; $$->push_back($1);} +; + +c_pref_goal_descriptor : + OPEN_BRAC PREFERENCE c_goal_descriptor CLOSE_BRAC + {$$= new preference($3); requires(E_PREFERENCES);} +| OPEN_BRAC PREFERENCE NAME c_goal_descriptor CLOSE_BRAC + {$$= new preference($3,$4); requires(E_PREFERENCES);} +// Restored... + +| c_goal_descriptor + {$$=$1;} +; + +c_constraint_goal_list : + c_constraint_goal_list c_constraint_goal + {$$ = $1; $$->push_back($2);} +| c_constraint_goal + {$$ = new goal_list; $$->push_back($1);} +; + +c_constraint_goal : + OPEN_BRAC AND c_constraint_goal_list CLOSE_BRAC + {$$= new conj_goal($3);} +| OPEN_BRAC c_forall OPEN_BRAC c_typed_var_list CLOSE_BRAC c_constraint_goal CLOSE_BRAC + {$$ = new qfied_goal(E_FORALL,$4,$6,current_analysis->var_tab_stack.pop()); + requires(E_UNIV_PRECS);} +| OPEN_BRAC AT_END c_goal_descriptor CLOSE_BRAC + {$$ = new constraint_goal(E_ATEND,$3);} +| OPEN_BRAC ALWAYS c_goal_descriptor CLOSE_BRAC + {$$ = new constraint_goal(E_ALWAYS,$3);} +| OPEN_BRAC SOMETIME c_goal_descriptor CLOSE_BRAC + {$$ = new constraint_goal(E_SOMETIME,$3);} +| OPEN_BRAC WITHIN c_number c_goal_descriptor CLOSE_BRAC + {$$ = new constraint_goal(E_WITHIN,$4,NULL,$3->double_value(),0.0);delete $3;} +| OPEN_BRAC ATMOSTONCE c_goal_descriptor CLOSE_BRAC + {$$ = new constraint_goal(E_ATMOSTONCE,$3);} +| OPEN_BRAC SOMETIMEAFTER c_goal_descriptor c_goal_descriptor CLOSE_BRAC + {$$ = new constraint_goal(E_SOMETIMEAFTER,$4,$3);} +| OPEN_BRAC SOMETIMEBEFORE c_goal_descriptor c_goal_descriptor CLOSE_BRAC + {$$ = new constraint_goal(E_SOMETIMEBEFORE,$4,$3);} +| OPEN_BRAC ALWAYSWITHIN c_number c_goal_descriptor c_goal_descriptor CLOSE_BRAC + {$$ = new constraint_goal(E_ALWAYSWITHIN,$5,$4,$3->double_value(),0.0);delete $3;} +| OPEN_BRAC HOLDDURING c_number c_number c_goal_descriptor CLOSE_BRAC + {$$ = new constraint_goal(E_HOLDDURING,$5,NULL,$4->double_value(),$3->double_value());delete $3;delete $4;} +| OPEN_BRAC HOLDAFTER c_number c_goal_descriptor CLOSE_BRAC + {$$ = new constraint_goal(E_HOLDAFTER,$4,NULL,0.0,$3->double_value());delete $3;} +; + +c_goal_descriptor : + c_proposition + {$$= new simple_goal($1,E_POS);} +| OPEN_BRAC NOT c_goal_descriptor CLOSE_BRAC + {$$= new neg_goal($3);simple_goal * s = dynamic_cast($3); + if(s && s->getProp()->head->getName()=="=") {requires(E_EQUALITY);} + else{requires(E_NEGATIVE_PRECONDITIONS);};} +| OPEN_BRAC AND c_goal_list CLOSE_BRAC + {$$= new conj_goal($3);} +| OPEN_BRAC OR c_goal_list CLOSE_BRAC + {$$= new disj_goal($3); + requires(E_DISJUNCTIVE_PRECONDS);} +| OPEN_BRAC IMPLY c_goal_descriptor c_goal_descriptor CLOSE_BRAC + {$$= new imply_goal($3,$4); + requires(E_DISJUNCTIVE_PRECONDS);} +| OPEN_BRAC c_forall OPEN_BRAC c_typed_var_list CLOSE_BRAC + c_goal_descriptor CLOSE_BRAC + {$$= new qfied_goal($2,$4,$6,current_analysis->var_tab_stack.pop());} +| OPEN_BRAC c_exists OPEN_BRAC c_typed_var_list CLOSE_BRAC + c_goal_descriptor CLOSE_BRAC + {$$= new qfied_goal($2,$4,$6,current_analysis->var_tab_stack.pop());} +| OPEN_BRAC c_comparison_op c_f_exp c_f_exp CLOSE_BRAC + {$$= new comparison($2,$3,$4); + requires(E_NFLUENTS);} +; + +c_pre_goal_descriptor_list : + c_pre_goal_descriptor_list c_pre_goal_descriptor + {$$=$1; $1->push_back($2);} +| c_pre_goal_descriptor + {$$= new goal_list; $$->push_back($1);} +; + +c_goal_list : + c_goal_list c_goal_descriptor + {$$=$1; $1->push_back($2);} +| c_goal_descriptor + {$$= new goal_list; $$->push_back($1);} +; + +//c_quantifier : +// c_forall {$$=$1;} +//| c_exists {$$=$1;} +; + +c_forall : + FORALL + {$$=E_FORALL; + current_analysis->var_tab_stack.push( + current_analysis->buildForallTab());} +; + +c_exists : + EXISTS + {$$=E_EXISTS; + current_analysis->var_tab_stack.push( + current_analysis->buildExistsTab());} +; + +c_proposition : + OPEN_BRAC c_pred_symbol c_parameter_symbols CLOSE_BRAC + {$$=new proposition($2,$3);} +; + +c_derived_proposition : + OPEN_BRAC c_pred_symbol c_typed_var_list CLOSE_BRAC + {$$ = new proposition($2,$3);} +; + +c_init_proposition : + OPEN_BRAC c_init_pred_symbol c_parameter_symbols CLOSE_BRAC + {$$=new proposition($2,$3);} +; + +c_predicates : + OPEN_BRAC PREDS c_pred_decls CLOSE_BRAC + {$$= $3;} +| OPEN_BRAC PREDS error CLOSE_BRAC + {yyerrok; $$=NULL; + log_error(E_FATAL,"Syntax error in (:predicates ...)"); + } +; + +c_functions_def : + OPEN_BRAC FUNCTIONS c_func_decls CLOSE_BRAC + {$$= $3;} +| OPEN_BRAC FUNCTIONS error CLOSE_BRAC + {yyerrok; $$=NULL; + log_error(E_FATAL,"Syntax error in (:functions ...)"); + } +; + +c_constraints_def : + OPEN_BRAC CONSTRAINTS c_constraint_goal CLOSE_BRAC + {$$ = $3;} +| OPEN_BRAC CONSTRAINTS error CLOSE_BRAC + {yyerrok; $$=NULL; + log_error(E_FATAL,"Syntax error in (:constraints ...)"); + } +; + +c_constraints_probdef : + OPEN_BRAC CONSTRAINTS c_pref_con_goal CLOSE_BRAC + {$$ = $3;}; +| OPEN_BRAC CONSTRAINTS error CLOSE_BRAC + {yyerrok; $$=NULL; + log_error(E_FATAL,"Syntax error in (:constraints ...)"); + } +; + +c_structure_defs : + c_structure_defs c_structure_def { $$=$1; $$->push_back($2); } +| c_structure_def { $$= new structure_store; $$->push_back($1); } +; + +c_structure_def : + c_action_def { $$= $1; } +| c_event_def { $$= $1; requires(E_TIME); } +| c_process_def { $$= $1; requires(E_TIME); } +| c_durative_action_def { $$= $1; requires(E_DURATIVE_ACTIONS); } +| c_derivation_rule { $$= $1; requires(E_DERIVED_PREDICATES);} +| c_class_def { $$ = $1; requires(E_MODULES);} +; + +c_class_def : OPEN_BRAC CLASS c_class +// Friends here +// Predicates next + c_functions_def +// Supports finally + CLOSE_BRAC {$$ = new class_def($3,$4);}; + + +c_rule_head : + DERIVED {$$= 0; + current_analysis->var_tab_stack.push( + current_analysis->buildRuleTab());} +; + +c_derivation_rule : + OPEN_BRAC + c_rule_head + c_derived_proposition + c_goal_descriptor + CLOSE_BRAC + {$$ = new derivation_rule($3,$4,current_analysis->var_tab_stack.pop());} +; + +c_action_def : + OPEN_BRAC + ACTION + NAME + c_args_head OPEN_BRAC c_typed_var_list + CLOSE_BRAC + PRE c_pre_goal_descriptor + EFFECTS c_effect + CLOSE_BRAC + { $$= current_analysis->buildAction(current_analysis->op_tab.new_symbol_put($3), + $6,$9,$11, + current_analysis->var_tab_stack.pop()); delete [] $3; } +| OPEN_BRAC ACTION error CLOSE_BRAC + {yyerrok; + log_error(E_FATAL,"Syntax error in action declaration."); + $$= NULL; } +; + +c_event_def : + OPEN_BRAC + EVENT + NAME /* $3 */ + c_args_head OPEN_BRAC c_typed_var_list CLOSE_BRAC + PRE c_goal_descriptor /* $9 */ + EFFECTS c_effect /* $11 */ + CLOSE_BRAC + {$$= current_analysis->buildEvent(current_analysis->op_tab.new_symbol_put($3), + $6,$9,$11, + current_analysis->var_tab_stack.pop()); delete [] $3;} + +| OPEN_BRAC EVENT error CLOSE_BRAC + {yyerrok; + log_error(E_FATAL,"Syntax error in event declaration."); + $$= NULL; }; + +c_process_def : + OPEN_BRAC + PROCESS + NAME + c_args_head OPEN_BRAC c_typed_var_list CLOSE_BRAC + PRE c_goal_descriptor + EFFECTS c_proc_effect + CLOSE_BRAC + {$$= current_analysis->buildProcess(current_analysis->op_tab.new_symbol_put($3), + $6,$9,$11, + current_analysis->var_tab_stack.pop()); delete [] $3;} +| OPEN_BRAC PROCESS error CLOSE_BRAC + {yyerrok; + log_error(E_FATAL,"Syntax error in process declaration."); + $$= NULL; }; + +c_durative_action_def : + OPEN_BRAC + DURATIVE_ACTION + NAME /* $3 */ + c_args_head OPEN_BRAC c_typed_var_list CLOSE_BRAC + DURATION c_duration_constraint /* $9 */ + c_da_def_body + CLOSE_BRAC + { $$= $10; + $$->name= current_analysis->op_tab.new_symbol_put($3); + $$->symtab= current_analysis->var_tab_stack.pop(); + $$->parameters= $6; + $$->dur_constraint= $9; + delete [] $3; + } + +| OPEN_BRAC DURATIVE_ACTION error CLOSE_BRAC + {yyerrok; + log_error(E_FATAL,"Syntax error in durative-action declaration."); + $$= NULL; } +; + +c_da_def_body : + c_da_def_body EFFECTS c_da_effect + {$$=$1; $$->effects=$3;} +| c_da_def_body CONDITION c_da_gd + {$$=$1; $$->precondition=$3;} +| /* empty */ {$$= current_analysis->buildDurativeAction();} +; + +c_da_gd : + c_timed_gd + { $$=$1; } +| OPEN_BRAC AND c_da_gds CLOSE_BRAC + { $$= new conj_goal($3); } +; + +c_da_gds : + c_da_gds c_da_gd + { $$=$1; $$->push_back($2); } +| /* empty */ + { $$= new goal_list; } +; + +c_timed_gd : + OPEN_BRAC AT_START c_goal_descriptor CLOSE_BRAC + {$$= new timed_goal($3,E_AT_START);} +| OPEN_BRAC AT_END c_goal_descriptor CLOSE_BRAC + {$$= new timed_goal($3,E_AT_END);} +| OPEN_BRAC OVER_ALL c_goal_descriptor CLOSE_BRAC + {$$= new timed_goal($3,E_OVER_ALL);} +| OPEN_BRAC PREFERENCE NAME c_timed_gd CLOSE_BRAC + {timed_goal * tg = dynamic_cast($4); + $$ = new timed_goal(new preference($3,tg->clearGoal()),tg->getTime()); + delete tg; + requires(E_PREFERENCES);} +| OPEN_BRAC PREFERENCE c_timed_gd CLOSE_BRAC + {$$ = new preference($3);requires(E_PREFERENCES);} +; + +c_args_head : + ARGS {$$= 0; current_analysis->var_tab_stack.push( + current_analysis->buildOpTab());} +; + +c_require_key : + EQUALITY {$$= E_EQUALITY;} + | STRIPS {$$= E_STRIPS;} + + | TYPING {$$= E_TYPING;} + | NEGATIVE_PRECONDITIONS + {$$= E_NEGATIVE_PRECONDITIONS;} + | DISJUNCTIVE_PRECONDS + {$$= E_DISJUNCTIVE_PRECONDS;} + | EXT_PRECS {$$= E_EXT_PRECS;} + | UNIV_PRECS {$$= E_UNIV_PRECS;} + | COND_EFFS {$$= E_COND_EFFS;} + | FLUENTS {$$= E_NFLUENTS | E_OFLUENTS;} + | DURATIVE_ACTIONS + {$$= E_DURATIVE_ACTIONS;} + | TIME {$$= E_TIME | + E_NFLUENTS | + E_DURATIVE_ACTIONS; } + | ACTIONCOSTS {$$=E_ACTIONCOSTS | E_NFLUENTS;} // Note that this is a hack: should + // just be ACTIONCOSTS and then checks + // throughout for the right requirement + | OBJECTFLUENTS {$$=E_OFLUENTS;} + | NUMERICFLUENTS {$$=E_NFLUENTS;} + | MODULES {$$=E_MODULES;} + + | ADL {$$= E_STRIPS | + E_TYPING | + E_NEGATIVE_PRECONDITIONS | + E_DISJUNCTIVE_PRECONDS | + E_EQUALITY | + E_EXT_PRECS | + E_UNIV_PRECS | + E_COND_EFFS;} + + | QUANT_PRECS {$$= E_EXT_PRECS | + E_UNIV_PRECS;} + + | DURATION_INEQUALITIES + {$$= E_DURATION_INEQUALITIES;} + + | CONTINUOUS_EFFECTS + {$$= E_CONTINUOUS_EFFECTS;} + | DERIVED_PREDICATES + {$$ = E_DERIVED_PREDICATES;} + | TIMED_INITIAL_LITERALS + {$$ = E_TIMED_INITIAL_LITERALS;} + | PREFERENCES + {$$ = E_PREFERENCES;} + | CONSTRAINTS + {$$ = E_CONSTRAINTS;} + | NAME + {log_error(E_WARNING,"Unrecognised requirements declaration "); + $$= 0; delete [] $1;} +; + + +c_domain_constants : OPEN_BRAC CONSTANTS c_typed_consts CLOSE_BRAC + {$$=$3;} +; + +c_type_names : OPEN_BRAC TYPES c_typed_types CLOSE_BRAC + {$$=$3; requires(E_TYPING);} +; + + +c_problem : OPEN_BRAC + DEFINE + OPEN_BRAC PROBLEM NAME CLOSE_BRAC + OPEN_BRAC FORDOMAIN NAME CLOSE_BRAC + c_problem_body + CLOSE_BRAC + {$$=$11; $$->name = $5; $$->domain_name = $9; + if (types_used && !types_defined) { + yyerrok; log_error(E_FATAL,"Syntax error in problem file - types used, but no :types section in domain file."); + } + + } +| OPEN_BRAC DEFINE OPEN_BRAC PROBLEM error + {yyerrok; $$=NULL; + log_error(E_FATAL,"Syntax error in problem definition."); } + +; + +c_problem_body : + c_domain_require_def c_problem_body {$$=$2; $$->req= $1;} +| c_objects c_problem_body {$$=$2; $$->objects= $1;} +| c_initial_state c_problem_body {$$=$2; $$->initial_state= $1;} +| c_goal_spec c_problem_body {$$=$2; $$->the_goal= $1;} +| c_constraints_probdef c_problem_body + {$$=$2; $$->constraints = $1;} +| c_metric_spec c_problem_body {$$=$2; if($$->metric == 0) {$$->metric= $1;} + else {$$->metric->add($1);}} +| c_length_spec c_problem_body {$$=$2; $$->length= $1;} +| /* Empty */ {$$=new problem;} +; + +c_objects : OPEN_BRAC OBJECTS c_typed_consts CLOSE_BRAC {$$=$3;} +; + +c_initial_state : OPEN_BRAC INITIALLY c_init_els CLOSE_BRAC {$$=$3;} +; + +c_goals : GOALS {$$ = current_analysis->buildOpTab();} +; + +c_goal_spec : OPEN_BRAC c_goals c_pre_goal_descriptor CLOSE_BRAC {$$=$3;delete $2;} +; + +c_metric_spec : + OPEN_BRAC METRIC c_optimization c_ground_f_exp CLOSE_BRAC + { $$= new metric_spec($3,$4); } +| OPEN_BRAC METRIC error CLOSE_BRAC + {yyerrok; + log_error(E_FATAL,"Syntax error in metric declaration."); + $$= NULL; } +; + +c_length_spec : + OPEN_BRAC LENGTH SERIAL INTVAL PARALLEL INTVAL CLOSE_BRAC + {$$= new length_spec(E_BOTH,$4,$6);} +| + OPEN_BRAC LENGTH SERIAL INTVAL CLOSE_BRAC + {$$ = new length_spec(E_SERIAL,$4);} + +| + OPEN_BRAC LENGTH PARALLEL INTVAL CLOSE_BRAC + {$$ = new length_spec(E_PARALLEL,$4);} +; + + + +c_optimization : + MINIMIZE {$$= E_MINIMIZE;} +| MAXIMIZE {$$= E_MAXIMIZE;} +; + + +c_ground_f_exp : + OPEN_BRAC c_binary_ground_f_exp CLOSE_BRAC {$$= $2;} +| c_ground_f_head {$$= $1;} +| c_number {$$= $1;} +| TOTAL_TIME { $$= new special_val_expr(E_TOTAL_TIME); } +| OPEN_BRAC ISVIOLATED NAME CLOSE_BRAC + {$$ = new violation_term($3);} +| OPEN_BRAC TOTAL_TIME CLOSE_BRAC { $$= new special_val_expr(E_TOTAL_TIME); } +; + +c_binary_ground_f_exp : + PLUS c_ground_f_exp c_binary_ground_f_pexps { $$= new plus_expression($2,$3); } +| HYPHEN c_ground_f_exp c_ground_f_exp { $$= new minus_expression($2,$3); } +| MUL c_ground_f_exp c_binary_ground_f_mexps { $$= new mul_expression($2,$3); } +| DIV c_ground_f_exp c_ground_f_exp { $$= new div_expression($2,$3); } +; + +c_binary_ground_f_pexps : + c_ground_f_exp {$$ = $1;} +| c_ground_f_exp c_binary_ground_f_pexps + {$$ = new plus_expression($1,$2);} +; + +c_binary_ground_f_mexps : + c_ground_f_exp {$$ = $1;} +| c_ground_f_exp c_binary_ground_f_mexps + {$$ = new mul_expression($1,$2);} +; +// Plans + +c_plan : + c_step_t_d c_plan + {$$= $2; + $$->push_front($1); } +| TIME FLOATVAL c_plan + {$$ = $3;$$->insertTime($2);} +| TIME INTVAL c_plan + {$$ = $3;$$->insertTime($2);} +| /* empty */ + {$$= new plan;} +; + +c_step_t_d : + c_float COLON c_step_d + {$$=$3; + $$->start_time_given=1; + $$->start_time=$1;} +| c_step_d + {$$=$1; + $$->start_time_given=0;} +; + +c_step_d : + c_step OPEN_SQ c_float CLOSE_SQ + {$$= $1; + $$->duration_given=1; + $$->duration= $3;} +| c_step + {$$= $1; + $$->duration_given=0;} +; + +c_step : + OPEN_BRAC NAME c_const_symbols CLOSE_BRAC + {$$= new plan_step( + current_analysis->op_tab.symbol_get($2), + $3); delete [] $2; + } +; + +c_float : + FLOATVAL {$$= $1;} +| INTVAL {$$= (float) $1;} +; + +%% + +#include +#include +int line_no= 1; +using std::istream; +#include "lex.yy.cc" + +namespace VAL { +extern yyFlexLexer* yfl; +}; + + +int yyerror(char * s) +{ + return 0; +} + +int yylex() +{ + return yfl->yylex(); +} diff --git a/src/typecheck.cpp b/src/typecheck.cpp index 41df5ff..bca0535 100644 --- a/src/typecheck.cpp +++ b/src/typecheck.cpp @@ -24,824 +24,824 @@ * ************************************************************************/ -#include "typecheck.h" -#include "ptree.h" -#include -#include "main.h" -#include "Exceptions.h" -#include - -namespace VAL { - -void TypeHierarchy::addDown(const PTypeRef & t1,const PTypeRef & t2) -{ - GIC i = downGraph.find(&t1); - GIC j = downGraph.find(&t2); - if(i == downGraph.end()) - { - i = graph.find(&t1); - downGraph[i->first] = Nodes(); - }; - if(j == downGraph.end()) - { - j = graph.find(&t2); - downGraph[j->first] = Nodes(); - j = downGraph.find(&t2); - }; - downGraph[&t1].insert(j->first); -}; - -TypeHierarchy::TypeHierarchy(const analysis * a) : leafNodes() -{ - if(!a || !a->the_domain) - { - ParseFailure pf; - throw(pf); - }; - - if(!a->the_domain->types) return; - for(pddl_type_list::const_iterator i = a->the_domain->types->begin(); - i != a->the_domain->types->end();++i) - { - if((*i)->type) - { - add(PTypeRef(*i),PTypeRef((*i)->type)); - addDown(PTypeRef((*i)->type),PTypeRef(*i)); - } - else - { - if((*i)->either_types) - { - for(pddl_type_list::const_iterator j = (*i)->either_types->begin(); - j != (*i)->either_types->end();++j) - { - add(PTypeRef(*i),PTypeRef(*j)); - addDown(PTypeRef(*j),PTypeRef(*i)); - }; - } - else - { - PTypeRef pt(*i); - Graph::iterator j = graph.find(&pt); - if(j == graph.end()) - { - TypeRef * c = pt.clone(); - graph[c] = set(); - downGraph[c] = set(); - }; - }; - }; - }; -}; - -TypeHierarchy::~TypeHierarchy() -{ - for(Graph::const_iterator i = graph.begin();i != graph.end();++i) - { - delete (i->first); - }; -}; - - - - -/* gi is the Graph::iterator starting point aiming for t. - * vs are the places visited so far. - * gs is the original starting point. - */ - -bool TypeHierarchy::closure(Graph & gr,GI & gi,Nodes & vs,GI & gs,const TypeRef * t) -{ - if(gi == gr.end()) - { - return false; - }; - if(*(gi->first) == *t) - { - for(Nodes::const_iterator i = vs.begin();i != vs.end();++i) - { - gs->second.insert(*i); - //insert(vs.begin(),vs.end()); - }; - //gs->second.insert(vs.begin(),vs.end()); - return true; - }; - - for(Nodes::iterator n = gi->second.begin();n != gi->second.end();++n) - { - if(vs.find(*n) == vs.end()) - { - vs.insert(*n); - GI tmp = gr.find(*n); - if(closure(gr,tmp,vs,gs,t)) return true; - }; - }; - return false; -}; - -vector TypeChecker::leaves(const pddl_type * t) -{ - typedef set Nodes; - PTypeRef pt(t); - const Nodes & ns = th.leaves(pt); - vector vs(ns.size()); - - int j = 0; - for(Nodes::const_iterator i = ns.begin();i != ns.end();++i,++j) - { - vs[j] = ***i; - }; - - return vs; -}; - -bool TypeChecker::isLeafType(const pddl_type * t) -{ - typedef set Nodes; - PTypeRef pt(t); - return th.leaves(pt).empty(); -}; - -vector TypeChecker::accumulateAll(const pddl_type * t) -{ - return th.accumulateAll(t); -}; - -vector TypeHierarchy::accumulateAll(const pddl_type * t) -{ - vector nds(1,t); - PTypeRef tt(t); - GI gi = downGraph.find(&tt); - if(gi == downGraph.end()) return nds; - Nodes ns; - PTypeRef pt(0); - closure(downGraph,gi,ns,gi,&pt); - for(Nodes::const_iterator i = ns.begin();i != ns.end();++i) - { - nds.push_back(***i); - }; - return nds; -}; - -const set & TypeHierarchy::leaves(PTypeRef & t) -{ - static Nodes empty; - - GI gi = leafNodes.find(&t); - if(gi != leafNodes.end()) - { - return (gi->second); - }; - - gi = downGraph.find(&t); - if(gi == downGraph.end()) return empty; - Nodes ns; - PTypeRef pt(0); - closure(downGraph,gi,ns,gi,&pt); - Nodes ms; - for(Nodes::const_iterator i = ns.begin();i != ns.end();++i) - { - Nodes xs; - gi = downGraph.find(*i); - closure(downGraph,gi,xs,gi,&pt); - if(xs.empty()) ms.insert(*i); - }; - leafNodes[downGraph.find(&t)->first] = ms; - return leafNodes[downGraph.find(&t)->first]; -}; - -void UTypeRef::addContents(TypeHierarchy * th) const -{ - for(std::set::const_iterator i = pts.begin(); - i != pts.end();++i) - { - th->add(PTypeRef(*i),*this); - }; -}; - -bool TypeHierarchy::reachable(const TypeRef & t1,const TypeRef & t2) -{ - if(t1 == t2) return true; - - Graph::iterator i = graph.find(&t1); - if(i == graph.end()) - { - return false; - }; - - Graph::const_iterator j = graph.find(&t2); - if(j == graph.end() && t2.expected()) - { - return false; - }; - t2.addContents(this); - j = graph.find(&t2); - - if(i->second.find(j->first) != i->second.end()) return true; - - Nodes ns; - return closure(graph,i,ns,i,j->first); -}; - -void TypeHierarchy::add(const PTypeRef & t1,const TypeRef & t2) -{ - Graph::const_iterator i = graph.find(&t1); - Graph::const_iterator j = graph.find(&t2); - if(j == graph.end()) - { - TypeRef * c = t2.clone(); - graph[c] = set(); - j = graph.find(&t2); - }; - if(i == graph.end()) - { - TypeRef * c = t1.clone(); - graph[c] = set(); - }; - graph[&t1].insert(j->first); -}; - -struct badchecker { - TypeChecker * thea; - - badchecker(TypeChecker * a) : thea(a) {}; - - bool operator() (const operator_ * a) const - { - return !thea->typecheckAction(a); - }; - bool operator() (const goal * g) const - { - return !thea->typecheckGoal(g); - }; - bool operator() (const plan_step * p) - { - return !thea->typecheckActionInstance(p); - }; - bool operator() (const effect * e) - { - return !thea->typecheckEffect(e); - }; - bool operator() (const derivation_rule * d) - { - return !thea->typecheckDerivationRule(d); - }; -}; - - -struct matchFunc { - const func_symbol * f; - - matchFunc(const func_symbol * fs) : f(fs) {}; - - bool operator() (const func_decl * fd) const - { - if(!fd) - { - if(Verbose) *report << "Problematic function declaration!\n"; - ParseFailure pe; - throw(pe); - }; - const func_symbol * fdf = fd->getFunction(); - if(!fdf) - { - if(Verbose) *report << *fd << " problematic function declaration!\n"; - ParseFailure pe; - throw(pe); - }; - - return f == fdf; - }; -}; - -struct matchPred { - const pred_symbol * p; - - matchPred(const pred_symbol * ps) : p(ps) {}; - - bool operator() (const pred_decl * pd) const - { - return p == pd->getPred(); - }; -}; - -struct matchOp { - const operator_symbol * f; - - matchOp(const operator_symbol * fs) : f(fs) {}; - - bool operator() (const operator_ * op) const - { - return f == op->name; - }; -}; - -/* What does it all mean? - * - * Let c be a constant symbol, v a variable symbol and t be a type symbol. - * - * t1 - t2 means t1 is a subset of t2. - * We allow multiple subset relations (multiple inheritance). - * c - t means c is a member of t. - * v - t means instantiations of v must be of type t. - * - * Therefore, subType(c - t1,v - t2) iff t1 - t2. Note that this relationship might - * be via a path of transitive subset relations. - * - * v - (either t1 t2) is equivalent to v - (t1 U t2). - * c - (either t1 t2) is not given a meaning, but we use the either field to record - * multiple types for constants. Thus, c - t1 and c - t2 is legal - * and is recorded internally using c - (either t1 t2). The meaning - * of the multiple declarations is that c is of both types t1 and t2, - * so can be substituted for any variable of either type. - * t - (either t1 t2) is also not given a meaning (although the current parser will - * actually interpret it as equivalent to "t - t1 t - t2"). - */ - - -bool TypeChecker::subType(const pddl_typed_symbol * tp1,const pddl_typed_symbol * tp2) -{ - if(!isTyped) return true; - if(tp1->type) - { - if(tp2->type) - { - return th.reachable(PTypeRef(tp1->type),PTypeRef(tp2->type)); - } - else - { - if(tp2->either_types) - { - return th.reachable(PTypeRef(tp1->type),UTypeRef(tp2->either_types)); - }; - if(Verbose) *report << tp2->getName() << " has bad type definition\n"; - TypeException te; - throw(te); - }; - } - else - { - if(!tp1->either_types) - { - if(Verbose) *report << "Object with unknown type: " << tp1->getName() << "\n"; - TypeException te; - throw(te); - }; - - // The situation is now complicated by the fact that variables and constants - // must be treated differently. Constants have either types representing - // conjunctions of types, while variables use them for disjunctions. - - if(!tp1->either_types) - { - if(Verbose) *report << tp1->getName() << " badly typed!\n"; - TypeException te; - throw(te); - }; - - if(dynamic_cast(tp1)) - { - // The following confirms that a constant is a subtype of a given type by - // checking that one of its types is appropriate. - - - for(pddl_type_list::const_iterator i = tp1->either_types->begin(); - i != tp1->either_types->end();++i) - { - if(subType(*i,tp2)) return true; - }; - return false; - } - else - { - - for(pddl_type_list::const_iterator i = tp1->either_types->begin(); - i != tp1->either_types->end();++i) - { - if(!subType(*i,tp2)) return false; - }; - return true; - }; - }; -}; - -bool TypeChecker::subType(const pddl_type * t,const pddl_typed_symbol * s) -{ - if(!isTyped) return true; - if(s->type) - { - return th.reachable(PTypeRef(t),PTypeRef(s->type)); - }; - - if(!s->either_types) - { - if(Verbose) *report << s->getName() << " badly typed!\n"; - TypeException te; - throw(te); - }; - - return th.reachable(PTypeRef(t),UTypeRef(s->either_types)); -}; - -bool TypeChecker::subType(const pddl_type * t1,const pddl_type * t2) -{ - if(!isTyped) return true; - - if(!t1 || !t2) - { - TypeException te; - throw(te); - }; - - return th.reachable(PTypeRef(t1),PTypeRef(t2)); -}; - -bool TypeChecker::typecheckProposition(const proposition * p) -{ - if(!isTyped || !thea->the_domain->predicates) return true; - pred_decl_list::const_iterator prd = - std::find_if(thea->the_domain->predicates->begin(),thea->the_domain->predicates->end(), - matchPred(p->head)); - if(prd==thea->the_domain->predicates->end()) - { - if(p->head->getName()=="=") return true; - if(Verbose) *report << "Predicate " << p->head->getName() << " not found\n"; - return false; - }; - int idx = 1; - - var_symbol_list::const_iterator arg = (*prd)->getArgs()->begin(); - const var_symbol_list::const_iterator argEnd = (*prd)->getArgs()->end(); - - parameter_symbol_list::const_iterator i = p->args->begin(); - const parameter_symbol_list::const_iterator e = p->args->end(); - - for(;i != e && arg != argEnd;++i,++arg,++idx) - { - if(!subType(*i,*arg)) - { - if(Verbose) { - *report << "Type problem with proposition ("; - *report << p->head->getName(); - parameter_symbol_list::const_iterator it = p->args->begin(); - parameter_symbol_list::const_iterator et = p->args->end(); - for(;it != et;++it) { - *report << " " << (*it)->getName(); - } - *report << ") - parameter " << idx << " is incorrectly typed\n"; - } - return false; - }; - }; - if (i != e) { - if(Verbose) { - *report << "Problem with proposition ("; - *report << p->head->getName(); - parameter_symbol_list::const_iterator it = p->args->begin(); - parameter_symbol_list::const_iterator et = p->args->end(); - for(;it != et;++it) { - *report << " " << (*it)->getName(); - } - *report << ") - too many parameters\n"; - } - return false; - } - - if (arg != argEnd) { - if(Verbose) { - *report << "Problem with proposition ("; - *report << p->head->getName(); - parameter_symbol_list::const_iterator it = p->args->begin(); - parameter_symbol_list::const_iterator et = p->args->end(); - for(;it != et;++it) { - *report << " " << (*it)->getName(); - } - *report << ") - too few parameters\n"; - } - return false; - } - - return true; -}; - -bool TypeChecker::typecheckFuncTerm(const func_term * ft) -{ - if(!isTyped) return true; - func_decl_list::const_iterator fd = - std::find_if(thea->the_domain->functions->begin(),thea->the_domain->functions->end(), - matchFunc(ft->getFunction())); - if(fd==thea->the_domain->functions->end()) - return false; - var_symbol_list::const_iterator arg = (*fd)->getArgs()->begin(); - const var_symbol_list::const_iterator argEnd = (*fd)->getArgs()->end(); - parameter_symbol_list::const_iterator i = ft->getArgs()->begin(); - const parameter_symbol_list::const_iterator e = ft->getArgs()->end(); - int idx = 1; - for(; i != e && arg != argEnd;++i,++arg,++idx) - { - if(!subType(*i,*arg)) - { - if(Verbose) { - *report << "Type problem with function term ("; - *report << ft->getFunction()->getName(); - parameter_symbol_list::const_iterator it = ft->getArgs()->begin(); - parameter_symbol_list::const_iterator et = ft->getArgs()->end(); - for(;it != et;++it) { - *report << " " << (*it)->getName(); - } - *report << ") - parameter " << idx << " is incorrectly typed\n"; - } - return false; - }; - }; - if (arg != argEnd) { - if(Verbose) { - *report << "Problem with function term ("; - *report << ft->getFunction()->getName(); - parameter_symbol_list::const_iterator it = ft->getArgs()->begin(); - parameter_symbol_list::const_iterator et = ft->getArgs()->end(); - for(;it != et;++it) { - *report << " " << (*it)->getName(); - } - *report << ") - too few parameters\n"; - } - } - if (i != e) { - if(Verbose) { - *report << "Problem with function term ("; - *report << ft->getFunction()->getName(); - parameter_symbol_list::const_iterator it = ft->getArgs()->begin(); - parameter_symbol_list::const_iterator et = ft->getArgs()->end(); - for(;it != et;++it) { - *report << " " << (*it)->getName(); - } - *report << ") - too many parameters\n"; - } - } - - return true; -}; - -bool TypeChecker::typecheckActionInstance(const plan_step * p) -{ - if(!isTyped) return true; - operator_list::const_iterator op = - std::find_if(thea->the_domain->ops->begin(),thea->the_domain->ops->end(), - matchOp(p->op_sym)); - if(op==thea->the_domain->ops->end()) - return false; - var_symbol_list::const_iterator arg = (*op)->parameters->begin(); - const_symbol_list::const_iterator e = p->params->end(); - for(const_symbol_list::const_iterator i = p->params->begin(); - i != e;++i,++arg) - { - if(!subType(*i,*arg)) - { - if(Verbose) *report << "Type problem in action " << *p << "\n"; - return false; - }; - }; - return true; -}; - -bool TypeChecker::typecheckExpression(const expression * exp) -{ - if(!isTyped) return true; - if(const binary_expression * be = dynamic_cast(exp)) - { - return typecheckExpression(be->getLHS()) && typecheckExpression(be->getRHS()); - }; - if(const uminus_expression * ue = dynamic_cast(exp)) - { - return typecheckExpression(ue->getExpr()); - }; - if(const func_term * ft = dynamic_cast(exp)) - { - return typecheckFuncTerm(ft); - }; - return true; -}; - - -bool TypeChecker::typecheckGoal(const goal * g) -{ - if(!isTyped) return true; - if(const preference * p = dynamic_cast(g)) - { - return typecheckGoal(p->getGoal()); - }; - if(const constraint_goal * cg = dynamic_cast(g)) - { - bool b1 = true; - if(cg->getTrigger()) - { - b1 = typecheckGoal(cg->getTrigger()); - }; - return b1 && typecheckGoal(cg->getRequirement()); - }; - if(const simple_goal * sg = dynamic_cast(g)) - { - return typecheckProposition(sg->getProp()); - }; - if(const conj_goal * cg = dynamic_cast(g)) - { - if(cg->getGoals()->end() == std::find_if(cg->getGoals()->begin(),cg->getGoals()->end(),badchecker(this))) - return true; - return false; - }; - if(const disj_goal * dg = dynamic_cast(g)) - { - if(dg->getGoals()->end() == std::find_if(dg->getGoals()->begin(),dg->getGoals()->end(),badchecker(this))) - return true; - return false; - }; - if(const imply_goal * ig = dynamic_cast(g)) - { - return typecheckGoal(ig->getAntecedent()) && typecheckGoal(ig->getConsequent()); - }; - if(const neg_goal * ng = dynamic_cast(g)) - { - return typecheckGoal(ng->getGoal()); - }; - if(const timed_goal * tg = dynamic_cast(g)) - { - return typecheckGoal(tg->getGoal()); - }; - if(const qfied_goal * qg = dynamic_cast(g)) - { - return typecheckGoal(qg->getGoal()); - }; - if(const comparison * c = dynamic_cast(g)) - { - return typecheckExpression(c->getLHS()) && typecheckExpression(c->getRHS()); - }; - if(const constraint_goal * cg = dynamic_cast(g)) - { - return (!cg->getRequirement() || typecheckGoal(cg->getRequirement())) && - (!cg->getTrigger() || typecheckGoal(cg->getTrigger())); - }; - return false; -}; - -bool TypeChecker::typecheckEffect(const effect * e) -{ - if(!isTyped) return true; - if(const simple_effect * se = dynamic_cast(e)) - { - return typecheckProposition(se->prop); - }; - if(const cond_effect * ce = dynamic_cast(e)) - { - return typecheckGoal(ce->getCondition()) && - typecheckEffects(ce->getEffects()); - }; - if(const forall_effect * fe = dynamic_cast(e)) - { - return typecheckEffects(fe->getEffects()); - }; - if(const timed_effect * te = dynamic_cast(e)) - { - return typecheckEffects(te->effs); - }; - if(const assignment * ass = dynamic_cast(e)) - { - return typecheckFuncTerm(ass->getFTerm()) && typecheckExpression(ass->getExpr()); - }; - return false; -}; - -bool TypeChecker::typecheckEffects(const effect_lists * es) -{ - if(!isTyped) return true; - return - (es->add_effects.end() == std::find_if(es->add_effects.begin(),es->add_effects.end(),badchecker(this))) - && - (es->del_effects.end() == std::find_if(es->del_effects.begin(),es->del_effects.end(),badchecker(this))) - && - (es->forall_effects.end() == std::find_if(es->forall_effects.begin(),es->forall_effects.end(),badchecker(this))) - && - (es->cond_effects.end() == std::find_if(es->cond_effects.begin(),es->cond_effects.end(),badchecker(this))) - && - (es->assign_effects.end() == std::find_if(es->assign_effects.begin(),es->assign_effects.end(),badchecker(this))) - && - (es->timed_effects.end() == std::find_if(es->timed_effects.begin(),es->timed_effects.end(),badchecker(this))); -}; - -bool TypeChecker::typecheckAction(const operator_ * act) -{ - if(!isTyped) return true; - if(Verbose) *report << "Type-checking " << act->name->getName() << "\n"; - if(!typecheckGoal(act->precondition)) { - if(Verbose) *report << "Conditions fail type-checking.\n"; - return false; - } - if(!typecheckEffects(act->effects)) { - if(Verbose) *report << "Effects fail type-checking.\n"; - return false; - } - if(const durative_action * da = dynamic_cast(act)) - { - if (!typecheckGoal(da->dur_constraint)) { - if(Verbose) *report << "Duration constraint fails type-checking.\n"; - return false; - }; - }; - if(Verbose) *report << "...action passes type checking.\n"; - return true; -}; - -bool TypeChecker::typecheckDerivationRule(const derivation_rule * d) -{ - if(!isTyped) return true; - if(Verbose) *report << "Type-checking derivation rule for " << (d->get_head()->head->getName()) << "\n"; - pred_decl_list::iterator i = thea->the_domain->predicates->begin(); - for(;i != thea->the_domain->predicates->end();++i) - { - if((*i)->getPred()==d->get_head()->head) - { - (*i)->setTypes(d->get_head()); - break; - }; - }; - return i != thea->the_domain->predicates->end() && typecheckGoal(d->get_body()); -}; - -bool TypeChecker::typecheckDomain() -{ - if(!isTyped) return true; - return thea->the_domain->ops->end() == - std::find_if(thea->the_domain->ops->begin(), - thea->the_domain->ops->end(),badchecker(this)) - && - thea->the_domain->drvs->end() == - std::find_if(thea->the_domain->drvs->begin(), - thea->the_domain->drvs->end(),badchecker(this)) - && - (!thea->the_domain->constraints || - typecheckGoal(thea->the_domain->constraints)); -}; - -bool TypeChecker::typecheckProblem() -{ - if(!isTyped) return true; - if(!thea || !thea->the_problem) - { - ParseFailure pf; - throw(pf); - }; - if (thea->the_problem->the_goal && !typecheckGoal(thea->the_problem->the_goal)) { - if (Verbose) *report << "Type-checking goal failed\n"; - return false; - } - if (!typecheckEffects(thea->the_problem->initial_state)) { - if (Verbose) *report << "Type-checking initial state failed\n"; - return false; - } - if (thea->the_problem->constraints && !typecheckGoal(thea->the_problem->constraints)) { - if (Verbose) *report << "Type-checking constraints failed\n"; - return false; - } - return true; -}; - -bool TypeChecker::typecheckPlan(const plan * p) -{ - if(!isTyped) return true; - return p->end() == std::find_if(p->begin(),p->end(),badchecker(this)); -}; - -vector TypeChecker::range(const var_symbol * v) -{ - vector l; - for(const_symbol_table::const_iterator i = thea->const_tab.begin(); - i != thea->const_tab.end();++i) - { - if(subType(i->second,v)) l.push_back(i->second); - }; - - return l; -}; - -vector TypeChecker::range(const parameter_symbol * v) -{ - vector l; - for(const_symbol_table::const_iterator i = thea->const_tab.begin(); - i != thea->const_tab.end();++i) - { - if(subType(i->second,v)) l.push_back(i->second); - }; - - return l; -}; - - -vector TypeChecker::range(const pddl_type * t) -{ - var_symbol v(""); - v.type = const_cast(t); // OK - we will keep v const. - v.either_types = 0; - return range(&v); -}; - - -}; +#include "typecheck.h" +#include "ptree.h" +#include +#include "main.h" +#include "Exceptions.h" +#include + +namespace VAL { + +void TypeHierarchy::addDown(const PTypeRef & t1,const PTypeRef & t2) +{ + GIC i = downGraph.find(&t1); + GIC j = downGraph.find(&t2); + if(i == downGraph.end()) + { + i = graph.find(&t1); + downGraph[i->first] = Nodes(); + }; + if(j == downGraph.end()) + { + j = graph.find(&t2); + downGraph[j->first] = Nodes(); + j = downGraph.find(&t2); + }; + downGraph[&t1].insert(j->first); +}; + +TypeHierarchy::TypeHierarchy(const analysis * a) : leafNodes() +{ + if(!a || !a->the_domain) + { + ParseFailure pf; + throw(pf); + }; + + if(!a->the_domain->types) return; + for(pddl_type_list::const_iterator i = a->the_domain->types->begin(); + i != a->the_domain->types->end();++i) + { + if((*i)->type) + { + add(PTypeRef(*i),PTypeRef((*i)->type)); + addDown(PTypeRef((*i)->type),PTypeRef(*i)); + } + else + { + if((*i)->either_types) + { + for(pddl_type_list::const_iterator j = (*i)->either_types->begin(); + j != (*i)->either_types->end();++j) + { + add(PTypeRef(*i),PTypeRef(*j)); + addDown(PTypeRef(*j),PTypeRef(*i)); + }; + } + else + { + PTypeRef pt(*i); + Graph::iterator j = graph.find(&pt); + if(j == graph.end()) + { + TypeRef * c = pt.clone(); + graph[c] = set(); + downGraph[c] = set(); + }; + }; + }; + }; +}; + +TypeHierarchy::~TypeHierarchy() +{ + for(Graph::const_iterator i = graph.begin();i != graph.end();++i) + { + delete (i->first); + }; +}; + + + + +/* gi is the Graph::iterator starting point aiming for t. + * vs are the places visited so far. + * gs is the original starting point. + */ + +bool TypeHierarchy::closure(Graph & gr,GI & gi,Nodes & vs,GI & gs,const TypeRef * t) +{ + if(gi == gr.end()) + { + return false; + }; + if(*(gi->first) == *t) + { + for(Nodes::const_iterator i = vs.begin();i != vs.end();++i) + { + gs->second.insert(*i); + //insert(vs.begin(),vs.end()); + }; + //gs->second.insert(vs.begin(),vs.end()); + return true; + }; + + for(Nodes::iterator n = gi->second.begin();n != gi->second.end();++n) + { + if(vs.find(*n) == vs.end()) + { + vs.insert(*n); + GI tmp = gr.find(*n); + if(closure(gr,tmp,vs,gs,t)) return true; + }; + }; + return false; +}; + +vector TypeChecker::leaves(const pddl_type * t) +{ + typedef set Nodes; + PTypeRef pt(t); + const Nodes & ns = th.leaves(pt); + vector vs(ns.size()); + + int j = 0; + for(Nodes::const_iterator i = ns.begin();i != ns.end();++i,++j) + { + vs[j] = ***i; + }; + + return vs; +}; + +bool TypeChecker::isLeafType(const pddl_type * t) +{ + //typedef set Nodes; + PTypeRef pt(t); + return th.leaves(pt).empty(); +}; + +vector TypeChecker::accumulateAll(const pddl_type * t) +{ + return th.accumulateAll(t); +}; + +vector TypeHierarchy::accumulateAll(const pddl_type * t) +{ + vector nds(1,t); + PTypeRef tt(t); + GI gi = downGraph.find(&tt); + if(gi == downGraph.end()) return nds; + Nodes ns; + PTypeRef pt(0); + closure(downGraph,gi,ns,gi,&pt); + for(Nodes::const_iterator i = ns.begin();i != ns.end();++i) + { + nds.push_back(***i); + }; + return nds; +}; + +const set & TypeHierarchy::leaves(PTypeRef & t) +{ + static Nodes empty; + + GI gi = leafNodes.find(&t); + if(gi != leafNodes.end()) + { + return (gi->second); + }; + + gi = downGraph.find(&t); + if(gi == downGraph.end()) return empty; + Nodes ns; + PTypeRef pt(0); + closure(downGraph,gi,ns,gi,&pt); + Nodes ms; + for(Nodes::const_iterator i = ns.begin();i != ns.end();++i) + { + Nodes xs; + gi = downGraph.find(*i); + closure(downGraph,gi,xs,gi,&pt); + if(xs.empty()) ms.insert(*i); + }; + leafNodes[downGraph.find(&t)->first] = ms; + return leafNodes[downGraph.find(&t)->first]; +}; + +void UTypeRef::addContents(TypeHierarchy * th) const +{ + for(std::set::const_iterator i = pts.begin(); + i != pts.end();++i) + { + th->add(PTypeRef(*i),*this); + }; +}; + +bool TypeHierarchy::reachable(const TypeRef & t1,const TypeRef & t2) +{ + if(t1 == t2) return true; + + Graph::iterator i = graph.find(&t1); + if(i == graph.end()) + { + return false; + }; + + Graph::const_iterator j = graph.find(&t2); + if(j == graph.end() && t2.expected()) + { + return false; + }; + t2.addContents(this); + j = graph.find(&t2); + + if(i->second.find(j->first) != i->second.end()) return true; + + Nodes ns; + return closure(graph,i,ns,i,j->first); +}; + +void TypeHierarchy::add(const PTypeRef & t1,const TypeRef & t2) +{ + Graph::const_iterator i = graph.find(&t1); + Graph::const_iterator j = graph.find(&t2); + if(j == graph.end()) + { + TypeRef * c = t2.clone(); + graph[c] = set(); + j = graph.find(&t2); + }; + if(i == graph.end()) + { + TypeRef * c = t1.clone(); + graph[c] = set(); + }; + graph[&t1].insert(j->first); +}; + +struct badchecker { + TypeChecker * thea; + + badchecker(TypeChecker * a) : thea(a) {}; + + bool operator() (const operator_ * a) const + { + return !thea->typecheckAction(a); + }; + bool operator() (const goal * g) const + { + return !thea->typecheckGoal(g); + }; + bool operator() (const plan_step * p) + { + return !thea->typecheckActionInstance(p); + }; + bool operator() (const effect * e) + { + return !thea->typecheckEffect(e); + }; + bool operator() (const derivation_rule * d) + { + return !thea->typecheckDerivationRule(d); + }; +}; + + +struct matchFunc { + const func_symbol * f; + + matchFunc(const func_symbol * fs) : f(fs) {}; + + bool operator() (const func_decl * fd) const + { + if(!fd) + { + if(Verbose) *report << "Problematic function declaration!\n"; + ParseFailure pe; + throw(pe); + }; + const func_symbol * fdf = fd->getFunction(); + if(!fdf) + { + if(Verbose) *report << *fd << " problematic function declaration!\n"; + ParseFailure pe; + throw(pe); + }; + + return f == fdf; + }; +}; + +struct matchPred { + const pred_symbol * p; + + matchPred(const pred_symbol * ps) : p(ps) {}; + + bool operator() (const pred_decl * pd) const + { + return p == pd->getPred(); + }; +}; + +struct matchOp { + const operator_symbol * f; + + matchOp(const operator_symbol * fs) : f(fs) {}; + + bool operator() (const operator_ * op) const + { + return f == op->name; + }; +}; + +/* What does it all mean? + * + * Let c be a constant symbol, v a variable symbol and t be a type symbol. + * + * t1 - t2 means t1 is a subset of t2. + * We allow multiple subset relations (multiple inheritance). + * c - t means c is a member of t. + * v - t means instantiations of v must be of type t. + * + * Therefore, subType(c - t1,v - t2) iff t1 - t2. Note that this relationship might + * be via a path of transitive subset relations. + * + * v - (either t1 t2) is equivalent to v - (t1 U t2). + * c - (either t1 t2) is not given a meaning, but we use the either field to record + * multiple types for constants. Thus, c - t1 and c - t2 is legal + * and is recorded internally using c - (either t1 t2). The meaning + * of the multiple declarations is that c is of both types t1 and t2, + * so can be substituted for any variable of either type. + * t - (either t1 t2) is also not given a meaning (although the current parser will + * actually interpret it as equivalent to "t - t1 t - t2"). + */ + + +bool TypeChecker::subType(const pddl_typed_symbol * tp1,const pddl_typed_symbol * tp2) +{ + if(!isTyped) return true; + if(tp1->type) + { + if(tp2->type) + { + return th.reachable(PTypeRef(tp1->type),PTypeRef(tp2->type)); + } + else + { + if(tp2->either_types) + { + return th.reachable(PTypeRef(tp1->type),UTypeRef(tp2->either_types)); + }; + if(Verbose) *report << tp2->getName() << " has bad type definition\n"; + TypeException te; + throw(te); + }; + } + else + { + if(!tp1->either_types) + { + if(Verbose) *report << "Object with unknown type: " << tp1->getName() << "\n"; + TypeException te; + throw(te); + }; + + // The situation is now complicated by the fact that variables and constants + // must be treated differently. Constants have either types representing + // conjunctions of types, while variables use them for disjunctions. + + if(!tp1->either_types) + { + if(Verbose) *report << tp1->getName() << " badly typed!\n"; + TypeException te; + throw(te); + }; + + if(dynamic_cast(tp1)) + { + // The following confirms that a constant is a subtype of a given type by + // checking that one of its types is appropriate. + + + for(pddl_type_list::const_iterator i = tp1->either_types->begin(); + i != tp1->either_types->end();++i) + { + if(subType(*i,tp2)) return true; + }; + return false; + } + else + { + + for(pddl_type_list::const_iterator i = tp1->either_types->begin(); + i != tp1->either_types->end();++i) + { + if(!subType(*i,tp2)) return false; + }; + return true; + }; + }; +}; + +bool TypeChecker::subType(const pddl_type * t,const pddl_typed_symbol * s) +{ + if(!isTyped) return true; + if(s->type) + { + return th.reachable(PTypeRef(t),PTypeRef(s->type)); + }; + + if(!s->either_types) + { + if(Verbose) *report << s->getName() << " badly typed!\n"; + TypeException te; + throw(te); + }; + + return th.reachable(PTypeRef(t),UTypeRef(s->either_types)); +}; + +bool TypeChecker::subType(const pddl_type * t1,const pddl_type * t2) +{ + if(!isTyped) return true; + + if(!t1 || !t2) + { + TypeException te; + throw(te); + }; + + return th.reachable(PTypeRef(t1),PTypeRef(t2)); +}; + +bool TypeChecker::typecheckProposition(const proposition * p) +{ + if(!isTyped || !thea->the_domain->predicates) return true; + pred_decl_list::const_iterator prd = + std::find_if(thea->the_domain->predicates->begin(),thea->the_domain->predicates->end(), + matchPred(p->head)); + if(prd==thea->the_domain->predicates->end()) + { + if(p->head->getName()=="=") return true; + if(Verbose) *report << "Predicate " << p->head->getName() << " not found\n"; + return false; + }; + int idx = 1; + + var_symbol_list::const_iterator arg = (*prd)->getArgs()->begin(); + const var_symbol_list::const_iterator argEnd = (*prd)->getArgs()->end(); + + parameter_symbol_list::const_iterator i = p->args->begin(); + const parameter_symbol_list::const_iterator e = p->args->end(); + + for(;i != e && arg != argEnd;++i,++arg,++idx) + { + if(!subType(*i,*arg)) + { + if(Verbose) { + *report << "Type problem with proposition ("; + *report << p->head->getName(); + parameter_symbol_list::const_iterator it = p->args->begin(); + parameter_symbol_list::const_iterator et = p->args->end(); + for(;it != et;++it) { + *report << " " << (*it)->getName(); + } + *report << ") - parameter " << idx << " is incorrectly typed\n"; + } + return false; + }; + }; + if (i != e) { + if(Verbose) { + *report << "Problem with proposition ("; + *report << p->head->getName(); + parameter_symbol_list::const_iterator it = p->args->begin(); + parameter_symbol_list::const_iterator et = p->args->end(); + for(;it != et;++it) { + *report << " " << (*it)->getName(); + } + *report << ") - too many parameters\n"; + } + return false; + } + + if (arg != argEnd) { + if(Verbose) { + *report << "Problem with proposition ("; + *report << p->head->getName(); + parameter_symbol_list::const_iterator it = p->args->begin(); + parameter_symbol_list::const_iterator et = p->args->end(); + for(;it != et;++it) { + *report << " " << (*it)->getName(); + } + *report << ") - too few parameters\n"; + } + return false; + } + + return true; +}; + +bool TypeChecker::typecheckFuncTerm(const func_term * ft) +{ + if(!isTyped) return true; + func_decl_list::const_iterator fd = + std::find_if(thea->the_domain->functions->begin(),thea->the_domain->functions->end(), + matchFunc(ft->getFunction())); + if(fd==thea->the_domain->functions->end()) + return false; + var_symbol_list::const_iterator arg = (*fd)->getArgs()->begin(); + const var_symbol_list::const_iterator argEnd = (*fd)->getArgs()->end(); + parameter_symbol_list::const_iterator i = ft->getArgs()->begin(); + const parameter_symbol_list::const_iterator e = ft->getArgs()->end(); + int idx = 1; + for(; i != e && arg != argEnd;++i,++arg,++idx) + { + if(!subType(*i,*arg)) + { + if(Verbose) { + *report << "Type problem with function term ("; + *report << ft->getFunction()->getName(); + parameter_symbol_list::const_iterator it = ft->getArgs()->begin(); + parameter_symbol_list::const_iterator et = ft->getArgs()->end(); + for(;it != et;++it) { + *report << " " << (*it)->getName(); + } + *report << ") - parameter " << idx << " is incorrectly typed\n"; + } + return false; + }; + }; + if (arg != argEnd) { + if(Verbose) { + *report << "Problem with function term ("; + *report << ft->getFunction()->getName(); + parameter_symbol_list::const_iterator it = ft->getArgs()->begin(); + parameter_symbol_list::const_iterator et = ft->getArgs()->end(); + for(;it != et;++it) { + *report << " " << (*it)->getName(); + } + *report << ") - too few parameters\n"; + } + } + if (i != e) { + if(Verbose) { + *report << "Problem with function term ("; + *report << ft->getFunction()->getName(); + parameter_symbol_list::const_iterator it = ft->getArgs()->begin(); + parameter_symbol_list::const_iterator et = ft->getArgs()->end(); + for(;it != et;++it) { + *report << " " << (*it)->getName(); + } + *report << ") - too many parameters\n"; + } + } + + return true; +}; + +bool TypeChecker::typecheckActionInstance(const plan_step * p) +{ + if(!isTyped) return true; + operator_list::const_iterator op = + std::find_if(thea->the_domain->ops->begin(),thea->the_domain->ops->end(), + matchOp(p->op_sym)); + if(op==thea->the_domain->ops->end()) + return false; + var_symbol_list::const_iterator arg = (*op)->parameters->begin(); + const_symbol_list::const_iterator e = p->params->end(); + for(const_symbol_list::const_iterator i = p->params->begin(); + i != e;++i,++arg) + { + if(!subType(*i,*arg)) + { + if(Verbose) *report << "Type problem in action " << *p << "\n"; + return false; + }; + }; + return true; +}; + +bool TypeChecker::typecheckExpression(const expression * exp) +{ + if(!isTyped) return true; + if(const binary_expression * be = dynamic_cast(exp)) + { + return typecheckExpression(be->getLHS()) && typecheckExpression(be->getRHS()); + }; + if(const uminus_expression * ue = dynamic_cast(exp)) + { + return typecheckExpression(ue->getExpr()); + }; + if(const func_term * ft = dynamic_cast(exp)) + { + return typecheckFuncTerm(ft); + }; + return true; +}; + + +bool TypeChecker::typecheckGoal(const goal * g) +{ + if(!isTyped) return true; + if(const preference * p = dynamic_cast(g)) + { + return typecheckGoal(p->getGoal()); + }; + if(const constraint_goal * cg = dynamic_cast(g)) + { + bool b1 = true; + if(cg->getTrigger()) + { + b1 = typecheckGoal(cg->getTrigger()); + }; + return b1 && typecheckGoal(cg->getRequirement()); + }; + if(const simple_goal * sg = dynamic_cast(g)) + { + return typecheckProposition(sg->getProp()); + }; + if(const conj_goal * cg = dynamic_cast(g)) + { + if(cg->getGoals()->end() == std::find_if(cg->getGoals()->begin(),cg->getGoals()->end(),badchecker(this))) + return true; + return false; + }; + if(const disj_goal * dg = dynamic_cast(g)) + { + if(dg->getGoals()->end() == std::find_if(dg->getGoals()->begin(),dg->getGoals()->end(),badchecker(this))) + return true; + return false; + }; + if(const imply_goal * ig = dynamic_cast(g)) + { + return typecheckGoal(ig->getAntecedent()) && typecheckGoal(ig->getConsequent()); + }; + if(const neg_goal * ng = dynamic_cast(g)) + { + return typecheckGoal(ng->getGoal()); + }; + if(const timed_goal * tg = dynamic_cast(g)) + { + return typecheckGoal(tg->getGoal()); + }; + if(const qfied_goal * qg = dynamic_cast(g)) + { + return typecheckGoal(qg->getGoal()); + }; + if(const comparison * c = dynamic_cast(g)) + { + return typecheckExpression(c->getLHS()) && typecheckExpression(c->getRHS()); + }; + if(const constraint_goal * cg = dynamic_cast(g)) + { + return (!cg->getRequirement() || typecheckGoal(cg->getRequirement())) && + (!cg->getTrigger() || typecheckGoal(cg->getTrigger())); + }; + return false; +}; + +bool TypeChecker::typecheckEffect(const effect * e) +{ + if(!isTyped) return true; + if(const simple_effect * se = dynamic_cast(e)) + { + return typecheckProposition(se->prop); + }; + if(const cond_effect * ce = dynamic_cast(e)) + { + return typecheckGoal(ce->getCondition()) && + typecheckEffects(ce->getEffects()); + }; + if(const forall_effect * fe = dynamic_cast(e)) + { + return typecheckEffects(fe->getEffects()); + }; + if(const timed_effect * te = dynamic_cast(e)) + { + return typecheckEffects(te->effs); + }; + if(const assignment * ass = dynamic_cast(e)) + { + return typecheckFuncTerm(ass->getFTerm()) && typecheckExpression(ass->getExpr()); + }; + return false; +}; + +bool TypeChecker::typecheckEffects(const effect_lists * es) +{ + if(!isTyped) return true; + return + (es->add_effects.end() == std::find_if(es->add_effects.begin(),es->add_effects.end(),badchecker(this))) + && + (es->del_effects.end() == std::find_if(es->del_effects.begin(),es->del_effects.end(),badchecker(this))) + && + (es->forall_effects.end() == std::find_if(es->forall_effects.begin(),es->forall_effects.end(),badchecker(this))) + && + (es->cond_effects.end() == std::find_if(es->cond_effects.begin(),es->cond_effects.end(),badchecker(this))) + && + (es->assign_effects.end() == std::find_if(es->assign_effects.begin(),es->assign_effects.end(),badchecker(this))) + && + (es->timed_effects.end() == std::find_if(es->timed_effects.begin(),es->timed_effects.end(),badchecker(this))); +}; + +bool TypeChecker::typecheckAction(const operator_ * act) +{ + if(!isTyped) return true; + if(Verbose) *report << "Type-checking " << act->name->getName() << "\n"; + if(!typecheckGoal(act->precondition)) { + if(Verbose) *report << "Conditions fail type-checking.\n"; + return false; + } + if(!typecheckEffects(act->effects)) { + if(Verbose) *report << "Effects fail type-checking.\n"; + return false; + } + if(const durative_action * da = dynamic_cast(act)) + { + if (!typecheckGoal(da->dur_constraint)) { + if(Verbose) *report << "Duration constraint fails type-checking.\n"; + return false; + }; + }; + if(Verbose) *report << "...action passes type checking.\n"; + return true; +}; + +bool TypeChecker::typecheckDerivationRule(const derivation_rule * d) +{ + if(!isTyped) return true; + if(Verbose) *report << "Type-checking derivation rule for " << (d->get_head()->head->getName()) << "\n"; + pred_decl_list::iterator i = thea->the_domain->predicates->begin(); + for(;i != thea->the_domain->predicates->end();++i) + { + if((*i)->getPred()==d->get_head()->head) + { + (*i)->setTypes(d->get_head()); + break; + }; + }; + return i != thea->the_domain->predicates->end() && typecheckGoal(d->get_body()); +}; + +bool TypeChecker::typecheckDomain() +{ + if(!isTyped) return true; + return thea->the_domain->ops->end() == + std::find_if(thea->the_domain->ops->begin(), + thea->the_domain->ops->end(),badchecker(this)) + && + thea->the_domain->drvs->end() == + std::find_if(thea->the_domain->drvs->begin(), + thea->the_domain->drvs->end(),badchecker(this)) + && + (!thea->the_domain->constraints || + typecheckGoal(thea->the_domain->constraints)); +}; + +bool TypeChecker::typecheckProblem() +{ + if(!isTyped) return true; + if(!thea || !thea->the_problem) + { + ParseFailure pf; + throw(pf); + }; + if (thea->the_problem->the_goal && !typecheckGoal(thea->the_problem->the_goal)) { + if (Verbose) *report << "Type-checking goal failed\n"; + return false; + } + if (!typecheckEffects(thea->the_problem->initial_state)) { + if (Verbose) *report << "Type-checking initial state failed\n"; + return false; + } + if (thea->the_problem->constraints && !typecheckGoal(thea->the_problem->constraints)) { + if (Verbose) *report << "Type-checking constraints failed\n"; + return false; + } + return true; +}; + +bool TypeChecker::typecheckPlan(const plan * p) +{ + if(!isTyped) return true; + return p->end() == std::find_if(p->begin(),p->end(),badchecker(this)); +}; + +vector TypeChecker::range(const var_symbol * v) +{ + vector l; + for(const_symbol_table::const_iterator i = thea->const_tab.begin(); + i != thea->const_tab.end();++i) + { + if(subType(i->second,v)) l.push_back(i->second); + }; + + return l; +}; + +vector TypeChecker::range(const parameter_symbol * v) +{ + vector l; + for(const_symbol_table::const_iterator i = thea->const_tab.begin(); + i != thea->const_tab.end();++i) + { + if(subType(i->second,v)) l.push_back(i->second); + }; + + return l; +}; + + +vector TypeChecker::range(const pddl_type * t) +{ + var_symbol v(""); + v.type = const_cast(t); // OK - we will keep v const. + v.either_types = 0; + return range(&v); +}; + + +}; diff --git a/validate b/validate deleted file mode 100755 index 086c5ba..0000000 Binary files a/validate and /dev/null differ