diff options
139 files changed, 46361 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog index 4f7797dbfe6..dbce2e812af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,199 @@ +Wed Aug 12 17:49:43 UTC 2009 Ben Podgursky <bpodgursky@gmail.com> + + * utils: + + * utils/PDDLtoSANetTranslator: + + * utils/PDDLtoSANetTranslator/PDDLParser: + + * utils/PDDLtoSANetTranslator/PDDLParser/README: + * utils/PDDLtoSANetTranslator/PDDLParser/build.xml: + * utils/PDDLtoSANetTranslator/PDDLParser/commons-collections-3.2.1.jar: + * utils/PDDLtoSANetTranslator/PDDLParser/src: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/PDDLtoSAN.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/ActionData.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/PDDL_Translator.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/CondNode.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/EffectLink.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/PrecondLink.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/TaskNode.java: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/ImplToResource.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/Resource.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/TaskImpl.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/TaskToImpl.java: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Domain.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/ErrorManager.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/EvaluationException.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/InvalidExpException.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/PDDLObject.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Parser.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/ParserException.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Problem.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/RequireKey.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Source.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/AbstractExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/AndExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/AtomicFormula.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/DerivedPredicate.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ExistsExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/Exp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ExpID.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ForallExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ImplyExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/InitEl.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ListExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/Literal.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/NotAtomicFormula.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/NotExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/OrExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/PrefExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ProbExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/QuantifiedExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/WhenExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/AbstractActionDef.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/Action.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/ActionDef.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/ActionID.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/DurativeAction.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/package.html: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/Assign.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/AssignOp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/AssignOpExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/Decrease.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/Increase.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/ScaleDown.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/ScaleUp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/package.html: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/AlwaysExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/AlwaysWithinExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/AtMostOnceExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/BinaryCondExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/CondExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/Condition.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/HoldAfterExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/HoldDuringExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/SometimeAfterExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/SometimeBeforeExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/SometimeExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/UnaryCondExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/WithinExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/package.html: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/Comp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/EqualComp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/FCompExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/GEqualComp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/GreaterComp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/LEqualComp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/LessComp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/package.html: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryAdd.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryDivide.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryMultiply.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryOp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinarySubstract.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/FExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/FHead.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/NArityAdd.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/NArityMultiply.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/NArityOp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/Number.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/Op.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/OpExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/package.html: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/MaximizeExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/MetricExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/MinimizeExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/Optimization.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/package.html: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/package.html: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/AbstractTerm.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/BindingException.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Constant.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Substitution.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Term.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/TermID.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Variable.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/package.html: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/AtEndTimedExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/AtStartTimedExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/AtTimedExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/Interval.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/OverAllTimedExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/OverTimedExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimeSpecifier.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimedExp.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimedExpID.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimedLiteral.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/package.html: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/Type.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/TypeSet.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/TypingException.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/package.html: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/JJTLexerState.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/Lexer.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/LexerConstants.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/LexerTokenManager.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/LexerTreeConstants.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/Node.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/ParseException.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/SimpleCharStream.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/SimpleNode.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/Token.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/TokenMgrError.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/package.html: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/overview.html: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/package.html: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/tests: + + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/tests/Test.java: + * utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/tests/TestCNF.java: + + The PDDL to SANet translator. Also includes the library PDDL4J which does the inital pddl parsing. I've made some + bug fixes to this library, so the source needs to be here. + Tue Aug 4 22:14:56 UTC 2009 Ben Podgursky <bpodgursky@gmail.com> * SANet/SANetFileIn.cpp: @@ -6,10 +202,10 @@ Tue Aug 4 22:14:56 UTC 2009 Ben Podgursky <bpodgursky@gmail.com> * SA_PlanHeuristics.h: * SA_PlanHeuristics.cpp: * SA_PlanStrategy.cpp: - - Various fixes that make SAPOP correctly handle situations with negative preconditions - /goals. Changed Condition equality to handle value, changed SANetFileIn to give conditions - correct initial values, and initial action effects all conditions now + + Various fixes that make SAPOP correctly handle situations with negative preconditions + /goals. Changed Condition equality to handle value, changed SANetFileIn to give conditions + correct initial values, and initial action effects all conditions now Wed Jul 29 20:06:21 UTC 2009 Ben Podgursky <bpodgursky@gmail.com> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/README b/utils/PDDLtoSANetTranslator/PDDLParser/README new file mode 100644 index 00000000000..9aa8624b45b --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/README @@ -0,0 +1,123 @@ +PDDL to SANet translator + +Ben Podgursky +benjamin.t.podgursky@vanderbilt.edu + +DESCRIPTION + + This package holds the java program which is able to automatically translate PDDL problems + into Spreading Activation networks, doing limited optimization and pruning in the process. + It takes as an input a PDDL domain file, PDDL problem file, and arguments dictating the form + of the conversion. + + It is capable of translating the following PDDL requirements: + + strips + typing + equality + negative preconditions + disjunctive preconditions + conditional effects + probabilistic--limited + +INSTALLATION/RUNNING + + Install ant (http://ant.apache.org/) + Make sure that ant's bin is in your path + Navigate to PDDLtoSANetTranslator\PDDLParser + + To run the translator, enter: + + ant clean build -Dargs="<domain file> <problem file> <want init action> + <condition checking depth> <output file name>" PDDLtoSAN + + The arguments: + <domain file> the name of the pddl domain file + <problem file> the name of the pddl problem file + <want init action> whether to include an initial action in the output xml + file. The initial action has no preconditions and effect links to all + conditions equivalent to their initial states + <condition checking depth> number of conditions to check against a condition. eg, + if it is set to 3, it will check if any 3 conditions are together effected by the + same tasks as any one other task. + <output file name> the 3 produced files are given this as their suffix. Eg, for name + "test" it would generate "test-san.xml", "test-tm.xml", "test-goals.xml" for the + spreading activation network, task map, and goal files respectively. + + For example, to run the ferry example included: + + ant clean build -Dargs="ferry.pddl pb1ferry.pddl false 3 ferry" PDDLtoSAN + +TRANSLATION STRATEGIES + + strips-- strips syntax is translated using a naive propositional expansion of all actions + and predicates, using all of the objects specified in the problem file + + typing-- propositionalizes actions and conditions using only objects of the proper types + for each action/condition + + equality/inequality-- makes sure that equality and inequality constraints are respected in + action definitions. preserves transitivity and reversibility + + negative preconditions-- spreading activation networks can easily handle negative preconditions; + the true probability of the precondition link from the condition to the action is 0, and the + false probability is positive + + disjunctive preconditions-- these are handled by first putting the action's preconditions in disjunctive normal + form, where the disjunction is the outermost function, and then splitting each clause into a separate + action. Eg, if an action A has preconditions condA || condB, it is split into two actions, A[0] with + precondition condA and A[1] with precondition condB. The effects of each action are identical to those + of the original action + + conditional effects-- actions conditional effects are resolved by splitting the action into two actions, the + first where the condition's preconditions are asserted true in the preconditions, and the second where + they are asserted false. + + probabilisitic effects-- by the nature of spreading activation networks, probabilistic effects can have + at most one term, and this term can have at most one condition asserted to a value (linking + effects together would be counter to the structure of a bayesian network, where effects are assumed to + be independent, and would generate incorrect plans.) + +OPTIMIZATIONS: + + The above actions will produce a spreading activation network, but a massive one. The following optimizations + cut down the size of the network, while still preserving optimal paths: + + Elimination and propagation of impossible conditions + Conditions falling in two categories should not need to exist in a network; conditions initially true + which have no effect links setting them false, and conditions initially false which are never set true; + collectively, these represent the conditions which never change value. Remove all of these condition nodes + from the network. + Then for each of these conditions, investigate its precondition links. If a task requires the condition in + the state it is always in, remove the precondition link, as it is trivial to satisfy anyway. If the action + needs the condition to be opposite its value, remove that task from the network, because it will never be able + to execute. This may cause other conditions to never change; continue in this manner until nothing can be + removed + + Pruning of irrelevant tasks and conditions + + All the conditions and tasks in the network are now likely attainable, but depending on the domain, most + be irrelevant to the problem at hand. We find only the relevant tasks by essentially doing a depth first search + from the goal conditions specified in the problem description. Start by finding all tasks which satisfy the + goal conditions. The find all tasks which satisfy the preconditions to these tasks, and continue until all + relevant tasks and conditions have been added. Now the network consists only of tasks and conditions which + are on a causal path to a goal. + + Elimiation of regressive tasks + + Often there are tasks which are intuitively bad to a human which do not get eliminated in the above steps + because they are on a valid path to the goal, albeit not the most efficient path. + One type of useless task is one which leaves the environment in a state which was necessarily true one + step before it was executed. We have to be careful though; we have to make sure that bringing the environment + into a state where this task can be executed did not allow another part of the plan to execute, and that the + task under scrutiny does not "reset" the environment to do something else useful; for example, a ferry sailing + repeatedly back and forth across a river. + + Removal of aggregate conditions + + Aggregate conditions are especially bad for causal link planners, but are common in strips problems, as + they have no negative preconditions. For example, in the ferry problem included, (empty-ferry) is equivalent + to (not (on c1 the-ferry)) && (not (on c2 the-ferry)). Replacing the former with the latter makes it easier + for the planner to choose the correct tasks to satisfy the preconditions. This translator looks for + situations where this can be done. A parameter passed in determines the depth of checking that should be done + here.
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/build.xml b/utils/PDDLtoSANetTranslator/PDDLParser/build.xml new file mode 100644 index 00000000000..a08b93a50e1 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/build.xml @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- WARNING: Eclipse auto-generated file. + Any modifications will be overwritten. + To include a user specific buildfile here, simply create one in the same + directory with the processing instruction <?eclipse.ant.import?> + as the first entry and export the buildfile again. --> +<project basedir="." default="build" name="PDDLParser"> + <property environment="env"/> + <property name="debuglevel" value="source,lines,vars"/> + <property name="target" value="1.6"/> + <property name="source" value="1.6"/> + <path id="PDDLParser.classpath"> + <pathelement location="bin"/> + <pathelement location="commons-collections-3.2.1.jar"/> + </path> + <target name="init"> + <mkdir dir="bin"/> + <copy includeemptydirs="false" todir="bin"> + <fileset dir="src"> + <exclude name="**/*.launch"/> + <exclude name="**/*.java"/> + </fileset> + </copy> + </target> + <target name="clean"> + <delete dir="bin"/> + </target> + <target depends="clean" name="cleanall"/> + <target depends="build-subprojects,build-project" name="build"/> + <target name="build-subprojects"/> + <target depends="init" name="build-project"> + <echo message="${ant.project.name}: ${ant.file}"/> + <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}"> + <src path="src"/> + <classpath refid="PDDLParser.classpath"/> + </javac> + </target> + + <target name="PDDLtoSAN"> + <java classname="PDDLtoSAN" failonerror="true" fork="yes"> + <classpath refid="PDDLParser.classpath"/> + <arg line="${args}" /> + </java> + </target> + + <target name="jar"> + <mkdir dir=""/> + <jar destfile="HelloWorld.jar" basedir="bin/"> + <zipfileset src="commons-collections-3.2.1.jar" /> + <manifest> + <attribute name="Main-Class" value="PDDLtoSAN"/> + </manifest> + </jar> + </target> + + <target name="run-jar"> + <java jar="HelloWorld.jar" fork="true"> + <arg line="${args}" /> + </java> + </target> + + +</project> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/commons-collections-3.2.1.jar b/utils/PDDLtoSANetTranslator/PDDLParser/commons-collections-3.2.1.jar Binary files differnew file mode 100644 index 00000000000..c35fa1fee14 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/commons-collections-3.2.1.jar diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/PDDLtoSAN.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/PDDLtoSAN.java new file mode 100644 index 00000000000..65081b0bbee --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/PDDLtoSAN.java @@ -0,0 +1,98 @@ +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Properties; + +import Translator.PDDL_Translator; + +import pddl4j.Domain; +import pddl4j.ErrorManager; +import pddl4j.PDDLObject; +import pddl4j.Parser; +import pddl4j.Problem; +import pddl4j.RequireKey; +import pddl4j.Source; +import pddl4j.ErrorManager.Message; + +public class PDDLtoSAN { + + /** + * @param args + */ + public static void main(String[] args) { + + if(args.length != 5){ + System.out.println("Wrong number of arguments: "+args.length); + System.exit(0); + } + + String domain_path = args[0]; + String problem_path = args[1]; + boolean include_init = new Boolean(args[2]); + int cond_combine = new Integer(args[3]); + String output_name = args[4]; + +// String domain_path = "travel.pddl"; +// String problem_path = "pb1.pddl"; +// boolean include_init = false; +// int cond_combine = 3; +// String output_name = "ferry"; + + Domain domain = null; + Problem problem = null; + + Properties options = new Properties(); + options.put("source", Source.V3_0); + options.put(RequireKey.STRIPS, true); + options.put(RequireKey.TYPING, true); + options.put(RequireKey.EQUALITY, true); + options.put(RequireKey.NEGATIVE_PRECONDITIONS, true); + options.put(RequireKey.DISJUNCTIVE_PRECONDITIONS, true); + options.put(RequireKey.CONDITIONAL_EFFECTS, true); + // options.put(RequireKey.EXISTENTIAL_PRECONDITIONS, true); + // options.put(RequireKey.UNIVERSAL_PRECONDITIONS, true); + + Parser parser = new Parser(options); + + File domain_file = new File(domain_path); + File problem_file = new File(problem_path); + + try { + domain = parser.parse(domain_file); + } catch (FileNotFoundException e) { + System.out.println("Error: domain file "+domain_file+" not found"); + System.exit(0); + } + + try { + problem = parser.parse(problem_file); + } catch (FileNotFoundException e) { + System.out.println("Error: problem file "+problem_file+" not found"); + System.exit(0); + } + + PDDLObject obj = parser.link(domain, problem); + + ErrorManager mgr = parser.getErrorManager(); + + if (mgr.contains(Message.ERROR)) { + mgr.print(Message.ALL); + } + else { + mgr.print(Message.WARNING); + + System.out.println(); + System.out.println("Translating:"); + + PDDL_Translator n = new PDDL_Translator(obj, cond_combine, include_init); + + System.out.println("Done translating"); + System.out.println(" SAN number of conditions: "+ n.getConditonNodeCount()); + System.out.println(" SAN number of actions: " + n.getActionNodeCount()); + + n.printSAN(); + n.write_SAN_to_xml(output_name+"-san.xml"); + n.write_TM_to_xml(output_name+"-tm.xml"); + n.write_goals_to_file(output_name+"-goals"); + } + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/ActionData.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/ActionData.java new file mode 100644 index 00000000000..17c82e39fab --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/ActionData.java @@ -0,0 +1,304 @@ +package Translator; + +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import pddl4j.exp.Exp; +import pddl4j.exp.action.Action; +import pddl4j.exp.term.Constant; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; +import pddl4j.exp.type.Type; +import pddl4j.exp.type.TypeSet; + +public class ActionData{ + + private Action a; + private Substitution s; + private List<Variable> free_parameters; + private List<Variable> all_params; + EqualityConstraintManager manager; + private Map<Type, List<Constant> > type_list; + + public ActionData(Action p_a, Map<Type, List<Constant> > p_type_list){ + + a = p_a; + s = new Substitution(); + free_parameters = new LinkedList<Variable>(); + all_params = new LinkedList<Variable>(); + manager = new EqualityConstraintManager(); + type_list = p_type_list; + } + + /** + * To save room when recursing, only copies certain data + * @param copy + */ + public ActionData(ActionData copy){ + + a = copy.a; + s =copy.s.clone(); + free_parameters = new LinkedList<Variable>(copy.free_parameters); + all_params = copy.all_params; + manager = new EqualityConstraintManager(copy.manager); + type_list = copy.type_list; + } + + public void add_free_variable(Variable v){ + free_parameters.add(v); + all_params.add(v); + manager.add_variable(v); + } + + /** + * done first + * @param v + * @param not + */ + public void fix_variable_not_equal_variable(Variable v, Variable not){ + + manager.assign_inequal_var_var(v, not); + } + + /** + * Second + * @param v + * @param to + */ + public void fix_variable_to_variable(Variable v, Variable to){ + + manager.assign_equal_var_var(v, to); + } + + /** + * third + * @param v + * @param not + */ + public void fix_variable_not_equal_constant(Variable v, Constant not){ + + manager.assign_inequal_var_const(v, not); + } + + + /** + * note--only call this when reading in the preconditions. Not while + * enumerating! + * @param v + * @param to + */ + public void fix_variable_to_constant(Variable v, Constant to){ + + s.bind(v, to); + manager.assign_equal_var_const(v, to); + } + + public void temp_fix_variable_to_constant(Variable v, Constant to){ + + s.bind(v, to); + free_parameters.remove(v); + manager.temp_assign_equal_var_const(v, to); + + } + + public boolean has_free_variable(){ + return !free_parameters.isEmpty(); + } + + public Variable get_first_free_variable(){ + return free_parameters.get(0); + } + + public List<String> get_all_substituted_parameters(){ + + List<String> params = new LinkedList<String>(); + for(Term t: a.getParameters()){ + params.add(s.getBinding((Variable)t).toString()); + } + + return params; + } + + public List<Constant> get_possible_values(Variable v){ + + if(manager.variable_to_constraint.get(v).fixed_to == null) + return manager.variable_to_constraint.get(v).possible_constant_values; + else{ + + List<Constant> possible = new LinkedList<Constant>(); + possible.add(manager.variable_to_constraint.get(v).fixed_to); + return possible; + } + } + + public String get_action_name(){ + + String action_name = a.getName(); + + for(Variable v: all_params){ + action_name+=(" "+s.getBinding(v).toString()); + } + + return action_name; + } + + public Exp get_precondition_expression(){ + return a.getPrecondition().apply(s); + } + + public Exp get_effect_expression(){ + return a.getEffect().apply(s); + } + + class EqualityConstraintManager{ + + Map<Variable, VariableConstraint> variable_to_constraint = new LinkedHashMap<Variable, VariableConstraint>(); + + public EqualityConstraintManager(EqualityConstraintManager copy){ + + + + for(VariableConstraint constr: copy.variable_to_constraint.values()){ + + + VariableConstraint new_entry = new VariableConstraint(constr); + for(Variable v: new_entry.equal_variables){ + variable_to_constraint.put(v, new_entry); + } + } + + } + + public EqualityConstraintManager(){ + + } + + public void add_variable(Variable v){ + variable_to_constraint.put(v, new VariableConstraint(v)); + } + + public void assign_equal_var_var(Variable a, Variable b){ + + VariableConstraint b_const = variable_to_constraint.get(b); + VariableConstraint a_const = variable_to_constraint.get(a); + + for(Variable v: b_const.inequality_variable_constraints){ + if(a_const.equal_variables.contains(v)){ + a_const.possible_constant_values.clear(); + } + } + + List<Variable> new_equal_variables = new LinkedList<Variable>(a_const.equal_variables); + for(Variable v: b_const.equal_variables){ + variable_to_constraint.put(v, a_const); + new_equal_variables.add(v); + } + + a_const.equal_variables = new_equal_variables; + a_const.possible_constant_values.retainAll(b_const.possible_constant_values); + a_const.inequality_variable_constraints.addAll(b_const.inequality_variable_constraints); + } + + public void assign_inequal_var_var(Variable a, Variable b){ + + VariableConstraint b_const = variable_to_constraint.get(b); + VariableConstraint a_const = variable_to_constraint.get(a); + + a_const.inequality_variable_constraints.add(b); + b_const.inequality_variable_constraints.add(a); + + if(a.equals(b)){ + a_const.possible_constant_values.clear(); + } + } + + public void assign_inequal_var_const(Variable a, Constant b){ + variable_to_constraint.get(a).possible_constant_values.remove(b); + } + + public void assign_equal_var_const(Variable a, Constant b){ + + VariableConstraint a_const = variable_to_constraint.get(a); + + if(a_const.possible_constant_values.contains(b)){ + + a_const.possible_constant_values.clear(); + a_const.possible_constant_values.add(b); + + for(Variable v: a_const.inequality_variable_constraints){ + variable_to_constraint.get(v).possible_constant_values.remove(b); + } + }else{ + a_const.possible_constant_values.clear(); + } + } + + public void temp_assign_equal_var_const(Variable a, Constant b){ + + VariableConstraint a_const = variable_to_constraint.get(a); + + if(a_const.fixed_to != null){ + + for(Variable v: a_const.inequality_variable_constraints){ + + VariableConstraint v_const = variable_to_constraint.get(v); + if(v_const.denied_by.contains(a)){ + v_const.possible_constant_values.add(a_const.fixed_to); + } + } + } + + a_const.fixed_to = b; + + for(Variable v: a_const.inequality_variable_constraints){ + + VariableConstraint v_const = variable_to_constraint.get(v); + + if(v_const.possible_constant_values.contains(b)){ + v_const.denied_by.add(a); + v_const.possible_constant_values.remove(b); + } + } + } + + class VariableConstraint{ + + public VariableConstraint(VariableConstraint copy){ + equal_variables = copy.equal_variables; + inequality_variable_constraints = copy.inequality_variable_constraints; + possible_constant_values = new LinkedList<Constant>(copy.possible_constant_values); + denied_by = new LinkedList<Variable>(copy.denied_by); + fixed_to = copy.fixed_to; + } + + public VariableConstraint(Variable v){ + equal_variables.add(v); + + possible_constant_values = new LinkedList<Constant>(); + + Iterator<Type> type_it = v.getTypeSet().iterator(); + + while(type_it.hasNext()){ + Type typ = type_it.next(); + if(type_list.get(typ) != null){ + possible_constant_values.addAll(type_list.get(typ)); + } + } + + denied_by = new LinkedList<Variable>(); + fixed_to = null; + } + + public List<Variable> equal_variables = new LinkedList<Variable>(); + public List<Variable> inequality_variable_constraints = new LinkedList<Variable>(); + public List<Constant> possible_constant_values; + public List<Variable> denied_by; + + public Constant fixed_to; + } + } +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/PDDL_Translator.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/PDDL_Translator.java new file mode 100644 index 00000000000..b31a49dd80b --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/PDDL_Translator.java @@ -0,0 +1,2229 @@ +package Translator; + +import java.io.FileWriter; +import java.io.StringWriter; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import Translator.SAN_Data.CondNode; +import Translator.SAN_Data.EffectLink; +import Translator.SAN_Data.PrecondLink; +import Translator.SAN_Data.TaskNode; +import Translator.TM_Data.ImplToResource; +import Translator.TM_Data.Resource; +import Translator.TM_Data.TaskImpl; +import Translator.TM_Data.TaskToImpl; + +import pddl4j.PDDLObject; +import pddl4j.exp.AndExp; +import pddl4j.exp.AtomicFormula; +import pddl4j.exp.Exp; +import pddl4j.exp.ExpID; +import pddl4j.exp.InitEl; +import pddl4j.exp.NotExp; +import pddl4j.exp.OrExp; +import pddl4j.exp.ProbExp; +import pddl4j.exp.WhenExp; +import pddl4j.exp.action.Action; +import pddl4j.exp.action.ActionDef; +import pddl4j.exp.fcomp.EqualComp; +import pddl4j.exp.term.Constant; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; +import pddl4j.exp.type.Type; +import pddl4j.exp.type.TypeSet; + +import org.apache.commons.collections.MultiMap; +import org.apache.commons.collections.map.MultiValueMap; +import org.w3c.dom.*; + +import javax.xml.parsers.*; + +import javax.xml.transform.*; +import javax.xml.transform.dom.*; +import javax.xml.transform.stream.*; + + +public class PDDL_Translator { + + Map<String, CondNode> condition_nodes = new LinkedHashMap<String, CondNode>(); + Map<String, TaskNode> task_nodes= new LinkedHashMap<String, TaskNode>(); + + List<PrecondLink> precondition_links = new LinkedList<PrecondLink>(); + List<EffectLink> effect_links = new LinkedList<EffectLink>(); + + Map<Type, List<Constant> > typeset_to_constant= new LinkedHashMap<Type, List<Constant> >(); + Map<String, Boolean> goal_states = new LinkedHashMap<String, Boolean>(); + + Map<String, TaskImpl> task_impls = new LinkedHashMap<String, TaskImpl>(); + Map<String, Resource> resources = new LinkedHashMap<String, Resource>(); + + List<TaskToImpl> task_to_impl_links = new LinkedList<TaskToImpl>(); + List<ImplToResource> impl_to_resource_links = new LinkedList<ImplToResource>(); + + Map<TaskNode, List<String> > task_to_resources = new LinkedHashMap<TaskNode, List<String> >(); + + boolean init_act_visible; + + /** + * + * @param pddl_object + * + * The object the parser uses to extract the SAN and TM + * + * @param use_initial_action + * + * Include an initial action, with effects to all conditions, in the SAN + */ + public PDDL_Translator(PDDLObject pddl_object, int condition_combine_levels, boolean use_initial_action){ + + init_act_visible = use_initial_action; + + List<Action> action_list; + List<ActionData> action_data; + + //Even if we don't use init act, we can't give SA-POP an action named 20. + TaskNode init_act = new TaskNode("initact"); + + //First, maps constants to their types; second, creates a resource for every constant + record_constants(pddl_object); + + //Read in the goals and remember what they are. + get_goals(pddl_object); + + //Creates conditions for every proposition, sets them all false at first + enumerate_propositions_default(pddl_object); + + //Now replace the ones that were asserted true in the problem + set_initial_propositions(pddl_object); + + //Get all the initial actions + action_list = get_all_actions(pddl_object); + + //Splices when constructs out of the effects and turns them into multiple actions + action_list = remove_conditionals(action_list); + + //Turns the preconditions to disjunctive normal form and splits the terms into multiple + //actions + action_list = remove_precondition_disjunctions(action_list); + + //Not sure if this step is necessary, but goes through and normalizes stuff, mainly to get + //rid of double nested not clauses. + action_list = convert_preconditions_to_prenex(action_list); + + //Go through and look at the equality/inequality constraints remaining. + action_data = parse_equality_constraints(action_list); + + //Make sure that there aren't untranslatable probabilities encoded + if(!are_probabilistics_translatable(action_list)){ + System.out.println("Probabilistics this complex cannot currently be translated to a SANet"); + System.exit(0); + } + + //Propositionalize all actions + enumerate_actions(action_data); + + //Add the initial action in as an anchor--otherwise it would seem that none + //of the conditions can come true + setup_initial_action(init_act); + + boolean keep_looping; + do { + + //Propagate up through all impossible tasks and get rid of ones that can never + //come true + keep_looping = eliminate_impossible_tasks(); + + //Basically cut down through the tasks and conditions and only take the relevant + //ones + keep_looping = eliminate_irreleevant_tasks_and_conditions()||keep_looping; + + //Get rid of tasks that take plan backwards and where getting there + //helps nothing else + keep_looping = eliminate_dominated_tasks()||keep_looping; + } while(keep_looping); + + //Go through and look to see if any conditions can be replaced by a set of other + //conditions + //TODO maybe try something like a kmap here? + combine_conditions(condition_combine_levels); + + //Give preconditions links the proper probabilities + set_probabilities(); + + //Make task impls for every task + record_task_impls(); + } + + MultiMap opp_effect_same_task; + MultiMap common_task; + + private void combine_conditions(int max_search){ + + long intv1 = new Date().getTime(); + + opp_effect_same_task = new MultiValueMap(); + common_task = new MultiValueMap(); + + for(TaskNode tn: this.task_nodes.values()){ + for(EffectLink efln: tn.get_positive_effect_links()){ + for(EffectLink o_efln: tn.get_negative_effect_links()){ + opp_effect_same_task.put(efln.effect, o_efln.effect); + opp_effect_same_task.put(o_efln.effect, efln.effect); + } + } + + for(EffectLink efln: tn.get_positive_effect_links()){ + for(EffectLink ef2: tn.get_positive_effect_links()){ + common_task.put(efln.effect, ef2.effect); + common_task.put(ef2.effect, efln.effect); + } + for(EffectLink ef2: tn.get_negative_effect_links()){ + common_task.put(efln.effect, ef2.effect); + common_task.put(ef2.effect, efln.effect); + } + } + for(EffectLink efln: tn.get_negative_effect_links()){ + for(EffectLink ef2: tn.get_positive_effect_links()){ + common_task.put(efln.effect, ef2.effect); + common_task.put(ef2.effect, efln.effect); + } + for(EffectLink ef2: tn.get_negative_effect_links()){ + common_task.put(efln.effect, ef2.effect); + common_task.put(ef2.effect, efln.effect); + } + } + } + + for(int i = 1; i <= max_search; i++) + { + boolean found_combine = true; + + while(found_combine){ + + found_combine = combine_conditions_aux(new LinkedList<CondNode>(), i); + + if(found_combine){ + if(!neg_combine){ + + for(PrecondLink lnk: replaced.getPreconditionTo()){ + for(CondNode cnd: replacers){ + precondition_links.add(lnk.action.attach_precondition(cnd, lnk.required_state)); + } + } + + if(this.goal_states.containsKey(replaced.getName())){ + boolean value = this.goal_states.get(replaced.getName()); + this.goal_states.remove(replaced.getName()); + for(CondNode cnd: replacers){ + + this.goal_states.put(cnd.getName(), value); + } + } + + destroy_condition(replaced); + }else{ + + + for(PrecondLink lnk: replaced.getPreconditionTo()){ + + for(CondNode cnd: replacers){ + precondition_links.add(lnk.action.attach_precondition(cnd, !lnk.required_state)); + } + } + + if(this.goal_states.containsKey(replaced.getName())){ + boolean value = this.goal_states.get(replaced.getName()); + this.goal_states.remove(replaced.getName()); + for(CondNode cnd: replacers){ + + this.goal_states.put(cnd.getName(), !value); + } + } + + destroy_condition(replaced); + + } + } + } + } + + long intv2 = new Date().getTime(); + System.out.println("Combining conditions: "+(intv2-intv1)+" ms"); + } + + private boolean combine_conditions_aux(List<CondNode> fixed_cnds, int still_to_fix){ + if(still_to_fix != 0){ + for(CondNode cn: this.condition_nodes.values()){ + + boolean skip = false; + Object to_cast = opp_effect_same_task.get(cn); + if(to_cast != null) + { + Collection<Object> cln = (Collection<Object>)to_cast; + + for(CondNode nd: fixed_cnds) + { + if(cln.contains(nd)){ + // System.out.println("Skip"); + skip = true; + break; + } + } + } + if(skip){ + continue; + } + + if(!fixed_cnds.contains(cn)){ + List<CondNode> nodes = new LinkedList<CondNode>(fixed_cnds); + nodes.add(cn); + + boolean to_return = combine_conditions_aux(nodes, still_to_fix-1); + if(to_return){ + return true; + } + } + } + }else{ + for(CondNode compare: this.condition_nodes.values()){ + + if(fixed_cnds.contains(compare)){ + continue; + } + + Object to_cast = opp_effect_same_task.get(compare); + if(!(to_cast == null)){ + Collection<Object> cln = (Collection<Object>)to_cast; + + if(!cln.containsAll(fixed_cnds)){ + continue; + } + } + + List<EffectLink> combined_effects = new LinkedList<EffectLink>(); + + for(CondNode cn: fixed_cnds){ + combined_effects.addAll(cn.getAffectedBy()); + } + + //if all links in combined_effects are the same as links in compare.getaff + + List<EffectLink> compare_effects = compare.getAffectedBy(); + + + if(equivalent_sets(combined_effects, compare_effects)){ + + replaced = compare; + replacers = fixed_cnds; + neg_combine = false; + return true; + } + else if(opposite_sets(combined_effects, compare_effects)){ + + replaced = compare; + replacers = fixed_cnds; + neg_combine = true; + return true; + } + } + } + + return false; + } + + private List<CondNode> replacers; + private CondNode replaced; + private boolean neg_combine; + + private boolean equivalent_sets(List<EffectLink> set1p, List<EffectLink> set2p){ + + List<EffectLink> set1 = new LinkedList<EffectLink>(set1p); + List<EffectLink> set2 = new LinkedList<EffectLink>(set2p); + + for(EffectLink ln: set1){ + + boolean found_equiv = false; + for(EffectLink chk: set2){ + if(chk.sameSource(ln)){ + found_equiv = true; + break; + } + } + + if(!found_equiv){ + return false; + } + + } + + for(EffectLink ln: set2){ + + boolean found_equiv = false; + for(EffectLink chk: set1){ + if(chk.sameSource(ln)){ + found_equiv = true; + break; + } + } + + if(!found_equiv){ + return false; + } + + } + + return true; + } + + private boolean opposite_sets(List<EffectLink> set1p, List<EffectLink> set2p){ + + List<EffectLink> set1 = new LinkedList<EffectLink>(set1p); + List<EffectLink> set2 = new LinkedList<EffectLink>(set2p); + + + for(EffectLink ln: set1){ + + boolean found_equiv = false; + for(EffectLink chk: set2){ + if(chk.oppositeSource(ln)){ + found_equiv = true; + break; + } + } + + if(!found_equiv){ + return false; + } + } + + for(EffectLink ln: set2){ + + boolean found_equiv = false; + for(EffectLink chk: set1){ + if(chk.oppositeSource(ln)){ + found_equiv = true; + break; + } + } + + if(!found_equiv){ + return false; + } + } + + return true; + } + + + //TODO make this work at an arbitrary depth + /** + * Returns true if tasks are eliminated + */ + private boolean eliminate_dominated_tasks(){ + + long intv1 = new Date().getTime(); + + List<TaskNode> to_remove = new LinkedList<TaskNode>(); + + boolean keep_looking = true; + boolean removed_something = false; + + while(keep_looking){ + + for(TaskNode t: this.task_nodes.values()){ + + + Map<CondNode, Boolean> preconditions = new LinkedHashMap<CondNode, Boolean>(); + for(PrecondLink l: t.get_positive_precondition_links()){ + preconditions.put(l.precondition, true); + } + for(PrecondLink l: t.get_negative_precondition_links()){ + preconditions.put(l.precondition, false); + } + + Map<CondNode, Boolean> useful_effects = new LinkedHashMap<CondNode, Boolean>(); + for(EffectLink l: t.get_positive_effect_links()){ + if(is_effect_useful(l)){ + useful_effects.put(l.effect, true); + } + } + + for(EffectLink l: t.get_negative_effect_links()){ + if(is_effect_useful(l)){ + useful_effects.put(l.effect, false); + } + } + + Map<CondNode, Set<TaskNode>> cond_to_satisfiers = new LinkedHashMap<CondNode, Set<TaskNode>>(); + Map<TaskNode, Map<CondNode, Boolean>> satisfiers_precond = new LinkedHashMap<TaskNode, Map<CondNode, Boolean>>(); + Map<TaskNode, Map<CondNode, Boolean>> satisfiers_effects = new LinkedHashMap<TaskNode, Map<CondNode, Boolean>>(); + + List<CondNode> cond_list = new LinkedList<CondNode>(); + + for(CondNode c: preconditions.keySet()){ + Set<TaskNode> satisfying = new HashSet<TaskNode>(); + cond_to_satisfiers.put(c, satisfying); + for(EffectLink l: c.getAffectedBy()){ + + if(l.getWeight() == 1 && preconditions.get(c) == true || + l.getWeight() == -1 && preconditions.get(c) == false){ + + satisfying.add(l.action); + + Map<CondNode, Boolean> preconds_for_sat = new LinkedHashMap<CondNode, Boolean>(); + for(PrecondLink pl: l.action.get_positive_precondition_links()){ + preconds_for_sat.put(pl.precondition, true); + } + for(PrecondLink pl: l.action.get_negative_precondition_links()){ + preconds_for_sat.put(pl.precondition, false); + } + + satisfiers_precond.put(l.action, preconds_for_sat); + + Map<CondNode, Boolean> effects_for_sat = new LinkedHashMap<CondNode, Boolean>(); + for(EffectLink el: l.action.get_positive_effect_links()){ + effects_for_sat.put(el.effect, true); + } + + for(EffectLink el: l.action.get_negative_effect_links()){ + effects_for_sat.put(el.effect, false); + } + + satisfiers_effects.put(l.action, effects_for_sat); + } + } + + cond_list.add(c); + } + + if(expand_satisfaction_combination(cond_list, cond_to_satisfiers, satisfiers_precond, + satisfiers_effects, new LinkedList<TaskNode>(), useful_effects)){ + + Map<CondNode, Boolean> all_sat_precond = new LinkedHashMap<CondNode, Boolean>(); + for(TaskNode tn: stored_satisfiers_precond.keySet()){ + all_sat_precond.putAll(stored_satisfiers_precond.get(tn)); + } + + //Note! bah + boolean all_necessary_preconditions_extraneous = true; + for(CondNode cn: preconditions.keySet()){ + if(!(all_sat_precond.containsKey(cn)&&all_sat_precond.get(cn)==preconditions.get(cn))){ + for(PrecondLink pl: cn.getPreconditionTo()){ + if(pl.getRequiredState() == preconditions.get(cn) && + !(pl.getTaskID()== t.getNodeID())){ + all_necessary_preconditions_extraneous = false; + } + } + } + } + // + if(all_necessary_preconditions_extraneous){ + System.out.println(" Deleting"+t.getName()); + // System.out.println(t.getName()+" definitely extraneous"); + to_remove.add(t); + } + + // for(EffectLink l: t.get_positive_effect_links()){ + // if(!this.is_effect_useful(l)){ + // System.out.println("Kill: "+t.getName()); + // } + // } + // + // for(EffectLink l: t.get_negative_effect_links()){ + // if(!this.is_effect_useful(l)){ + // System.out.println("Kill: "+t.getName()); + // } + // } + + //Now know that this task leaves the environment the same + //as sometime before. Now we prune it if it invalidates a condition that has to stay true + + // for(CondNode cn: useful_effects.keySet()){ + // for(PrecondLink l: cn.getPreconditionTo()){ + // if(l.required_state == useful_effects.get(cn)){ + // System.out.println(" actually, "+ l); + // num_clinks++; + // } + // } + // } + + // for(EffectLink el: t.get_effect_links()){ + // if(this.goal_states.containsKey(el.effect.getName()) && + // this.goal_states.get(el.effect.getName()) != (el.getWeight()==1)){ + // to_remove.add(t); + // } + // } + + // if(num_clinks < 2){ + // + // } + } + + } + + for(TaskNode tn: to_remove){ + destroy_task(tn); + } + + + + keep_looking = !to_remove.isEmpty(); + removed_something = removed_something||keep_looking; + + to_remove.clear(); + + } + + long intv2 = new Date().getTime(); + System.out.println("Removing useless tasks: "+(intv2-intv1)+" ms"); + + return removed_something; + + //0. for every task: + //1. Get all preconditions of task + //Map<CondNode, boolean> preconditions + //1' Get all useful effects of task + //Map<CondNode, boolean> task_effects + //2. For each precondition, get all tasks that satisfy that precondition + //Map<CondNode, Set<TaskNode>> cond_to_satisfiers + //3. For each task that satisfies precondition, get preconditions + //Map<TaskNode, Set<CondNode>> satisfiers_precond + //4. For every combination of 1 task for each entry in cond_to_satisfiers + //get the whole collection of those tasks' preconditions from + //satisfiers_precond + //remove from the collection the negated effects of the tasks in the + //combination + //If for every combination, all entries in task_effects are in the collection, + //the task is useless. Delete task, move to next. + //5. If previous step didn't terminate, repeat 2 on the new collection until search is + //as deep as desired + //Note: to do it deeper, we would need to keep track of what task each condition + //is for + + } + + Map<TaskNode, Map<CondNode, Boolean>> stored_satisfiers_precond; + + private boolean expand_satisfaction_combination( + List<CondNode> not_satisfied, + Map<CondNode, Set<TaskNode>> cond_to_satisfiers, + Map<TaskNode, Map<CondNode, Boolean>> satisfiers_precond, + Map<TaskNode, Map<CondNode, Boolean>> satisfiers_effects, + List<TaskNode> added, + Map<CondNode, Boolean> act_effects + ){ + + if(!not_satisfied.isEmpty()){ + + CondNode sat_cond = not_satisfied.get(0); + + for(TaskNode tn: cond_to_satisfiers.get(sat_cond)){ + + + List<CondNode> new_to_sat = new LinkedList<CondNode>(not_satisfied); + new_to_sat.remove(sat_cond); + + List<TaskNode> fixed_tasks = new LinkedList<TaskNode>(added); + fixed_tasks.add(tn); + + + boolean toret = expand_satisfaction_combination( + new_to_sat, + cond_to_satisfiers, + satisfiers_precond, + satisfiers_effects, + fixed_tasks, + act_effects + ); + + if(!toret){ + return false; + } + + } + return true; + + }else{ + + Map<CondNode, Boolean> all_sat_preconds = new LinkedHashMap<CondNode, Boolean>(); + + for(TaskNode t: added){ + + Map<CondNode, Boolean> to_add = satisfiers_precond.get(t); + for(CondNode cnode: to_add.keySet()){ + + if(all_sat_preconds.containsKey(cnode)){ + if(all_sat_preconds.get(cnode).booleanValue() != + to_add.get(cnode).booleanValue()){ + all_sat_preconds.remove(cnode); + } + }else{ + all_sat_preconds.put(cnode, to_add.get(cnode)); + } + } + } + + Map<CondNode, Boolean> all_sat_effects = new LinkedHashMap<CondNode, Boolean>(); + + for(TaskNode t: added){ + Map<CondNode, Boolean> to_add = satisfiers_precond.get(t); + all_sat_effects.putAll(to_add); + } + + + List<CondNode> effects_remove = new LinkedList<CondNode>(); + for(CondNode c: all_sat_effects.keySet()){ + Boolean determined_value= all_sat_preconds.get(c); + if(determined_value != null){ + if(determined_value.booleanValue() != all_sat_effects.get(c).booleanValue()){ + effects_remove.add(c); + } + } + } + + for(CondNode cnd: effects_remove){ + all_sat_preconds.remove(cnd); + } + + + //If all preconditions in the sat_preconditions, continue + //If any are not in it, return false + + + for(CondNode cnd: act_effects.keySet()){ + if(all_sat_preconds.containsKey(cnd)){ + if(all_sat_preconds.get(cnd).booleanValue() != + act_effects.get(cnd).booleanValue()){ + return false; + } + + }else{ + return false; + } + } + + stored_satisfiers_precond = satisfiers_precond; + + return true; + } + } + + private boolean is_effect_useful(EffectLink c){ + + double effect_value = c.getWeight(); + CondNode cnd = c.effect; + + if(this.goal_states.containsKey(c.effect.getName()) && this.goal_states.get(c.effect.getName()) == (c.getWeight()==1)) + return true; + + for(PrecondLink l: cnd.getPreconditionTo()){ + if(l.required_state == true && effect_value > 0 || + l.required_state == false && effect_value < 0){ + + return true; + } + } + + return false; + } + + private void setup_initial_action(TaskNode initial_action){ + + task_nodes.put("initact", initial_action); + + for(CondNode c: condition_nodes.values()){ + initial_action.attach_effect(c, (c.getProbability()-.5)*2); + } + + effect_links.addAll(initial_action.get_positive_effect_links()); + effect_links.addAll(initial_action.get_negative_effect_links()); + + this.task_to_resources.put(initial_action, new LinkedList<String>()); + } + + private boolean eliminate_irreleevant_tasks_and_conditions(){ + + long intv1 = new Date().getTime(); + + for(TaskNode t: this.task_nodes.values()){ + t.get_positive_effect_links().clear(); + t.get_negative_effect_links().clear(); + } + + for(CondNode con: this.condition_nodes.values()){ + con.getPreconditionTo().clear(); + } + + ExpansionDataSet d = new ExpansionDataSet(); + + for(String s: goal_states.keySet()){ + expand_relevant_condition(this.goal_states.get(s), this.condition_nodes.get(s), d); + } + + boolean return_value = (condition_nodes.size() != d.pos_condition_nodes.size()+ + d.neg_condition_nodes.size()); + + condition_nodes = new LinkedHashMap<String, CondNode>(); + condition_nodes.putAll(d.pos_condition_nodes); + condition_nodes.putAll(d.neg_condition_nodes); + + return_value = return_value||(task_nodes.size() != d.task_nodes.size()); + + task_nodes = d.task_nodes; + precondition_links = d.relevant_preconditions; + effect_links = d.relevant_effects; + + long intv2 = new Date().getTime(); + System.out.println("Pruned irrelevant tasks and conditions: "+(intv2-intv1)+" ms"); + + + return return_value; + } + + class SplitChangePair{ + + Exp split_partial_exp; + Exp additions_to_other_exp; + } + + class ExpansionDataSet{ + + Map<String, CondNode> pos_condition_nodes = new LinkedHashMap<String, CondNode>(); + Map<String, CondNode> neg_condition_nodes = new LinkedHashMap<String, CondNode>(); + + Map<String, TaskNode> task_nodes= new LinkedHashMap<String, TaskNode>(); + + List<PrecondLink> relevant_preconditions = new LinkedList<PrecondLink>(); + List<EffectLink> relevant_effects = new LinkedList<EffectLink>(); + } + + private void expand_relevant_condition(boolean val, CondNode cond, ExpansionDataSet d){ + + if(val){ + if(d.pos_condition_nodes.containsValue(cond)){ + return; + } + d.pos_condition_nodes.put(cond.getName(), cond); + }else{ + if(d.neg_condition_nodes.containsValue(cond)){ + return; + } + d.neg_condition_nodes.put(cond.getName(), cond); + } + + + for(EffectLink l: cond.getAffectedBy()){ + if(val && l.getWeight() == 1){ + l.action.get_positive_effect_links().add(l); + d.relevant_effects.add(l); + expand_relevant_task(l.action, d); + }else if (l.getWeight() == -1){ + l.action.get_negative_effect_links().add(l); + d.relevant_effects.add(l); + expand_relevant_task(l.action, d); + } + } + } + + private void expand_relevant_task(TaskNode t, ExpansionDataSet d){ + + if(d.task_nodes.containsValue(t)){ + return; + } + + d.task_nodes.put(t.getName(), t); + + for(PrecondLink l: t.get_positive_precondition_links()){ + + l.precondition.getPreconditionTo().add(l); + d.relevant_preconditions.add(l); + expand_relevant_condition(true, l.precondition, d); + } + + for(PrecondLink l: t.get_negative_precondition_links()){ + + l.precondition.getPreconditionTo().add(l); + d.relevant_preconditions.add(l); + expand_relevant_condition(false, l.precondition, d); + } + } + + private boolean eliminate_impossible_tasks(){ + + long intv1 = new Date().getTime(); + + List<CondNode> new_values = new LinkedList<CondNode>(condition_nodes.values()); + + boolean removed_something; + boolean ever_removed_something = false; + + do{ + + removed_something = false; + + for(CondNode c_node: new_values){ + if(condition_nodes.values().contains(c_node)){ + removed_something = propagate_impossible_condition(c_node)||removed_something; + } + } + + ever_removed_something = ever_removed_something||removed_something; + + }while(removed_something); + + long intv2 = new Date().getTime(); + System.out.println("Eliminated impossible tasks: "+(intv2-intv1)+" ms"); + + return ever_removed_something; + } + + private void destroy_task(TaskNode t){ + + for(PrecondLink l:t.get_positive_precondition_links()){ + this.precondition_links.remove(l); + } + + for(PrecondLink l:t.get_negative_precondition_links()){ + this.precondition_links.remove(l); + } + + for(EffectLink l:t.get_positive_effect_links()){ + this.effect_links.remove(l); + } + + for(EffectLink l:t.get_negative_effect_links()){ + this.effect_links.remove(l); + } + + t.destroy(); + + task_nodes.remove(t.getName()); + } + + private void destroy_condition(CondNode c){ + + for(PrecondLink l:c.getPreconditionTo()){ + this.precondition_links.remove(l); + } + + for(EffectLink l:c.getAffectedBy()){ + this.effect_links.remove(l); + } + + + c.destroy(); + + condition_nodes.remove(c.getName()); + } + + private boolean propagate_impossible_condition(CondNode c_node){ + + boolean isTurnedFalse = false; + boolean isTurnedTrue = false; + + boolean removed_something = false; + + List<EffectLink> new_affected = new LinkedList<EffectLink>(c_node.getAffectedBy()); + + for(EffectLink e: new_affected){ + + if(c_node.getAffectedBy().contains(e)){ + if(e.getWeight() > 0){ + isTurnedTrue = true; + }else if(e.getWeight() < 0){ + isTurnedFalse = true; + } + } + } + + boolean condition_state = false; + + if(!isTurnedTrue && c_node.getProbability() == 0){ + condition_state = true; + } + + if((!isTurnedTrue && c_node.getProbability() == 0)||(!isTurnedFalse && c_node.getProbability() == 1)){ + List<PrecondLink> new_preconditions = new LinkedList<PrecondLink>(c_node.getPreconditionTo()); + + //There are actions, but they don't do anything, so get rid of them + for(EffectLink eff: c_node.getAffectedBy()){ + if(eff.getWeight() > 0){ + eff.action.get_positive_effect_links().remove(eff); + }else{ + eff.action.get_negative_effect_links().remove(eff); + } + } + + removed_something = true; + destroy_condition(c_node); + for(PrecondLink pre_link: new_preconditions){ + if(c_node.getPreconditionTo().contains(pre_link) + && (condition_state == pre_link.required_state)){ + + TaskNode t = pre_link.action; + destroy_task(t); + + List<EffectLink> new_effects = new LinkedList<EffectLink>(); + new_effects.addAll(t.get_positive_effect_links()); + new_effects.addAll(t.get_negative_effect_links()); + +// for(EffectLink l: new_effects){ +// if( +// ((l.getWeight() > 0 && t.get_positive_effect_links().contains(l)) +// ||(l.getWeight() < 0 &&t.get_negative_effect_links().contains(l))) && +// condition_nodes.containsValue(l.effect)){ +// propagate_impossible_condition(l.effect); +// } +// } + }else if (c_node.getPreconditionTo().contains(pre_link)){ + if(pre_link.getRequiredState()){ + pre_link.action.get_positive_precondition_links().remove(pre_link); + }else{ + pre_link.action.get_negative_precondition_links().remove(pre_link); + } + + } + } + } + + return removed_something; + } + + + private void set_probabilities(){ + for(TaskNode t: task_nodes.values()){ + t.set_precondition_probabilities(); + } + } + + private boolean are_probabilistics_translatable(List<Action> action_list){ + + for(Action a: action_list){ + + Exp e = a.getEffect(); + + if(are_dependent_prob_terms(e) || are_conjunctive_prob_terms(e)){ + return false; + } + } + + return true; + } + + private boolean are_dependent_prob_terms(Exp e){ + + switch(e.getExpID()){ + case AND:{ + AndExp and_exp = (AndExp)e; + Iterator<Exp> children = and_exp.iterator(); + while(children.hasNext()){ + Exp child = children.next(); + boolean result = are_dependent_prob_terms(child); + if(result){ + return true; + } + } + return false; + } + case PROB_EXP:{ + ProbExp prob_exp = (ProbExp)e; + if(prob_exp.size() > 1){ + return true; + } + + Iterator<Exp> children = prob_exp.iterator(); + while(children.hasNext()){ + Exp child = children.next(); + boolean result = are_dependent_prob_terms(child); + if(result){ + return true; + } + } + + return false; + + }case ATOMIC_FORMULA:{ + return false; + }case NOT:{ + return are_dependent_prob_terms(((NotExp)e).getExp()); + } default:{ + System.out.println("Error: term "+e+" not recognized here"); + System.exit(0); + return true; + } + } + + } + + private boolean are_conjunctive_prob_terms(Exp e){ + switch(e.getExpID()){ + case AND:{ + AndExp and_exp = (AndExp)e; + Iterator<Exp> children = and_exp.iterator(); + while(children.hasNext()){ + Exp child = children.next(); + boolean result = are_conjunctive_prob_terms(child); + if(result){ + return true; + } + } + return false; + } + case PROB_EXP:{ + ProbExp prob_exp = (ProbExp)e; + + + Iterator<Exp> children = prob_exp.iterator(); + while(children.hasNext()){ + Exp child = children.next(); + + if(child.getExpID() == ExpID.AND){ + return true; + } + + boolean result = are_conjunctive_prob_terms(child); + if(result){ + return true; + } + } + + return false; + + }case ATOMIC_FORMULA:{ + return false; + }case NOT:{ + return are_conjunctive_prob_terms(((NotExp)e).getExp()); + } default:{ + System.out.println("Error: term "+e+" not recognized here"); + System.exit(0); + return true; + } + } + } + + private void enumerate_actions(List<ActionData> action_data){ + + long intv1 = new Date().getTime(); + + for(ActionData a: action_data){ + actionEnumerationAux(a); + } + + long intv2 = new Date().getTime(); + System.out.println("Enumerated actions: "+(intv2-intv1)+" ms"); + } + + private List<ActionData> parse_equality_constraints(List<Action> action_list){ + + long intv1 = new Date().getTime(); + + List<ActionData> action_data = new LinkedList<ActionData>(); + + Map<Variable, Variable> variable_equal_variable_list = new LinkedHashMap<Variable, Variable>(); + Map<Variable, Variable> variable_not_equal_variable_list = new LinkedHashMap<Variable, Variable>(); + Map<Variable, Constant> variable_equal_constant_list = new LinkedHashMap<Variable, Constant>(); + Map<Variable, Constant> variable_not_equal_constant_list = new LinkedHashMap<Variable, Constant>(); + + + Iterator<Action> action_iterator = action_list.iterator(); + List<Action> new_actions = new LinkedList<Action>(); + + //TODO tentatively agree that this works because everything is and. When forall and exists + //are implemented, take another look + while(action_iterator.hasNext()){ + + variable_equal_variable_list.clear(); + variable_not_equal_variable_list.clear(); + variable_equal_constant_list.clear(); + variable_not_equal_constant_list.clear(); + + Action current_action = action_iterator.next(); + ActionData this_action_data = new ActionData(current_action, typeset_to_constant); + new_actions.add(current_action); + + action_data.add(this_action_data); + + List<Term> all_variables = current_action.getParameters(); + + for(Term t: all_variables){ + if(t instanceof Variable){ + this_action_data.add_free_variable((Variable)t); + } + } + + AndExp tmp = new AndExp(); + tmp.add(((Action)current_action).getPrecondition()); + Iterator<Exp> precond_it = tmp.iterator(); + + AndExp new_precondition = tmp.clone(); + + + + while(precond_it.hasNext()){ + + + Exp k = precond_it.next(); + + switch(k.getExpID()){ + case ATOMIC_FORMULA:{ + break; + } + case NOT:{ + + Exp internal = ((NotExp)k).getExp(); + + switch(internal.getExpID()) + { + case F_COMP:{ + + EqualComp equal_exp = (EqualComp)internal; + + Term arg1 = equal_exp.getArg1(); + Term arg2 = equal_exp.getArg2(); + + boolean term1_var = (arg1 instanceof Variable); + boolean term2_var = (arg2 instanceof Variable); + + if(term1_var && term2_var){ + variable_not_equal_variable_list.put((Variable)arg1, (Variable)arg2); + new_precondition.remove(k); + } + else if(!term1_var && term2_var){ + variable_not_equal_constant_list.put((Variable)arg2, (Constant)arg1); + new_precondition.remove(k); + } + else if(term1_var && !term2_var){ + variable_not_equal_constant_list.put((Variable)arg1, (Constant)arg2); + new_precondition.remove(k); + } + else{ + if(arg1.equals(arg2)){ + + new_actions.remove(current_action); + break; + + }else{ + new_precondition.remove(k); + + } + new_precondition.remove(k); + } + + break; + }default:{ + break; + } + } + break; + } + case F_COMP:{ + EqualComp equal_exp = (EqualComp)k; + + Term arg1 = equal_exp.getArg1(); + Term arg2 = equal_exp.getArg2(); + + boolean term1_var = (arg1 instanceof Variable); + boolean term2_var = (arg2 instanceof Variable); + + + if(term1_var && term2_var){ + variable_equal_variable_list.put((Variable)arg1, (Variable)arg2); + new_precondition.remove(k); + } + else if(!term1_var && term2_var){ + variable_equal_constant_list.put((Variable)arg2, (Constant)arg1); + new_precondition.remove(k); + } + else if(term1_var && !term2_var){ + variable_equal_constant_list.put((Variable)arg1, (Constant)arg1); + new_precondition.remove(k); + } + else{ + if(arg1.equals(arg2)){ + new_precondition.remove(k); + }else{ + new_actions.remove(current_action); + break; + } + new_precondition.remove(k); + } + + break; + + }default:{ + System.out.println("Error: term "+k+" not recognized here"); + break; + } + + } + } + + current_action.setPrecondition(new_precondition); + + for(Variable t: variable_not_equal_variable_list.keySet()){ + this_action_data.fix_variable_not_equal_variable(t, variable_not_equal_variable_list.get(t)); + } + for(Variable t: variable_equal_variable_list.keySet()){ + this_action_data.fix_variable_to_variable(t, variable_equal_variable_list.get(t)); + } + for(Variable t: variable_not_equal_constant_list.keySet()){ + this_action_data.fix_variable_not_equal_constant(t, variable_not_equal_constant_list.get(t)); + } + for(Variable t: variable_equal_constant_list.keySet()){ + this_action_data.fix_variable_to_constant(t,variable_equal_constant_list.get(t)); + } + } + + long intv2 = new Date().getTime(); + System.out.println("Parsed equalities: "+(intv2-intv1)+" ms"); + + return action_data; + } + + private List<Action> convert_preconditions_to_prenex(List<Action> action_list){ + + long intv1 = new Date().getTime(); + + List<Action> new_actions = new LinkedList<Action>(); + + for(Action a: action_list){ + + Action a2 = a.clone(); + a2.setPrecondition(a2.getPrecondition().toNegativeNormalForm()); + new_actions.add(a2); + } + + long intv2 = new Date().getTime(); + System.out.println("Normalized: "+(intv2 - intv1)+" ms"); + + return new_actions; + } + + private List<Action> remove_conditionals(List<Action> action_list){ + + long intv1 = new Date().getTime(); + + boolean still_conditionals = true; + while(still_conditionals){ + still_conditionals = false; + List<Action> new_actions = new LinkedList<Action>(); + + for(Action a: action_list){ + + List<SplitChangePair> changes = split_when_conditions(a.getEffect()); + + if(changes.isEmpty()){ + new_actions.add(a); + } + + int i = 0; + for(SplitChangePair p: changes){ + + Action newAct = a.clone(); + newAct.setName(newAct.getName()+((i++==0)?"+":"-")); + newAct.setEffect(p.split_partial_exp); + AndExp newPrecondition = new AndExp(); + newPrecondition.add(a.getPrecondition().clone()); + newPrecondition.add(p.additions_to_other_exp); + newAct.setPrecondition(newPrecondition); + new_actions.add(newAct); + + still_conditionals = true; + } + } + + action_list = new_actions; + } + + long intv2 = new Date().getTime(); + System.out.println("Removed conditionals: "+(intv2-intv1)+" ms"); + + return action_list; + + } + + private List<Action> remove_precondition_disjunctions(List<Action> action_list){ + //TODO I'm not convinced that the toDisjunctive stuff necessarily gets rid of every or expression + //Check if this is true, and if it's not, do the disjunction cleaner + + long intv1 = new Date().getTime(); + + List<Action> actions_after_disjunctions = new LinkedList<Action>(); + + for(Action a: action_list){ + + Exp act_preconditions = ((Action)a).getPrecondition(); + OrExp act_preconditions_disj = (OrExp)act_preconditions.toDisjunctiveNormalForm(); + Iterator<Exp> terms_it = act_preconditions_disj.iterator(); + + int i = 0; + while(terms_it.hasNext()){ + + Exp new_act_preconditions = terms_it.next(); + Action new_action = ((Action)a).clone(); + new_action.setPrecondition(new_act_preconditions); + new_action.setName(a.getName()+"["+(i++)+"]"); + actions_after_disjunctions.add(new_action); + } + } + + + long intv2 = new Date().getTime(); + System.out.println("Removed disjunctions: "+(intv2-intv1)+" ms"); + + return actions_after_disjunctions; + + } + + private List<Action> get_all_actions(PDDLObject obj){ + + List<Action> actions_list = new LinkedList<Action>(); + Iterator<ActionDef> action_def_it = obj.actionsIterator(); + + while(action_def_it.hasNext()){ + + ActionDef d = action_def_it.next(); + actions_list.add(((Action)d).clone()); + } + + return actions_list; + } + + private void set_initial_propositions(PDDLObject obj){ + for(InitEl e: obj.getInit()){ + CondNode n = condition_nodes.get(e.toString()); + n.setProbability(1); + } + } + + private void enumerate_propositions_default(PDDLObject obj){ + + long intv1 = new Date().getTime(); + + Iterator<AtomicFormula> atom_it = obj.predicatesIterator(); + + //First enumerate all propositions--all set to false + while(atom_it.hasNext()){ + + AtomicFormula form = atom_it.next(); + List<Variable> variables = new LinkedList<Variable>(form.getFreeVariables()); + propositionEnumerationAux(form, variables, variables, new Substitution()); + } + + long intv2 = new Date().getTime(); + System.out.println("Enumerated conditions: "+(intv2-intv1)+" ms"); + } + + private void get_goals(PDDLObject obj){ + + Exp goals = obj.getGoal(); + Iterator<Exp> goal_it = ((AndExp)goals.toConjunctiveNormalForm()).iterator(); + + while(goal_it.hasNext()){ + + Exp current = goal_it.next(); + + String seek_string = null; + + switch(current.getExpID()) + { + case NOT: + { + seek_string = (((NotExp)current).getExp().toString()); + goal_states.put(seek_string, false); + break; + + } + default: { + + seek_string = (current.toString()); + goal_states.put(seek_string, true); + } + } + } + } + + private void record_constants(PDDLObject obj){ + + Iterator<Constant> const_it = obj.constantsIterator(); + + + //Keep track of what type each constant is, to save pain later + while(const_it.hasNext()){ + Constant c = const_it.next(); + + TypeSet type = c.getTypeSet(); + + Set<Type> all_types = new HashSet<Type>(); + Iterator<Type> type_it = type.iterator(); + while(type_it.hasNext()){ + Type typ = type_it.next(); + all_types.add(typ); + all_types.addAll(typ.getAllSuperTypes()); + } + + for(Type typ: all_types){ + + if(typeset_to_constant.get(typ) == null){ + typeset_to_constant.put(typ, new LinkedList<Constant>()); + + } + + typeset_to_constant.get(typ).add(c); + } + + resources.put(c.toTypedString(), new Resource(c.toString(), "DISCRETE", "1")); + + } + } + + /** + * Finds all conditions in effects and splits them into separate actions. + * + * else false + */ + + //TODO when forall and exists are implemented, see if this is still valid. + + private List<SplitChangePair> split_when_conditions(Exp e){ + + switch(e.getExpID()){ + + case AND:{ + + AndExp exp = (AndExp)e.clone(); + Iterator<Exp> exp_it = exp.iterator(); + + while(exp_it.hasNext()){ + + Exp search = exp_it.next(); + List<SplitChangePair> returned = split_when_conditions(search); + + if(!returned.isEmpty()){ + + for(SplitChangePair p: returned){ + + AndExp copy = exp.clone(); + copy.remove(search); + copy.add(p.split_partial_exp); + p.split_partial_exp = copy; + } + return returned; + } + } + + //Nothing new to add, return nothing + return new LinkedList<SplitChangePair>(); + + }case ATOMIC_FORMULA:{ + + return new LinkedList<SplitChangePair>(); + + }case NOT:{ + + NotExp exp = (NotExp)e; + Exp inner = exp.getExp(); + List<SplitChangePair> returned = split_when_conditions(inner); + + if(!returned.isEmpty()){ + + for(SplitChangePair p: returned){ + + NotExp copy = exp.clone(); + copy.setExp(p.split_partial_exp); + p.split_partial_exp = copy; + } + + return returned; + } + + return new LinkedList<SplitChangePair>(); + + }case WHEN:{ + + WhenExp when = (WhenExp)e; + + Exp condition = when.getCondition(); + Exp effect = when.getEffect(); + + List<SplitChangePair> changes = new LinkedList<SplitChangePair>(); + + SplitChangePair positive = new SplitChangePair(); + positive.additions_to_other_exp = condition; + positive.split_partial_exp = effect; + + SplitChangePair negative = new SplitChangePair(); + negative.additions_to_other_exp = new NotExp(condition); + negative.split_partial_exp = new AndExp(); + + changes.add(positive); + changes.add(negative); + + return changes; + + }case PROB_EXP:{ + + ProbExp p = (ProbExp)e; + + Iterator<Exp> exp_it = p.iterator(); + + while(exp_it.hasNext()){ + Exp expr = exp_it.next(); + + List<SplitChangePair> returned = split_when_conditions(expr); + + if(!returned.isEmpty()){ + + for(SplitChangePair pair: returned){ + + ProbExp new_exp = p.clone(); + new_exp.removeExp(expr); + new_exp.addExp(pair.split_partial_exp, p.getProbability(expr)); + pair.split_partial_exp = new_exp; + + } + + return returned; + + } + } + + return new LinkedList<SplitChangePair>(); + + } + } + + System.out.println("Error: term "+e+" not recognized here"); + System.exit(0); + return null; + + } + + private void actionEnumerationAux(ActionData dat){ + if(dat.has_free_variable()) + { + ActionData clone_dat = new ActionData(dat); + Variable to_fix = dat.get_first_free_variable(); + for(Constant c: dat.get_possible_values(to_fix)){ + clone_dat.temp_fix_variable_to_constant(to_fix, c); + actionEnumerationAux(clone_dat); + } + + }else + { + + String action_name = dat.get_action_name(); + Exp preconditions = dat.get_precondition_expression(); + Exp effects = dat.get_effect_expression(); + + + Iterator<Exp> precond_it = ((AndExp)preconditions).iterator(); + Iterator<Exp> effect_it = ((AndExp)effects).iterator(); + + TaskNode act = new TaskNode(action_name); + + + while(precond_it.hasNext()){ + + Exp k = precond_it.next(); + String condition_seek = null; + + switch(k.getExpID()){ + case ATOMIC_FORMULA:{ + condition_seek = (k.toString()); + act.attach_precondition(condition_nodes.get(condition_seek),true); + break; + }case NOT:{ + condition_seek = (((NotExp)k).getExp().toString()); + act.attach_precondition(condition_nodes.get(condition_seek),false); + break; + }default: + { + System.out.println("Error: term "+k+" not recognized here"); + System.exit(0); + break; + } + } + } + + while(effect_it.hasNext()){ + + Exp k = effect_it.next(); + String condition_seek = null; + + switch(k.getExpID()){ + case ATOMIC_FORMULA:{ + condition_seek = (k.toString()); + act.attach_effect(condition_nodes.get(condition_seek), 1); + break; + }case NOT:{ + condition_seek = (((NotExp)k).getExp().toString()); + act.attach_effect(condition_nodes.get(condition_seek), -1); + break; + }case PROB_EXP:{ + + ProbExp p = (ProbExp)k; + if(p.size() == 1){ + + Exp term = p.iterator().next(); + + switch(term.getExpID()){ + case ATOMIC_FORMULA:{ + + condition_seek = (term.toString()); + act.attach_effect(condition_nodes.get(condition_seek), p.getProbability(term)); + + break; + } + case NOT:{ + + condition_seek = ((NotExp)term).getExp().toString(); + act.attach_effect(condition_nodes.get(condition_seek), -p.getProbability(term)); + + break; + } + default:{ + + System.out.println("Error: term "+term+" not recognized here"); + System.exit(0); + } + } + }else if(p.size() == 0){ + //meh + } + else{ + System.out.println("Error: term "+k+" not recognized here"); + System.exit(0); + } + break; + }default:{ + + System.out.println("Error: term "+k+" not recognized here"); + System.exit(0); + break; + } + } + } + + + task_nodes.put(action_name, act); + task_to_resources.put(act, dat.get_all_substituted_parameters()); + precondition_links.addAll(act.get_positive_precondition_links()); + precondition_links.addAll(act.get_negative_precondition_links()); + + effect_links.addAll(act.get_positive_effect_links()); + effect_links.addAll(act.get_negative_effect_links()); + } + } + + + private void record_task_impls(){ + + for(TaskNode t: this.task_nodes.values()){ + task_impls.put(t.getName(), new TaskImpl(t.getName()+"_impl")); + task_to_impl_links.add(new TaskToImpl(t.getNodeID(), (t.getName()+"_impl"), "1")); + + for(String c: task_to_resources.get(t)){ + impl_to_resource_links.add(new ImplToResource((t.getName()+"_impl"), c, "1")); + } + } + } + + private void propositionEnumerationAux(AtomicFormula predicate, List<Variable> free, List<Variable> all_vars, Substitution s){ + + if(!free.isEmpty()) + { + Variable to_fix = free.get(0); + List<Variable> reduced = new LinkedList<Variable>(free); + reduced.remove(0); + + + Iterator<Type> type_it = to_fix.getTypeSet().iterator(); + + while(type_it.hasNext()){ + Type typ = type_it.next(); + if(typeset_to_constant.get(typ) != null) + for(Constant c: typeset_to_constant.get(typ)){ + + Substitution s2 = s.clone(); + s2.bind(to_fix, c); + + propositionEnumerationAux(predicate, reduced, all_vars, s2); + } + } + + }else + { + + AtomicFormula substituted = predicate.apply(s); + String formula = (substituted.toString()); + CondNode node = new CondNode(formula, 0, 0); + condition_nodes.put(formula, node); + + } + } + + public void printConditionNodes(){ + System.out.println("Conditions: "); + System.out.println(); + for(String s: condition_nodes.keySet()){ + System.out.println(condition_nodes.get(s).toString()); + } + System.out.println(); + } + + public void printTaskNodes(){ + System.out.println("Actions: "); + System.out.println(); + for(String s: task_nodes.keySet()){ + System.out.println(); + System.out.println(task_nodes.get(s).toString()); + } + System.out.println(); + } + + public void printGoals(){ + System.out.println("Goals: "); + System.out.println(); + for(String s: goal_states.keySet()){ + System.out.println(s+" Desired state: "+goal_states.get(s)); + } + System.out.println(); + } + + public void printSAN(){ + printConditionNodes(); + printTaskNodes(); + printGoals(); + } + + public void printTaskImpls(){ + System.out.println("Task Impls:"); + System.out.println(); + for(String s: task_impls.keySet()){ + System.out.println(task_impls.get(s).toString()); + } + + System.out.println(); + } + + public void printResources(){ + System.out.println("Resources:"); + System.out.println(); + for(String s: resources.keySet()){ + System.out.println(resources.get(s).toString()); + } + System.out.println(); + } + + public void printTaskToImpls(){ + System.out.println("TaskToImpls: "); + System.out.println(); + for(TaskToImpl s: task_to_impl_links){ + System.out.println(s.toString()); + } + System.out.println(); + } + + public void printResourceToImpls(){ + System.out.println("ResourceToImpls: "); + System.out.println(); + for(ImplToResource r: impl_to_resource_links){ + System.out.println(r.toString()); + } + System.out.println(); + } + + public void printTM(){ + printTaskImpls(); + printResources(); + printTaskToImpls(); + printResourceToImpls(); + } + + public long getConditonNodeCount(){ + return condition_nodes.size(); + } + + public long getActionNodeCount(){ + return task_nodes.size(); + } + + public void write_SAN_to_xml(String filename){ + + try{ + DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); + Document doc = docBuilder.newDocument(); + + Element root = doc.createElement("SANet:network"); + + root.setAttribute("xmlns:SANet", "http://www.vanderbilt.edu/SANet"); + root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); + root.setAttribute("xsi:schemaLocation", "http://www.vanderbilt.edu/SANet SANet_Network.xsd"); + root.setAttribute("xmlns", "http://www.vanderbilt.edu/SANet"); + + doc.appendChild(root); + + Element defaultAtten = doc.createElement("defaultAttenFactor"); + Text dAtten = doc.createTextNode(""); + defaultAtten.appendChild(dAtten); + + Element defCost = doc.createElement("defaultTaskCost"); + Text dCText = doc.createTextNode(""); + defCost.appendChild(dCText); + + Element defCondUtil = doc.createElement("defaultCondUtil"); + Text dCU = doc.createTextNode(""); + defCondUtil.appendChild(dCU); + + Element defProb = doc.createElement("defaultCondProbTrue"); + Text probTextt = doc.createTextNode(""); + defProb.appendChild(probTextt); + + Element linkThresh = doc.createElement("linkThresh"); + Text lThrT = doc.createTextNode(""); + linkThresh.appendChild(lThrT); + + root.appendChild(defaultAtten); + root.appendChild(defCost); + root.appendChild(defCondUtil); + root.appendChild(defProb); + root.appendChild(linkThresh); + + for(TaskNode a: task_nodes.values()){ + + if(!init_act_visible && a.getNodeID().equals("20")){ + continue; + } + + Element taskNode = doc.createElement("taskNode"); + + Element nodeID = doc.createElement("nodeID"); + Text idText = doc.createTextNode(a.getNodeID()); + nodeID.appendChild(idText); + + Element name = doc.createElement("name"); + Text nameText = doc.createTextNode(a.getName()); + name.appendChild(nameText); + + Element priorProb = doc.createElement("priorProb"); + Text probText = doc.createTextNode(new Double(a.getPriorProb()).toString()); + priorProb.appendChild(probText); + + Element attenFactor = doc.createElement("attenFactor"); + Text text = doc.createTextNode(a.getAttenFactor()); + attenFactor.appendChild(text); + + Element cost = doc.createElement("cost"); + Text costText = doc.createTextNode(a.getCost()); + cost.appendChild(costText); + + taskNode.appendChild(nodeID); + taskNode.appendChild(name); + taskNode.appendChild(priorProb); + taskNode.appendChild(attenFactor); + taskNode.appendChild(cost); + + root.appendChild(taskNode); + } + + for(CondNode c: condition_nodes.values()){ + Element condNode = doc.createElement("condNode"); + + Element nodeID = doc.createElement("nodeID"); + Text idText = doc.createTextNode(c.getNodeID()); + nodeID.appendChild(idText); + + Element name = doc.createElement("name"); + Text nameText = doc.createTextNode(c.getName()); + name.appendChild(nameText); + + Element probTrue = doc.createElement("probTrue"); + Text probText = doc.createTextNode(new Double(c.getProbability()).toString()); + probTrue.appendChild(probText); + + Element utility = doc.createElement("utility"); + Text utilText = doc.createTextNode(new Double(c.getUtility()).toString()); + utility.appendChild(utilText); + + Element kind = doc.createElement("kind"); + Text kindText = doc.createTextNode(c.getKind()); + kind.appendChild(kindText); + + Element attenFactor = doc.createElement("attenFactor"); + Text attenText = doc.createTextNode(c.getAttenFactor()); + attenFactor.appendChild(attenText); + + condNode.appendChild(nodeID); + condNode.appendChild(name); + condNode.appendChild(probTrue); + condNode.appendChild(utility); + condNode.appendChild(kind); + condNode.appendChild(attenFactor); + + root.appendChild(condNode); + } + + for(PrecondLink l: precondition_links){ + + + + Element preLink = doc.createElement("precondLink"); + + Element condID = doc.createElement("condID"); + Text idText = doc.createTextNode(l.getCondID()); + condID.appendChild(idText); + + Element taskID = doc.createElement("taskID"); + Text taskText = doc.createTextNode(l.getTaskID()); + taskID.appendChild(taskText); + + Element portID = doc.createElement("portID"); + Text portText = doc.createTextNode(l.getPortID()); + portID.appendChild(portText); + + Element trueProb = doc.createElement("trueProb"); + Text trueText = doc.createTextNode(new Double(l.getTrueProb()).toString()); + trueProb.appendChild(trueText); + + Element falseProb = doc.createElement("falseProb"); + Text falseText = doc.createTextNode(new Double(l.getFalseProb()).toString()); + falseProb.appendChild(falseText); + + preLink.appendChild(condID); + preLink.appendChild(taskID); + preLink.appendChild(portID); + preLink.appendChild(trueProb); + preLink.appendChild(falseProb); + + root.appendChild(preLink); + } + + for(EffectLink l: effect_links){ + + if(!init_act_visible && l.action.getNodeID().equals("20")){ + continue; + } + + Element effLink = doc.createElement("effectLink"); + + Element taskID = doc.createElement("taskID"); + Text idText = doc.createTextNode(l.getTaskID()); + taskID.appendChild(idText); + + Element condID = doc.createElement("condID"); + Text condText = doc.createTextNode(l.getCondID()); + condID.appendChild(condText); + + Element portID = doc.createElement("portID"); + Text portText = doc.createTextNode(l.getPortID()); + portID.appendChild(portText); + + Element weight = doc.createElement("weight"); + Text weightText = doc.createTextNode(new Double(l.getWeight()).toString()); + weight.appendChild(weightText); + + effLink.appendChild(taskID); + effLink.appendChild(condID); + effLink.appendChild(portID); + effLink.appendChild(weight); + + root.appendChild(effLink); + } + + //set up a transformer + TransformerFactory transfac = TransformerFactory.newInstance(); + Transformer trans = transfac.newTransformer(); + trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); + trans.setOutputProperty(OutputKeys.INDENT, "yes"); + trans.setOutputProperty(OutputKeys.STANDALONE, "no"); + + //create string from xml tree + StringWriter sw = new StringWriter(); + StreamResult result = new StreamResult(sw); + DOMSource source = new DOMSource(doc); + trans.transform(source, result); + + FileWriter f = new FileWriter(filename); + f.write(sw.toString()); + f.close(); + + }catch(Exception e){ + e.printStackTrace(); + } + + } + + public void write_TM_to_xml(String filename){ + + try{ + DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); + Document doc = docBuilder.newDocument(); + + Element root = doc.createElement("SA-POP:taskMap"); + + root.setAttribute("xmlns:SA-POP", "http://www.vanderbilt.edu/SA-POP"); + root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); + root.setAttribute("xsi:schemaLocation", "http://www.vanderbilt.edu/SA-POP Task_Map.xsd"); + root.setAttribute("xmlns", "http://www.vanderbilt.edu/SA-POP"); + + for(TaskImpl t: task_impls.values()){ + + if(!init_act_visible && t.getImplID().equals("initact_impl")){ + continue; + } + + Element taskImpl = doc.createElement("taskImpl"); + + Element implID = doc.createElement("implID"); + Text implText = doc.createTextNode(t.getImplID()); + implID.appendChild(implText); + + Element param = doc.createElement("param"); + + Element paramID = doc.createElement("paramID"); + Text paramIDText = doc.createTextNode(t.getParam().getParamID()); + paramID.appendChild(paramIDText); + + Element paramKind = doc.createElement("kind"); + Text paramKindText = doc.createTextNode(t.getParam().getKind()); + paramKind.appendChild(paramKindText); + + Element paramValue = doc.createElement("value"); + Text paramValueText = doc.createTextNode(t.getParam().getValue()); + paramValue.appendChild(paramValueText); + + param.appendChild(paramID); + param.appendChild(paramKind); + param.appendChild(paramValue); + + taskImpl.appendChild(implID); + taskImpl.appendChild(param); + + root.appendChild(taskImpl); + + } + + for(Resource r: resources.values()){ + + Element resource = doc.createElement("resource"); + + Element resourceID = doc.createElement("resourceID"); + Text resourceText = doc.createTextNode(r.getResourceID()); + resourceID.appendChild(resourceText); + + Element kind = doc.createElement("kind"); + Text kindText = doc.createTextNode(r.getKind()); + kind.appendChild(kindText); + + Element capacity = doc.createElement("capacity"); + Text capacityText = doc.createTextNode(r.getCapacity()); + capacity.appendChild(capacityText); + + resource.appendChild(resourceID); + resource.appendChild(kind); + resource.appendChild(capacity); + + root.appendChild(resource); + + } + + for(TaskToImpl t: task_to_impl_links){ + + if(!init_act_visible && t.getTaskID().equals("20")){ + continue; + } + + Element taskToImpl = doc.createElement("taskToImpl"); + + Element taskID = doc.createElement("taskID"); + Text taskIDText = doc.createTextNode(t.getTaskID()); + taskID.appendChild(taskIDText); + + Element implID = doc.createElement("implID"); + Text implIDText = doc.createTextNode(t.getImplID()); + implID.appendChild(implIDText); + + Element duration = doc.createElement("duration"); + Text durationText = doc.createTextNode(t.getDuration()); + duration.appendChild(durationText); + + taskToImpl.appendChild(taskID); + taskToImpl.appendChild(implID); + taskToImpl.appendChild(duration); + + root.appendChild(taskToImpl); + + } + + for(ImplToResource i: impl_to_resource_links){ + + Element implToResource = doc.createElement("implToResource"); + + Element implID = doc.createElement("implID"); + Text implIDText = doc.createTextNode(i.getImplID()); + implID.appendChild(implIDText); + + Element resourceID = doc.createElement("resourceID"); + Text resourceIDText = doc.createTextNode(i.getResourceID()); + resourceID.appendChild(resourceIDText); + + Element utilization = doc.createElement("utilization"); + Text utilizationText = doc.createTextNode(i.getUtilization()); + utilization.appendChild(utilizationText); + + implToResource.appendChild(implID); + implToResource.appendChild(resourceID); + implToResource.appendChild(utilization); + + root.appendChild(implToResource); + } + + doc.appendChild(root); + + //set up a transformer + TransformerFactory transfac = TransformerFactory.newInstance(); + Transformer trans = transfac.newTransformer(); + trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); + trans.setOutputProperty(OutputKeys.INDENT, "yes"); + trans.setOutputProperty(OutputKeys.STANDALONE, "no"); + + //create string from xml tree + StringWriter sw = new StringWriter(); + StreamResult result = new StreamResult(sw); + DOMSource source = new DOMSource(doc); + trans.transform(source, result); + + FileWriter f = new FileWriter(filename); + f.write(sw.toString()); + f.close(); + + }catch(Exception e){ + e.printStackTrace(); + } + } + + public void write_goals_to_file(String filename){ + try{ + FileWriter f = new FileWriter(filename); + for(String s: goal_states.keySet()){ + f.write(condition_nodes.get(s).getNodeID()+"\n"); + f.write(new Integer((goal_states.get(s))?10:-10).toString()+"\n"); + } + f.close(); + }catch(Exception e){ + e.printStackTrace(); + } + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/CondNode.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/CondNode.java new file mode 100644 index 00000000000..33a77f964ba --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/CondNode.java @@ -0,0 +1,106 @@ +package Translator.SAN_Data; + +import java.util.LinkedList; +import java.util.List; + + +/** + * Boolean state variable + * @author Ben + * + */ +public class CondNode{ + + private static int id_count = 0; + + final String name; + final String nodeID; + + double probTrue; + double utility; + + String kind = "ENVIRON"; + + String attenFactor =""; + + private List<EffectLink> affected_by; + private List<PrecondLink> precondition_to; + + public CondNode(String p_name, double p_initial_probability, double p_init_util){ + + name = p_name; + nodeID = ("1"+id_count++); + probTrue = p_initial_probability; + utility = p_init_util; + + affected_by = new LinkedList<EffectLink>(); + precondition_to = new LinkedList<PrecondLink>(); + } + + public void destroy(){ + for(EffectLink l: affected_by){ + if(l.getWeight() > 0){ + l.action.get_positive_effect_links().remove(l); + }else{ + l.action.get_negative_effect_links().remove(l); + } + } + + for(PrecondLink l: precondition_to){ + if(l.getRequiredState()){ + l.action.get_positive_precondition_links().remove(l); + }else{ + l.action.get_negative_precondition_links().remove(l); + } + } + } + + public List<EffectLink> getAffectedBy(){ + return affected_by; + } + + public List<PrecondLink> getPreconditionTo(){ + return precondition_to; + } + + public void setProbability(double prob){ + probTrue = prob; + } + + public String getNodeID(){ + return nodeID; + } + + public String getName(){ + return name; + } + + public double getProbability(){ + return probTrue; + } + + public double getUtility(){ + return utility; + } + + + public String getKind(){ + return kind; + } + + public String getAttenFactor(){ + return attenFactor; + } + + public String toString(){ + return ("Condition node: ["+name + "] ID: "+ nodeID +" Probability: "+ probTrue+ " Utility: "+ utility); + } + + public void attach_precondition_link(PrecondLink l){ + precondition_to.add(l); + } + + public void attach_effect_link(EffectLink l){ + affected_by.add(l); + } +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/EffectLink.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/EffectLink.java new file mode 100644 index 00000000000..69eeb862360 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/EffectLink.java @@ -0,0 +1,63 @@ +package Translator.SAN_Data; + +public class EffectLink{ + + final public TaskNode action; + final public CondNode effect; + + final double weight; + + String portID =""; + + public EffectLink(TaskNode p_action, CondNode p_effect, double p_weight){ + + action = p_action; + effect = p_effect; + weight = p_weight; + + p_effect.attach_effect_link(this); + } + + public String getTaskID(){ + return action.getNodeID(); + } + + public String getCondID(){ + return effect.getNodeID(); + } + + public String getPortID(){ + return portID; + } + + public double getWeight(){ + return weight; + } + + public String toString(){ + return ("Effect link from: ["+action.name+"] to ["+ effect.name + "] Weight: "+weight); + } + + public boolean sameSource(EffectLink l){ + return this.action == l.action && this.weight == l.weight; + } + + public boolean oppositeSource(EffectLink l){ + return this.action == l.action && this.weight != l.weight; + } + +// /** +// * Note! this does not +// */ +// public boolean equals(Object obj){ +// +// if(!(obj instanceof EffectLink)){ +// return false; +// } +// +// EffectLink other_link = (EffectLink)obj; +// +// return (other_link.action == action && other_link.weight == weight); +// +// } +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/PrecondLink.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/PrecondLink.java new file mode 100644 index 00000000000..175124eb64a --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/PrecondLink.java @@ -0,0 +1,62 @@ +package Translator.SAN_Data; + +public class PrecondLink{ + + final public CondNode precondition; + final public TaskNode action; + + final public boolean required_state; + + double true_prob; + double false_prob; + + String portID = ""; + + public PrecondLink(CondNode p_precond, TaskNode p_action, boolean required){ + + precondition = p_precond; + action = p_action; + required_state = required; + + p_precond.attach_precondition_link(this); + } + + public String getCondID(){ + return precondition.getNodeID(); + } + + public String getTaskID(){ + return action.getNodeID(); + } + + public double getTrueProb(){ + return true_prob; + } + + public double getFalseProb(){ + return false_prob; + } + + public boolean getRequiredState(){ + return required_state; + } + + public void setProbability(double prob){ + + if(required_state){ + true_prob = prob; + false_prob = 0; + }else{ + true_prob = 0; + false_prob = prob; + } + } + + public String getPortID(){ + return portID; + } + + public String toString(){ + return ("Precondition link from: ["+ precondition.name+ "] to ["+ action.name + "] t/f: "+ true_prob+ " "+ false_prob); + } +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/TaskNode.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/TaskNode.java new file mode 100644 index 00000000000..1ce17caf131 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/SAN_Data/TaskNode.java @@ -0,0 +1,161 @@ +package Translator.SAN_Data; + +import java.util.LinkedList; +import java.util.List; + + +/** + * Action node + * @author Ben + * + */ +public class TaskNode{ + + private static int id_count = 0; + + final String name; + final String nodeID; + + String attenFactor = ""; + String cost = ""; + +// private List<PrecondLink> preconditions; + private List<PrecondLink> positive_preconditions; + private List<PrecondLink> negative_preconditions; + + private List<EffectLink> negative_effects; + private List<EffectLink> positive_effects; + + + public TaskNode(String p_name){ + + name = p_name; + nodeID = "2"+(id_count++); + + positive_preconditions = new LinkedList<PrecondLink>(); + negative_preconditions = new LinkedList<PrecondLink>(); + + positive_effects = new LinkedList<EffectLink>(); + negative_effects = new LinkedList<EffectLink>(); + } + + public void destroy(){ + + for(PrecondLink l: positive_preconditions){ + l.precondition.getPreconditionTo().remove(l); + } + + for(PrecondLink l: negative_preconditions){ + l.precondition.getPreconditionTo().remove(l); + } + + for(EffectLink l: positive_effects){ + l.effect.getAffectedBy().remove(l); + } + + for(EffectLink l: negative_effects){ + l.effect.getAffectedBy().remove(l); + } + + } + + public void set_precondition_probabilities(){ + + int links = positive_preconditions.size()+negative_preconditions.size(); + + for(PrecondLink l: positive_preconditions){ + l.setProbability(Math.pow(.5, links-1)); + } + + for(PrecondLink l: negative_preconditions){ + l.setProbability(Math.pow(.5, links-1)); + } + } + + public PrecondLink attach_precondition(CondNode n, boolean required_state){ + PrecondLink plk = new PrecondLink(n, this, required_state); + + if(required_state){ + positive_preconditions.add(plk); + } + else{ + negative_preconditions.add(plk); + } + + return plk; + } + + public EffectLink attach_effect(CondNode n, double weight){ + EffectLink elk = new EffectLink(this, n, weight); + + if(weight > 0){ + positive_effects.add(elk); + }else{ + negative_effects.add(elk); + } + + return elk; + } + + public String getName(){ + return name; + } + + public String getNodeID(){ + return nodeID; + } + + public String getAttenFactor(){ + return attenFactor; + } + + public String getCost(){ + return cost; + } + +// public List<PrecondLink> get_precondition_links(){ +// return preconditions; +// } + + public List<PrecondLink> get_positive_precondition_links(){ + return positive_preconditions; + } + + public List<PrecondLink> get_negative_precondition_links(){ + return negative_preconditions; + } + + public List<EffectLink> get_positive_effect_links(){ + return positive_effects; + } + + public List<EffectLink> get_negative_effect_links(){ + return negative_effects; + } + + public double getPriorProb(){ + return Math.pow(.5, positive_preconditions.size()+ negative_preconditions.size()); + } + + public String toString(){ + String s = ("Action node: ["+ name+"] ID: "+nodeID); + + for(PrecondLink l: positive_preconditions){ + s+=("\n "+l.toString()); + } + + for(PrecondLink l: negative_preconditions){ + s+=("\n "+l.toString()); + } + + for(EffectLink l: positive_effects){ + s+=("\n "+l.toString()); + } + + for(EffectLink l: negative_effects){ + s+=("\n "+l.toString()); + } + + return s; + } +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/ImplToResource.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/ImplToResource.java new file mode 100644 index 00000000000..2acbdb2bc97 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/ImplToResource.java @@ -0,0 +1,31 @@ +package Translator.TM_Data; + +public class ImplToResource { + + public ImplToResource(String implID, String resourceID, String utilization) { + this.implID = implID; + this.resourceID = resourceID; + this.utilization = utilization; + } + + private String implID; + private String resourceID; + private String utilization; + + public String getImplID(){ + return implID; + } + + public String getResourceID(){ + return resourceID; + } + + public String getUtilization(){ + return utilization; + } + + public String toString(){ + return ("ImplID: "+ implID+ " ResourceID: "+resourceID+ " Utilization: "+ utilization); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/Resource.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/Resource.java new file mode 100644 index 00000000000..990e736dd23 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/Resource.java @@ -0,0 +1,31 @@ +package Translator.TM_Data; + +public class Resource { + + public Resource(String resourceID, String kind, String capacity) { + this.resourceID = resourceID; + this.kind = kind; + this.capacity = capacity; + } + + private String resourceID; + private String kind; + private String capacity; + + public String getCapacity() { + return capacity; + } + + public String getResourceID(){ + return resourceID; + } + + public String getKind(){ + return kind; + } + + public String toString(){ + return ("ResourceID: "+ resourceID+" Kind: "+kind+" Capacity: "+capacity); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/TaskImpl.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/TaskImpl.java new file mode 100644 index 00000000000..e02e56b5456 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/TaskImpl.java @@ -0,0 +1,44 @@ +package Translator.TM_Data; + +public class TaskImpl { + + public TaskImpl(String p_implID){ + implID = p_implID; + param = new Param(); + } + + private String implID; + private Param param; + + public String getImplID(){ + return implID; + } + + public Param getParam(){ + return param; + } + + public String toString(){ + return ("ImplID: "+implID); + } + + public class Param{ + + String paramID = "test_param1"; + String kind = "test_kind1"; + String value = "test_param_value1"; + + public String getParamID(){ + return paramID; + } + + public String getKind(){ + return kind; + } + + public String getValue(){ + return value; + } + } +} + diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/TaskToImpl.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/TaskToImpl.java new file mode 100644 index 00000000000..5960bc2edc1 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/Translator/TM_Data/TaskToImpl.java @@ -0,0 +1,30 @@ +package Translator.TM_Data; + +public class TaskToImpl { + + public TaskToImpl(String taskID, String implID, String duration) { + this.taskID = taskID; + this.implID = implID; + this.duration = duration; + } + + private String taskID; + private String implID; + private String duration; + + public String getTaskID(){ + return taskID; + } + + public String getImplID(){ + return implID; + } + + public String getDuration(){ + return duration; + } + + public String toString(){ + return ("TaskID: "+ " ImplID: "+implID+" Duration: "+duration); + } +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Domain.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Domain.java new file mode 100644 index 00000000000..cebc0ce72e3 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Domain.java @@ -0,0 +1,119 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j; + +import java.io.File; +import java.io.Serializable; +import java.util.Iterator; +import java.util.Set; + +import pddl4j.exp.AtomicFormula; +import pddl4j.exp.action.ActionDef; +import pddl4j.exp.term.Constant; +import pddl4j.exp.type.Type; +import pddl4j.exp.type.TypeSet; + +/** + * This interface defines the accessible methods from a domain. + * + * @author Damien Pellier + * @version 1.0 + */ +public interface Domain extends Serializable { + + /** + * Returns an iterator over the requirements of this pddl object. + * + * @return an iterator over the requirements of this pddl object. + */ + Iterator<RequireKey> requirementsIterator(); + + /** + * Returns the set of constants associated to a specified type. + * + * @param type the type. + * @return the set of constants associated to a type or <code>null</code> + * if the type is not defined in the pddl object. + */ + Set<Constant> getTypedDomain(Type type); + + /** + * Returns the set of constants associated to a specified type. + * + * @param typeSet the type. + * @return the set of constants associated to a type or <code>null</code> + * if the type is not defined in the pddl object. + */ + Set<Constant> getTypedDomain(TypeSet typeSet); + + /** + * Returns an iterator over the types defined in this pddl object. + * + * @return an iterator over the types defined in this pddl object. + */ + //Iterator<Type> typesIterator(); + + /** + * Returns an iterator over the constants defined in this pddl object. + * + * @return an iterator over the constants defined in this pddl object. + */ + Iterator<Constant> constantsIterator(); + + /** + * Returns an iterator over the constants defined in this pddl object. + * + * @return an iterator over the constants defined in this pddl object. + */ + Iterator<AtomicFormula> predicatesIterator(); + + /** + * Returns an iterator over the actions defined in this pddl object. + * + * @return an iterator over the actions defined in this pddl object. + */ + Iterator<ActionDef> actionsIterator(); + + /** + * Returns the domain file where the PDDL object is defined. + * + * @return the domain file where the PDDL object is defined. + */ + File getDomainFile(); + + /** + * Returns the name of the domain. + * + * @return the name of the domain. + */ + String getDomainName(); + +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/ErrorManager.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/ErrorManager.java new file mode 100644 index 00000000000..c1e4fcd48a0 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/ErrorManager.java @@ -0,0 +1,466 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j; + +import java.io.File; +import java.io.PrintStream; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.SortedMap; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; + +/** + * This class implements the error manager used by the parser and java pddl + * compiler. + * + * @author Damien Pellier + * @version 1.0 + */ +public class ErrorManager { + + /** + * This enumeration defines the type of message log in the error manager. + */ + public enum Message { + /** + * The parser error message. + */ + PARSER_ERROR, + + /** + * The parser warning message. + */ + PARSER_WARNING, + /** + * The lexical error message. + */ + LEXICAL_ERROR, + /** + * The linker error message. + */ + LINKER_ERROR, + /** + * The linker warning message. + */ + LINKER_WARNING, + /** + * The all type message. + */ + ALL, + /** + * The parser message. + */ + PARSER, + /** + * The parser message. + */ + LINKER, + /** + * The error message. + */ + ERROR, + /** + * The warning message. + */ + WARNING, + + } + /** + * The tree set used to store the messages. + */ + private SortedSet<String> msg; + + /** + * The tree set used to store the messages by type. + */ + private TreeMap<Message, Set<String>> tMsg; + + /** + * The tree set used to store the messages by file. + */ + private SortedMap<File, Set<String>> fMsg; + + /** + * The print stream of the error manager. + */ + private PrintStream out; + + /** + * Creates a new msg manager. + */ + public ErrorManager() { + this.msg = new TreeSet<String>(); + this.tMsg = new TreeMap<Message, Set<String>>(); + this.fMsg = new TreeMap<File, Set<String>>(); + this.out = System.out; + } + + /** + * Sets a new output stream to the error manager. + * + * @param out the new output stream of the error manager. + */ + private void setOutputStream(PrintStream out) { + this.out = out; + } + + /** + * Print the messages log in the error manager. + * + * @param type the type of message to print. + */ + public void print(Message type) { + this.print(this.getMessages(type)); + } + + /** + * Print the messages log in the error manager that concerns a specific file. + * + * @param file The file. + */ + public void print(File file) { + this.print(this.fMsg.get(file)); + } + + /** + * Print the messages log in the error manager of a specific and concerning a specific file. + * + * @param type the type of message to print. + * @param file the file. + */ + public void print(Message type, File file) { + this.print(this.getMessages(type, file)); + } + + /** + * Print the message to the current output stream. + * + * @param msg the list of messages to print. + */ + private void print(Collection<String> msg) { + if (msg != null) { + for (String error : msg) { + this.out.println(error); + } + } + } + + /** + * Returns the list of messages of a specific type. + * + * @param type The type of messages. + * @return The list of messages of a specific type. + */ + public Set<String> getMessages(Message type) { + Set<String> messages = new HashSet<String>(); + switch(type) { + case PARSER: + messages.addAll(this.getMessages(Message.PARSER_ERROR)); + messages.addAll(this.getMessages(Message.PARSER_WARNING)); + break; + case LINKER: + messages.addAll(this.getMessages(Message.LINKER_ERROR)); + messages.addAll(this.getMessages(Message.LINKER_WARNING)); + break; + case ERROR: + messages.addAll(this.getMessages(Message.LEXICAL_ERROR)); + messages.addAll(this.getMessages(Message.PARSER_ERROR)); + messages.addAll(this.getMessages(Message.LINKER_ERROR)); + break; + case WARNING: + messages.addAll(this.getMessages(Message.PARSER_WARNING)); + messages.addAll(this.getMessages(Message.LINKER_WARNING)); + break; + case ALL: + messages = this.msg; + break; + default: + messages = this.tMsg.get(type); + if (messages == null) { + messages = new HashSet<String>(); + } + } + return messages; + } + + /** + * Returns the list of messages that concerns a specific file. + * + * @param file The file. + * @return The list of messages. + */ + public Set<String> getMessages(File file) { + Set<String> msg = this.fMsg.get(file); + return msg == null ? new HashSet<String>() : msg; + } + + /** + * Returns the list of messages of a specific type concerning a specific file. + * + * @param type The type of messages. + * @param file The file. + * @return The list of messages of a specific type concerning a specific file. + */ + public Set<String> getMessages(Message type, File file) { + Set<String> s1 = new HashSet<String>(this.getMessages(type)); + Set<String> s2 = this.getMessages(file); + s1.retainAll(s2); + return s1; + } + + /** + * Init the msg manager. + */ + public void clear() { + this.msg.clear(); + } + + /** + * Returns if the msg manager is empty, i.e., contains no message of any + * type. + * + * @return <code>true</code> if the msg manager is empty; + * <code>false</code> otherwise. + */ + public boolean isEmpty() { + return this.msg.isEmpty(); + } + + /** + * Returns <code>true</code> if the error manager contains message of a + * specific type. + * + * @param type th type tested. + * @return <code>true</code> if the error manager contains message of a + * specific type; <code>false</code> otherwise. + */ + public boolean contains(Message type) { + return !this.getMessages(type).isEmpty(); + } + + /** + * Log an error message to the current print stream. + * + * @param msg the error message. + * @param file the file where the warning was encoutered. + * @param line the line of the error. + * @param column the column of the error. + */ + public void logParserError(String msg, File file, int line, int column) { + String error = "Parser error at line " + line + ", column " + column + + " file (" + file.getName() + ") : " + msg; + this.msg.add(error); + Set<String> msgl = this.tMsg.get(Message.PARSER_ERROR); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.tMsg.put(Message.PARSER_ERROR, msgl); + } + msgl.add(error); + msgl = this.fMsg.get(file); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.fMsg.put(file, msgl); + } + msgl.add(error); + } + + /** + * Log an lexical error message. + * + * @param msg the error message. + * @param file the file where the error was encoutered. + */ + public void logLexicalError(String msg, File file) { + String error = msg + " in file " + file.getName(); + this.msg.add(error); + Set<String> msgl = this.tMsg.get(Message.LEXICAL_ERROR); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.tMsg.put(Message.LEXICAL_ERROR, msgl); + } + msgl.add(error); + msgl = this.fMsg.get(file); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.fMsg.put(file, msgl); + } + msgl.add(error); + } + + /** + * Log an lexical error message. + * + * @param msg the error message. + * @param file the file where the error was encoutered. + * @param line the line of the error. + * @param column the column of the error. + */ + public void logLexicalError(String msg, File file, int line, int column) { + String error = "Lexical error at line " + line + ", column " + column + ", file (" + file.getName() + ") : " + msg; + this.msg.add(error); + Set<String> msgl = this.tMsg.get(Message.LEXICAL_ERROR); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.tMsg.put(Message.LEXICAL_ERROR, msgl); + } + msgl.add(error); + msgl = this.fMsg.get(file); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.fMsg.put(file, msgl); + } + msgl.add(error); + } + + /** + * Log a warning message to the current print stream. + * + * @param msg the warning message. + * @param file the file where the warning was encoutered. + * @param line the line of the warning. + * @param column the column of the warning. + */ + public void logParserWarning(String msg, File file, int line, int column) { + String warning = "Parser warning at line " + line + ", column " + column + + " file (" + file.getName() + ") : " + msg; + this.msg.add(warning); + Set<String> msgl = this.tMsg.get(Message.PARSER_WARNING); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.tMsg.put(Message.PARSER_WARNING, msgl); + } + msgl.add(warning); + msgl = this.fMsg.get(file); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.fMsg.put(file, msgl); + } + msgl.add(warning); + } + + /** + * Log a warning message to the current print stream. + * + * @param msg the warning message. + * @param file the file where the warning was encoutered. + */ + public void logLinkerWarning(String msg, File file) { + String warning = "Linker warning (" + file.getName() + "): " + msg; + this.msg.add(warning); + Set<String> msgl = this.tMsg.get(Message.LINKER_WARNING); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.tMsg.put(Message.LINKER_WARNING, msgl); + } + msgl.add(warning); + msgl = this.fMsg.get(file); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.fMsg.put(file, msgl); + } + msgl.add(warning); + } + + /** + * Log an error message to the current print stream. + * + * @param msg the warning message. + * @param file the file where the warning was encoutered. + */ + public void logLinkerError(String msg, File file) { + String error = "Linker error (" + file.getName() + "): " + msg; + this.msg.add(error); + Set<String> msgl = this.tMsg.get(Message.LINKER_ERROR); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.tMsg.put(Message.LINKER_ERROR, msgl); + } + msgl.add(error); + msgl = this.fMsg.get(file); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.fMsg.put(file, msgl); + } + msgl.add(error); + } + + /** + * Log a warning message to the current print stream. + * + * @param msg the warning message. + * @param file the file where the warning was encoutered. + */ + public void logParserWarning(String msg, File file) { + String warning = "Parser warning (" + file.getName() + "): " + msg; + this.msg.add(warning); + Set<String> msgl = this.tMsg.get(Message.PARSER_WARNING); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.tMsg.put(Message.PARSER_WARNING, msgl); + } + msgl.add(warning); + msgl = this.fMsg.get(file); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.fMsg.put(file, msgl); + } + msgl.add(warning); + } + + /** + * Log an error message to the current print stream. + * + * @param msg the warning message. + * @param file the file where the warning was encoutered. + */ + public void logParserError(String msg, File file) { + String error = "Compiler error (" + file.getName() + "): " + msg; + this.msg.add(error); + Set<String> msgl = this.tMsg.get(Message.PARSER_ERROR); + + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.tMsg.put(Message.PARSER_ERROR, msgl); + } + msgl.add(error); + msgl = this.fMsg.get(file); + if (msgl == null) { + msgl = new LinkedHashSet<String>(); + this.fMsg.put(file, msgl); + } + msgl.add(error); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/EvaluationException.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/EvaluationException.java new file mode 100644 index 00000000000..7996517c118 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/EvaluationException.java @@ -0,0 +1,100 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j; + +/** + * EvaluationException is thrown if an attempt is made to evaluate a function + * and its evaluation fails. Specially, the evaluation may fail if the function + * is not ground or if an arithmetic error occurs during the evaluation. + * + * @author Damien Pellier + * @version 1.0 + */ +public class EvaluationException extends RuntimeException { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 6846672849363008483L; + + /** + * Creates a new evaluation exception. with null as its detail message. The + * cause is not initialized, and may subsequently be initialized by a call + * to <code>Throwable.initCause(java.lang.Throwable)</code>. + */ + public EvaluationException() { + super(); + } + + /** + * Creates a new evaluation exception with the specified detail message and + * cause. + * + * @param message the detail message (which is saved for later retrieval by + * the <code>Throwable.getMessage() method</code>). + * @param cause the cause (which is saved for later retrieval by the + * <code>Throwable.getCause()</code> method). (A + * <code>null</code> value is permitted, and indicates that the + * cause is nonexistent or unknown.) + */ + public EvaluationException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Creates a new evaluation exception with the specified detail message. The + * cause is not initialized, and may subsequently be initialized by a call + * to Throwable.initCause(java.lang.Throwable). + * + * @param message the detail message (which is saved for later retrieval by + * the Throwable.getMessage() method). + */ + public EvaluationException(String message) { + super(message); + } + + /** + * Creates a new evaluation exception with the specified cause and a detail + * message of <code>(cause==null ? null : cause.toString())</code> (which + * typically contains the class and detail message of cause). This + * constructor is useful for exceptions that are little more than wrappers + * for other throwables (for example, <code>PrivilegedActionException</code>). + * + * @param cause the cause (which is saved for later retrieval by the + * <code>Throwable.getCause()</code> method). (A + * <code>null</code> value is permitted, and indicates that the + * cause is nonexistent or unknown.) + */ + public EvaluationException(Throwable cause) { + super(cause); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/InvalidExpException.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/InvalidExpException.java new file mode 100644 index 00000000000..506a8d2f0a9 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/InvalidExpException.java @@ -0,0 +1,114 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j; + +import pddl4j.exp.ExpID; + + +/** + * This expression is throw when an unexpected pddl expression is detected. + * + * @author Damien Pellier + * @version 1.0 + */ +public class InvalidExpException extends Exception { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 5912801078385971869L; + + /** + * The id of the invalid pddl expression. + */ + private ExpID id; + + /** + * Creates a new invalid PDDL expression. + */ + private InvalidExpException() {} + + /** + * Creates a new invalid PDDL expression with a specified expression id. + * + * @param id the id of the pddl expression that produce the exception. + */ + public InvalidExpException(ExpID id) { + super(); + this.id = id; + } + + /** + * Creates a new invalid PDDL expression with a specified expression id. + * + * @param id the id of the pddl expression that produce the exception. + * @param message The message of the exception. + * @param cause The cause of the exception. + */ + public InvalidExpException(ExpID id, String message, Throwable cause) { + super(message, cause); + this.id = id; + } + + /** + * Creates a new invalid PDDL expression with a specified expression id. + * + * @param id the id of the pddl expression that produce the exception. + * @param message The message of the exception. + */ + public InvalidExpException(ExpID id, String message) { + super(message); + this.id = id; + } + + /** + * Creates a new invalid PDDL expression with a specified expression id. + * + * @param id the id of the pddl expression that produce the exception. + * @param cause The cause of the exception. + */ + public InvalidExpException(ExpID id, Throwable cause) { + super(cause); + this.id = id; + } + + /** + * Returns a string representation of this exception. + * + * @return a string representation of this exception. + */ + public String toString() { + return super.getMessage() != null ? + "invalid PDDL expression " + this.id + " : " + super.getMessage() : + "invalid PDDL expression " + this.id; + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/PDDLObject.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/PDDLObject.java new file mode 100644 index 00000000000..69c9af1241b --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/PDDLObject.java @@ -0,0 +1,697 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j; + +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.AndExp; +import pddl4j.exp.AtomicFormula; +import pddl4j.exp.DerivedPredicate; +import pddl4j.exp.Exp; +import pddl4j.exp.InitEl; +import pddl4j.exp.action.ActionDef; +import pddl4j.exp.fexp.FHead; +import pddl4j.exp.metric.MetricExp; +import pddl4j.exp.type.Type; +import pddl4j.exp.type.TypeSet; +import pddl4j.exp.term.Constant; + +/** + * This class implements a PDDL object that represente a planning domain either + * a planning problem. + * + * @author Damien Pellier + * @version 1.0 + */ +public class PDDLObject implements Domain, Problem { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -8333968277204698622L; + + /** + * This enumeration defines the content of the PDDL object. + * + * @author Damien Pellier + * @version 1.0 + */ + public enum Content { + /** + * The DOMAIN content. + */ + DOMAIN, + /** + * The PARTIAL_PROBLEM content. + */ + PARTIAL_PROBLEM, + /** + * The FULL_PROBLEM content. + */ + FULL_PROBLEM; + } + + /** + * The source version of PDDL object. + */ + protected Source source; + + /** + * The domain name of this PDDL object. + */ + protected String domainName; + + /** + * The problem name of this PDDL object. + */ + protected String problemName; + + /** + * The require table of this PDDL object. + */ + protected LinkedHashSet<RequireKey> requirements; + + /** + * Returns an iterator over the requirements of this pddl object. + * + * @return an iterator over the requirements of this pddl object. + */ + public Iterator<RequireKey> requirementsIterator() { + return this.requirements.iterator(); + } + + /** + * The types table of this PDDL object. + */ + protected Map<String, Set<String>> types; + + /** + * The map used to store for each type its domain. + */ + protected Map<Type, Set<Constant>> typeDomains; + + /** + * Returns the set of constants associated to a specified type. + * + * @param type the type. + * @return the set of constants associated to a type or <code>null</code> + * if the type is not defined in the pddl object. + */ + public Set<Constant> getTypedDomain(Type type) { + Set<Constant> domain = this.typeDomains.get(type); + if (domain == null) { + domain = new LinkedHashSet<Constant>(); + } + for (Type st : type.getSubTypes()) { + Set<Constant> tmp = this.typeDomains.get(st); + if (tmp != null) domain.addAll(tmp); + } + return domain; + } + + /** + * Returns the set of constants associated to a specified type. + * + * @param typeSet the type. + * @return the set of constants associated to a type or <code>null</code> + * if the type is not defined in the pddl object. + */ + public Set<Constant> getTypedDomain(TypeSet typeSet) { + Set<Constant> domain = new LinkedHashSet<Constant>(); + for (Type type : typeSet) { + domain.addAll(this.getTypedDomain(type)); + } + return domain; + } + + + + /** + * The constants table of this PDDL object. + */ + protected Map<String, Constant> constants; + + /** + * Returns an iterator over the constants defined in this pddl object. + * + * @return an iterator over the constants defined in this pddl object. + */ + public Iterator<Constant> constantsIterator() { + return this.constants.values().iterator(); + } + + /** + * The predicates table of this PDDL object. + */ + protected Set<AtomicFormula> predicates; + + /** + * Returns an iterator over the constants defined in this pddl object. + * + * @return an iterator over the constants defined in this pddl object. + */ + public Iterator<AtomicFormula> predicatesIterator() { + return this.predicates.iterator(); + } + + /** + * The functions table of this PDDL object. + */ + protected Set<FHead> functions; + + /** + * Returns an iterator over the functions defined in this pddl object. + * + * @return an iterator over the functions defined in this pddl object. + */ + public Iterator<FHead> functionsIterator() { + return this.functions.iterator(); + } + + /** + * The constraints table of this PDDL object. + */ + protected Set<Exp> constraints; + + /** + * The actions table of this PDDL object. + */ + protected Map<String, ActionDef> actions; + + /** + * Returns an iterator over the actions defined in this pddl object. + * + * @return an iterator over the actions defined in this pddl object. + */ + public Iterator<ActionDef> actionsIterator() { + return this.actions.values().iterator(); + } + + /** + * The axioms predicates table of this PDDL object. + */ + protected Set<DerivedPredicate> axioms; + + /** + * The initial state. + */ + protected ArrayList<InitEl> init; + + /** + * The goal. + */ + protected Exp goal; + + /** + * The content of the PDDL object. + */ + protected Content content; + + /** + * The metric specification. + */ + protected MetricExp metric; + + /** + * The domain file where the PDDL object is defined. + */ + protected File domainFile; + + /** + * The domain file where the PDDL object is defined. + */ + protected File problemFile; + + + /** + * Creates a new PDDL object. + */ + public PDDLObject() { + this.content = Content.DOMAIN; + this.domainFile = null; + this.problemFile = null; + this.source = Source.V3_0; + this.domainName = new String(); + this.problemName = new String(); + this.requirements = new LinkedHashSet<RequireKey>(); + this.requirements.add(RequireKey.STRIPS); + this.types = new LinkedHashMap<String, Set<String>>(); + this.types.put(Type.OBJECT_SYMBOL, new LinkedHashSet<String>()); + this.typeDomains = new LinkedHashMap<Type, Set<Constant>>(); + this.constants = new LinkedHashMap<String, Constant>(); + this.predicates = new LinkedHashSet<AtomicFormula>(); + this.functions = new LinkedHashSet<FHead>(); + this.constraints = new LinkedHashSet<Exp>(); + this.actions = new LinkedHashMap<String, ActionDef>(); + this.axioms = new LinkedHashSet<DerivedPredicate>(); + this.init = new ArrayList<InitEl>(); + this.goal = new AndExp(); + this.metric = null; + } + + /** + * Returns the metric of the PDDL object. + * + * @return the metric of the PDDL object. + */ + public MetricExp getMetric() { + return this.metric; + } + + /** + * Returns the domain file where the PDDL object is defined. + * + * @return the domain file where the PDDL object is defined. + */ + public File getDomainFile() { + return this.domainFile; + } + + /** + * Returns the problem file where the PDDL object is defined. + * + * @return the problem file where the PDDL object is defined. + */ + public File getProblemFile() { + return this.problemFile; + } + + /** + * Returns the content of the PDDL object. + * + * @return the content of the PDDL object. + */ + public Content getContent() { + return this.content; + } + + /** + * Returns the goal of the PDDL object. + * + * @return the goal of the PDDL object. + */ + public Exp getGoal() { + return this.goal; + } + + /** + * Returns the initial state of the PDDL object. + * + * @return the initial state of the PDDL object. + */ + public List<InitEl> getInit() { + return this.init; + } + + /** + * Returns the name of the domain. + * + * @return the name of the domain. + */ + public String getDomainName() { + return this.domainName; + } + + /** + * Returns the name of the problem. + * + * @return the name of the problem. + */ + public String getProblemName() { + return this.problemName; + } + + /** + * Returns <code>true</code> if this domain is equal to an other object, + * i.e., if the other object is an instance of the class <code>Domain</code> + * not null and has the image. + * + * @param obj the object to compare. + * @return <code>true</code> if this domain is equals to an other object; + * <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj.getClass().equals(this.getClass())) { + PDDLObject other = (PDDLObject) obj; + return this.domainName.equals(other.domainName) + && this.problemName.equals(other.problemName) + && this.content.equals(other.content); + } + return false; + } + + /** + * Returns the hash code value of this domain. + * + * @return the hash code value of this domain. + */ + public int hashCode() { + return this.domainName.hashCode() + this.problemName.hashCode() + + this.content.hashCode(); + } + + /** + * Returns a string representation of the PDDL object. + * + * @return the string representation of the PDDL object. + */ + public String toString() { + String str = new String(); + switch (this.content) { + case DOMAIN: + str = toDomainString(); + break; + case PARTIAL_PROBLEM: + str = toPartialProblemString(); + break; + case FULL_PROBLEM: + str = toFullProblemString(); + break; + } + return str; + } + + /** + * Returns a string representation of a domain. + * + * @return the string representation of a domain. + */ + private String toDomainString() { + StringBuffer str = new StringBuffer(); + str.append("(define (domain " + this.domainName + ")\n"); + str.append(this.requirementstoString()); + str.append(this.typestoString()); + str.append(this.constantsToString("constants")); + str.append(this.predicatesToString()); + str.append(this.functionsToString()); + str.append(this.constraintsToString()); + str.append(this.axiomsToString()); + str.append(this.actionsToString()); + return str.toString(); + + } + + /** + * Returns a string representation of a partial problem. + * + * @return the string representation of a partial problem. + */ + private String toPartialProblemString() { + StringBuffer str = new StringBuffer(); + str.append("(define (problem " + this.problemName + ")\n"); + str.append("(:domain " + this.domainName + ")\n"); + str.append(this.requirementstoString()); + str.append(this.constantsToString("objects")); + str.append(this.constraintsToString()); + str.append(this.initToString()); + str.append(this.goalToString()); + str.append(this.metricToString()); + return str.toString(); + + } + + /** + * Returns a string representation of a full problem. + * + * @return the string representation of a full problem. + */ + private String toFullProblemString() { + StringBuffer str = new StringBuffer(); + str.append("(:problem " + this.problemName + ")\n"); + str.append("(:domain " + this.domainName + ")\n"); + str.append(this.requirementstoString()); + str.append(this.typestoString()); + str.append(this.constantsToString("constants")); + str.append(this.predicatesToString()); + str.append(this.functionsToString()); + str.append(this.constraintsToString()); + str.append(this.axiomsToString()); + str.append(this.actionsToString()); + str.append(this.initToString()); + str.append(this.goalToString() + "\n"); + str.append(this.metricToString()); + return str.toString(); + + } + + /** + * Returns a string representation of the requirements. + * + * @return a string representation of the requirements. + */ + private String requirementstoString() { + StringBuffer str = new StringBuffer(); + if (!this.requirements.isEmpty()) { + str.append("(:requirements"); + for (RequireKey rk : this.requirements) { + str.append(" " + rk.toString()); + } + str.append(")\n"); + } + return str.toString(); + } + + /** + * Returns a string representation of the types. + * + * @return a string representation of the types. + */ + private String typestoString() { + StringBuffer str = new StringBuffer(); + if (!this.types.isEmpty()) { + str.append("(:types"); + for (String img : this.types.keySet()) { + Type type = new Type(img, this.types); + str.append("\n " + type.toString()); + Set<Type> superTypes = type.getSuperTypes(); + if (!superTypes.isEmpty()) { + str.append(" -"); + Iterator<Type> i = superTypes.iterator(); + if (superTypes.size() > 1) { + str.append(" (either"); + while (i.hasNext()) { + str.append(" " + i.next().toString()); + } + str.append(")"); + } else { + str.append(" " + i.next().toString()); + } + } + } + str.append(")\n"); + } + return str.toString(); + } + + /** + * Returns a string representation of the constants. + * + * @param label the label "constants" for domain and "objects for problem. + * @return a string representation of the constants. + */ + private String constantsToString(String label) { + StringBuffer str = new StringBuffer(); + if (!this.constants.isEmpty()) { + str.append("(:" + label); + for (Constant cst : this.constants.values()) { + if (this.requirements.contains(RequireKey.TYPING)) { + str.append("\n " + cst.toTypedString()); + } else { + str.append(" " + cst.toString()); + } + } + str.append(")\n"); + } + return str.toString(); + } + + /** + * Returns a string representation of the predicates. + * + * @return a string representation of the predicates. + */ + private String predicatesToString() { + StringBuffer str = new StringBuffer(); + if (!this.predicates.isEmpty()) { + str.append("(:predicates"); + for (AtomicFormula atom : this.predicates) { + if (this.requirements.contains(RequireKey.TYPING)) { + str.append("\n " + atom.toTypedString()); + } else { + str.append(" " + atom.toString()); + } + } + str.append(")\n"); + } + return str.toString(); + } + + /** + * Returns a string representation of the functions. + * + * @return a string representation of the functions. + */ + private String functionsToString() { + StringBuffer str = new StringBuffer(); + if (!this.functions.isEmpty()) { + str.append("(:functions"); + for (FHead func : this.functions) { + if (this.requirements.contains(RequireKey.TYPING)) { + str.append("\n " + func.toTypedString()); + } else { + str.append("\n " + func.toString()); + } + } + str.append(")\n"); + } + return str.toString(); + } + + /** + * Returns a string representation of the constraints. + * + * @return a string representation of the constraints. + */ + private String constraintsToString() { + StringBuffer str = new StringBuffer(); + if (!this.constraints.isEmpty()) { + str.append("(:constraints"); + for (Exp exp : this.constraints) { + if (this.requirements.contains(RequireKey.TYPING)) { + str.append("\n " + exp.toTypedString()); + } else { + str.append("\n " + exp.toString()); + } + } + str.append(")\n"); + } + return str.toString(); + } + + /** + * Returns a string representation of the axioms. + * + * @return a string representation of the axioms. + */ + private String axiomsToString() { + StringBuffer str = new StringBuffer(); + if (!this.axioms.isEmpty()) { + for (DerivedPredicate axiom : this.axioms) { + if (this.requirements.contains(RequireKey.TYPING)) { + str.append(axiom.toTypedString()); + } else { + str.append(axiom.toString()); + } + str.append("\n"); + } + } + return str.toString(); + } + + /** + * Returns a string representation of the actions. + * + * @return a string representation of the actions. + */ + private String actionsToString() { + StringBuffer str = new StringBuffer(); + if (!this.actions.isEmpty()) { + for (ActionDef action : this.actions.values()) { + str.append(action.toTypedString()); + str.append("\n"); + } + } + return str.toString(); + } + + /** + * Returns a string representation of the metric. + * + * @return a string representation of the metric. + */ + private String metricToString() { + StringBuffer str = new StringBuffer(); + if (this.metric != null) { + str.append(this.metric.toString()); + } + return str.toString(); + } + + /** + * Returns a string representation of the init. + * + * @return a string representation of the init. + */ + private String initToString() { + StringBuffer str = new StringBuffer(); + if (!this.init.isEmpty()) { + str.append("(:init"); + for (InitEl el : this.init) { + str.append("\n "); + if (this.requirements.contains(RequireKey.TYPING)) { + str.append(el.toTypedString()); + } else { + str.append(el.toString()); + } + } + str.append(")\n"); + } + return str.toString(); + } + + /** + * Returns a string representation of the goal. + * + * @return a string representation of the goal. + */ + private String goalToString() { + StringBuffer str = new StringBuffer(); + if (this.goal != null) { + str.append("(:goal "); + str.append("\n "); + if (this.requirements.contains(RequireKey.TYPING)) { + str.append(goal.toTypedString()); + } else { + str.append(goal.toString()); + } + str.append(")"); + } + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Parser.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Parser.java new file mode 100644 index 00000000000..ac34dd91069 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Parser.java @@ -0,0 +1,5152 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import pddl4j.PDDLObject.Content; +import pddl4j.exp.AndExp; +import pddl4j.exp.AtomicFormula; +import pddl4j.exp.DerivedPredicate; +import pddl4j.exp.ExistsExp; +import pddl4j.exp.Exp; +import pddl4j.exp.ExpID; +import pddl4j.exp.ForallExp; +import pddl4j.exp.ImplyExp; +import pddl4j.exp.InitEl; +import pddl4j.exp.Literal; +import pddl4j.exp.NotAtomicFormula; +import pddl4j.exp.NotExp; +import pddl4j.exp.OrExp; +import pddl4j.exp.PrefExp; +import pddl4j.exp.ProbExp; +import pddl4j.exp.QuantifiedExp; +import pddl4j.exp.WhenExp; +import pddl4j.exp.action.Action; +import pddl4j.exp.action.ActionDef; +import pddl4j.exp.action.DurativeAction; +import pddl4j.exp.assign.Assign; +import pddl4j.exp.assign.AssignOpExp; +import pddl4j.exp.assign.Decrease; +import pddl4j.exp.assign.Increase; +import pddl4j.exp.assign.ScaleDown; +import pddl4j.exp.assign.ScaleUp; +import pddl4j.exp.cond.AlwaysExp; +import pddl4j.exp.cond.AlwaysWithinExp; +import pddl4j.exp.cond.AtMostOnceExp; +import pddl4j.exp.cond.HoldAfterExp; +import pddl4j.exp.cond.HoldDuringExp; +import pddl4j.exp.cond.SometimeAfterExp; +import pddl4j.exp.cond.SometimeBeforeExp; +import pddl4j.exp.cond.SometimeExp; +import pddl4j.exp.cond.WithinExp; +import pddl4j.exp.fcomp.Comp; +import pddl4j.exp.fcomp.EqualComp; +import pddl4j.exp.fcomp.FCompExp; +import pddl4j.exp.fcomp.GEqualComp; +import pddl4j.exp.fcomp.GreaterComp; +import pddl4j.exp.fcomp.LEqualComp; +import pddl4j.exp.fcomp.LessComp; +import pddl4j.exp.fexp.BinaryAdd; +import pddl4j.exp.fexp.BinaryDivide; +import pddl4j.exp.fexp.BinaryMultiply; +import pddl4j.exp.fexp.BinaryOp; +import pddl4j.exp.fexp.BinarySubstract; +import pddl4j.exp.fexp.FExp; +import pddl4j.exp.fexp.FHead; +import pddl4j.exp.fexp.NArityAdd; +import pddl4j.exp.fexp.NArityMultiply; +import pddl4j.exp.fexp.NArityOp; +import pddl4j.exp.fexp.Number; +import pddl4j.exp.metric.MaximizeExp; +import pddl4j.exp.metric.MetricExp; +import pddl4j.exp.metric.MinimizeExp; +import pddl4j.exp.term.Constant; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; +import pddl4j.exp.time.AtEndTimedExp; +import pddl4j.exp.time.AtStartTimedExp; +import pddl4j.exp.time.AtTimedExp; +import pddl4j.exp.time.OverAllTimedExp; +import pddl4j.exp.time.OverTimedExp; +import pddl4j.exp.time.TimedLiteral; +import pddl4j.exp.type.Type; +import pddl4j.exp.type.TypeSet; +import pddl4j.lexer.Lexer; +import pddl4j.lexer.LexerTreeConstants; +import pddl4j.lexer.ParseException; +import pddl4j.lexer.SimpleNode; + +/** + * Implements the <tt>Parser</tt> of PDD4L library. The parser can be + * configured to accept only specified requirements of PDDL langage. The list of + * requirements accepted are as follow: + * <ul> + * <li><tt>:strips</tt> - Basic STRIPS-style.</li> + * <li><tt>:typing</tt> - Allows type names in declaration of variables</li> + * <li><tt>:negative-preconditions</tt> - Allows <tt>not</tt> in goal and + * preconditions descriptions.</li> + * <li><tt>:disjunctive-preconditions</tt> - Allows </tt>or</tt> in goal + * and preconditions descriptions.</li> + * <li><tt>:equality</tt> - Supports <tt>=</tt> as built-in predicate.</li> + * <li><tt>:existential-preconditions</tt> - Allows <tt>exists</tt> in goal + * and preconditions descriptions.</li> + * <li><tt>:universal-preconditions</tt> - Allows <tt>forall</tt> in goal + * and preconditions descriptions.</li> + * <li><tt>:quantified-preconditions</tt> - Is equivalent to <tt>:existential-preconditions</tt> + + * <tt>:universal-preconditions</tt>.</li> + * <li><tt>:conditional-effects</tt> - Allows <tt>when</tt> clause in + * actionCtx effects.</li> + * <li><tt>:fluents</tt> - Allows function definitions and use of effects + * using assignement operators and numeric preconditions.</li> + * <li><tt>:adl</tt> - Is equivalent to <tt>:strips</tt> + <tt>:typing</tt> + + * <tt>:negative-preconditions</tt> + <tt>:disjunctive-preconditions</tt> + + * <tt>:equality</tt> + <tt>:quantified-preconditions</tt> + <tt>:conditional-effects</tt>.</li> + * <li><tt>:durative-actions</tt> - Allows durative actions. Note that this + * does note imply <tt>:fluents</tt>.</li> + * <li><tt>:derived-predicate</tt> - Allows predicates whose truth value is + * defined by a formula.</li> + * <li><tt>:time-initial-literals</tt> - Allows the initial state to specify + * literals that will become true at a specified time point implies <tt>durative-actions</tt>.</li> + * <li><tt>:preferences</tt> - Allows use of preferences in actionCtx + * preconditions and goals.</li> + * <li><tt>:constraints</tt> - Allows use of constraints fields in domain and + * problem description. These may contain modal operator supporting trajectory + * constraints.</li> + * </ul> + * <p> + * All the properties can be modified using the following methods (by default + * the parser is ADL): + * + * <pre> + * Properties options = new Properties(); + * options.pu(RequireKey.TYPING, true); + * options.put(RequireKey.NEGATIVE_PRECONDITIONS, true); + * ... + * parser.setOptions(options); + * </pre> + * + * </p> + * <p> + * A simple example of how to use the ADL parser: + * + * <pre> + * public static void main(String[] args) { + * // Checks the command line + * if (args.length != 2) { + * System.err.println("Invalid command line"); + * } else { + * // Creates an instance of the java pddl parser + * Parser parser = new Parser(options); + * Domain domain = parser.parse(new File(args[0])); + * Problem problem = parser.parse(new File(args[1])); + * PDDLObject obj = parser.link(domain, problem); + * // Gets the error manager of the pddl parser + * ErrorManager mgr = parser.getErrorManager(); + * // If the parser produces errors we print it and stop + * if (mgr.contains(Message.ERROR)) { + * mgr.print(Message.ALL); + * } // else we print the warnings + * else { + * mgr.print(Message.WARNING); + * System.out.println("\nParsing domain \"" + domain.getDomainName() + * + "\" done successfully ..."); + * System.out.println("Parsing problem \"" + problem.getProblemName() + * + "\" done successfully ...\n"); + * } + * } + * } + * </pre> + * + * @author Damien Pellier + * @version 1.0, 14/01/03 + */ +public final class Parser { + + /** + * The file extention pddl. + */ + public static final String PDDL_EXTENTION = ".pddl"; + + /** + * The error manager of the parser. + */ + private ErrorManager mgr; + + /** + * The parser input file. + */ + private File file; + + /** + * The PDDL object returns by the parser. + */ + private PDDLObject obj; + + /** + * The requirement accepted by the parser. + */ + private Properties options; + + /** + * The actionCtx used to store the context. + */ + private ActionDef actionCtx; + + /** + * The quantified expression used to store the context. + */ + private QuantifiedExp quantifiedExpCtx; + + /** + * The flag use to specified the context. + */ + private boolean constantDef = false; + + /** + * Create a new <tt>Parser</tt>. + */ + public Parser() { + super(); + this.options = Parser.getDefaultOptions(); + this.mgr = new ErrorManager(); + } + + /** + * Create a new <tt>Parser</tt> with a specific errors manager. + * + * @param options the options of the parser. + */ + public Parser(Properties options) { + super(); + this.options = options; + this.mgr = new ErrorManager(); + } + + /** + * Create a new <tt>Parser</tt> with a specific errors manager. + * + * @param mgr the error manager of the parser. + */ + public Parser(ErrorManager mgr) { + super(); + this.options = Parser.getDefaultOptions(); + this.mgr = mgr; + } + + /** + * Create a new <tt>Parser</tt> with a specific errors manager. + * + * @param options the options of the parser. + * @param mgr the error manager of the parser. + */ + public Parser(Properties options, ErrorManager mgr) { + super(); + this.options = options; + this.mgr = mgr; + } + + /** + * Parses a PDDL file. + * + * @param file the file to parse. + * @return The PDDL object representing the PDDL file or null if the parsing fails. + * @throws FileNotFoundException if the file to parse does not exist. + * @throws NullPointerException if <code>file == null</code>. + */ + public PDDLObject parse(File file) throws FileNotFoundException { + if (file == null) + throw new NullPointerException("\"file\" parameter is null"); + PDDLObject obj = null; + + try { + String ext = file.getName().substring(file.getName().lastIndexOf(".")); + if (!ext.equals(Parser.PDDL_EXTENTION)) { + this.mgr.logParserWarning("File \"" + + file.getName() + "\": " + " File should have \".pddl\" extension.", file); + } + } catch (StringIndexOutOfBoundsException e) { + this.mgr.logParserWarning("File \"" + + file.getName() + "\": " + " File should have \".pddl\" extension.", file); + } + SimpleNode root = null; + this.file = file; + Lexer lexer = new Lexer(new FileInputStream(file)); + lexer.setErrorManager(this.mgr); + lexer.setFile(this.file); + try { + root = lexer.parse(); + if (root != null) { + obj = this.root(root); + } + } catch (Throwable e) { + boolean print = false; + Object debug = this.options.get("debug"); + if (debug instanceof String) { + if (debug.equals("true")) { + print = true; + } + } else if (debug instanceof Boolean) { + if (debug.equals(true)) { + print = true; + } + } + if (print) { + e.printStackTrace(System.err); + } + } + + return obj; + } + + /** + * Prints the syntaxic tree of a specific pddl file. + * + * @param file the pddl file. + * @throws FileNotFoundException if the file to parse does not exist. + * @throws NullPointerException if <code>file == null</code>. + */ + public void printSyntaxicTree(File file) throws FileNotFoundException { + if (file == null) + throw new NullPointerException("\"file\" parameter is null"); + SimpleNode n; + try { + this.file = file; + Lexer lexer = new Lexer(new FileInputStream(file)); + lexer.setFile(file); + lexer.setErrorManager(this.mgr); + SimpleNode root = lexer.parse(); + root.dump(""); + } catch (ParseException pe) { + boolean print = false; + Object debug = this.options.get("debug"); + if (debug instanceof String) { + if (debug.equals("true")) { + print = true; + } + } else if (debug instanceof Boolean) { + if (debug.equals(true)) { + print = true; + } + } + if (print) { + pe.printStackTrace(System.err); + } + } + } + + /** + * Returns the options of the parser. + * + * @return the options of the parser. + */ + public Properties getOptions() { + return this.options; + } + + /** + * Sets the new options of the parser. + * + * @param options the new options of the parser. + */ + public void setOptions(Properties options) { + this.options = options; + } + + /** + * Returns the error manager of the compiler. + * + * @return the error manager of the compiler. + */ + public ErrorManager getErrorManager() { + return this.mgr; + } + + /** + * Sets a new error manager to the compiler. + * + * @param mgr the new error manager of the compiler. + */ + public void setErrorManager(ErrorManager mgr) { + this.mgr = mgr; + } + + /** + * Returns the default options of the parser. + * + * @return the default options. + */ + public static Properties getDefaultOptions() { + Properties options = new Properties(); + options.put("source", Source.V3_0); + options.put("debug", true); + options.put(RequireKey.STRIPS, true); + options.put(RequireKey.TYPING, true); + options.put(RequireKey.NEGATIVE_PRECONDITIONS, true); + options.put(RequireKey.EQUALITY, true); + options.put(RequireKey.QUANTIFIED_PRECONDITIONS, true); + options.put(RequireKey.EXISTENTIAL_PRECONDITIONS, true); + options.put(RequireKey.UNIVERSAL_PRECONDITIONS, true); + options.put(RequireKey.CONDITIONAL_EFFECTS, true); + options.put(RequireKey.ADL, true); + return options; + } + + /** + * Creates a new PDDL + * object containing also the domain informations. This method is usefull to + * check the symbol shared between domain and problem input files. + * + * @param domain the domain. + * @param problem the problem. + * @return a PDDL object containing all the information needed for planning. + * @throws NullPointerException if <code>domain == null || problem == null</code>. + */ + public PDDLObject link(Domain domain, Problem problem) { + if (domain == null || problem == null) { + throw new NullPointerException(); + } + PDDLObject dom = (PDDLObject) domain; + PDDLObject pb = (PDDLObject) problem; + boolean failure = false; + PDDLObject object = new PDDLObject(); + object.content = PDDLObject.Content.FULL_PROBLEM; + object.domainFile = domain.getDomainFile(); + object.problemFile = problem.getProblemFile(); + object.actions.putAll(dom.actions); + object.axioms.addAll(dom.axioms); + object.constants.putAll(dom.constants); + for (Constant cts : pb.constants.values()) { + TypeSet newType = new TypeSet(); + for (Type ts : cts.getTypeSet()) { + Set<String> pt = dom.types.get(ts.getImage()); + if (pt == null) { + this.mgr.logLinkerError("type \"" + ts.toString() + "\" of object \"" + + cts + "\" is undefined.", problem.getProblemFile()); + failure = true; + } else { + newType.add(new Type(ts.getImage(), dom.types)); + } + } + cts.setTypeSet(newType); + object.constants.put(cts.getImage(), cts); + } + + for (Constant cst : object.constants.values()) { + for (Type type : cst.getTypeSet()) { + Set<Constant> setCst = object.typeDomains.get(type); + if (setCst == null) { + setCst = new LinkedHashSet<Constant>(); + object.typeDomains.put(type, setCst); + } + setCst.add(cst); + } + } + object.constraints.addAll(dom.constraints); + object.constraints.addAll(pb.constraints); + object.domainName = domain.getDomainName(); + object.goal = pb.goal; + object.init = pb.init; + for (InitEl el : object.init) { + if (el.getExpID().equals(ExpID.ATOMIC_FORMULA)) { + AtomicFormula atom = (AtomicFormula) el; + boolean match = false; + Iterator<AtomicFormula> i = dom.predicates.iterator(); + while (i.hasNext() && !match) { + AtomicFormula copy = i.next().clone().standardize(); + Substitution sigma = copy.match(atom); + match = sigma != null; + } + if (!match) { + this.mgr.logLinkerError("predicate \"" + + atom.toString() + + "\" undefined.", this.file); + } + } else if (el.getExpID().equals(ExpID.F_COMP)) { + FCompExp fComp = (FCompExp) el; + boolean match = false; + Iterator<FHead> i = dom.functions.iterator(); + while (i.hasNext() && !match) { + FHead copy = i.next().clone().standardize(); + Substitution sigma = copy.unify(fComp.getArg2()); + match = sigma != null; + } + if (!match) { + this.mgr.logLinkerError("function \"" + + fComp.getArg2().toString() + + "\" undefined.", this.file); + } + } else { + this.mgr.logLinkerError("invalide expression in init block", + problem.getProblemFile()); + } + + } + + object.metric = pb.metric; + object.predicates.addAll(dom.predicates); + object.problemName = problem.getProblemName(); + if (!pb.requirements.equals(dom.requirements)) { + this.mgr.logLinkerWarning("domain and problem should have the same requirements.", + problem.getProblemFile()); + } + object.types.putAll(dom.types); + object.requirements = dom.requirements; + if (!dom.source.equals(pb.source)) { + this.mgr.logLinkerError("Imcompatible source version\"" , problem.getProblemFile()); + } else { + object.source = dom.source; + } + return failure ? null : object; + } + + /** + * Extracts the object structures from the <code>ROOT</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>ROOT</code> node. + * @return the domain extract. + * @throws ParserException if an error occurs while parsing. + */ + private PDDLObject root(SimpleNode node) throws ParserException { + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTDOMAIN: + return this.domain(cn); + case LexerTreeConstants.JJTPROBLEM: + return this.problem(cn); + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException( + "An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from a <code>PROBLEM</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>PROBLEM</code> node. + * @return the problem structure built. + * @throws ParserException if an error occurs while parsing. + */ + private PDDLObject problem(SimpleNode node) throws ParserException { + this.obj = new PDDLObject(); + this.obj.content = PDDLObject.Content.PARTIAL_PROBLEM; + this.obj.problemFile = this.file; + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTPROBLEM_NAME: + String name = this.file.getName(); + if (!cn.getImage().equals(name.substring(0, name.lastIndexOf(".")))) { + this.mgr.logParserWarning("problem \"" + cn.getImage() + "\" must be defined in a file \"" + + cn.getImage() + ".pddl\".", this.file, cn.getLine(), + cn.getColumn()); + } + this.obj.problemName = cn.getImage(); + break; + case LexerTreeConstants.JJTDOMAIN_NAME: + this.obj.domainName = cn.getImage(); + break; + case LexerTreeConstants.JJTREQUIRE_DEF: + this.requireDef(cn); + break; + case LexerTreeConstants.JJTOBJECT_DECLARATION: + this.object_declaration(cn); + break; + case LexerTreeConstants.JJTINIT: + this.init(cn); + break; + case LexerTreeConstants.JJTGOAL: + this.goal(cn); + break; + case LexerTreeConstants.JJTCONSTRAINTS: + this.constraints(cn); + break; + case LexerTreeConstants.JJTMETRIC_SPEC: + this.metric_spec(cn); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return obj; + } + + /** + * Extracts the object structures from the <code>METRIC_SPEC</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>METRIC_SPEC</code> node. + * @return the metric expression built. + * @throws ParserException if an error occurs while parsing. + */ + private MetricExp metric_spec(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch(cn.getId()) { + case LexerTreeConstants.JJTMAXIMIZE: + obj.metric = this.maximize(cn); + return obj.metric; + case LexerTreeConstants.JJTMINIMIZE: + obj.metric = this.minimize(cn); + return obj.metric; + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>MAXIMIZE</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>MAXIMIZE</code> node. + * @return the maximize expression built. + * @throws ParserException if an error occurs while parsing. + */ + private MetricExp maximize(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTMETRIC_F_EXP) { + return new MaximizeExp(this.metric_f_exp(cn)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>MINIMIZE</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>MINIMIZE</code> node. + * @return the minimize expression built. + * @throws ParserException if an error occurs while parsing. + */ + private MetricExp minimize(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTMETRIC_F_EXP) { + return new MinimizeExp(this.metric_f_exp(cn)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>METRIC_F_EXP</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>METRIC_F_EXP</code> node. + * @return the metric function expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Term metric_f_exp(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch(cn.getId()) { + case LexerTreeConstants.JJTUNARY_OP_METRIC_F_EXP: + return this.unary_op_metric_f_exp(cn); + case LexerTreeConstants.JJTBINARY_OP_METRIC_F_EXP: + return this.binary_op_metric_f_exp(cn); + case LexerTreeConstants.JJTMULTI_OP_METRIC_F_EXP: + return this.multi_op_metric_f_exp(cn); + case LexerTreeConstants.JJTNUMBER: + return this.number(cn); + case LexerTreeConstants.JJTCONSTANT_F_HEAD: + return this.constant_f_head(cn); + case LexerTreeConstants.JJTTOTAL_TIME: + return new Variable(Variable.TOTAL_TIME, Type.NUMBER); + case LexerTreeConstants.JJTVIOLATED_PREF_EXP: + return this.violated_pref_exp(cn); + + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>VIOLATED_PREF_EXP</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>VIOLATED_PREF_EXP</code> node. + * @return the violated preference expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Variable violated_pref_exp(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTPREF_NAME) { + return new Variable(Variable.VIOLATED_PREF_VARIABLE + this.pref_name(cn), + Type.NUMBER); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>CONSTANT_F_HEAD</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>CONSTANT_F_HEADF_HEAD</code> node. + * @return the function head structure built. + * @throws ParserException if an error occurs while parsing. + */ + private FHead constant_f_head(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() > 0) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + if (cn1.getId() == LexerTreeConstants.JJTFUNCTOR) { + FHead f_head = new FHead(this.functor(cn1), Type.NUMBER); + for (int i = 1; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTCONSTANT: + f_head.add(this.constant(cn)); + break; + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + + " unexpected."); + } + } + return f_head; + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>MULTI_OP_METRIC_F_EXP</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>MULTI_OP_METRIC_F_EXP</code> node. + * @return the binray numeric operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private NArityOp multi_op_metric_f_exp(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTADD_NARITY_OP_METRIC_F_EXP: + return this.add_narity_op_metric_f_exp(cn); + case LexerTreeConstants.JJTMULTIPLY_NARITY_OP_METRIC_F_EXP: + return this.multiply_narity_op_metric_f_exp(cn); + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>ADD_NARITY_OP_METRIC_F_EXP</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>ADD_NARITY_OP_METRIC_F_EXP</code> node. + * @return the multi divide function expression build + * @throws ParserException if an error occurs while parsing. + */ + private NArityAdd add_narity_op_metric_f_exp(SimpleNode node) throws ParserException { + NArityAdd exp = new NArityAdd(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTMETRIC_F_EXP: + exp.add(this.metric_f_exp(cn)); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return exp; + } + + /** + * Extracts the object structures from the <code>MULTIPLY_NARITY_OP_METRIC_F_EXP</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>MULTIPLY_NARITY_OP_METRIC_F_EXP</code> node. + * @return the multi divide function expression build + * @throws ParserException if an error occurs while parsing. + */ + private NArityMultiply multiply_narity_op_metric_f_exp(SimpleNode node) throws ParserException { + NArityMultiply exp = new NArityMultiply(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTMETRIC_F_EXP: + exp.add(this.metric_f_exp(cn)); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return exp; + } + + /** + * Extracts the object structures from the <code>BINARY_OP_METRIC_F_EXP</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>BINARY_OP_METRIC_F_EXP</code> node. + * @return the binray numeric operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinaryOp binary_op_metric_f_exp(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTADD_OP_METRIC_F_EXP: + return this.add_op_metric_f_exp(cn); + case LexerTreeConstants.JJTSUBSTRACT_OP_METRIC_F_EXP: + return this.substract_op_metric_f_exp(cn); + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>ADD_OP_METRIC_F_EXP</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>ADD_OP_METRIC_F_EXP</code> node. + * @return the add operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinaryAdd add_op_metric_f_exp(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTMETRIC_F_EXP + && cn2.getId() == LexerTreeConstants.JJTMETRIC_F_EXP) { + return new BinaryAdd(this.metric_f_exp(cn1), this.metric_f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>SUBSTRACT_OP_METRIC_F_EXP</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>SUBSTRACT_OP_METRIC_F_EXP</code> node. + * @return the substract operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinarySubstract substract_op_metric_f_exp(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTMETRIC_F_EXP + && cn2.getId() == LexerTreeConstants.JJTMETRIC_F_EXP) { + return new BinarySubstract(this.metric_f_exp(cn1), this.metric_f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + + /** + * Extracts the object structures from the <code>UNARY_OP_METRIC_F_EXP</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>UNARY_OP_METRIC_F_EXP</code> node. + * @return the unary op metric function expression built. + * @throws ParserException if an error occurs while parsing. + */ + private FExp unary_op_metric_f_exp(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTMETRIC_F_EXP) { + return new BinarySubstract(new Number(), this.metric_f_exp(cn)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>INIT</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>INIT</code> node. + * @return the initial state structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Exp goal(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTPRE_GD) { + obj.goal = this.pre_gd(cn); + return obj.goal; + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>INIT</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>INIT</code> node. + * @return the initial state structure built. + * @throws ParserException if an error occurs while parsing. + */ + private ArrayList<InitEl> init(SimpleNode node) throws ParserException { + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTINIT_EL: + obj.init.add(this.init_el(cn)); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return obj.init; + } + + /** + * Extracts the object structures from the <code>INIT_EL</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>INIT_EL</code> node. + * @return initial state element. + * @throws ParserException if an error occurs while parsing. + */ + private InitEl init_el(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTLITERAL: + return this.ground_literal(cn); + case LexerTreeConstants.JJTEQUAL_INIT_EL: + return this.equal_init_el(cn); + case LexerTreeConstants.JJTTIMED_LITERAL: + return this.timed_literal(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + + /** + * Extracts the object structures from the <code>INIT_EL</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>INIT_EL</code> node. + * @return initial state element. + * @throws ParserException if an error occurs while parsing. + */ + private TimedLiteral timed_literal(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTNUMBER + && cn2.getId() == LexerTreeConstants.JJTLITERAL) { + Number number = this.number(cn1); + if (number.getValue() < 0) { + this.mgr.logParserError("time stamp of timed literal must be positive", + file, cn1.getLine(), cn1.getColumn()); + } + return new TimedLiteral(number, this.ground_literal(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>INIT_EL</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>INIT_EL</code> node. + * @return initial state element. + * @throws ParserException if an error occurs while parsing. + */ + private EqualComp equal_init_el(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_HEAD + && cn2.getId() == LexerTreeConstants.JJTNUMBER) { + return new EqualComp(this.f_head(cn1), this.number(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>OBJECT_DECLARATION</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>OBJECT_DECLARATION</code> node. + * @return the object declartion structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Map<String, Constant> object_declaration(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTTYPED_LIST) { + this.constantDef = true; + this.constant_typed_list(cn, obj.constants); + this.constantDef = false; + return obj.constants; + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + + /** + * Extracts the object structures from a <code>DOMAIN</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>DOMAIN</code> node. + * @return the domain structure built. + * @throws ParserException if an error occurs while parsing. + */ + private PDDLObject domain(SimpleNode node) throws ParserException { + this.obj = new PDDLObject(); + this.obj.content = PDDLObject.Content.DOMAIN; + this.obj.domainFile = this.file; + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + + switch (cn.getId()) { + case LexerTreeConstants.JJTDOMAIN_NAME: + obj.domainName = cn.getImage(); + String name = file.getName(); + if (!cn.getImage().equals(name.substring(0, name.lastIndexOf(".")))) { + this.mgr.logParserWarning("Domain \"" + cn.getImage() + "\" should be defined in a file \"" + + cn.getImage() + ".pddl\".", this.file, cn.getLine(), + cn.getColumn()); + } + break; + case LexerTreeConstants.JJTREQUIRE_DEF: + this.requireDef(cn); + break; + case LexerTreeConstants.JJTTYPE_DEF: + this.types_def(cn); + break; + case LexerTreeConstants.JJTCONSTANT_DEF: + this.constants_def(cn); + break; + case LexerTreeConstants.JJTPREDICATE_DEF: + this.predicates_def(cn); + break; + case LexerTreeConstants.JJTFUNCTION_DEF: + this.functions_def(cn); + break; + case LexerTreeConstants.JJTCONSTRAINTS: + this.constraints(cn); + break; + case LexerTreeConstants.JJTSTRUCTURE_DEF: + this.structure_def(cn); + break; + default: + + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return obj; + } + + /** + * Extracts the object structures from the <code>STRUCTURE_DEF</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>STRUCTURE_DEF</code> node. + * @throws ParserException if an error occurs while parsing. + */ + private void structure_def(SimpleNode node) throws ParserException { + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTACTION_DEF: + this.action_def(cn); + break; + case LexerTreeConstants.JJTDURATION_ACTION_DEF: + if (!this.obj.requirements.contains(RequireKey.DURATIVE_ACTIONS)) { + this.mgr.logParserError("Require key \"" + RequireKey.DURATIVE_ACTIONS + + "\" needed to specify durative actions.", + this.file, node.getLine(), node.getColumn()); + } + this.durative_action_def(cn); + break; + case LexerTreeConstants.JJTDERIVED_DEF: + this.derived_def(cn); + break; + default: + this.actionCtx = null; + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + } + + /** + * Extracts the object structures from the <code>DURATIVE_ACTION</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DURATIVE_ACTION</code> node. + * @return the durative actionCtx structure built. + * @throws ParserException if an error occurs while parsing. + */ + private DurativeAction durative_action_def(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 3) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + SimpleNode cn3 = (SimpleNode) node.jjtGetChild(2); + if (cn1.getId() == LexerTreeConstants.JJTDA_SYMBOL + && cn2.getId() == LexerTreeConstants.JJTTYPED_LIST + && cn3.getId() == LexerTreeConstants.JJTDA_DEF_BODY) { + DurativeAction action = new DurativeAction(this.action_name(cn1)); + LinkedHashMap<String, Variable> parameters = new LinkedHashMap<String, Variable>(); + this.var_typed_list(cn2, parameters); + for (Variable param : parameters.values()) { + action.add(param); + } + this.da_def_body(cn3, action); + if (this.obj.actions.containsKey(action.getName())) { + this.mgr.logParserError("Duplicated action \"" + action.getName() + + " \"." , this.file, cn1.getLine(), cn1.getColumn()); + } else { + this.obj.actions.put(action.getName(), action); + } + return action; + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DA_DEF_BODY</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_DEF_BODY</code> node. + * @param action the duratiive actionCtx to initialize. + * @throws ParserException if an error occurs while parsing. + */ + private void da_def_body(SimpleNode node, DurativeAction action) throws ParserException { + this.actionCtx = action; + if (node.jjtGetNumChildren() == 3) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + SimpleNode cn3 = (SimpleNode) node.jjtGetChild(2); + if (cn1.getId() == LexerTreeConstants.JJTDURATION_CONSTRAINT + && cn2.getId() == LexerTreeConstants.JJTDA_GD + && cn3.getId() == LexerTreeConstants.JJTDA_EFFECT) { + action.setConstraint(this.duration_constraint(cn1)); + action.setCondition(this.da_gd(cn2)); + action.setEffect(this.da_effect(cn3)); + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + this.actionCtx = null; + } + + /** + * Extracts the object structures from the <code>DA_EFFECT</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_EFFECT</code> node. + * @return the durative actionCtx effect expression built + * @throws ParserException if an error occurs while parsing. + */ + private Exp da_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTAND_DA_EFFECT: + return this.and_da_effect(cn); + case LexerTreeConstants.JJTTIMED_EFFECT: + return this.timed_effect(cn); + case LexerTreeConstants.JJTFORALL_DA_EFFECT: + if (!this.obj.requirements.contains(RequireKey.CONDITIONAL_EFFECTS)) { + this.mgr.logParserError("Require key \"" + RequireKey.CONDITIONAL_EFFECTS + + "\" needed to specify conditional durative effect.", + this.file, node.getLine(), node.getColumn()); + } + return this.forall_da_effect(cn); + case LexerTreeConstants.JJTWHEN_DA_EFFECT: + if (!this.obj.requirements.contains(RequireKey.CONDITIONAL_EFFECTS)) { + this.mgr.logParserError("Require key \"" + RequireKey.CONDITIONAL_EFFECTS + + "\" needed to specify conditional durative effect.", + this.file, node.getLine(), node.getColumn()); + } + return this.when_da_effect(cn); + case LexerTreeConstants.JJTDA_ASSIGN_OP: + if (!this.obj.requirements.contains(RequireKey.FLUENTS)) { + this.mgr.logParserError("Require key \"" + RequireKey.FLUENTS + + "\" needed to specify assign operation in durative actionCtx effect.", + this.file, node.getLine(), node.getColumn()); + } + return this.da_assign_op(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + + /** + * Extracts the object structures from the <code>F_ASSIGN_DA</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_END_F_ASSIGN_DA_EFFECT</code> node. + * @return the durative assign function expression. + * @throws ParserException if an error occurs while parsing. + */ + private AssignOpExp da_assign_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTASSIGN: + return this.da_assign(cn); + case LexerTreeConstants.JJTSCALE_UP: + return this.da_scale_up(cn); + case LexerTreeConstants.JJTSCALE_DOWN: + return this.da_scale_down(cn); + case LexerTreeConstants.JJTINCREASE: + return this.da_increase(cn); + case LexerTreeConstants.JJTDECREASE: + return this.da_decrease(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>WHEN_DA_EFFECT</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>WHEN_DA_EFFECT</code> node. + * @return the when duratve actionCtx effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private WhenExp when_da_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTDA_GD + && cn2.getId() == LexerTreeConstants.JJTTIMED_EFFECT) { + Exp cond = this.da_gd(cn1); + Exp effect = this.timed_effect(cn2); + return new WhenExp(cond, effect); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>FORALL_DA_EFFECT</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>FORALL_DA_EFFECT</code> node. + * @return the universal durative effect expression structure built. + * @throws ParserException if an error occurs while parsing. + */ + private ForallExp forall_da_effect(SimpleNode node) throws ParserException { + + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTTYPED_LIST + && cn2.getId() == LexerTreeConstants.JJTDA_EFFECT) { + ActionDef tmp = this.actionCtx; + this.actionCtx = null; + ForallExp forall = new ForallExp(); + LinkedHashMap<String, Variable> vars = new LinkedHashMap<String, Variable>(); + this.var_typed_list(cn1, vars); + this.actionCtx = tmp; + for (Variable var : vars.values()) { + forall.add(var); + } + this.quantifiedExpCtx = forall; + Exp exp = this.da_effect(cn2); + forall.setExp(exp); + this.quantifiedExpCtx = null; + return forall; + } + } + this.quantifiedExpCtx = null; + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>TIMED_EFFECT</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>TIMED_EFFECT</code> node. + * @return the timed effect expression built + * @throws ParserException if an error occurs while parsing. + */ + private Exp timed_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTAT_DA_EFFECT: + return this.at_da_effect(cn); + case LexerTreeConstants.JJTAT_F_ASSIGN_DA_EFFECT: + return this.at_f_assign_da_effect(cn); + case LexerTreeConstants.JJTASSIGN_OP_T: + if (!this.obj.requirements.contains(RequireKey.CONDITIONAL_EFFECTS)) { + this.mgr.logParserError("Require key \"" + RequireKey.CONDITIONAL_EFFECTS + + "\" needed to specify conditional durative effect.", + this.file, node.getLine(), node.getColumn()); + } + return this.assign_op_t(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + + /** + * Extracts the object structures from the <code>ASSIGN_OP_T</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>ASSIGN_OP_T</code> node. + * @return the durative assign operation expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AssignOpExp assign_op_t(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTINCREASE: + return this.increase_assign_op_t(cn); + case LexerTreeConstants.JJTDECREASE: + return this.decrease_assign_op_t(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DECREASE_ASSIGN_OP_T</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DECREASE_ASSIGN_OP_T</code> node. + * @return the decrease durative expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Decrease decrease_assign_op_t(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_HEAD + && cn2.getId() == LexerTreeConstants.JJTF_EXP_T) { + return new Decrease(this.f_head(cn1), this.f_exp_t(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>INCREASE_ASSIGN_OP_T</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>INCREASE_ASSIGN_OP_T</code> node. + * @return the increase durative expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Increase increase_assign_op_t(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_HEAD + && cn2.getId() == LexerTreeConstants.JJTF_EXP_T) { + return new Increase(this.f_head(cn1), this.f_exp_t(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>F_EXP_T</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>F_EXP_T</code> node. + * @return the durative fonction expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Term f_exp_t(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTCONTINOUS_VARIABLE) { + return new Variable(Variable.CONTINOUS_VARIABLE, Type.NUMBER); + } + } else if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + Variable cv = new Variable(Variable.CONTINOUS_VARIABLE, Type.NUMBER); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP + && cn2.getId() == LexerTreeConstants.JJTCONTINOUS_VARIABLE) { + return new BinaryMultiply(this.f_exp(cn1), cv); + } else if (cn1.getId() == LexerTreeConstants.JJTCONTINOUS_VARIABLE + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new BinaryMultiply(cv, this.f_exp(cn1)); + + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AT_F_ASSIGN_DA_EFFECT</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_F_ASSIGN_DA_EFFECT</code> node. + * @return the at durative actionCtx effect expression that contains a fonction assign. + * @throws ParserException if an error occurs while parsing. + */ + private AtTimedExp at_f_assign_da_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTAT_END_F_ASSIGN_DA_EFFECT: + return this.at_end_f_assign_da_effect(cn); + case LexerTreeConstants.JJTAT_START_F_ASSIGN_DA_EFFECT: + return this.at_start_f_assign_da_effect(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + + /** + * Extracts the object structures from the <code>AT_START_F_ASSIGN_DA_EFFECT</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_START_F_ASSIGN_DA_EFFECT</code> node. + * @return the at start durative actionCtx effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AtStartTimedExp at_start_f_assign_da_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTF_ASSIGN_DA) { + Exp exp = this.f_assign_da(cn); + return new AtStartTimedExp(exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AT_END_F_ASSIGN_DA_EFFECT</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_END_F_ASSIGN_DA_EFFECT</code> node. + * @return the at start durative actionCtx effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AtEndTimedExp at_end_f_assign_da_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTF_ASSIGN_DA) { + Exp exp = this.f_assign_da(cn); + return new AtEndTimedExp(exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>F_ASSIGN_DA</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_END_F_ASSIGN_DA_EFFECT</code> node. + * @return the durative assign function expression. + * @throws ParserException if an error occurs while parsing. + */ + private AssignOpExp f_assign_da(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTASSIGN: + return this.da_assign(cn); + case LexerTreeConstants.JJTSCALE_UP: + return this.da_scale_up(cn); + case LexerTreeConstants.JJTSCALE_DOWN: + return this.da_scale_down(cn); + case LexerTreeConstants.JJTINCREASE: + return this.da_increase(cn); + case LexerTreeConstants.JJTDECREASE: + return this.da_decrease(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + + /** + * Extracts the object structures from the <code>DA_SCALE_UP</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_SCALE_UP</code> node. + * @return the durative actionCtx assign scale up expression built. + * @throws ParserException if an error occurs while parsing. + */ + private ScaleUp da_scale_up(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_HEAD + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new ScaleUp(this.f_head(cn1), this.f_exp_da(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DA_DECREASE</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_DECREASE</code> node. + * @return the durative actionCtx descrease expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Decrease da_decrease(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_HEAD + && cn2.getId() == LexerTreeConstants.JJTF_EXP_DA) { + return new Decrease(this.f_head(cn1), this.f_exp_da(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DA_INCREASE</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_INCREASE</code> node. + * @return the durative actionCtx increase expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Increase da_increase(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_HEAD + && cn2.getId() == LexerTreeConstants.JJTF_EXP_DA) { + return new Increase(this.f_head(cn1), this.f_exp_da(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DA_SCALE_DOWN</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_SCALE_DOWN</code> node. + * @return the surative actionCtx assign scale up expression built. + * @throws ParserException if an error occurs while parsing. + */ + private ScaleDown da_scale_down(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_HEAD + && cn2.getId() == LexerTreeConstants.JJTF_EXP_DA) { + return new ScaleDown(this.f_head(cn1), this.f_exp_da(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DA_ASSIGN</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_ASSIGN</code> node. + * @return the durative assign effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Assign da_assign(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_HEAD + && cn2.getId() == LexerTreeConstants.JJTF_EXP_DA) { + return new Assign(this.f_head(cn1), this.f_exp_da(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>F_EXP_DA</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>F_EXP_DA</code> node. + * @return the durative fonction expression structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Term f_exp_da(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTF_EXP: + return this.f_exp(cn); + case LexerTreeConstants.JJTDA_BINARY_OP: + return this.da_binary_op(cn); + case LexerTreeConstants.JJTDA_UNARY_OP: + return this.da_unary_op(cn); + case LexerTreeConstants.JJTVAR_DURATION: + if (!this.obj.requirements.contains(RequireKey.DURATION_INEQUALITIES)) { + this.mgr.logParserError("Require key \"" + RequireKey.DURATION_INEQUALITIES + + "\" needed to specify durative inequalities in actionCtx effect.", + this.file, node.getLine(), node.getColumn()); + } + return new Variable(Variable.DURATIVE_VARIABLE, Type.NUMBER); + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DA_UNARY_OP</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_UNARY_OP</code> node. + * @return the durative unary operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinaryOp da_unary_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTF_EXP_DA) { + return new BinarySubstract(new Number(0.0), this.f_exp_da(cn)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DA_BINARY_OP</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_BINARY_OP</code> node. + * @return the surative binary numeric operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinaryOp da_binary_op(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTADD_OP: + return this.da_add_op(cn); + case LexerTreeConstants.JJTSUBSTRACT_OP: + return this.da_substract_op(cn); + case LexerTreeConstants.JJTMULTIPLY_OP: + return this.multiply_op(cn); + case LexerTreeConstants.JJTDIVIDE_OP: + return this.divide_op(cn); + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DA_ADD_OPERATION</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_ADD_OPERATION</code> node. + * @return the add operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinaryAdd da_add_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP_DA + && cn2.getId() == LexerTreeConstants.JJTF_EXP_DA) { + return new BinaryAdd(this.f_exp_da(cn1), this.f_exp_da(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DA_SUBSTRACT_OP</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_SUBSTRACT_OP</code> node. + * @return the substract operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinarySubstract da_substract_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP_DA + && cn2.getId() == LexerTreeConstants.JJTF_EXP_DA) { + return new BinarySubstract(this.f_exp_da(cn1), this.f_exp_da(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DA_MULTIPLY_OP</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_MULTIPLY_OP</code> node. + * @return the durative multiply operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinaryMultiply da_multiply_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP_DA + && cn2.getId() == LexerTreeConstants.JJTF_EXP_DA) { + return new BinaryMultiply(this.f_exp_da(cn1), this.f_exp_da(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DA_DIVIDE_OP</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_DIVIDE_OP</code> node. + * @return the durative divide operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinaryDivide da_divide_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP_DA + && cn2.getId() == LexerTreeConstants.JJTF_EXP_DA) { + return new BinaryDivide(this.f_exp_da(cn1), this.f_exp_da(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AT_DA_EFFECT</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_DA_EFFECT</code> node. + * @return the at durative actionCtx effect expression built + * @throws ParserException if an error occurs while parsing. + */ + private AtTimedExp at_da_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTAT_END_DA_EFFECT: + return this.at_end_da_effect(cn); + case LexerTreeConstants.JJTAT_START_DA_EFFECT: + return this.at_start_da_effect(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + + /** + * Extracts the object structures from the <code>AT_END_DA_EFFECT</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_END_DA_EFFECT</code> node. + * @return the at start durative actionCtx effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AtEndTimedExp at_end_da_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTLITERAL) { + Exp exp = this.literal(cn); + return new AtEndTimedExp(exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AT_START_DA_EFFECT</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_START_DA_EFFECT</code> node. + * @return the at start durative actionCtx effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AtStartTimedExp at_start_da_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTLITERAL) { + Exp exp = this.literal(cn); + return new AtStartTimedExp(exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AND_DA_EFFECT</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>AND_DA_EFFECT</code> node. + * @return the conjunctive durative actionCtx effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AndExp and_da_effect(SimpleNode node) throws ParserException { + AndExp exp = new AndExp(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTDA_EFFECT: + exp.add(this.da_effect(cn)); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return exp; + } + + /** + * Extracts the object structures from the <code>DA_GD</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DA_GD</code> node. + * @return the durative actionCtx goal description expression built + * @throws ParserException if an error occurs while parsing. + */ + private Exp da_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTPREF_TIMED_GD: + return this.pref_timed_gd(cn); + case LexerTreeConstants.JJTAND_DA_GD: + return this.and_da_gd(cn); + case LexerTreeConstants.JJTFORALL_DA_GD: + if (!this.obj.requirements.contains(RequireKey.UNIVERSAL_PRECONDITIONS)) { + this.mgr.logParserError("Require key \"" + RequireKey.PREFERENCES + + "\" needed to specify preferences.", + this.file, node.getLine(), node.getColumn()); + } + return this.forall_da_gd(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + + /** + * Extracts the object structures from the <code>FORALL_DA_GD</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>FORALL_DA_GD</code> node. + * @return the universal duartive actionCtx goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private ForallExp forall_da_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTTYPED_LIST + && cn2.getId() == LexerTreeConstants.JJTDA_GD) { + ActionDef tmp = this.actionCtx; + this.actionCtx = null; + ForallExp forall = new ForallExp(); + LinkedHashMap<String, Variable> vars = new LinkedHashMap<String, Variable>(); + this.var_typed_list(cn1, vars); + this.actionCtx = tmp; + for (Variable var : vars.values()) { + forall.add(var); + } + this.quantifiedExpCtx = forall; + Exp exp = this.da_gd(cn2); + forall.setExp(exp); + this.quantifiedExpCtx = null; + return forall; + } + } + this.quantifiedExpCtx = null; + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AND_DA_GD</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>AND_DA_GD</code> node. + * @return the conjunctive durative actionCtx goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private AndExp and_da_gd(SimpleNode node) throws ParserException { + AndExp exp = new AndExp(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTDA_GD: + exp.add(this.da_gd(cn)); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return exp; + } + + /** + * Extracts the object structures from the <code>PREF_TIMED_GD</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>PREF_TIMED_GD</code> node. + * @return the preference timed goal description expression built + * @throws ParserException if an error occurs while parsing. + */ + private Exp pref_timed_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTTIMED_GD: + return this.timed_gd(cn); + case LexerTreeConstants.JJTNAMED_PREF_TIMED_GD: + if (!this.obj.requirements.contains(RequireKey.PREFERENCES)) { + this.mgr.logParserError("Require key \"" + RequireKey.PREFERENCES + + "\" needed to specify preferences.", + this.file, node.getLine(), node.getColumn()); + } + return this.named_pref_timed_gd(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + + /** + * Extracts the object structures from the <code>NAMED_PREF_TIMED_GD</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>NAMED_PREF_TIMED_GD</code> node. + * @return the name preference timed goal description expression built + * @throws ParserException if an error occurs while parsing. + */ + private PrefExp named_pref_timed_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + if (cn1.getId() == LexerTreeConstants.JJTTIMED_GD) { + Exp exp = this.timed_gd(cn1); + return new PrefExp(exp); + } + } else if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTPREF_NAME + && cn2.getId() == LexerTreeConstants.JJTPREF_TIMED_GD) { + String name = this.pref_name(cn1); + Exp exp = this.timed_gd(cn2); + return new PrefExp(name, exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>TIMED_GD</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>TIMED_GD</code> node. + * @return the timed goal description expression built + * @throws ParserException if an error occurs while parsing. + */ + private Exp timed_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTAT_TIMED_GD: + return this.at_timed_gd(cn); + case LexerTreeConstants.JJTOVER_TIMED_GD: + return this.over_timed_gd(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + + /** + * Extracts the object structures from the <code>OVER_TIMED_GD</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>OVER_TIMED_GD</code> node. + * @return the over timed goal description expression built + * @throws ParserException if an error occurs while parsing. + */ + private OverTimedExp over_timed_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTOVER_ALL_TIMED_GD: + return this.over_all_timed_gd(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + + /** + * Extracts the object structures from the <code>OVER_ALL_TIMED_GD</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>OVER_ALL_TIMED_GD</code> node. + * @return the over all timed goal description expression built + * @throws ParserException if an error occurs while parsing. + */ + private OverTimedExp over_all_timed_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTGD) { + Exp exp = this.gd(cn); + return new OverAllTimedExp(exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AT_TIMED_GD</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_TIMED_GD</code> node. + * @return the at timed goal description expression built + * @throws ParserException if an error occurs while parsing. + */ + private AtTimedExp at_timed_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTAT_START_TIMED_GD: + return this.at_start_timed_gd(cn); + case LexerTreeConstants.JJTAT_END_TIMED_GD: + return this.at_end_timed_gd(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + + /** + * Extracts the object structures from the <code>AT_START_TIMED_GD</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_START_TIMED_GD</code> node. + * @return the at start timed goal description expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AtStartTimedExp at_start_timed_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTGD) { + Exp exp = this.gd(cn); + return new AtStartTimedExp(exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AT_END_TIMED_GD</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_END_TIMED_GD</code> node. + * @return the at end timed goal description expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AtEndTimedExp at_end_timed_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTGD) { + Exp exp = this.gd(cn); + return new AtEndTimedExp(exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DURATION_CONSTRAINT</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DURATION_CONSTRAINT</code> node. + * @return the duration constraint expression built + * @throws ParserException if an error occurs while parsing. + */ + private Exp duration_constraint(SimpleNode node) throws ParserException { + Exp exp = null; + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTEMPTY_OR: + exp = this.empty_or(cn); + break; + case LexerTreeConstants.JJTAND_SIMPLE_DURATION_CONSTRAINT: + if (!this.obj.requirements.contains(RequireKey.DURATION_INEQUALITIES)) { + this.mgr.logParserError("Require key \"" + RequireKey.DURATION_INEQUALITIES + + "\" needed to specify conjunction of durative constraints.", + this.file, node.getLine(), node.getColumn()); + } + exp = this.and_simple_duration_constraint(cn); + break; + case LexerTreeConstants.JJTSIMPLE_DURATION_CONSTRAINT: + exp = this.simple_duration_constraint(cn); + break; + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + return exp; + } + + /** + * Extracts the object structures from the <code>AND_SIMPLE_DURATION_CONSTRAINT</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AND_SIMPLE_DURATION_CONSTRAINT</code> node. + * @return the conjuncive simple duration constraint expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AndExp and_simple_duration_constraint(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTSIMPLE_DURATION_CONSTRAINT) { + AndExp exp = new AndExp(); + exp.add(this.simple_duration_constraint(cn)); + return exp; + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>SIMPLE_DURATION_CONSTRAINT</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>SIMPLE_DURATION_CONSTRAINT</code> node. + * @return the simple duration constraint expression built + * @throws ParserException if an error occurs while parsing. + */ + private Exp simple_duration_constraint(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTD_OP: + return this.d_op(cn); + case LexerTreeConstants.JJTAT_SIMPLE_DURATION_CONSTRAINT: + return this.at_simple_duration_constraint(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + + /** + * Extracts the object structures from the <code>AT_SIMPLE_DURATION_CONSTRAINT</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_SIMPLE_DURATION_CONSTRAINT</code> node. + * @return the at simple duration constraint expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AtTimedExp at_simple_duration_constraint(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTAT_END_SIMPLE_DURATION_CONSTRAINT: + return this.at_end_simple_duration_constraint(cn); + case LexerTreeConstants.JJTAT_START_SIMPLE_DURATION_CONSTRAINT: + return this.at_start_simple_duration_constraint(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + + /** + * Extracts the object structures from the <code>AT_END_SIMPLE_DURATION_CONSTRAINT</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_END_SIMPLE_DURATION_CONSTRAINT</code> node. + * @return the at end simple durative constraint expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AtEndTimedExp at_end_simple_duration_constraint(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTSIMPLE_DURATION_CONSTRAINT) { + Exp exp = this.simple_duration_constraint(cn); + return new AtEndTimedExp(exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AT_START_SIMPLE_DURATION_CONSTRAINT</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_START_SIMPLE_DURATION_CONSTRAINT</code> node. + * @return the at start simple durative constraint expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AtStartTimedExp at_start_simple_duration_constraint(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTSIMPLE_DURATION_CONSTRAINT) { + Exp exp = this.simple_duration_constraint(cn); + return new AtStartTimedExp(exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>D_OP</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>D_OP</code> node. + * @return the durative operation expression built + * @throws ParserException if an error occurs while parsing. + */ + private FCompExp d_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTGEQUAL_D_OP: + if (!this.obj.requirements.contains(RequireKey.DURATION_INEQUALITIES)) { + this.mgr.logParserError("Require key \"" + RequireKey.DURATION_INEQUALITIES + + "\" needed to specify durative inequalitities.", + this.file, node.getLine(), node.getColumn()); + } + return this.gequal_d_op(cn); + case LexerTreeConstants.JJTLEQUAL_D_OP: + if (!this.obj.requirements.contains(RequireKey.DURATION_INEQUALITIES)) { + this.mgr.logParserError("Require key \"" + RequireKey.DURATION_INEQUALITIES + + "\" needed to specify durative inequalitities.", + this.file, node.getLine(), node.getColumn()); + } + return this.lequal_d_op(cn); + case LexerTreeConstants.JJTEQUAL_D_OP: + return this.equal_d_op(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + + /** + * Extracts the object structures from the <code>EQUAL_D_OP</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>EQUAL_D_OP</code> node. + * @return the equal durative operation expression built + * @throws ParserException if an error occurs while parsing. + */ + private FCompExp equal_d_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTVAR_DURATION + && cn2.getId() == LexerTreeConstants.JJTD_VALUE) { + Variable cv = new Variable(Variable.DURATIVE_VARIABLE, Type.NUMBER); + return new EqualComp(cv, this.d_value(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>LEQUAL_D_OP</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>LEQUAL_D_OP</code> node. + * @return the less equal durative operation expression built + * @throws ParserException if an error occurs while parsing. + */ + private FCompExp lequal_d_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTVAR_DURATION + && cn2.getId() == LexerTreeConstants.JJTD_VALUE) { + Variable cv = new Variable(Variable.DURATIVE_VARIABLE, Type.NUMBER); + return new LEqualComp(cv, this.d_value(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>GEQUAL_D_OP</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>GEQUAL_D_OP</code> node. + * @return the greater equal durative operation expression built + * @throws ParserException if an error occurs while parsing. + */ + private FCompExp gequal_d_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTVAR_DURATION + && cn2.getId() == LexerTreeConstants.JJTD_VALUE) { + Variable cv = new Variable(Variable.DURATIVE_VARIABLE, Type.NUMBER); + return new GEqualComp(cv, this.d_value(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>GEQUAL_D_OP</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>D_OP</code> node. + * @return the greater equal durative operation expression built + * @throws ParserException if an error occurs while parsing. + */ + private Term d_value(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTNUMBER: + return this.number(cn); + case LexerTreeConstants.JJTF_EXP: + if (!this.obj.requirements.contains(RequireKey.FLUENTS)) { + this.mgr.logParserError("Require key \"" + RequireKey.FLUENTS + + "\" needed to specify fluent expressions.", + this.file, node.getLine(), node.getColumn()); + } + return this.f_exp(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + + /** + * Extracts the object structures from the <code>EMPTY_OR</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>EMPTY_OR</code> node. + * @return the empty or expression built + * @throws ParserException if an error occurs while parsing. + */ + private OrExp empty_or(SimpleNode node) throws ParserException { + return new OrExp(); + } + + /** + * Extracts the object structures from the <code>DURATION_CONSTRAINT</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DURATION_CONSTRAINT</code> node. + * @return the duration constraint expression built + * @throws ParserException if an error occurs while parsing. + */ + + /** + * Extracts the object structures from the <code>DERIVED_DEF</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DERIVED_DEF</code> node. + * @return the actionCtx structure built. + * @throws ParserException if an error occurs while parsing. + */ + private DerivedPredicate derived_def(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTATOMIC_FORMULA + && cn2.getId() == LexerTreeConstants.JJTGD) { + AtomicFormula head = this.atomic_formula(cn1); + Exp body = this.gd(cn2); + DerivedPredicate axiom = new DerivedPredicate(head, body); + this.obj.axioms.add(axiom); + return axiom; + } + + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + /** + * Extracts the object structures from the <code>ACTION_DEF</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>ACTION_DEF</code> node. + * @return the actionCtx structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Action action_def(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 3) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + SimpleNode cn3 = (SimpleNode) node.jjtGetChild(2); + if (cn1.getId() == LexerTreeConstants.JJTACTION_NAME + && cn2.getId() == LexerTreeConstants.JJTTYPED_LIST + && cn3.getId() == LexerTreeConstants.JJTACTION_DEF_BODY) { + Action action = new Action(this.action_name(cn1)); + LinkedHashMap<String, Variable> parameters = new LinkedHashMap<String, Variable>(); + this.var_typed_list(cn2, parameters); + for (Variable param : parameters.values()) { + action.add(param); + } + this.action_def_body(cn3, action); + if (this.obj.actions.containsKey(action.getName())) { + this.mgr.logParserError("Duplicated action \"" + action.getName() + + " \"." , this.file, cn1.getLine(), cn1.getColumn()); + } else { + this.obj.actions.put(action.getName(), action); + } + return action; + } + } + return null; + } + + + /** + * Extracts the object structures from the <code>ACTION_DEF_BODY</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>ACTION_DEF_BODY</code> node. + * @param action the actionCtx to initialize. + * @throws ParserException if an error occurs while parsing. + */ + private void action_def_body(SimpleNode node, Action action) throws ParserException { + this.actionCtx = action; + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTPRE_GD + && cn2.getId() == LexerTreeConstants.JJTEFFECT) { + action.setPrecondition(this.pre_gd(cn1)); + action.setEffect(this.effect(cn2)); + } else { + this.actionCtx = null; + } + } else { + this.actionCtx = null; + } + this.actionCtx = null; + } + + /** + * Extracts the object structures from the <code>EFFECT</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>EFFECT</code> node. + * @return the effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Exp effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTAND_C_EFFECT: + return this.and_c_effect(cn); + case LexerTreeConstants.JJTC_EFFECT: + return this.c_effect(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return null; + } + + /** + * Extracts the object structures from the <code>EFFECT</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>EFFECT</code> node. + * @return the effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Exp c_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTFORALL_EFFECT: + return this.forall_effect(cn); + case LexerTreeConstants.JJTWHEN_CON_EFFECT: + return this.when_con_effect(cn); + case LexerTreeConstants.JJTP_EFFECT: + return this.p_effect(cn); + case LexerTreeConstants.JJTPROB_EFFECT: + return this.prob_effect(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * For cleanliness, this returns an AndExp which is the conjunction of + * all the individual probability expressions. + * + * @param node + * @return + * @throws ParserException + */ + private ProbExp prob_effect(SimpleNode node) throws ParserException { + + Iterator<SimpleNode> children = node.iterator(); + + ProbExp prob_term = new ProbExp(); + + for(int i=0; i < node.jjtGetNumChildren(); i++){ + SimpleNode cn = (SimpleNode)node.jjtGetChild(i); + SimpleNode real_cn = (SimpleNode)cn.jjtGetChild(1); + + Exp child = null; + + switch(real_cn.getId()){ + case LexerTreeConstants.JJTC_EFFECT: + child = this.c_effect(real_cn); + break; + case LexerTreeConstants.JJTAND_C_EFFECT: + child = this.and_c_effect(real_cn); + break; + + } + + prob_term.addExp(child, this.number(((SimpleNode)cn.jjtGetChild(0))).getValue()); + + } + + return prob_term; + + } + + + /** + * Extracts the object structures from the <code>WHEN_CON_EFFECT</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>WHEN_CON_EFFECT</code> node. + * @return the when effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private WhenExp when_con_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTGD + && cn2.getId() == LexerTreeConstants.JJTCOND_EFFECT) { + Exp cond = this.gd(cn1); + Exp effect = this.cond_effect(cn2); + return new WhenExp(cond, effect); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>WHEN_C_EFFECT</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>WHEN_C_EFFECT</code> node. + * @return the when effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Exp cond_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTAND_P_EFFECT: + return this.and_p_effect(cn); + case LexerTreeConstants.JJTP_EFFECT: + return this.p_effect(cn); + case LexerTreeConstants.JJTAND_C_EFFECT: + return this.and_c_effect(cn); + case LexerTreeConstants.JJTC_EFFECT: + return this.c_effect(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AND_P_EFFECT</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AND_P_EFFECT</code> node. + * @return the conjuncive propositional effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AndExp and_p_effect(SimpleNode node) throws ParserException { + AndExp exp = new AndExp(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTP_EFFECT: + exp.add(this.p_effect(cn)); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return exp; + } + + /** + * Extracts the object structures from the <code>P_EFFECT</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>P_EFFECT</code> node. + * @return the propositional effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Exp p_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTASSIGN_OP: + if (!this.obj.requirements.contains(RequireKey.FLUENTS)) { + this.mgr.logParserError("Require key \"" + RequireKey.FLUENTS + + "\" missing.", this.file, + node.getLine(), node.getColumn()); + } + return this.assign_op(cn); + case LexerTreeConstants.JJTLITERAL: + return this.literal(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>ASSIGN_OP_EXP</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>ASSIGN_OP_EXP</code> node. + * @return the assign operation expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AssignOpExp assign_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTASSIGN: + return this.assign(cn); + case LexerTreeConstants.JJTSCALE_UP: + return this.scale_up(cn); + case LexerTreeConstants.JJTSCALE_DOWN: + return this.scale_down(cn); + case LexerTreeConstants.JJTINCREASE: + return this.increase(cn); + case LexerTreeConstants.JJTDECREASE: + return this.decrease(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>SCALE_UP</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>SCALE_UP</code> node. + * @return the assign scale up expression built. + * @throws ParserException if an error occurs while parsing. + */ + private ScaleUp scale_up(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_HEAD + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new ScaleUp(this.f_head(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DECREASE</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DECREASE</code> node. + * @return the descrease expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Decrease decrease(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_HEAD + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new Decrease(this.f_head(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>INCREASE</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>INCREASE</code> node. + * @return the increase expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Increase increase(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_HEAD + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new Increase(this.f_head(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>SCALE_DOWN</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>SCALE_DOWN</code> node. + * @return the assign scale up expression built. + * @throws ParserException if an error occurs while parsing. + */ + private ScaleDown scale_down(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_HEAD + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new ScaleDown(this.f_head(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>ASSIGN</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>ASSIGN</code> node. + * @return the propositional effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private Assign assign(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_HEAD + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new Assign(this.f_head(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>FORALL_C_EFFECT</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>FORALL_C_EFFECT</code> node. + * @return the universal effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private ForallExp forall_effect(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTTYPED_LIST + && cn2.getId() == LexerTreeConstants.JJTEFFECT) { + ActionDef tmp = this.actionCtx; + this.actionCtx = null; + ForallExp forall = new ForallExp(); + LinkedHashMap<String, Variable> vars = new LinkedHashMap<String, Variable>(); + this.var_typed_list(cn1, vars); + this.actionCtx = tmp; + for (Variable var : vars.values()) { + forall.add(var); + } + this.quantifiedExpCtx = forall; + Exp exp = this.effect(cn2); + forall.setExp(exp); + this.quantifiedExpCtx = null; + return forall; + } + } + this.quantifiedExpCtx = null; + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AND_C_EFFECT</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AND_C_EFFECT</code> node. + * @return the conjuncive effect expression built. + * @throws ParserException if an error occurs while parsing. + */ + private AndExp and_c_effect(SimpleNode node) throws ParserException { + AndExp effect = new AndExp(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + if (cn.getId() == LexerTreeConstants.JJTC_EFFECT) { + effect.add(this.c_effect(cn)); + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + return effect; + } + + /** + * Extracts the object structures from the <code>PRE_GD</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>PRE_GD</code> node. + * @return the precondition goal description built + * @throws ParserException if an error occurs while parsing. + */ + private Exp pre_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTEMPTY_OR: + return this.empty_or(cn); + case LexerTreeConstants.JJTPREF_GD: + return this.pref_gd(cn); + case LexerTreeConstants.JJTAND_PRE_GD: + return this.and_pre_gd(cn); + case LexerTreeConstants.JJTFORALL_PRE_GD: + if (!this.obj.requirements.contains(RequireKey.UNIVERSAL_PRECONDITIONS) + && !this.obj.requirements.contains(RequireKey.QUANTIFIED_PRECONDITIONS)) { + this.mgr.logParserError("Universal formula cannot be defined without require keys \"" + + RequireKey.UNIVERSAL_PRECONDITIONS + + "\" or \"" + + RequireKey.QUANTIFIED_PRECONDITIONS + + "\".", this.file, node.getLine(), node.getColumn()); + } + return this.forall_pre_gd(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>FORALL_PRE_GD</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>FORALL_PRE_GD</code> node. + * @return the universal precondition goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private ForallExp forall_pre_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTTYPED_LIST + && cn2.getId() == LexerTreeConstants.JJTPRE_GD) { + ActionDef tmp = this.actionCtx; + this.actionCtx = null; + ForallExp forall = new ForallExp(); + LinkedHashMap<String, Variable> vars = new LinkedHashMap<String, Variable>(); + this.var_typed_list(cn1, vars); + this.actionCtx = tmp; + for (Variable var : vars.values()) { + forall.add(var); + } + this.quantifiedExpCtx = forall; + Exp exp = this.pre_gd(cn2); + forall.setExp(exp); + this.quantifiedExpCtx = null; + return forall; + } + } + this.quantifiedExpCtx = null; + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AND_PRE_GD</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AND_PRE_GD</code> node. + * @return the conjuncive precondition goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private AndExp and_pre_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTPRE_GD) { + AndExp pre_gd = new AndExp(); + pre_gd.add(this.pre_gd(cn)); + return pre_gd; + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>PREF_GD</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>PREF_GD</code> node. + * @return the precondition goal description built + * @throws ParserException if an error occurs while parsing. + */ + private Exp pref_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTNAMED_PREF_GD: + return this.named_pref_gd(cn); + case LexerTreeConstants.JJTGD: + return this.gd(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>PREF_GD</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>PREF_GD</code> node. + * @return the precondition goal description built + * @throws ParserException if an error occurs while parsing. + */ + private Exp named_pref_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + if (cn1.getId() == LexerTreeConstants.JJTGD) { + Exp exp = this.gd(cn1); + return new PrefExp(exp); + } + } else if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTPREF_NAME + && cn2.getId() == LexerTreeConstants.JJTGD) { + String name = this.pref_name(cn1); + Exp exp = this.gd(cn2); + return new PrefExp(name, exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>ACTION_NAME</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>ACTION_NAME</code> node. + * @return the actionCtx name structure built. + * @throws ParserException if an error occurs while parsing. + */ + private String action_name(SimpleNode node) throws ParserException { + return node.getImage(); + } + + /** + * Extracts the object structures from the <code>REQUIRE_DEF</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>REQUIRE_DEF</code> node. + * @return the require definition structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Set<RequireKey> requireDef(SimpleNode node) throws ParserException { + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTREQUIRE_KEY: + RequireKey rk = RequireKey.getRequireKey(cn.getImage()); + + if (rk == null) { + this.mgr.logParserError("Invalid require key \"" + cn.getImage() + "\".", + file, node.getLine(), node.getColumn()); + } else if (rk != null && this.options.get(rk) == null) { + this.mgr.logParserError("Require key \"" + rk.getImage() + + "\" forbidden due to parser requirement options." , + file, cn.getLine(), cn.getColumn()); + } else { + if (rk.equals(RequireKey.ADL)) { + obj.requirements.add(RequireKey.ADL); + obj.requirements.add(RequireKey.STRIPS); + obj.requirements.add(RequireKey.TYPING); + obj.requirements.add(RequireKey.EXISTENTIAL_PRECONDITIONS); + obj.requirements.add(RequireKey.UNIVERSAL_PRECONDITIONS); + obj.requirements.add(RequireKey.QUANTIFIED_PRECONDITIONS); + obj.requirements.add(RequireKey.CONDITIONAL_EFFECTS); + obj.requirements.add(RequireKey.DISJUNCTIVE_PRECONDITIONS); + obj.requirements.add(RequireKey.EQUALITY); + obj.requirements.add(RequireKey.FLUENTS); + obj.requirements.add(RequireKey.NEGATIVE_PRECONDITIONS); + } else if (rk.equals(RequireKey.QUANTIFIED_PRECONDITIONS)) { + obj.requirements.add(RequireKey.QUANTIFIED_PRECONDITIONS); + obj.requirements.add(RequireKey.EXISTENTIAL_PRECONDITIONS); + obj.requirements.add(RequireKey.UNIVERSAL_PRECONDITIONS); + } else { + obj.requirements.add(rk); + } + } + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return obj.requirements; + } + + /** + * Extracts the object structures from the <code>TYPE_DEF</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>TYPE_DEF</code> node. + * @return the type definition structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Map<String, Set<String>> types_def(SimpleNode node) throws ParserException { + if (!this.obj.requirements.contains(RequireKey.TYPING)) { + this.mgr.logParserError("Require key \"" + RequireKey.TYPING + + "\" needed to specify typed terms.", this.file, + node.getLine(), node.getColumn()); + } + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTTYPED_LIST: + this.type_typed_list(cn, obj.types); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return obj.types; + } + + + /** + * Extracts the object structures from the <code>TYPED_LIST</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>TYPED_LIST</code> node. + * @param tl the types list of primitive type already built. + * @return the typed list structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Map<String, Set<String>> type_typed_list(SimpleNode node, + Map<String, Set<String>> tl) throws ParserException { + boolean typed = false; + Set<String> ptl = new LinkedHashSet<String>(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTPRIMITIVE_TYPE: + String pt = primitive_type(cn); + if (pt.equals(Type.NUMBER_SYMBOL) || pt.equals(Type.OBJECT_SYMBOL)) { + this.mgr.logParserError("Type \"" + pt + "\" is a reserved type.", + this.file, cn.getLine(), cn.getColumn()); + } else if (tl.containsKey(pt)) { + this.mgr.logParserError("Type \"" + pt + "\" duplicated definition.", + this.file, cn.getLine(), cn.getColumn()); + } else { + tl.put(pt, new LinkedHashSet<String>()); + ptl.add(pt); + } + break; + case LexerTreeConstants.JJTTYPE: + typed = true; + Set<String> type = type(cn); + for (String pti : type) { + if (pti.equals(Type.NUMBER_SYMBOL)) { + this.mgr.logParserError("Type \"" + pti + "\" not allow in type declaration.", + this.file, node.getLine(), node.getColumn()); + } else if (!tl.containsKey(pti)) { + this.mgr.logParserError("Type \"" + pti + "\" undefinied.", + this.file, node.getLine(), node.getColumn()); + } else { + Set<String> ti = tl.get(pti); + ti.addAll(ptl); + } + } + break; + case LexerTreeConstants.JJTTYPED_LIST: + if (!this.obj.requirements.contains(RequireKey.TYPING)) { + this.mgr.logParserError("Require key \"" + RequireKey.TYPING + + "\" needed to specify types.", this.file, + node.getLine(), node.getColumn()); + } + Map<String, Set<String>> typed_list = this.type_typed_list(cn, tl); + tl.putAll(typed_list); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + if (!typed) { + Set<String> obj = tl.get(Type.OBJECT_SYMBOL); + for (String t : tl.keySet()) { + if (!t.equals(Type.NUMBER_SYMBOL) && !t.equals(Type.OBJECT_SYMBOL)) { + obj.add(t); + } + } + + } + return tl; + } + + + + /** + * Extracts the object structures from the <code>TYPED_LIST</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>TYPED_LIST</code> node. + * @param tl the typed list of variables already built. + * @return the typed list structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Map<String, Variable> var_typed_list(SimpleNode node, + LinkedHashMap<String, Variable> tl) throws ParserException { + List<Variable> vtl = new ArrayList<Variable>(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTVARIABLE: + Variable v = this.variable(cn); + if (tl.containsKey(v.getImage())) { + this.mgr.logParserError("Variable \"" + v + "\" duplicated definition.", + this.file, cn.getLine(), cn.getColumn()); + } else { + vtl.add(v); + tl.put(v.getImage(), v); + } + + break; + case LexerTreeConstants.JJTTYPE: + Set<String> type = type(cn); + TypeSet newType = new TypeSet(); + for (String pti : type) { + if (pti.equals(Type.NUMBER_SYMBOL)) { + this.mgr.logParserError("Type \"" + pti + "\" not allow in type declaration.", + this.file, node.getLine(), node.getColumn()); + } else if (!this.obj.types.containsKey(pti)) { + this.mgr.logParserError("Type \"" + pti + "\" undefinied.", + this.file, node.getLine(), node.getColumn()); + } else { + newType.add(new Type(pti, obj.types)); + } + } + for (Variable vi : vtl) { + vi.setTypeSet(newType); + } + break; + case LexerTreeConstants.JJTTYPED_LIST: + + if (!this.obj.requirements.contains(RequireKey.TYPING)) { + this.mgr.logParserError("Require key \"" + RequireKey.TYPING + + "\" needed to specify typed variables.", this.file, + node.getLine(), node.getColumn()); + } + this.var_typed_list(cn, tl); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return tl; + } + + + /** + * Extracts the object structures from the <code>TYPED_LIST</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>TYPED_LIST</code> node. + * @param tl the typed list of constants already built. + * @return the typed list structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Map<String, Constant> constant_typed_list(SimpleNode node, + Map<String, Constant> tl) throws ParserException { + List<Constant> ctl = new ArrayList<Constant>(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTCONSTANT: + Constant c = this.constant(cn); + if (tl.containsKey(c.getImage())) { + this.mgr.logParserError("Constant \"" + c + "\" duplicated definition.", + this.file, cn.getLine(), cn.getColumn()); + } else { + ctl.add(c); + tl.put(c.getImage(), c); + } + break; + case LexerTreeConstants.JJTTYPE: + Set<String> type = type(cn); + TypeSet newType = new TypeSet(); + for (String pti : type) { + if (pti.equals(Type.NUMBER_SYMBOL)) { + this.mgr.logParserError("Type \"" + pti + "\" not allow in type declaration.", + this.file, node.getLine(), node.getColumn()); + } else if (!this.obj.types.containsKey(pti) + && !this.obj.getContent().equals(PDDLObject.Content.PARTIAL_PROBLEM)) { + this.mgr.logParserError("Type \"" + pti + "\" undefinied.", + this.file, node.getLine(), node.getColumn()); + } else { + newType.add(new Type(pti, obj.types)); + } + } + for (Constant ci : ctl) { + ci.setTypeSet(newType); + } + break; + case LexerTreeConstants.JJTTYPED_LIST: + if (!this.obj.requirements.contains(RequireKey.TYPING)) { + this.mgr.logParserError("Require key \"" + RequireKey.TYPING + + "\" needed to specify typed constants.", this.file, + node.getLine(), node.getColumn()); + } + this.constant_typed_list(cn, tl); + break; + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return tl; + } + + + /** + * Extracts the object structures from the <code>PRIMITIVE_TYPE</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>PRIMITIVE_TYPE</code> node. + * @return the primitive type structure built. + * @throws ParserException if an error occurs while parsing. + */ + private String primitive_type(SimpleNode node) throws ParserException { + return node.getImage(); + } + + + /** + * Extracts the object structures from the <code>TYPE</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>TYPE</code> node. + * @return the type structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Set<String> type(SimpleNode node) throws ParserException { + Set<String> type = new LinkedHashSet<String>(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + if (cn.getId() == LexerTreeConstants.JJTPRIMITIVE_TYPE) { + type.add(this.primitive_type(cn)); + } else { + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + return type; + } + + /** + * Extracts the object structures from the <code>CONSTANTS_DEF</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>CONSTANTS_DEF</code> node. + * @return the constants definition structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Map<String, Constant> constants_def(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTTYPED_LIST) { + this.constantDef = true; + this.constant_typed_list(cn, obj.constants); + for (Constant cst : obj.constants.values()) { + for (Type pt : cst.getTypeSet()) { + Set<Constant> domain = this.obj.typeDomains.get(pt); + if (domain == null) { + domain = new LinkedHashSet<Constant>(); + } + domain.add(cst); + } + } + this.constantDef = false; + return obj.constants; + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>CONSTANT</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>CONSTANT</code> node. + * @return the constant structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Constant constant(SimpleNode node) throws ParserException { + Constant cons = new Constant(node.getImage(), new Type(Type.OBJECT_SYMBOL, obj.types)); + if (!this.constantDef) { + Constant cst = this.obj.constants.get(cons.getImage()); + if (cst == null) { + this.mgr.logParserError("Constant \"" + cons +"\" undefined." , + this.file, node.getLine(), node.getColumn()); + } else { + cons = cst; + } + } + return cons; + } + + /** + * Extracts the object structures from the <code>PREDICATES_DEF</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>PREDICATES_DEF</code> node. + * @return the predicates definition structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Set<AtomicFormula> predicates_def(SimpleNode node) throws ParserException { + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTATOMIC_FORMULA_SKELETON: + obj.predicates.add(this.atomic_formula_skeleton(cn)); + break; + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return obj.predicates; + } + + /** + * Extracts the object structures from the <code>PREDICATES_DEF</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>PREDICATES_DEF</code> node. + * @return the predicates definition structure built. + * @throws ParserException if an error occurs while parsing. + */ + private AtomicFormula atomic_formula_skeleton(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTPREDICATE + && cn2.getId() == LexerTreeConstants.JJTTYPED_LIST) { + AtomicFormula afs = new AtomicFormula(this.predicate(cn1)); + LinkedHashMap<String, Variable> arguments = new LinkedHashMap<String, Variable>(); + this.var_typed_list(cn2, arguments); + for (Variable arg : arguments.values()) { + afs.add(arg); + } + return afs; + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + + } + + /** + * Extracts the object structures from the <code>PREDICATE</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>PREDICATE</code> node. + * @return the predicate structure built. + * @throws ParserException if an error occurs while parsing. + */ + private String predicate(SimpleNode node) throws ParserException { + return node.getImage(); + } + + /** + * Extracts the object structures from the <code>FUNCTIONS_DEF</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>FUNCTIONS_DEF</code> node. + * @return the functions definition structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Set<FHead> functions_def(SimpleNode node) throws ParserException { + if (!this.obj.requirements.contains(RequireKey.FLUENTS)) { + this.mgr.logParserError("Require key \"" + RequireKey.FLUENTS + + "\" needed to defined functions.", this.file, node.getLine(), + node.getColumn()); + } + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTFUNCTION_TYPED_LIST: + this.atomic_function_skeleton_typed_list(cn, obj.functions); + break; + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return obj.functions; + } + + /** + * Extracts the object structures from the <code>TYPED_LIST</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>TYPED_LIST</code> node. + * @param tl the typed list of constants already built. + * @return the typed list structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Set<FHead> atomic_function_skeleton_typed_list( + SimpleNode node, Set<FHead> tl) + throws ParserException { + List<FHead> atftl = new ArrayList<FHead>(); + TypeSet number = new TypeSet(); + number.add(Type.NUMBER); + + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTATOMIC_FUNCTION_SKELETON: + FHead func = this.atomic_function_skeleton(cn); + func.setTypeSet(number); + tl.add(func); + break; + case LexerTreeConstants.JJTFUNCTION_TYPE: + if (!cn.getImage().equals(Type.NUMBER_SYMBOL)) { + this.mgr.logParserError("FExp can be only typed as number.", + this.file, node.getLine(), node.getColumn()); + } + break; + case LexerTreeConstants.JJTFUNCTION_TYPED_LIST: + if (!this.obj.requirements.contains(RequireKey.TYPING)) { + this.mgr.logParserError("Require key \"" + RequireKey.TYPING + + "\" needed to specify typed functions.", this.file, + node.getLine(), node.getColumn()); + } + this.atomic_function_skeleton_typed_list(cn, tl); + break; + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return tl; + } + + + /** + * Extracts the object structures from the + * <code>ATOMIC_FUNCTION_SKELETON</code> node of the syntaxic tree and + * implements the semantic check. + * + * @param node the <code>ATOMIC_FUNCTION_SKELETON</code> node. + * @return the atomic function skeleton structure built. + * @throws ParserException if an error occurs while parsing. + */ + private FHead atomic_function_skeleton(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTFUNCTOR + && cn2.getId() == LexerTreeConstants.JJTTYPED_LIST) { + FHead afs = new FHead(this.functor(cn1), Type.NUMBER); + LinkedHashMap<String, Variable> arguments = new LinkedHashMap<String, Variable>(); + this.var_typed_list(cn2, arguments); + for (Variable arg : arguments.values()) { + afs.add(arg); + } + return afs; + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>FUNCTOR</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>FUNCTOR</code> node. + * @return the functor structure built. + * @throws ParserException if an error occurs while parsing. + */ + private String functor(SimpleNode node) throws ParserException { + return node.getImage(); + } + + /** + * Extracts the object structures from the <code>TERM</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>TERM</code> node. + * @return the exp structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Variable variable(SimpleNode node) throws ParserException { + Variable var = new Variable(node.getImage(), new Type(Type.OBJECT_SYMBOL, obj.types)); + if (this.actionCtx != null) { + TypeSet qt = null; + if (this.quantifiedExpCtx != null) { + Iterator<Variable> i = this.quantifiedExpCtx.iterator(); + while (i.hasNext() && qt == null) { + Variable vi = i.next(); + if (var.getImage().equals(vi.getImage())) { + qt = vi.getTypeSet(); + } + } + } + TypeSet pt = null; + if (this.actionCtx != null) { + Iterator<Term> i = this.actionCtx.iterator(); + while (i.hasNext() && pt == null) { + Term ti = i.next(); + if (var.getImage().equals(ti.getImage())) { + pt = ti.getTypeSet(); + } + } + } + if (qt == null && pt == null) { + this.mgr.logParserError("Variable \"" + var +"\" undefined in action \"" + + this.actionCtx.getName() + "\".", + this.file, node.getLine(), node.getColumn()); + } else if (qt != null && pt != null && !qt.equals(pt)) { + this.mgr.logParserError("Variable \"" + var +"\" conflicted type in action \"" + + this.actionCtx.getName() + "\".", + this.file, node.getLine(), node.getColumn()); + } else { + if (qt != null) { + var.setTypeSet(qt); + } else { + var.setTypeSet(pt); + } + } + } + return var; + + } + + /** + * Extracts the object structures from the <code>CONSTRAINTS</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>CONSTRAINTS</code> node. + * @return the constraints definition structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Set<Exp> constraints(SimpleNode node) throws ParserException { + if (!this.obj.requirements.contains(RequireKey.CONSTRAINTS)) { + this.mgr.logParserError("Require key \"" + RequireKey.CONSTRAINTS + + "\" missing to define constraints.", this.file, + node.getLine(), + node.getColumn()); + } + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTPREF_CON_GD) { + obj.constraints.add(this.pref_con_gd(cn)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>PREF_CON_GD</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>PREF_CON_GD</code> node. + * @return the conditional goal description preference structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Exp pref_con_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTAND_PREF_CON_GD: + return this.and_pref_con_gd(cn); + case LexerTreeConstants.JJTFORALL_PREF_CON_GD: + return this.forall_pref_con_gd(cn); + case LexerTreeConstants.JJTNAMED_PREF_CON_GD: + return this.named_pref_con_gd(cn); + case LexerTreeConstants.JJTCON_GD: + return this.con_gd(cn); + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AND_PREF_CON_GD</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AND_PREF_CON_GD</code> node. + * @return the and condition goal description preference structure built. + * @throws ParserException if an error occurs while parsing. + */ + private AndExp and_pref_con_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTPREF_CON_GD) { + AndExp pre_con_gd = new AndExp(); + pre_con_gd.add(this.pref_con_gd(cn)); + return pre_con_gd; + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>FORALL_PREF_CON_GD</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>FORALL_PREF_CON_GD</code> node. + * @return the forall condition goal description preference structure built. + * @throws ParserException if an error occurs while parsing. + */ + private ForallExp forall_pref_con_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTTYPED_LIST + && cn2.getId() == LexerTreeConstants.JJTPREF_CON_GD) { + ActionDef tmp = this.actionCtx; + this.actionCtx = null; + ForallExp forall = new ForallExp(); + LinkedHashMap<String, Variable> vars = new LinkedHashMap<String, Variable>(); + this.var_typed_list(cn1, vars); + this.actionCtx = tmp; + for (Variable var : vars.values()) { + forall.add(var); + } + this.quantifiedExpCtx = forall; + Exp exp = this.pref_con_gd(cn2); + forall.setExp(exp); + this.quantifiedExpCtx = null; + return forall; + } + } + this.quantifiedExpCtx = null; + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>PREFERENCE</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>PREFERENCE</code> node. + * @return the preference structure built. + * @throws ParserException if an error occurs while parsing. + */ + private PrefExp named_pref_con_gd(SimpleNode node) throws ParserException { + if (!this.obj.requirements.contains(RequireKey.PREFERENCES)) { + this.mgr.logParserError("Require key \"" + RequireKey.PREFERENCES + + "\" missing.", this.file, node.getLine(), node.getColumn()); + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + if (cn1.getId() == LexerTreeConstants.JJTCON_GD) { + Exp exp = this.con_gd(cn1); + return new PrefExp(exp); + } + + } else if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTPREF_NAME + && cn2.getId() == LexerTreeConstants.JJTCON_GD) { + String name = this.pref_name(cn1); + Exp exp = this.con_gd(cn2); + return new PrefExp(name, exp); + } + } else { + throw new ParserException("aAn internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + } + throw new ParserException("1An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + + } + + /** + * Extracts the object structures from the <code>PREF_NAME</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>PREF_NAME</code> node. + * @return the preference image structure built. + * @throws ParserException if an error occurs while parsing. + */ + private String pref_name(SimpleNode node) throws ParserException { + return node.getImage(); + } + + /** + * Extracts the object structures from the <code>CON_GD</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>CON_GD</code> node. + * @return the conditional goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Exp con_gd(SimpleNode node) throws ParserException { + Exp exp = null; + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTAND_CON_GD: + exp = this.and_con_gd(cn); + break; + case LexerTreeConstants.JJTFORALL_CON_GD: + exp = this.forall_con_gd(cn); + break; + case LexerTreeConstants.JJTAT_END_CON_GD: + exp = this.at_end_con_gd(cn); + break; + case LexerTreeConstants.JJTALWAYS_CON_GD: + exp = this.always_con_gd(cn); + break; + case LexerTreeConstants.JJTSOMETIME_CON_GD: + exp = this.sometime_con_gd(cn); + break; + case LexerTreeConstants.JJTWITHIN_CON_GD: + exp = this.within_con_gd(cn); + break; + case LexerTreeConstants.JJTAT_MOST_ONCE_CON_GD: + exp = this.at_most_once_con_gd(cn); + break; + case LexerTreeConstants.JJTSOMETIME_AFTER_CON_GD: + exp = this.sometime_after_con_gd(cn); + break; + case LexerTreeConstants.JJTSOMETIME_BEFORE_CON_GD: + exp = this.sometime_before_con_gd(cn); + break; + case LexerTreeConstants.JJTALWAYS_WITHIN_CON_GD: + exp = this.always_within_con_gd(cn); + break; + case LexerTreeConstants.JJTHOLD_DURING_CON_GD: + exp = this.hold_during_con_gd(cn); + break; + case LexerTreeConstants.JJTHOLD_AFTER_CON_GD: + exp = this.hold_after_con_gd(cn); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return exp; + } + + /** + * Extracts the object structures from the <code>HOLD_AFTER</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>HOLD_AFTER</code> node. + * @return the "hold after" conditional goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private HoldAfterExp hold_after_con_gd(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTNUMBER + && cn2.getId() == LexerTreeConstants.JJTGD) { + Number time = this.number(cn1); + Exp exp = this.gd(cn2); + return new HoldAfterExp(exp, time); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>HOLD_DURING</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>HOLD_DURING</code> node. + * @return the "hold during" conditional goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private HoldDuringExp hold_during_con_gd(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 3) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + SimpleNode cn3 = (SimpleNode) node.jjtGetChild(2); + if (cn1.getId() == LexerTreeConstants.JJTNUMBER + && cn2.getId() == LexerTreeConstants.JJTNUMBER + && cn2.getId() == LexerTreeConstants.JJTGD) { + Number lt = this.number(cn1); + Number ut = this.number(cn2); + Exp exp = this.gd(cn3); + return new HoldDuringExp(lt, ut, exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>ALWAYS_WITHIN</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>ALWAYS_WITHIN</code> node. + * @return the "always within" conditional goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private AlwaysWithinExp always_within_con_gd(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 3) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + SimpleNode cn3 = (SimpleNode) node.jjtGetChild(2); + if (cn1.getId() == LexerTreeConstants.JJTNUMBER + && cn2.getId() == LexerTreeConstants.JJTGD + && cn2.getId() == LexerTreeConstants.JJTGD) { + Number time = this.number(cn1); + Exp arg1 = this.gd(cn2); + Exp arg2 = this.gd(cn3); + return new AlwaysWithinExp(arg1, arg2, time); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>SOMETIME_BEFORE</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>SOMETIME_BEFORE</code> node. + * @return the "sometime before" conditional goal description structure + * built. + * @throws ParserException if an error occurs while parsing. + */ + private SometimeBeforeExp sometime_before_con_gd(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTGD + && cn2.getId() == LexerTreeConstants.JJTGD) { + Exp arg1 = this.gd(cn1); + Exp arg2 = this.gd(cn2); + return new SometimeBeforeExp(arg1, arg2); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>SOMETIME_AFTER</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>SOMETIME_AFTER</code> node. + * @return the "sometime after" conditional goal description structure + * built. + * @throws ParserException if an error occurs while parsing. + */ + private SometimeAfterExp sometime_after_con_gd(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTGD + && cn2.getId() == LexerTreeConstants.JJTGD) { + Exp arg1 = this.gd(cn1); + Exp arg2 = this.gd(cn2); + return new SometimeAfterExp(arg1, arg2); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AT_MOST_ONCE</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_MOST_ONCE</code> node. + * @return the "at most once" conditional goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private AtMostOnceExp at_most_once_con_gd(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTGD) { + Exp exp = this.gd(cn); + return new AtMostOnceExp(exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>WITHIN</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>WITHIN</code> node. + * @return the "within" conditional goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private WithinExp within_con_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTNUMBER + && cn2.getId() == LexerTreeConstants.JJTGD) { + Number time = this.number(cn1); + Exp exp = this.gd(cn2); + return new WithinExp(exp, time); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>SOMETIME</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>SOMETIME</code> node. + * @return the "sometime" conditional goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private SometimeExp sometime_con_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTGD) { + Exp exp = this.gd(cn); + return new SometimeExp(exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>ALWAYS</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>ALWAYS</code> node. + * @return the "always" conditional goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private AlwaysExp always_con_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTGD) { + Exp exp = this.gd(cn); + return new AlwaysExp(exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AND_CON_GD</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>AND_CON_GD</code> node. + * @return the and conditional goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private AndExp and_con_gd(SimpleNode node) throws ParserException { + AndExp and = new AndExp(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTCON_GD: + and.add(this.con_gd(cn)); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return and; + } + + /** + * Extracts the object structures from the <code>FORALL_CON_GD</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>FORALL_CON_GD</code> node. + * @return the universal conditional goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private ForallExp forall_con_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTTYPED_LIST + && cn2.getId() == LexerTreeConstants.JJTCON_GD) { + ActionDef tmp = this.actionCtx; + this.actionCtx = null; + ForallExp forall = new ForallExp(); + LinkedHashMap<String, Variable> vars = new LinkedHashMap<String, Variable>(); + this.var_typed_list(cn1, vars); + this.actionCtx = tmp; + for (Variable var : vars.values()) { + forall.add(var); + } + this.quantifiedExpCtx = forall; + Exp exp = this.con_gd(cn2); + forall.setExp(exp); + this.quantifiedExpCtx = null; + return forall; + } + } + this.quantifiedExpCtx = null; + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>AT_END_CON_GD</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>AT_END_CON_GD</code> node. + * @return the at end conditional goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private AtEndTimedExp at_end_con_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTCON_GD) { + Exp exp = this.gd(cn); + return new AtEndTimedExp(exp); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>GD</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>GD</code> node. + * @return the goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Exp gd(SimpleNode node) throws ParserException { + Exp exp = null; + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTATOMIC_FORMULA: + exp = this.atomic_formula(cn); + break; + case LexerTreeConstants.JJTAND_GD: + exp = this.and_gd(cn); + break; + case LexerTreeConstants.JJTOR_GD: + if (!this.obj.requirements.contains(RequireKey.DISJUNCTIVE_PRECONDITIONS)) { + this.mgr.logParserError("Disjunctive formula cannot be defined without require key \"" + + RequireKey.DISJUNCTIVE_PRECONDITIONS + + "\".", this.file, node.getLine(), node.getColumn()); + } + exp = this.or_gd(cn); + break; + case LexerTreeConstants.JJTNOT_GD: + NotExp notExp = this.not_gd(cn); + if (!notExp.getExp().getExpID().equals(ExpID.F_COMP) && !this.obj.requirements.contains(RequireKey.NEGATIVE_PRECONDITIONS)) { + this.mgr.logParserError("Negative formula cannot be defined without require key \"" + + RequireKey.NEGATIVE_PRECONDITIONS + + "\".", this.file, node.getLine(), node.getColumn()); + } + exp = notExp; + break; + case LexerTreeConstants.JJTIMPLY_GD: + if (!this.obj.requirements.contains(RequireKey.DISJUNCTIVE_PRECONDITIONS)) { + this.mgr.logParserError("Implication formula cannot be defined without require key \"" + + RequireKey.DISJUNCTIVE_PRECONDITIONS + + "\".", this.file, node.getLine(), node.getColumn()); + } + exp = this.imply_gd(cn); + break; + case LexerTreeConstants.JJTFORALL_GD: + if (!this.obj.requirements.contains(RequireKey.UNIVERSAL_PRECONDITIONS) + && !this.obj.requirements.contains(RequireKey.QUANTIFIED_PRECONDITIONS)) { + this.mgr.logParserError("Universal formula cannot be defined without require keys \"" + + RequireKey.UNIVERSAL_PRECONDITIONS + + "\" or \"" + + RequireKey.QUANTIFIED_PRECONDITIONS + + "\".", this.file, node.getLine(), node.getColumn()); + } + exp = this.forall_gd(cn); + break; + case LexerTreeConstants.JJTEXISTS_GD: + if (!this.obj.requirements.contains(RequireKey.EXISTENTIAL_PRECONDITIONS) + && !this.obj.requirements.contains(RequireKey.QUANTIFIED_PRECONDITIONS)) { + this.mgr.logParserError("Existential formula cannot be defined without require keys \"" + + RequireKey.EXISTENTIAL_PRECONDITIONS + + "\" or \"" + + RequireKey.QUANTIFIED_PRECONDITIONS + + "\".", this.file, node.getLine(), node.getColumn()); + } + exp = this.exists_gd(cn); + break; + case LexerTreeConstants.JJTF_COMP: + FCompExp fCompExp = this.f_comp(cn); + if (!this.obj.requirements.contains(RequireKey.FLUENTS)) { + if (!(fCompExp.getOp().equals(Comp.EQUAL) + && fCompExp.getArg1().getExpID().equals(ExpID.TERM) + && fCompExp.getArg2().getExpID().equals(ExpID.TERM) + && this.obj.requirements.contains(RequireKey.EQUALITY))) { + this.mgr.logParserError("FExp expression cannot be defined without require keys \"" + + RequireKey.FLUENTS + "\" or \"" +RequireKey.EQUALITY + "\".", this.file, node.getLine(), node.getColumn()); + } + } + exp = fCompExp; + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return exp; + } + + /** + * Extracts the object structures from the <code>FCOMP</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>FCOMP</code> node. + * @return the comparaison function structure built. + * @throws ParserException if an error occurs while parsing. + */ + private FCompExp f_comp(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTBINARY_COMP) { + return this.binary_comp(cn); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>BINARY_COMP</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>BINARY_COMP</code> node. + * @return the binray numeric operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private FCompExp binary_comp(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTGREATER_COMP: + return this.greater_comp(cn); + case LexerTreeConstants.JJTGREATER_EQUAL_COMP: + return this.greater_equal_comp(cn); + case LexerTreeConstants.JJTLESS_COMP: + return this.less_comp(cn); + case LexerTreeConstants.JJTLESS_EQUAL_COMP: + return this.less_equal_comp(cn); + case LexerTreeConstants.JJTEQUAL_COMP: + return this.equal_comp(cn); + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>GREATER_COMP</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>GREATER_COMP</code> node. + * @return the greater compraison structure built. + * @throws ParserException if an error occurs while parsing. + */ + private GreaterComp greater_comp(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new GreaterComp(this.f_exp(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>LESS_COMP</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>LESS_COMP</code> node. + * @return the less compraison structure built. + * @throws ParserException if an error occurs while parsing. + */ + private LessComp less_comp(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new LessComp(this.f_exp(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>EQUAL_COMP</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>EQUAL_COMP</code> node. + * @return the equal compraison structure built. + * @throws ParserException if an error occurs while parsing. + */ + private EqualComp equal_comp(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new EqualComp(this.f_exp(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>GREATER_EQUAL_COMP</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>GREATER_EQUAL_COMP</code> node. + * @return the greater equal compraison structure built. + * @throws ParserException if an error occurs while parsing. + */ + private GEqualComp greater_equal_comp(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new GEqualComp(this.f_exp(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>LESS_EQUAL_COMP</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>LESS_EQUAL_COMP</code> node. + * @return the less equal compraison structure built. + * @throws ParserException if an error occurs while parsing. + */ + private LEqualComp less_equal_comp(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new LEqualComp(this.f_exp(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>F_EXP</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>F_EXP</code> node. + * @return the fonction expression structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Term f_exp(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTNUMBER: + return this.number(cn); + case LexerTreeConstants.JJTOP: + return this.op(cn); + case LexerTreeConstants.JJTF_HEAD: + return this.f_head(cn); + case LexerTreeConstants.JJTVARIABLE: + return this.variable(cn); + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>F_HEAD</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>F_HEAD</code> node. + * @return the function head structure built. + * @throws ParserException if an error occurs while parsing. + */ + private FHead f_head(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() > 0) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + if (cn1.getId() == LexerTreeConstants.JJTFUNCTOR) { + FHead f_head = new FHead(this.functor(cn1), Type.NUMBER); + for (int i = 1; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTTERM: + f_head.add(this.term(cn)); + break; + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + + " unexpected."); + } + } + return f_head; + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>OPERATION</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>OPERATION</code> node. + * @return the operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinaryOp op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTBINARY_OPERATION: + return this.binary_operation(cn); + case LexerTreeConstants.JJTUNARY_OP: + return this.unary_operation(cn); + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>UNARY_OPERATION</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>UNARY_OPERATION</code> node. + * @return the unary operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinaryOp unary_operation(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTF_EXP) { + return new BinarySubstract(new Number(0.0), this.f_exp(cn)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>BINRAY_OPERATION</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>BINRAY_OPERATION</code> node. + * @return the binray numeric operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinaryOp binary_operation(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTADD_OP: + return this.add_op(cn); + case LexerTreeConstants.JJTSUBSTRACT_OP: + return this.substract_op(cn); + case LexerTreeConstants.JJTMULTIPLY_OP: + return this.multiply_op(cn); + case LexerTreeConstants.JJTDIVIDE_OP: + return this.divide_op(cn); + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>ADD_OPERATION</code> node + * of the syntaxic tree and implements the semantic check. + * + * @param node the <code>ADD_OPERATION</code> node. + * @return the add operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinaryAdd add_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new BinaryAdd(this.f_exp(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>SUBSTRACT_OPERATION</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>SUBSTRACT_OPERATION</code> node. + * @return the substract operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinarySubstract substract_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new BinarySubstract(this.f_exp(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>MULTIPLY_OPERATION</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>MULTIPLY_OPERATION</code> node. + * @return the multiply operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinaryMultiply multiply_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new BinaryMultiply(this.f_exp(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>DIVIDE_OPERATION</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>DIVIDE_OPERATION</code> node. + * @return the divide operation structure built. + * @throws ParserException if an error occurs while parsing. + */ + private BinaryDivide divide_op(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTF_EXP + && cn2.getId() == LexerTreeConstants.JJTF_EXP) { + return new BinaryDivide(this.f_exp(cn1), this.f_exp(cn2)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>NUMBER</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>NUMBER</code> node. + * @return the number structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Number number(SimpleNode node) throws ParserException { + return new Number(Double.valueOf(node.getImage())); + } + + /** + * Extracts the object structures from the <code>AND_GD</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>AND_GD</code> node. + * @return the conjunctive goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private AndExp and_gd(SimpleNode node) throws ParserException { + AndExp exp = new AndExp(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTGD: + exp.add(this.gd(cn)); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return exp; + } + + /** + * Extracts the object structures from the <code>OR_GD</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>OR_GD</code> node. + * @return the disjunctive goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private OrExp or_gd(SimpleNode node) throws ParserException { + OrExp exp = new OrExp(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + switch (cn.getId()) { + case LexerTreeConstants.JJTGD: + exp.add(this.gd(cn)); + break; + default: + throw new ParserException( + "An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return exp; + } + + /** + * Extracts the object structures from the <code>NOT_GD</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>NOT_GD</code> node. + * @return the negative goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private NotExp not_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTGD) { + return new NotExp(this.gd(cn)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>IMPLY_GD</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>IMPLY_GD</code> node. + * @return the implicative goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private ImplyExp imply_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTGD + && cn2.getId() == LexerTreeConstants.JJTGD) { + Exp head = this.gd(cn1); + Exp body = this.gd(cn2); + return new ImplyExp(head, body); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>FORALL_GD</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>FORALL_GD</code> node. + * @return the universal goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private ForallExp forall_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTTYPED_LIST + && cn2.getId() == LexerTreeConstants.JJTGD) { + ActionDef tmp = this.actionCtx; + this.actionCtx = null; + ForallExp forall = new ForallExp(); + LinkedHashMap<String, Variable> vars = new LinkedHashMap<String, Variable>(); + this.var_typed_list(cn1, vars); + this.actionCtx = tmp; + for (Variable var : vars.values()) { + forall.add(var); + } + this.quantifiedExpCtx = forall; + Exp exp = this.gd(cn2); + forall.setExp(exp); + this.quantifiedExpCtx = null; + return forall; + } + } + this.quantifiedExpCtx = null; + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>EXISTS_GD</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>EXISTS_GD</code> node. + * @return the existential goal description structure built. + * @throws ParserException if an error occurs while parsing. + */ + private ExistsExp exists_gd(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() == 2) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + SimpleNode cn2 = (SimpleNode) node.jjtGetChild(1); + if (cn1.getId() == LexerTreeConstants.JJTTYPED_LIST + && cn2.getId() == LexerTreeConstants.JJTGD) { + ActionDef tmp = this.actionCtx; + this.actionCtx = null; + ExistsExp exists = new ExistsExp(); + LinkedHashMap<String, Variable> vars = new LinkedHashMap<String, Variable>(); + this.var_typed_list(cn1, vars); + this.actionCtx = tmp; + for (Variable var : vars.values()) { + exists.add(var); + } + this.quantifiedExpCtx = exists; + Exp exp = this.gd(cn2); + exists.setExp(exp); + this.quantifiedExpCtx = null; + return exists; + } + } + this.quantifiedExpCtx = null; + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>LITERAL</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>LITERAL</code> node. + * @return the exp literal structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Literal literal(SimpleNode node) throws ParserException { + Literal exp = null; + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTATOMIC_FORMULA: + exp = this.atomic_formula(cn); + break; + case LexerTreeConstants.JJTNOT_ATOMIC_FORMULA: + exp = this.not_atomic_formula(cn); + break; + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return exp; + } + + /** + * Extracts the object structures from the <code>LITERAL</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>LITERAL</code> node. + * @return the exp literal structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Literal ground_literal(SimpleNode node) throws ParserException { + Literal exp = null; + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTATOMIC_FORMULA: + exp = this.ground_atomic_formula(cn); + break; + case LexerTreeConstants.JJTNOT_ATOMIC_FORMULA: + exp = this.not_ground_atomic_formula(cn); + break; + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return exp; + } + + /** + * Extracts the object structures from the <code>LITERAL</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>LITERAL</code> node. + * @return the exp literal structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Literal not_atomic_formula(SimpleNode node) + throws ParserException { + Literal exp = null; + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTATOMIC_FORMULA) { + return new NotAtomicFormula(this.atomic_formula(cn)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>LITERAL</code> node of + * the syntaxic tree and implements the semantic check. + * + * @param node the <code>LITERAL</code> node. + * @return the exp literal structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Literal not_ground_atomic_formula(SimpleNode node) + throws ParserException { + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + if (cn.getId() == LexerTreeConstants.JJTATOMIC_FORMULA) { + return new NotAtomicFormula(this.ground_atomic_formula(cn)); + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>ATOMIC_FORMULA</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>ATOMIC_FORMULA</code> node. + * @return the atomic formula structure built. + * @throws ParserException if an error occurs while parsing. + */ + private AtomicFormula atomic_formula(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() > 0) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + if (cn1.getId() == LexerTreeConstants.JJTPREDICATE) { + AtomicFormula atomic_formula = new AtomicFormula(this.predicate(cn1)); + for (int i = 1; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + if (cn.getId() == LexerTreeConstants.JJTTERM) { + atomic_formula.add(this.term(cn)); + } else { + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + if (!this.obj.getContent().equals(Content.PARTIAL_PROBLEM)) { + boolean match = false; + Iterator<AtomicFormula> i = obj.predicates.iterator(); + while (i.hasNext() && !match) { + AtomicFormula copy = i.next().clone().standardize(); + Substitution sigma = copy.match(atomic_formula); + match = sigma != null; + + } + if (!match) { + this.mgr.logParserWarning("predicate \"" + + atomic_formula.toTypedString() + + "\" undefined.", this.file, node + .getLine(), node.getColumn()); + obj.predicates.add(atomic_formula); + } + } + return atomic_formula; + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>ATOMIC_FORMULA</code> + * node of the syntaxic tree and implements the semantic check. + * + * @param node the <code>ATOMIC_FORMULA</code> node. + * @return the atomic formula structure built. + * @throws ParserException if an error occurs while parsing. + */ + private AtomicFormula ground_atomic_formula(SimpleNode node) throws ParserException { + if (node.jjtGetNumChildren() > 0) { + SimpleNode cn1 = (SimpleNode) node.jjtGetChild(0); + if (cn1.getId() == LexerTreeConstants.JJTPREDICATE) { + AtomicFormula atomic_formula = new AtomicFormula(this.predicate(cn1)); + for (int i = 1; i < node.jjtGetNumChildren(); i++) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(i); + if (cn.getId() == LexerTreeConstants.JJTCONSTANT) { + atomic_formula.add(this.constant(cn)); + } else { + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return atomic_formula; + } + } + throw new ParserException("An internal parser error occurs: node " + + node.getLabel() + " unexpected."); + } + + /** + * Extracts the object structures from the <code>TERM</code> node of the + * syntaxic tree and implements the semantic check. + * + * @param node the <code>TERM</code> node. + * @return the exp structure built. + * @throws ParserException if an error occurs while parsing. + */ + private Term term(SimpleNode node) throws ParserException { + Term t = null; + if (node.jjtGetNumChildren() == 1) { + SimpleNode cn = (SimpleNode) node.jjtGetChild(0); + switch (cn.getId()) { + case LexerTreeConstants.JJTCONSTANT: + t = this.constant(cn); + break; + case LexerTreeConstants.JJTVARIABLE: + t = this.variable(cn); + break; + default: + throw new ParserException("An internal parser error occurs: node " + + cn.getLabel() + " unexpected."); + } + } + return t; + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/ParserException.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/ParserException.java new file mode 100644 index 00000000000..303350717f9 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/ParserException.java @@ -0,0 +1,131 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j; + +import java.io.File; + +/** + * This class implements a parser exception. The parser exception of exception + * is thrown if an internal error occurs in parser. + * + * @author Damien Pellier + * @version 1.0 + */ +public class ParserException extends Exception { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 1695639410883338894L; + + /** + * The line of the error. + */ + private int line; + + /** + * The column of the error. + */ + private int column; + + /** + * The file where the error was detected. + */ + private File file; + + /** + * Creates a new parser exception with a specific message and cause. + * + * @param message the message. + * @param cause the cause. + */ + public ParserException(String message, Throwable cause) { + super(message, cause); + this.line = -1; + this.column = -1; + this.file = null; + } + + /** + * Creates a new parser exception with a specific message. + * + * @param message the message. + */ + public ParserException(String message) { + super(message); + this.line = -1; + this.column = -1; + this.file = null; + } + + /** + * Creates a new parser exception with a specific message. + * + * @param message the message. + * @param file the file where the error was detected. + * @param line the line of the file where the error was detected. + * @param column the column of the file where the error was detected. + */ + public ParserException(String message, File file, int line, int column) { + super(message); + this.file = file; + this.line = line; + this.column = column; + } + + /** + * Returns the file where the error was detected. + * + * @return the file where the error was detected or <code>null</code> if no file was specifies. + */ + public File getFile() { + return this.file; + } + + /** + * Returns the column of parser exception. + * + * @return the column of the parser exception or -1 if no column was specified. + */ + public int getColumn() { + return this.column; + } + + /** + * Returns the line of parser exception. + * + * @return the line of the parser exception or -1 if no line was specified. + */ + public int getLine() { + return this.line; + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Problem.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Problem.java new file mode 100644 index 00000000000..668328a00ff --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Problem.java @@ -0,0 +1,107 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j; + +import java.io.File; +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import pddl4j.exp.Exp; +import pddl4j.exp.InitEl; +import pddl4j.exp.metric.MetricExp; +import pddl4j.exp.term.Constant; + +/** + * This interface defines the accessible methods from a problem. + * + * @author Damien Pellier + * @version 1.0 + */ +public interface Problem extends Serializable { + + /** + * Returns an iterator over the requirements of this pddl object. + * + * @return an iterator over the requirements of this pddl object. + */ + Iterator<RequireKey> requirementsIterator(); + + /** + * Returns an iterator over the constants defined in this pddl object. + * + * @return an iterator over the constants defined in this pddl object. + */ + Iterator<Constant> constantsIterator(); + + /** + * Returns the metric of the PDDL object. + * + * @return the metric of the PDDL object. + */ + MetricExp getMetric(); + + /** + * Returns the problem file where the PDDL object is defined. + * + * @return the problem file where the PDDL object is defined. + */ + File getProblemFile(); + + /** + * Returns the goal of the PDDL object. + * + * @return the goal of the PDDL object. + */ + Exp getGoal(); + + /** + * Returns the initial state of the PDDL object. + * + * @return the initial state of the PDDL object. + */ + List<InitEl> getInit(); + + /** + * Returns the name of the domain. + * + * @return the name of the domain. + */ + String getDomainName(); + + /** + * Returns the name of the problem. + * + * @return the name of the problem. + */ + String getProblemName(); + +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/RequireKey.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/RequireKey.java new file mode 100644 index 00000000000..6caa82b178e --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/RequireKey.java @@ -0,0 +1,161 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j; + +/** + * This enumeration defines le set of PDDL require key. + * + * @author Damien Pellier + * @version 1.0 + */ +public enum RequireKey { + /** + * The PDDL :strips requirement. + */ + STRIPS(":strips"), + /** + * The PDDL :typing requirement. + */ + TYPING(":typing"), + /** + * The PDDL :negative-preconditions requirement. + */ + NEGATIVE_PRECONDITIONS(":negative-preconditions"), + /** + * The PDDL :disjunctive-preconditions requirement. + */ + DISJUNCTIVE_PRECONDITIONS(":disjunctive-preconditions"), + /** + * The PDDL :equality requirement. + */ + EQUALITY(":equality"), + /** + * The PDDL :existential-preconditions requirement. + */ + EXISTENTIAL_PRECONDITIONS(":existential-preconditions"), + /** + * The PDDL :universal-preconditions requirement. + */ + UNIVERSAL_PRECONDITIONS(":universal-preconditions"), + /** + * The PDDL :quantified-preconditions requirement. + */ + QUANTIFIED_PRECONDITIONS(":quantified-preconditions"), + /** + * The PDDL :conditional-effects requirement. + */ + CONDITIONAL_EFFECTS(":conditional-effects"), + /** + * The PDDL :fluents requirement. + */ + FLUENTS(":fluents"), + /** + * The PDDL :adl requirement. + */ + ADL(":adl"), + /** + * The PDDL :durative-actions requirement. + */ + DURATIVE_ACTIONS(":durative-actions"), + /** + * The PDDL :derived-predicates requirement. + */ + DERIVED_PREDICATES(":derived-predicates"), + /** + * The PDDL :times-initial-literals requirement. + */ + TIMED_INITIAL_LITERALS(":timed-initial-literals"), + /** + * The PDDL :preferences requirement. + */ + PREFERENCES(":preferences"), + /** + * The PDDL :constraints requirement. + */ + CONSTRAINTS(":constraints"), + /** + * The PDDL :continus-effects requirement. + */ + CONTINUS_EFFECTS(":continous-effects"), + /** + * The PDDL :duration-inegalities requirement. + */ + DURATION_INEQUALITIES(":duration-inequalities"); + + /** + * The image associate to the require key in the PDDL langage. + */ + private String image; + + /** + * Create a new require key with a specific image. + * + * @param image the image of the require key. The image of the require key must be not null. + */ + private RequireKey(String image) { + this.image = image; + } + + /** + * Returns the require key with a specific image or <code>null</code> if there is no require key with the + * specific image. + * + * @param image the image of the require key searched. + * @return the require key searched or <code>null</code> if it was not found in the enumeration. + */ + public static RequireKey getRequireKey(String image) { + for (RequireKey rk : RequireKey.values()) { + if (rk.image.equalsIgnoreCase(image)) { + return rk; + } + } + return null; + } + + /** + * Returns the image of this require key. + * + * @return the image of this require key. + */ + public String getImage() { + return this.image; + } + + /** + * Returns a string representation of this require key. + * + * @return a string representation of this require key. + */ + public String toString() { + return this.image; + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Source.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Source.java new file mode 100644 index 00000000000..d5e65c8cee0 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/Source.java @@ -0,0 +1,41 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j; + +/** + * This enumeration is used to specify the difference version of PDDL langage. + */ +public enum Source { + /** + * The 3.0 version of the PDDL source. + */ + V3_0; +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/AbstractExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/AbstractExp.java new file mode 100644 index 00000000000..0844edf7f16 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/AbstractExp.java @@ -0,0 +1,161 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +/** + * This abstract class implements the common part of all PDDl expression. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class AbstractExp implements Exp { + + /** + * The id of the expression. + */ + private ExpID id; + + /** + * Creates a new expression with a specific id. + * + * @param id The id of the expression. + */ + protected AbstractExp(ExpID id) { + this.id = id; + } + + /** + * Returns the id of the expression. + * + * @return the id of the expression. + * @see pddl4j.exp.Exp#getExpID() + */ + public final ExpID getExpID() { + return this.id; + } + + /** + * Returns <code>true</code> if this expression is equal to an other + * object. This method returns <code>true</code> if the object is a not + * null reference to an instance of the class <code>AbstractExp</code> and + * both expressions have the same expression id. + * + * @param obj the reference object with which to compare. + * @return <code>true</code> if the expression is equal to an other + * object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof AbstractExp) { + AbstractExp other = (AbstractExp) obj; + return this.id.equals(other.id); + } + return false; + } + + /** + * Returns a hash code value for this expression. This method + * is supported for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for this expression. + */ + public int hashCode() { + return this.id.hashCode(); + } + + /** + * Returns a deep copy of this expression. + * + * @return a deep copy of this expression. + */ + public Exp clone() { + try { + Exp other = (Exp) super.clone(); + return other; + } catch (CloneNotSupportedException e) { + throw new InternalError(); + } + } + + /** + * Returns the prenex normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the prenex normal form of this expression. + */ + public Exp toPrenexNormaForm() { + return this.standardize().moveQuantifierOutward(); + } + + /** + * Returns a copy of this expression such that the quantifiers appear first. + * + * @return a copy of this expression such that the quantifiers appear first. + * @see pddl4j.exp.Exp#moveQuantifierOutward() + */ + public Exp moveQuantifierOutward() { + return this.clone(); + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public Exp toDisjunctiveNormalForm() { + return this.clone(); + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public Exp toConjunctiveNormalForm() { + return this.clone(); + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public Exp toNegativeNormalForm() { + return this.clone(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/AndExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/AndExp.java new file mode 100644 index 00000000000..5956fdfebe9 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/AndExp.java @@ -0,0 +1,314 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Variable; + +/** + * This abstract generic class is implemented by all conjunctive PDDL expression. + * + * @author Damien Pellier + * @version 1.0 + */ +public class AndExp extends ListExp { + + /** + * The serial version if of the class. + */ + private static final long serialVersionUID = -61659117952471061L; + + /** + * Creates a new empty conjunctive expression. + */ + public AndExp() { + super(ExpID.AND); + } + + /** + * Creates a new list expression with a specific id and expressions. + * + * @param exps an expressions list. + */ + public AndExp(Exp... exps) { + super(ExpID.AND, exps); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * expression. + * + * @param sigma the substitution. + * @return @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public AndExp apply(Substitution sigma) { + return (AndExp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + * @see pddl4j.exp.Exp#standardize() + */ + public AndExp standardize() { + return this.standardize(new HashMap<String,String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. + * Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null || bound == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public AndExp standardize(Map<String, String> images) { + return (AndExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public AndExp clone() { + return (AndExp) super.clone(); + } + + /** + * Returns the prenex normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the prenex normal form of this expression. + */ + public Exp toPrenexNormaForm() { + return this.standardize().moveQuantifierOutward(); + } + + /** + * Returns a copy of this expression such that the quantifiers appear first. + * + * @return a copy of this expression such that the quantifiers appear first. + * @see pddl4j.exp.Exp#moveQuantifierOutward() + */ + public Exp moveQuantifierOutward() { + Exp qexp = null; + AndExp and = new AndExp(); + Iterator<Exp> i = this.iterator(); + while (i.hasNext()) { + Exp exp = i.next(); + if (exp.getExpID().equals(ExpID.FORALL)) { + ForallExp forall = (ForallExp) exp; + if (!forall.exp.getExpID().equals(ExpID.WHEN)) { + ForallExp tmp = new ForallExp(); + for (Variable var : forall) { + tmp.add(var.clone()); + } + and.add(forall.getExp()); + while (i.hasNext()) { + and.add(i.next()); + } + tmp.setExp(and.moveQuantifierOutward()); + qexp = tmp; + } else { + and.add(exp.moveQuantifierOutward()); + } + } + else if (exp.getExpID().equals(ExpID.EXIST)) { + ExistsExp exists = (ExistsExp) exp; + if (!exists.exp.getExpID().equals(ExpID.WHEN)) { + ExistsExp tmp = new ExistsExp(); + for (Variable var : exists) { + tmp.add(var.clone()); + } + and.add(exists.getExp()); + while (i.hasNext()) { + and.add(i.next()); + } + tmp.setExp(and.moveQuantifierOutward()); + qexp = tmp; + } else { + and.add(exp.moveQuantifierOutward()); + } + } else { + and.add(exp); + } + } + return qexp == null ? and : qexp; + } + + /** + * Returns <code>true</code> if this and expression is conditional, i.e., + * if this expression contains a when expression. + * + * @return <code>true</code> if this and expression is conditional; + * <code>false</code> otherwise. + */ + private boolean isConditional() { + boolean isConditional = false; + Iterator<Exp> i = this.iterator(); + while (i.hasNext() && !isConditional) { + isConditional = i.next().getExpID().equals(ExpID.WHEN); + } + return isConditional; + } + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the conjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + */ + public AndExp toConjunctiveNormalForm() { + AndExp nnf = this.toNegativeNormalForm(); + AndExp cnf = new AndExp(); + if (nnf.isConditional()) { + for (Exp elt : nnf) { + if (!elt.getExpID().equals(ExpID.WHEN)) { + for (Exp cnfi : cnf) { + if (cnfi.getExpID().equals(ExpID.WHEN)) { + WhenExp when = (WhenExp) cnfi; + AndExp effect = new AndExp(); + effect.add(when.getEffect()); + effect.add(elt); + when.setEffect(effect); + when = when.normalize(); + } + } + } else { + WhenExp when = (WhenExp) elt; + cnf.add(when.normalize()); + } + } + } else { + for (Exp elt : nnf) { + elt = elt.toConjunctiveNormalForm(); + cnf.add(elt); + } + } + return cnf; + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public OrExp toDisjunctiveNormalForm() { + AndExp nnf = this.toNegativeNormalForm(); + OrExp dnf = new OrExp(); + dnf.add(new AndExp()); + for (Exp e : nnf) { + Exp ednf = e.toDisjunctiveNormalForm(); + if (ednf.getExpID().equals(ExpID.OR)) { + OrExp or = (OrExp) ednf; + OrExp newDnf = new OrExp(); + for (Exp oe : or) { + for (Exp and : dnf) { + AndExp other = (AndExp) and.clone(); + other.add(oe); + newDnf.add(other); + } + } + dnf = newDnf; + } else { + for (Exp ex : dnf) { + ((AndExp) ex).add(ednf); + } + } + } + return dnf; + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public AndExp toNegativeNormalForm() { + AndExp other = new AndExp(); + for (Exp exp : this) { + other.add(exp.toNegativeNormalForm()); + } + return other; + } + + /** + * Returns a string representation of the conjunctive expression. + * + * @return a string representation of the conjunctive expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(and"); + for (Exp elt : this.elements) { + str.append(" "); + str.append(elt.toString()); + } + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of the conjunctive expression. + * + * @return a typed string representation of the conjunctive expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(and"); + for (Exp elt : this.elements) { + str.append(" "); + str.append(elt.toTypedString()); + } + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/AtomicFormula.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/AtomicFormula.java new file mode 100644 index 00000000000..3b6dd89f5f6 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/AtomicFormula.java @@ -0,0 +1,398 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; +import pddl4j.exp.term.Variable; + +/** + * This class implements a atomic formula of the PDDL langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public class AtomicFormula extends AbstractExp implements Literal { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -9015916938283328690L; + + /** + * The predicate of the atomic formula. + */ + private String predicate; + + /** + * The list of arguments contained in the atomic formula. + */ + private ArrayList<Term> arguments; + + /** + * Creates a new atomic formula with a specific predicate. + * + * @param predicate the predicate of the atomic formula. The predicate must + * be a not null reference. + */ + public AtomicFormula(String predicate) { + super(ExpID.ATOMIC_FORMULA); + this.predicate = predicate; + this.arguments = new ArrayList<Term>(); + } + + /** + * Sets a new predicate to this atomic formula. + * + * @param predicate the new predicate to set. The predicate must be a not + * null reference. + */ + public final void setPredicate(String predicate) { + this.predicate = predicate; + } + + /** + * Returns the predicate of this atomic formula. + * + * @return the predicate of this atomic formula. + */ + public final String getPredicate() { + return this.predicate; + } + + /** + * Adds a new term to this atomic formula. + * + * @param term the term to add. The term must be not null. + * @return <code>true</code> if the term was added; <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public final boolean add(Term term) { + if (term == null) + throw new NullPointerException(); + return this.arguments.add(term); + } + + /** + * Returns the arity of this atomic formula. + * + * @return the arity of this atomic formula. + */ + public final int getArity() { + return this.arguments.size(); + } + + /** + * Returns an iterator over the terms of the atomic formula. + * + * @return an iterator over the terms of the atomic formula. + * @see java.lang.Iterable#iterator() + */ + public final Iterator<Term> iterator() { + return this.arguments.iterator(); + } + + /** + * Returns <code>true</code> if a term occurs in this atomic formula. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this atomic formula; + * <code>false</code> otherwise. + */ + public boolean occurs(Term term) { + return this.arguments.contains(term); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public final AtomicFormula apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + AtomicFormula other = new AtomicFormula(this.predicate); + for (Term arg : this) { + other.add(arg.apply(sigma)); + } + return other; + } + + /** + * Matches this atomic formula with an other specified atomic formula. Two + * atomic formulas match if they have the same predicate symbol and arity + * and each arguments are pairwise unifiable. Note, called match does not + * modify the parameters of this method. + * + * @param atom the atomic formula to match with. + * @return The substitution that defines the binding constraints needed to + * match this atomic formula with the other atomic formula or + * <code>null</code> if no binding constraints allows to match the + * two atomic formulas. + * @throws NullPointerException if <code>atom == null</code> or + * <code>sigma == null</code>. + * @see pddl4j.exp.term.Term#unify(Term, Substitution) + */ + public final Substitution match(AtomicFormula atom) { + return this.match(atom, new Substitution()); + } + + /** + * Matches this atomic formula with an other specified atomic formula by + * taking into account a specified set of binding constraints. Two atomic + * formulas match if they have the same predicate symbol and arity and each + * arguments are pairwise unifiable. Note, called match does not modify the + * parameters of this method. + * + * @param atom the atomic formula to match with. + * @param sigma the substitution containing the binding constraints. + * @return The substitution that defines the binding constraints needed to + * match this atomic formula with the other atomic formula or + * <code>null</code> if no binding constraints allows to match the + * two atomic formulas. + * @throws NullPointerException if <code>atom == null</code> or + * <code>sigma == null</code>. + * @see pddl4j.exp.term.Term#unify(Term, Substitution) + */ + public final Substitution match(AtomicFormula atom, Substitution sigma) { + if (this.predicate.equals(atom.predicate) + && this.getArity() == atom.getArity()) { + Substitution theta = sigma.clone(); + int i = 0; + boolean failure = false; + while (i < this.getArity() && !failure) { + Term tthis = this.arguments.get(i); + Term tother = atom.arguments.get(i); + Substitution gamma = tthis.unify(tother, theta); + if (gamma == null) { + failure = true; + } else { + theta.compose(gamma); + } + i++; + } + return failure ? null : theta; + } + return null; + + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public AtomicFormula standardize() { + return this.standardize(new HashMap<String,String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public AtomicFormula standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + AtomicFormula other = new AtomicFormula(this.predicate); + for (Term arg : this.arguments) { + other.add(arg.standardize(images)); + } + return other; + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + boolean isGround = true; + Iterator<Term> i = this.iterator(); + while (i.hasNext() && isGround) { + isGround = i.next().isGround(); + } + return isGround; + } + + /** + * Returns <code>true</code> if this atomic formula is equals to an other + * object. This method return <code>true</code> if the object is a not + * null instance of the class <code>AtomicFormula</code> and both atomic + * formulas have the same predicate and arguments. + * + * @param obj the object to compare. + * @return <code>true</code> if this atomic formula is equals to an other + * object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof AtomicFormula) { + AtomicFormula other = (AtomicFormula) obj; + return this.predicate.equals(other.predicate) + && this.arguments.equals(other.arguments); + } + return false; + } + + /** + * Returns the hash code value of this atomic formula. This method is + * supported for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return the hash code value of this atomic formula. + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + return this.predicate.hashCode() + this.arguments.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public AtomicFormula clone() { + AtomicFormula other = (AtomicFormula) super.clone(); + other.arguments = new ArrayList<Term>(); + for (Term arg : this.arguments) { + other.arguments.add(arg.clone()); + } + return other; + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public OrExp toDisjunctiveNormalForm() { + OrExp dnf = new OrExp(); + dnf.add(this.clone()); + return dnf; + } + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the conjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + */ + public AndExp toConjunctiveNormalForm() { + AndExp cnf = new AndExp(); + cnf.add(this.clone()); + return cnf; + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public AtomicFormula toNegativeNormalForm() { + return this.clone(); + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + Set<Variable> vars = new HashSet<Variable>(); + for (Term arg : this) { + if (arg.getTermID().equals(TermID.VARIABLE)) { + vars.add((Variable) arg); + } + } + return vars; + } + + /** + * Returns a string representation of this atomic formula. + * + * @return a string representation of this atomic formula. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("("); + str.append(this.predicate); + for (Term t : this.arguments) { + str.append(" "); + str.append(t.toString()); + } + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this atomic formula. + * + * @return a typed string representation of this atomic formula. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("("); + str.append(this.predicate); + for (Term t : this.arguments) { + str.append(" "); + str.append(t.toTypedString()); + } + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/DerivedPredicate.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/DerivedPredicate.java new file mode 100644 index 00000000000..9ce7c31253c --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/DerivedPredicate.java @@ -0,0 +1,323 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; + +/** + * This class implements a derived predicate of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class DerivedPredicate extends AbstractExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 523481664576398238L; + + /** + * The expression that defines the derived predicate. + */ + private ImplyExp exp; + + /** + * Creates a new derived predicate with a specific head and body. + * + * @param head the head of this derived predicate. + * @param body the body of this derived predicate + * @throws NullPointerException if <code>head == null || body == null</code>. + */ + public DerivedPredicate(AtomicFormula head, Exp body) { + super(ExpID.DERIVED_PREDICATE); + if (head == null || body == null) + throw new NullPointerException(); + this.exp = new ImplyExp(head, body); + } + + /** + * Sets a new head to this derived predicate. + * + * @param head the new head of this implication expression. The new head of + * the derived predicate must be a not null reference to an + * instance of <code>AtomicFormula</code>. + * @throws NullPointerException if <code>head == null</code>. + */ + public final void setHead(AtomicFormula head) { + if (head == null) + throw new NullPointerException(); + this.exp.setHead(head); + } + + /** + * Returns the head of the derived predicate. + * + * @return the head of the derived predicate. + */ + public final AtomicFormula getHead() { + return (AtomicFormula) this.exp.getHead(); + } + + /** + * Sets a new body to this derived predicate. + * + * @param body the new body of this derived predicate. The new body of + * the derived predicate must be a not null reference to an + * instance of <code>Exp</code>. + * @throws NullPointerException if <code>body == null</code>. + */ + public final void setBody(Exp body) { + if (body == null) + throw new NullPointerException(); + this.setBody(body); + } + + /** + * Returns the body of the derived predicate. + * + * @return the body of the derived predicate. + */ + public final Exp getBody() { + return this.exp.getBody(); + } + + /** + * Returns <code>true</code> if a expression occurs in this derived predicate. + * + * @param term the expression to be tested. + * @return <code>true</code> if a expression occurs in this derived predicate; + * <code>false</code> otherwise. + */ + public final boolean occurs(Term term) { + return this.exp.occurs(term); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding expression. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public final Exp apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + DerivedPredicate other = this.clone(); + other.exp = this.exp.apply(sigma); + return other; + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + * @see pddl4j.exp.Exp#standardize() + */ + public DerivedPredicate standardize() { + return this.standardize(new LinkedHashMap<String,String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public DerivedPredicate standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + DerivedPredicate other = this.clone(); + other.exp = this.exp.standardize(images); + return other; + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + return this.exp.isGround(); + } + + + /** + * Returns <code>true</code> if this derived predicate is equal to an + * other object, i.e., if the object is a not null reference to an instance + * of the class <code>DerivedPredicate</code> and both derived predicates + * have the same parameters and expression. + * + * @param obj - the reference object with which to compare. + * @return <code>true</code> if this derived predicate is equal to an + * other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof DerivedPredicate) { + DerivedPredicate other = (DerivedPredicate) obj; + return this.exp.equals(other.exp); + } + return false; + } + + /** + * Returns a hash code value for the derived predicate. This method is + * supported for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the derived predicate. + */ + public int hashCode() { + return this.getExpID().hashCode() + this.exp.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public DerivedPredicate clone() { + DerivedPredicate other = (DerivedPredicate) super.clone(); + other.exp = exp.clone(); + return other; + } + + /** + * Returns a copy of this expression such that the quantifiers appear first. + * + * @return a copy of this expression such that the quantifiers appear first. + * @see pddl4j.exp.Exp#moveQuantifierOutward() + */ + public Exp moveQuantifierOutward() { + DerivedPredicate other = this.clone(); + other.exp.body = this.exp.body.moveQuantifierOutward(); + return other; + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public DerivedPredicate toDisjunctiveNormalForm() { + DerivedPredicate dnf = this.clone(); + dnf.exp.body = this.exp.body.toDisjunctiveNormalForm(); + return dnf; + } + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the conjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + */ + public DerivedPredicate toConjunctiveNormalForm() { + DerivedPredicate cnf = this.clone(); + cnf.exp.body = this.exp.body.toConjunctiveNormalForm(); + return cnf; + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public DerivedPredicate toNegativeNormalForm() { + DerivedPredicate nnf = this.clone(); + nnf.exp.body = this.exp.body.toNegativeNormalForm(); + return nnf; + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + return this.exp.getFreeVariables(); + } + + /** + * Returns a string representation of the derived predicate. + * + * @return a string representation of the derived predicate. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(:derived "); + str.append("("); + str.append(this.exp.toString()); + str.append(")"); + str.append(" "); + str.append(this.exp.toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a string representation of the derived predicate. + * + * @return a string representation of the derived predicate. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(:derived "); + str.append("("); + str.append(this.exp.toTypedString()); + str.append(")"); + str.append(" "); + str.append(this.exp.toTypedString()); + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ExistsExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ExistsExp.java new file mode 100644 index 00000000000..ee8eb83a7fc --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ExistsExp.java @@ -0,0 +1,173 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.exp.term.Variable; + +/** + * This class implements an existential expression of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class ExistsExp extends QuantifiedExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 509423923623946119L; + + /** + * Creates a new existential expression with a specific list of bound + * variables and quantified expression. + * + * @param exp the quantified expression. + */ + public ExistsExp(Exp exp) { + super(ExpID.EXIST, exp); + } + + /** + * Creates a new existential expression with a specific list of bound + * variables and quantified expression. + */ + public ExistsExp() { + super(ExpID.EXIST); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public ExistsExp standardize() { + return this.standardize(new LinkedHashMap<String,String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. + * Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null || bound == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public ExistsExp standardize(Map<String, String> images) { + return (ExistsExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public ExistsExp clone() { + return (ExistsExp) super.clone(); + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public ExistsExp toDisjunctiveNormalForm() { + ExistsExp dnf = this.clone(); + dnf.exp = this.exp.toDisjunctiveNormalForm(); + return dnf; + } + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the conjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + */ + public ExistsExp toConjunctiveNormalForm() { + ExistsExp cnf = this.clone(); + cnf.exp = this.exp.toConjunctiveNormalForm(); + return cnf; + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public ExistsExp toNegativeNormalForm() { + ExistsExp nnf = this.clone(); + nnf.exp = this.exp.toNegativeNormalForm(); + return nnf; + } + + /** + * Returns a copy of this expression such that the quantifiers appear first. + * + * @return a copy of this expression such that the quantifiers appear first. + * @see pddl4j.exp.Exp#moveQuantifierOutward() + */ + public Exp moveQuantifierOutward() { + ExistsExp exists = this.clone(); + exists.exp = this.exp.moveQuantifierOutward(); + if (exists.exp.getExpID().equals(ExpID.FORALL)) { + ForallExp forall = (ForallExp) exists.exp; + exists.setExp(forall.exp); + forall.setExp(exists); + return forall; + } else if (exists.exp.getExpID().equals(ExpID.EXIST)) { + ExistsExp other = (ExistsExp) exists.exp; + for (Variable var : other) { + exists.add(var); + } + exists.setExp(other.exp); + return exists; + } else if (exists.exp.getExpID().equals(ExpID.WHEN)) { + WhenExp when = (WhenExp) exists.exp; + exists.setExp(when.getCondition()); + when.setCondition(exists); + return when; + } + return exists; + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/Exp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/Exp.java new file mode 100644 index 00000000000..1c6858e1124 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/Exp.java @@ -0,0 +1,254 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import java.io.Serializable; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; + +/** + * This interface is implemented by all expression of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public interface Exp extends Serializable, Cloneable { + + /** + * Returns the id of the expression. + * + * @return the id of the expression. + */ + ExpID getExpID(); + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + */ + boolean isGround(); + + /** + * Returns <code>true</code> if this expression is equal to an other + * object, i.e., if the object is a not null instance of the class of the + * expression and both expressions have the same content. + * + * @param obj the reference object with which to compare. + * @return <code>true</code> if this expression is equal to an other + * object; <code>false</code> otherwise. + */ + boolean equals(Object obj); + + /** + * Returns a hash code value for the expression. This method is supported + * for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the expression. + */ + int hashCode(); + + /** + * Returns a string representation of the expression. + * + * @return a string representation of the expression. + */ + String toString(); + + /** + * Returns <code>true</code> if a term occurs in this expression. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this expression; + * <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + boolean occurs(Term term); + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are bound in the substitution by its binding term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + Exp apply(Substitution sigma); + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + Exp standardize(); + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + */ + Exp standardize(Map<String, String> images); + + /** + * Returns a typed string of this expression. + * + * @return a typed string of this expression. + */ + String toTypedString(); + + /** + * Returns a deep copy of this expression. Creates and returns a copy of + * this expression. The precise meaning of "copy" is as follow: + * + * <pre> + * x.clone() != x + * </pre> + * + * will be true, and that the expression: + * + * <pre> + * x.clone().getClass() == x.getClass() + * </pre> + * + * will be true. While it is the case that: + * + * <pre> + * x.clone().equals(x) + * </pre> + * + * will be true. Finally, note that except type of term expression are + * deeply copy. + * + * @return a deep copy of this expression. + * @see java.lang.Cloneable + */ + Exp clone(); + + /** + * Returns the prenex normal form of this expression. Note, the expression + * returned is a copy. The expression is first standardized and it is placed + * in the prenex normal form by recursively moving quantifier inward with + * the existential quantifier first using the following rewriting rules + * (which are in fact equivalences): + * <ul> + * <li><code>(and (forall (x) A) B) => (forall (x) (and A B))</code></li> + * <li><code>(or (forall (x) A) B) => (forall (x) (or A B))</code></li> + * <li><code>(and (exists (x) A) B) => (exists (x) (and A B))</code></li> + * <li><code>(or (exists (x) A) B) => (exists (x) (or A B))</code></li> + * <li> <code>(not (exists (x) (A))) => (forall (x) (not A)) </code></li> + * <li> <code>(not (forall (x) (A))) => (exists (x) (not A)) </code></li> + * <li> <code>(imply A (forall (x) (B))) => (forall (x) (imply A B)) </code></li> + * <li> <code>(imply A (exists (x) (B))) => (exists (x) (imply A B)) </code></li> + * <li> <code>(imply (forall (x) (A)) B) => (exists (x) (imply A B)) </code></li> + * <li> <code>(imply (exists (x) (A)) B) => (forall (x) (imply A B)) </code></li> + * </ul> + * + * @return the prenex normal form of this expression. + */ + Exp toPrenexNormaForm(); + + /** + * Returns a copy of this expression such that the quantifiers appear first + * and in which all existential quantifiers precede all universal + * quantifiers + * + * @return a copy of this expression such that the quantifiers appear first. + */ + Exp moveQuantifierOutward(); + + /** + * Returns the disjunctive normal form of this expression. Note, the + * expression returned is a copy. The expression is first converted into + * negative normal form and it is placed in the disjunctive normal form by + * recursively moving conjunctions inward and disjunctions outward using the + * following rewriting rules (which are in fact equivalences): + * <ul> + * <li><code>(and A (or B C)) => (or (and A B) (and A C))</code></li> + * <li><code>(and (or A B) C)) => (or (and A C) (and B C))</code></li> + * </ul> + * + * @return the disjunctive normal form of this expression. + */ + Exp toDisjunctiveNormalForm(); + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. The expression is first converted into + * negative normal form and it is placed in the conjunctive normal form by + * recursively moving disjunction inward and conjunction outward using the + * following rewriting rules (which are in fact equivalences): + * <ul> + * <li><code>(or A (and B C)) => (and (or A B) (or A C))</code></li> + * <li><code>(or (and A B) C)) => (and (or A C) (or B C))</code></li> + * </ul> + * + * @return the disjunctive normal form of this expression. + */ + Exp toConjunctiveNormalForm(); + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. The negative normal form is obtained by recursively + * replace formulas appearing on the left with formulas appearing on the + * right: + * <ul> + * <li> <code>(imply A B) => (or (not A) B) </code></li> + * <li> <code>(not (not F)) => F </code></li> + * <li> <code>(not (or A B)) => (and (not A) (not B)) </code></li> + * <li> <code>(not (and A B)) => (or (not A) (not B)) </code></li> + * <li> <code>(not (imply A B)) => (and A (not B)) </code></li> + * <li> <code>(not (exists (x) (F))) => (forall (x) (not F)) </code></li> + * <li> <code>(not (forall (x) (F))) => (exists (x) (not F)) </code></li> + * <li> default a copy of the expression where inner expressions are in + * negative normal form</li> + * + * @return the negative normal form of this expression. + */ + Exp toNegativeNormalForm(); + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + Set<Variable> getFreeVariables(); + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ExpID.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ExpID.java new file mode 100644 index 00000000000..d9401ca3c53 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ExpID.java @@ -0,0 +1,110 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +/** + * This enumeration list all expression id used in the pddl language. + * + * @author Damien Pellier + * @version 1.0 + */ +public enum ExpID { + /** + * The compared function expression id. + */ + F_COMP, + /** + * The assign operator expression id. + */ + ASSIGN_OP, + /** + * The when expression id. + */ + WHEN, + /** + * The and expression id. + */ + AND, + /** + * The or expression id. + */ + OR, + /** + * The imply expression id. + */ + IMPLY, + /** + * The node expression id. + */ + NOT, + /** + * The preference expression id. + */ + PREFERENCE, + /** + * The existential expression id. + */ + EXIST, + /** + * The universal expression id. + */ + FORALL, + /** + * The atomic formula expression id. + */ + ATOMIC_FORMULA, + /** + * The derived predicate expression id. + */ + DERIVED_PREDICATE, + /** + * The term expression id. + */ + TERM, + /** + * The optimization expression id. + */ + METRIC_EXP, + /** + * The conditional expression id. + */ + COND_EXP, + /** + * The timed expression id. + */ + TIMED_EXP, + + /** + * New--probabilistic + */ + PROB_EXP, + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ForallExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ForallExp.java new file mode 100644 index 00000000000..9e3a3082d84 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ForallExp.java @@ -0,0 +1,173 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.exp.term.Variable; + +/** + * This class implements an universal expression of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class ForallExp extends QuantifiedExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -6762523987177898777L; + + /** + * Creates a new universal expression with a specific list of bound + * variables and quantified expression. + * + * @param exp the quantified expression. + */ + public ForallExp(Exp exp) { + super(ExpID.FORALL, exp); + } + + /** + * Creates a new universal expression with a specific list of bound + * variables and quantified expression. + * + */ + public ForallExp() { + super(ExpID.FORALL, new AndExp()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + * @see pddl4j.exp.Exp#standardize() + */ + public ForallExp standardize() { + return this.standardize(new LinkedHashMap<String,String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. + * Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null || bound == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public ForallExp standardize(Map<String, String> images) { + return (ForallExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public ForallExp clone() { + return (ForallExp) super.clone(); + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public ForallExp toDisjunctiveNormalForm() { + ForallExp dnf = this.clone(); + dnf.exp = this.exp.toDisjunctiveNormalForm(); + return dnf; + } + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the conjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + */ + public ForallExp toConjunctiveNormalForm() { + ForallExp cnf = this.clone(); + cnf.exp = this.exp.toConjunctiveNormalForm(); + return cnf; + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public ForallExp toNegativeNormalForm() { + ForallExp nnf = this.clone(); + nnf.exp = this.exp.toNegativeNormalForm(); + return nnf; + } + + /** + * Returns a copy of this expression such that the quantifiers appear first. + * + * @return a copy of this expression such that the quantifiers appear first. + * @see pddl4j.exp.Exp#moveQuantifierOutward() + */ + public Exp moveQuantifierOutward() { + Exp exp = null; + ForallExp forall = this.clone(); + forall.exp = this.exp.moveQuantifierOutward(); + if (forall.exp.getExpID().equals(ExpID.FORALL)) { + ForallExp other = (ForallExp) forall.exp; + for (Variable var : other) { + forall.add(var); + } + forall.setExp(other.exp); + exp = forall; + } else if (forall.exp.getExpID().equals(ExpID.WHEN)) { + WhenExp when = (WhenExp) forall.exp; + forall.setExp(when.getCondition()); + when.setCondition(forall); + exp = when; + } else { + exp = forall; + } + return exp; + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ImplyExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ImplyExp.java new file mode 100644 index 00000000000..afe024dd1a8 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ImplyExp.java @@ -0,0 +1,367 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; + +/** + * This class is implemented by all implication expression of the PDDL langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public class ImplyExp extends AbstractExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 1L; + + /** + * The head of the implication expression. + */ + protected Exp head; + + /** + * The body of the implication expression. + */ + protected Exp body; + + /** + * Creates a new empty implication expression with a specific head and body + * expressions. + * + * @param head the head the implication expression. The head of the imply + * expression must be a not null reference to an instance of + * <code>Exp</code>. + * @param body the body the implication expression. The body of the imply + * formula must be a not null reference to an instance of + * <code>Exp</code>. + */ + public ImplyExp(Exp head, Exp body) { + super(ExpID.IMPLY); + this.head = head; + this.body = body; + } + + /** + * Sets a new head to this implication expression. + * + * @param head the new head of this implication expression. The new head of + * the implication expression must be a not null reference to an + * instance of <code>Exp</code>. + * @throws NullPointerException if <code>head == null</code>. + */ + public final void setHead(Exp head) { + if (head == null) + throw new NullPointerException(); + this.head = head; + } + + /** + * Returns the head of the implication expression. + * + * @return the head of the implication expression. + */ + public final Exp getHead() { + return this.head; + } + + /** + * Sets a new body to this implication expression. + * + * @param body the new body of this implication expression. The new body of + * the implication expression must be a not null reference to an + * instance of <code>Exp</code>. + * @throws NullPointerException if <code>body == null</code>. + */ + public final void setBody(Exp body) { + if (body == null) + throw new NullPointerException(); + this.body = body; + } + + /** + * Returns the body of the implication expression. + * + * @return the body of the implication expression. + */ + public final Exp getBody() { + return this.body; + } + + /** + * Returns <code>true</code> if a exp occurs in this not + * expression. + * + * @param term the exp to be tested. + * @return <code>true</code> if a exp occurs in this not + * expression; <code>false</code> otherwise. + */ + public final boolean occurs(Term term) { + return this.head.occurs(term) || this.body.occurs(term); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression + * @throws NullPointerException if <code>sigma == null</code>. + */ + public final ImplyExp apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + return new ImplyExp(this.head.apply(sigma), this.body.apply(sigma)); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + * @see pddl4j.exp.Exp#standardize() + */ + public ImplyExp standardize() { + return this.standardize(new LinkedHashMap<String,String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public ImplyExp standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + return new ImplyExp(this.head.standardize(images), + this.body.standardize(images)); + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + return this.head.isGround() && this.body.isGround(); + } + + /** + * Returns <code>true</code> if this implication expression is equal to an + * other object, i.e., if the object is a not null reference to an instance + * of the class <code>ImplyExp</code> and both implication expressions + * have the same head and body expressions. + * + * @param obj The reference object with which to compare. + * @return <code>true</code> if this implication expression is equal to an + * other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof ImplyExp) { + ImplyExp other = (ImplyExp) obj; + return this.getExpID().equals(other.getExpID()) + && this.head.equals(other.head) + && this.body.equals(other.body); + } + return false; + } + + /** + * Returns a hash code value for the implication expression. This method is + * supported for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the implication expression. + */ + public int hashCode() { + return this.getExpID().hashCode() + this.head.hashCode() + + this.body.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public ImplyExp clone() { + ImplyExp other = (ImplyExp) super.clone(); + other.head = this.head.clone(); + other.body = this.body.clone(); + return other; + } + + /** + * Returns a copy of this expression such that the quantifiers appear first. + * + * @return a copy of this expression such that the quantifiers appear first. + * @see pddl4j.exp.Exp#moveQuantifierOutward() + */ + public Exp moveQuantifierOutward() { + Exp exp = null; + if (this.head.getExpID().equals(ExpID.EXIST)) { + ExistsExp exists = (ExistsExp) this.head; + ForallExp forall = new ForallExp(); + for (Variable var : exists) { + forall.add(var.clone()); + } + ImplyExp imply = new ImplyExp(exists.getExp(), this.body); + forall.setExp(imply.moveQuantifierOutward()); + exp = forall.moveQuantifierOutward(); + } else if (this.head.getExpID().equals(ExpID.FORALL)) { + ForallExp forall = (ForallExp) this.head; + ExistsExp exists = new ExistsExp(); + for (Variable var : forall) { + exists.add(var.clone()); + } + ImplyExp imply = new ImplyExp(forall.getExp(), this.body); + exists.setExp(imply.moveQuantifierOutward()); + exp = exists.moveQuantifierOutward(); + } else if (this.body.getExpID().equals(ExpID.EXIST)) { + ExistsExp exists = (ExistsExp) this.body; + ExistsExp tmp = new ExistsExp(); + for (Variable var : exists) { + tmp.add(var.clone()); + } + ImplyExp imply = new ImplyExp(this.head, exists.getExp()); + tmp.setExp(imply.moveQuantifierOutward()); + exp = tmp.moveQuantifierOutward(); + } else if (this.body.getExpID().equals(ExpID.FORALL)) { + ForallExp forall = (ForallExp) this.body; + ForallExp tmp = new ForallExp(); + for (Variable var : forall) { + tmp.add(var.clone()); + } + ImplyExp imply = new ImplyExp(this.head, forall.getExp()); + tmp.setExp(imply.moveQuantifierOutward()); + exp = tmp.moveQuantifierOutward(); + } else { + exp = this.clone(); + } + return exp; + } + + /** + * Return the disjunctive normal form of this expression. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public OrExp toDisjunctiveNormalForm() { + return this.toNegativeNormalForm().toDisjunctiveNormalForm(); + } + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the conjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + */ + public AndExp toConjunctiveNormalForm() { + return this.toNegativeNormalForm().toConjunctiveNormalForm(); + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public OrExp toNegativeNormalForm() { + OrExp nnf = new OrExp(); + nnf.add(new NotExp(this.head)); + nnf.add(this.body); + return nnf.toNegativeNormalForm(); + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + Set<Variable> vars = new LinkedHashSet<Variable>(); + vars.addAll(this.head.getFreeVariables()); + vars.addAll(this.body.getFreeVariables()); + return vars; + } + + /** + * Returns a string representation of the implication expression. + * + * @return a string representation of the implication expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(imply "); + str.append(this.head.toString()); + str.append(" "); + str.append(this.body.toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of the implication expression. + * + * @return a typed string representation of the implication expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(imply "); + str.append(this.head.toTypedString()); + str.append(" "); + str.append(this.body.toTypedString()); + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/InitEl.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/InitEl.java new file mode 100644 index 00000000000..09c22996ff4 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/InitEl.java @@ -0,0 +1,42 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +/** + * This interface is implements by all expression that can be used in the PDDL + * language in the initial state description. + * + * @author Damien Pellier + * @version 1.0 + */ +public interface InitEl extends Exp { + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ListExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ListExp.java new file mode 100644 index 00000000000..9a2ebdc31e3 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ListExp.java @@ -0,0 +1,323 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; + +/** + * This abstract class implements the common part of the conjunctive and + * disjunctive expression of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class ListExp extends AbstractExp implements Iterable<Exp> { + + /** + * The list of the elements contained in this list. + */ + protected ArrayList<Exp> elements; + + /** + * Creates a new empty list expression with a specific id. + * + * @param id The id of the list expression. + */ + protected ListExp(ExpID id) { + super(id); + this.elements = new ArrayList<Exp>(); + } + + /** + * Creates a new list expression with a specific id and expressions. + * + * @param id The id of the list expression. + * @param exps an expressions list. + */ + protected ListExp(ExpID id, Exp... exps) { + super(id); + for (Exp exp : exps) { + this.elements.add(exp); + } + } + + /** + * Adds a new element to this to this list expression. + * + * @param elt the element to add. The element must be a not null reference. + * @return <code>true</code> if the element was added; <code>false</code> + * otherwise. + */ + public final boolean add(Exp elt) { + boolean added = true; + if (elt.getExpID().equals(this.getExpID())) { + ListExp listExp = (ListExp) elt; + for (Exp exp : listExp) { + added &= this.elements.add(exp); + } + } else { + added = this.elements.add(elt); + } + return added; + } + + /** + * Adds a new element to this to this list expression at a specified position. + * + * @param i the position where the element must be added. + * @param elt the element to add. The element must be a not null reference. + */ + public final void add(int i, Exp elt) { + if (elt.getExpID().equals(this.getExpID())) { + ListExp listExp = (ListExp) elt; + int index = i; + for (Exp exp : listExp) { + this.elements.add(index, exp); + index++; + } + } else { + this.elements.add(i, elt); + } + } + + /** + * Set a new element at a specified position. + * + * @param i the position where the element must be added. + * @param elt the element to add. The element must be a not null reference. + */ + public final void set(int i, Exp elt) { + this.elements.set(i, elt); + } + + /** + * Returns the element at a specified position. + * + * @param i the position of the element to be returned. + * @return the element at the specified position. + */ + public final Exp get(int i) { + return this.elements.get(i); + } + + /** + * Removes a specified elements of the list expression. + * + * @param elt the element to be removed. + * @return <code>true</code> if the element of the list expression was + * removed; <code>false</code> otherwise. + */ + public final boolean remove(Exp elt) { + return this.elements.remove(elt); + } + + /** + * Removes an elements of the list expression at a specified position. + * + * @param i the position of the element to be removed. + * @return the element removed. + */ + public final Exp remove(int i) { + return this.elements.remove(i); + } + + /** + * Returns an iterator over the elements contained in this list expression. + * + * @return an iterator over the elements contained in this list expression. + * @see java.lang.Iterable#iterator() + */ + public final Iterator<Exp> iterator() { + return this.elements.iterator(); + } + + /** + * Returns <code>true</code> if an expression occurs in this list + * expression. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this list + * expression; <code>false</code> otherwise. + */ + public final boolean occurs(Term term) { + boolean occurs = false; + Iterator<Exp> i = this.iterator(); + while (i.hasNext() && !occurs) { + occurs = i.next().occurs(term); + } + return occurs; + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding exp. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public ListExp apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + ListExp other = this.clone(); + other.elements.clear(); + for (Exp exp : this) { + other.add(exp.apply(sigma)); + } + return other; + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + boolean isGround = true; + Iterator<Exp> i = this.iterator(); + while (i.hasNext() && isGround) { + isGround = i.next().isGround(); + } + return isGround; + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. + * + * @return a standardized copy of this expression. + * @see pddl4j.exp.Exp#standardize() + */ + public ListExp standardize() { + return this.standardize(new LinkedHashMap<String,String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public ListExp standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + ListExp other = this.clone(); + other.elements.clear(); + for (Exp exp : this.elements) { + other.add(exp.standardize(images)); + } + return other; + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + Set<Variable> vars = new LinkedHashSet<Variable>(); + for (Exp exp : this) { + vars.addAll(exp.getFreeVariables()); + } + return vars; + } + + /** + * Returns <code>true</code> if this list expression is equal to an + * other object, i.e., if the object is a not null reference to an instance + * of the class <code>ListExp</code> and both conjunctive expressions have + * the same elements. + * + * @param obj - the reference object with which to compare. + * @return <code>true</code> if this list expression is equal to an + * other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof ListExp) { + ListExp other = (ListExp) obj; + return this.getExpID().equals(other.getExpID()) + && this.elements.equals(other.elements); + } + return false; + } + + /** + * Returns a hash code value for the list expression. This method is + * supported for the benefit of hashtables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the list expression. + */ + public int hashCode() { + return this.getExpID().hashCode() + this.elements.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public ListExp clone() { + ListExp other = (ListExp) super.clone(); + other.elements = new ArrayList<Exp>(); + for (Exp exp : this.elements) { + other.elements.add(exp.clone()); + } + return other; + } + + /** + * Returns the size of the list expression. + * + * @return the size of the list expression. + */ + public final int size() { + return this.elements.size(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/Literal.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/Literal.java new file mode 100644 index 00000000000..3305e78ee5c --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/Literal.java @@ -0,0 +1,77 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; + +/** + * This interface defines a literal in the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public interface Literal extends InitEl, Iterable<Term> { + + /** + * Returns the predicate of this literal. + * + * @return the predicate of this literal. + */ + String getPredicate(); + + /** + * Adds a new term to this literal. + * + * @param term the term to add. + * @return <code>true</tt> if the term was added; <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + boolean add(Term term); + + /** + * Returns the arity of this literal. + * + * @return the arity of this literal. + */ + int getArity(); + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * expression. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + Literal apply(Substitution sigma); +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/NotAtomicFormula.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/NotAtomicFormula.java new file mode 100644 index 00000000000..98678351733 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/NotAtomicFormula.java @@ -0,0 +1,136 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes This + * software is governed by the CeCILL license under French law and abiding by + * the rules of distribution of free software. You can use, modify and/ or + * redistribute the software under the terms of the CeCILL license as circulated + * by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a + * counterpart to the access to the source code and rights to copy, modify and + * redistribute granted by the license, users are provided only with a limited + * warranty and the software's author, the holder of the economic rights, and + * the successive licensors have only limited liability. In this respect, the + * user's attention is drawn to the risks associated with loading, using, + * modifying and/or developing or reproducing the software by the user in light + * of its specific status of free software, that may mean that it is complicated + * to manipulate, and that also therefore means that it is reserved for + * developers and experienced professionals having in-depth computer knowledge. + * Users are therefore encouraged to load and test the software's suitability as + * regards their requirements in conditions enabling the security of their + * systems and/or data to be ensured and, more generally, to use and operate it + * in the same conditions as regards security. The fact that you are presently + * reading this means that you have had knowledge of the CeCILL license and that + * you accept its terms. + */ + +package pddl4j.exp; + +import java.util.Iterator; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; + +/** + * This class implements negative atomic formula of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class NotAtomicFormula extends NotExp implements Literal { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -1751696323200745754L; + + /** + * Creates a new negative atomic formula with a specific atomic formula. + * + * @param atom the atomic formula contained in this negative atomic formula. + * @throws NullPointerException if <code>atom == null</code>. + */ + public NotAtomicFormula(AtomicFormula atom) { + super(atom); + } + + /** + * Sets a new predicate to this negative atomic formula. + * + * @param predicate the new predicate to set. + * @throws NullPointerException if <code>predicate == null</code>. + */ + public final void setPredicate(String predicate) { + this.getExp().setPredicate(predicate); + } + + /** + * Returns the predicate of this negative atomic formula. + * + * @return the predicate of this negative atomic formula. + */ + public final String getPredicate() { + return this.getExp().getPredicate(); + } + + /** + * Adds a new term to this negative atomic formula. + * + * @param term the term to add. + * @return <code>true</tt> if the expression was added; <code>false</code> + * otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public final boolean add(Term term) { + return this.getExp().add(term); + } + + /** + * Returns the arity of this negative atomic formula. + * + * @return the arity of this negative atomic formula. + */ + public final int getArity() { + return this.getExp().getArity(); + } + + /** + * Returns an iterator over the expression of this negative atomic formula. + * + * @return an iterator over the expression of this negative atomic formula. + * @see java.lang.Iterable#iterator() + */ + public final Iterator<Term> iterator() { + return this.getExp().iterator(); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * expression. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public final NotAtomicFormula apply(Substitution sigma) { + return new NotAtomicFormula((AtomicFormula) this.exp.apply(sigma)); + } + + /** + * Returns the negated expression of this expression. + * + * @return the negated expression of this expression. + */ + public AtomicFormula getExp() { + return (AtomicFormula) super.getExp(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public NotAtomicFormula clone() { + return (NotAtomicFormula) super.clone(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/NotExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/NotExp.java new file mode 100644 index 00000000000..0ebb4295112 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/NotExp.java @@ -0,0 +1,370 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; + +/** + * This class is implemented by all negative expression in the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class NotExp extends AbstractExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 4325921465416962373L; + + /** + * The negative goal descriptions of this not formula. + */ + protected Exp exp; + + /** + * Creates a new empty negative expression from a specific expression. + * + * @param exp The negative expression. + * @throws NullPointerException if <code>exp == null</code>. + */ + public NotExp(Exp exp) { + super(ExpID.NOT); + if (exp == null) + throw new NullPointerException(); + this.exp = exp; + + } + + /** + * Sets a new negative goal description to this not formula. + * + * @param exp the new negative expression to set. + * @throws NullPointerException if <code>exp == null</code>. + */ + public final void setExp(Exp exp) { + if (exp == null) + throw new NullPointerException(); + this.exp = exp; + } + + /** + * Returns the negative expression of expression. + * + * @return the negative expression of expression. + */ + public Exp getExp() { + return this.exp; + } + + /** + * Returns <code>true</code> if a term occurs in this not expression. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this not expression; + * <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public final boolean occurs(Term term) { + if (term == null) + throw new NullPointerException(); + return this.exp.occurs(term); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding expression. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public NotExp apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + return new NotExp(this.exp.apply(sigma)); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + * @see pddl4j.exp.Exp#standardize() + */ + public NotExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public NotExp standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + return new NotExp(this.exp.standardize(images)); + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + return this.exp.isGround(); + } + + /** + * Returns <code>true</code> if this negative expression is equal to an + * other object, i.e., if the object is a not null reference to an instance + * of the class <code>NotExp</code> and both negative expressions have the + * same expression. + * + * @param obj The reference object with which to compare. + * @return <code>true</code> if this negative expression is equal to an + * other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof NotExp) { + NotExp other = (NotExp) obj; + return this.getExpID().equals(other.getExpID()) + && this.exp.equals(other.exp); + } + return false; + } + + /** + * Returns a hash code value for the negative expression. This method is + * supported for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the negative expression. + */ + public int hashCode() { + return this.getExpID().hashCode() + this.exp.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public NotExp clone() { + NotExp other = (NotExp) super.clone(); + other.exp = this.exp.clone(); + return other; + } + + /** + * Returns a copy of this expression such that the quantifiers appear first. + * + * @return a copy of this expression such that the quantifiers appear first. + * @see pddl4j.exp.Exp#moveQuantifierOutward() + */ + public Exp moveQuantifierOutward() { + Exp exp = null; + ExistsExp exists = null; + ForallExp forall = null; + + switch(this.exp.getExpID()) { + case EXIST: + exists = (ExistsExp) this.exp; + forall = new ForallExp(); + for (Variable var : exists) { + forall.add(var.clone()); + } + forall.setExp(new NotExp(exists.getExp()).moveQuantifierOutward()); + exp = forall.moveQuantifierOutward(); + break; + case FORALL: + forall = (ForallExp) this.exp; + exists = new ExistsExp(); + for (Variable var : forall) { + exists.add(var.clone()); + } + exists.setExp(new NotExp(forall.getExp()).moveQuantifierOutward()); + exp = exists.moveQuantifierOutward(); + break; + default: + exp = this.clone(); + } + return exp; + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public OrExp toDisjunctiveNormalForm() { + Exp nnf = this.toNegativeNormalForm(); + if (nnf.getExpID().equals(ExpID.NOT)) { + OrExp dnf = new OrExp(); + dnf.add(new NotExp(this.exp.toDisjunctiveNormalForm()).toNegativeNormalForm()); + return dnf; + } + return (OrExp) nnf.toDisjunctiveNormalForm(); + } + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the conjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + */ + public AndExp toConjunctiveNormalForm() { + Exp nnf = this.toNegativeNormalForm(); + if (nnf.getExpID().equals(ExpID.NOT)) { + AndExp cnf = new AndExp(); + cnf.add(new NotExp(this.exp.toConjunctiveNormalForm()).toNegativeNormalForm()); + return cnf; + } + return (AndExp) nnf.toConjunctiveNormalForm(); + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public Exp toNegativeNormalForm() { + AndExp and = null; + OrExp or = null; + NotExp not = null; + ImplyExp imply = null; + ExistsExp exists = null; + ForallExp forall = null; + + switch(this.exp.getExpID()) { + case AND: + and = (AndExp) this.exp; + or = new OrExp(); + for (Exp e : and) { + not = new NotExp(e); + or.add(not.toNegativeNormalForm()); + } + return or.size() == 1 ? or.get(0) : or; + case OR: + or = (OrExp) this.exp; + and = new AndExp(); + for (Exp e : or) { + not = new NotExp(e); + and.add(not.toNegativeNormalForm()); + } + return and.size() == 1 ? and.get(0) : and; + case NOT: + // return this.exp.toNegativeNormalForm(); + return ((NotExp)this.exp).exp.toNegativeNormalForm(); + case IMPLY: + imply = (ImplyExp) this.exp; + and = new AndExp(); + and.add(imply.getHead()); + and.add(new NotExp(imply.getBody())); + return and.toNegativeNormalForm(); + case EXIST: + exists = (ExistsExp) this.exp; + forall = new ForallExp(); + for (Variable var : exists) { + forall.add(var.clone()); + } + forall.setExp(new NotExp(exists.getExp()).toNegativeNormalForm()); + return forall; + case FORALL: + forall = (ForallExp) this.exp; + exists = new ExistsExp(); + for (Variable var : forall) { + exists.add(var.clone()); + } + exists.setExp(new NotExp(forall.getExp()).toNegativeNormalForm()); + return exists; + default: + return this.clone(); + } + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + return this.exp.getFreeVariables(); + } + + /** + * Returns a string representation of the negative expression. + * + * @return a string representation of the negative expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(not "); + str.append(this.exp.toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of the negative expression. + * + * @return a typed string representation of the negative expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(not "); + str.append(this.exp.toTypedString()); + str.append(")"); + return str.toString(); + } + +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/OrExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/OrExp.java new file mode 100644 index 00000000000..af8f27d8449 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/OrExp.java @@ -0,0 +1,269 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import java.util.LinkedHashMap; +import java.util.Iterator; +import java.util.Map; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Variable; + +/** + * This generic class is implemented by all disjunctive PDDL expression. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class OrExp extends ListExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 7735506016529447105L; + + /** + * Creates a new empty disjunctive expression. + */ + public OrExp() { + super(ExpID.OR); + } + + /** + * Creates a new list expression with a specific id and expressions. + * + * @param exps an expressions list. + */ + public OrExp(Exp... exps) { + super(ExpID.OR, exps); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * expression. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public OrExp apply(Substitution sigma) { + return (OrExp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return this expression. + */ + public OrExp standardize() { + return this.standardize(new LinkedHashMap<String,String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. + * Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return this expression. + * @throws IllegalArgumentException if <code>images == null || bound == null</code>. + */ + public OrExp standardize(Map<String, String> images) { + return (OrExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public OrExp clone() { + return (OrExp) super.clone(); + } + + /** + * Returns the prenex normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the prenex normal form of this expression. + */ + public Exp toPrenexNormaForm() { + return this.standardize().moveQuantifierOutward(); + } + + /** + * Returns a copy of this expression such that the quantifiers appear first. + * + * @return a copy of this expression such that the quantifiers appear first. + * @see pddl4j.exp.Exp#moveQuantifierOutward() + */ + public Exp moveQuantifierOutward() { + Exp qexp = null; + OrExp or = new OrExp(); + Iterator<Exp> i = this.iterator(); + while (i.hasNext()) { + Exp exp = i.next(); + if (exp.getExpID().equals(ExpID.FORALL)) { + ForallExp forall = (ForallExp) exp; + ForallExp tmp = new ForallExp(); + for (Variable var : forall) { + tmp.add(var); + } + or.add(forall.getExp()); + while (i.hasNext()) { + or.add(i.next()); + } + tmp.setExp(or.moveQuantifierOutward()); + qexp = tmp; + } + else if (exp.getExpID().equals(ExpID.EXIST)) { + ExistsExp exists = (ExistsExp) exp; + ExistsExp tmp = new ExistsExp(); + for (Variable var : exists) { + tmp.add(var); + } + or.add(exists.getExp()); + while (i.hasNext()) { + or.add(i.next()); + } + tmp.setExp(or.moveQuantifierOutward()); + qexp = tmp; + } else { + or.add(exp); + } + } + return qexp == null ? or : qexp; + + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public OrExp toNegativeNormalForm() { + OrExp other = new OrExp(); + for (Exp exp : this) { + other.add(exp.toNegativeNormalForm()); + } + return other; + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public OrExp toDisjunctiveNormalForm() { + OrExp nnf = this.toNegativeNormalForm(); + OrExp dnf = new OrExp(); + for (Exp i : nnf) { + Exp exp = i.toDisjunctiveNormalForm(); + dnf.add(exp); + } + return dnf; + } + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the conjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + */ + public AndExp toConjunctiveNormalForm() { + OrExp nnf = this.toNegativeNormalForm(); + AndExp cnf = new AndExp(); + cnf.add(new OrExp()); + for (Exp e : nnf) { + Exp ecnf = e.toConjunctiveNormalForm(); + if (ecnf.getExpID().equals(ExpID.AND)) { + AndExp and = (AndExp) ecnf; + AndExp newCnf = new AndExp(); + for (Exp ae : and) { + for (Exp or : cnf) { + OrExp other = (OrExp) or.clone(); + other.add(ae); + newCnf.add(other); + } + } + cnf = newCnf; + } else { + for (Exp ex : cnf) { + ((OrExp) ex).add(ecnf); + } + } + } + return cnf; + } + + /** + * Returns a string representation of the disjunctive expression. + * + * @return a string representation of the disjunctive expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(or"); + for (Exp elt : this.elements) { + str.append(" "); + str.append(elt.toString()); + } + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of the disjunctive expression. + * + * @return a typed string representation of the disjunctive expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(or"); + for (Exp elt : this.elements) { + str.append(" "); + str.append(elt.toTypedString()); + } + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/PrefExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/PrefExp.java new file mode 100644 index 00000000000..2127e4b9379 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/PrefExp.java @@ -0,0 +1,329 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; + +/** + * This class implements the common methods of all preference expressions of the + * PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class PrefExp extends AbstractExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 2518753354183976408L; + + /** + * The name of this preference. + */ + private String name; + + /** + * The goal description of the preference. + */ + private Exp exp; + + /** + * Creates a new preference expression with a specific expression name and + * expression preference. + * + * @param name The name of the preference. + * @param exp The preference expression. + * @throws NullPointerException if <code>name == null</code> or + * <code>exp == null</code>. + */ + public PrefExp(String name, Exp exp) { + super(ExpID.PREFERENCE); + if (name == null || exp == null) + throw new NullPointerException(); + this.name = name; + this.exp = exp; + } + + /** + * Creates a new preference expression with a specific expression + * preference. + * + * @param exp The preference expression. + * @throws NullPointerException if <code>exp == null</code>. + */ + public PrefExp(Exp exp) { + this(new String(), exp); + } + + /** + * Returns the name of the preference expression. + * + * @return the name of the preference expression. + */ + public final String getName() { + return this.name; + } + + /** + * Sets a new name to the preference expression. + * + * @param name the new name to set. + * @throws NullPointerException if <code>name == null</code>. + */ + public final void setName(String name) { + if (name == null) + throw new NullPointerException(); + this.name = name; + } + + /** + * Returns the expression describing the preference. + * + * @return the expression describing the preference. + */ + public final Exp getExp() { + return this.exp; + } + + /** + * Sets a new expression describing the preference. + * + * @param exp the new expression describing the preference. + * @throws NullPointerException if <code>exp == null</code>. + */ + public final void setExp(Exp exp) { + if (exp == null) + throw new NullPointerException(); + this.exp = exp; + } + + /** + * Returns <code>true</code> if a term occurs in this preference + * expression. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this preference + * expression; <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public final boolean occurs(Term term) { + if (term == null) + throw new NullPointerException(); + return this.exp.occurs(term); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * expression. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public PrefExp apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + return new PrefExp(this.name, this.exp.apply(sigma)); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + * @see pddl4j.exp.Exp#standardize() + */ + public PrefExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public PrefExp standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + return new PrefExp(this.exp.standardize(images)); + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + return this.exp.isGround(); + } + + /** + * Returns <code>true</code> if this preference expression is equal to an + * other object, i.e., if the object is a not null reference to an instance + * of the class <code>PrefExp</code> and both preference expressions have + * the name and expression. + * + * @param obj The reference object with which to compare. + * @return <code>true</code> if this preference expression is equal to an + * other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof PrefExp) { + PrefExp other = (PrefExp) obj; + return this.getExpID().equals(other.getExpID()) + && this.name.equals(other.name) + && this.exp.equals(other.exp); + } + return false; + } + + /** + * Returns a hash code value for the preference expression. This method is + * supported for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the preference expression. + */ + public int hashCode() { + return this.getExpID().hashCode() + this.name.hashCode() + + this.exp.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public PrefExp clone() { + PrefExp other = (PrefExp) super.clone(); + other.exp = this.exp.clone(); + return other; + } + + /** + * Returns a copy of this expression such that the quantifiers appear first. + * + * @return a copy of this expression such that the quantifiers appear first. + * @see pddl4j.exp.Exp#moveQuantifierOutward() + */ + public Exp moveQuantifierOutward() { + return new PrefExp(this.name, this.exp.moveQuantifierOutward()); + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public PrefExp toDisjunctiveNormalForm() { + return new PrefExp(this.name, this.exp.toDisjunctiveNormalForm()); + } + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the conjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + */ + public PrefExp toConjunctiveNormalForm() { + return new PrefExp(this.name, this.exp.toConjunctiveNormalForm()); + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public PrefExp toNegativeNormalForm() { + return new PrefExp(this.name, this.exp.toNegativeNormalForm()); + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + return this.exp.getFreeVariables(); + } + + /** + * Returns a string representation of the preference expression. + * + * @return a string representation of the preference expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(preference "); + str.append(this.name.toString()); + str.append(" "); + str.append(this.exp.toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of the preference expression. + * + * @return a typed string representation of the preference expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(preference "); + str.append(this.name.toString()); + str.append(" "); + str.append(this.exp.toTypedString()); + str.append(")"); + return str.toString(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ProbExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ProbExp.java new file mode 100644 index 00000000000..029584d4074 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/ProbExp.java @@ -0,0 +1,300 @@ +package pddl4j.exp; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; + +public class ProbExp extends AbstractExp{ + + protected Map<Exp, Double> terms; + + + + public ProbExp() { + super(ExpID.PROB_EXP); + + terms = new LinkedHashMap<Exp, Double>(); + } + + //TODO make this prettier. Maybe refactor to make a ListExp? + public void addExp(Exp exp, double prob){ + + if(exp.getExpID() == ExpID.PROB_EXP){ + + ProbExp prob_child = (ProbExp)exp; + + Iterator<Exp> child_children = prob_child.iterator(); + + while(child_children.hasNext()){ + Exp toAdd = child_children.next(); + addExp(toAdd, (prob*prob_child.getProbability(toAdd))); + } + } + else if(exp.getExpID() == ExpID.AND){ + + AndExp and_child = (AndExp)exp; + if(and_child.size() == 1){ + addExp(and_child.iterator().next(), prob); + }else if(and_child.size() == 0){ + + }else{ + terms.put(exp, prob); + } + } + else{ + terms.put(exp, prob); + } + } + + public void removeExp(Exp exp){ + terms.remove(exp); + } + + public ProbExp apply(Substitution sigma) { + + ProbExp p = new ProbExp(); + + for(Exp e: terms.keySet()){ + p.addExp(e.clone().apply(sigma), terms.get(e)); + } + + + + return p; + } + + @Override + public Set<Variable> getFreeVariables() { + + Set<Variable> vars = new HashSet<Variable>(); + + for(Exp e: terms.keySet()){ + for(Variable v: e.getFreeVariables()){ + vars.add(v); + } + } + + return vars; + } + + @Override + public boolean isGround() { + + for(Exp e: terms.keySet()){ + if(!e.isGround()){ + return false; + } + } + + return true; + } + + @Override + public boolean occurs(Term term) { + + for(Exp e: terms.keySet()){ + if(e.occurs(term)){ + return true; + } + } + + return false; + } + + @Override + public Exp standardize() { + + + return this.standardize(new LinkedHashMap<String, String>()); + } + + @Override + public Exp standardize(Map<String, String> images) { + + ProbExp p = new ProbExp(); + + for(Exp e: terms.keySet()){ + p.addExp(e.standardize(images), terms.get(e)); + } + + return p; + } + + public String toString(){ + + String s = "(probabilistic "; + for(Exp e: terms.keySet()){ + s+=terms.get(e)+" "+e.toString()+" "; + } + + return s; + } + + @Override + public String toTypedString() { + + String s = "(probabilistic "; + for(Exp e: terms.keySet()){ + s+=terms.get(e)+" "+e.toTypedString()+" "; + } + + return s; + } + + public Iterator<Exp> iterator(){ + return terms.keySet().iterator(); + } + + public double getProbability(Exp e){ + return terms.get(e); + } + + public ProbExp clone(){ + + ProbExp clone = new ProbExp(); + + for(Exp e: terms.keySet()){ + clone.addExp(e.clone(), terms.get(e)); + } + + return clone; + } + + public int size(){ + return terms.size(); + } + + +// +// public final void setExp(Exp exp) { +// if (exp == null) +// throw new NullPointerException(); +// this.exp = exp; +// } +// +// public Exp getExp() { +// return this.exp; +// } +// +// public final boolean occurs(Term term) { +// if (term == null) +// throw new NullPointerException(); +// return this.exp.occurs(term); +// } +// +// public NotExp apply(Substitution sigma) { +// if (sigma == null) +// throw new NullPointerException(); +// return new NotExp(this.exp.apply(sigma)); +// } +// +// public NotExp standardize() { +// return this.standardize(new LinkedHashMap<String, String>()); +// } +// +// public NotExp standardize(Map<String, String> images) { +// if (images == null) +// throw new NullPointerException(); +// return new NotExp(this.exp.standardize(images)); +// } +// +// public final boolean isGround() { +// return this.exp.isGround(); +// } +// +// public boolean equals(Object obj) { +// if (obj != null && obj instanceof ProbExp) { +// ProbExp other = (ProbExp) obj; +// return this.getExpID().equals(other.getExpID()) +// && this.exp.equals(other.exp) +// && this.probability == other.probability; +// } +// return false; +// } +// +// public int hashCode() { +// return this.getExpID().hashCode() + this.exp.hashCode(); +// } +// +// public ProbExp clone() { +// ProbExp other = (ProbExp) super.clone(); +// other.exp = this.exp.clone(); +// other.probability = this.probability; +// return other; +// } +// +// public Exp moveQuantifierOutward() { +//// Exp exp = null; +//// ExistsExp exists = null; +//// ForallExp forall = null; +//// +//// switch(this.exp.getExpID()) { +//// case EXIST: +//// exists = (ExistsExp) this.exp; +//// forall = new ForallExp(); +//// for (Variable var : exists) { +//// forall.add(var.clone()); +//// } +//// forall.setExp(new NotExp(exists.getExp()).moveQuantifierOutward()); +//// exp = forall.moveQuantifierOutward(); +//// break; +//// case FORALL: +//// forall = (ForallExp) this.exp; +//// exists = new ExistsExp(); +//// for (Variable var : forall) { +//// exists.add(var.clone()); +//// } +//// exists.setExp(new NotExp(forall.getExp()).moveQuantifierOutward()); +//// exp = exists.moveQuantifierOutward(); +//// break; +//// default: +//// exp = this.clone(); +//// } +// return exp; +// } +// +// public OrExp toDisjunctiveNormalForm() { +// OrExp dnf = new OrExp(); +// dnf.add(this.clone()); +// +// return dnf; +// } +// +// public AndExp toConjunctiveNormalForm() { +// +// AndExp cnf = new AndExp(); +// cnf.add(this.clone()); +// return cnf; +// } +// public Exp toNegativeNormalForm() { +// return this.clone(); +// } +// +// public Set<Variable> getFreeVariables() { +// return this.exp.getFreeVariables(); +// } +// +// public String toString() { +// StringBuffer str = new StringBuffer(); +// str.append("(probabilistic "); +// str.append(this.probability+" "); +// str.append(this.exp.toString()); +// str.append(")"); +// return str.toString(); +// } +// +// public String toTypedString() { +// StringBuffer str = new StringBuffer(); +// str.append("(probabilistic "); +// str.append(this.probability+" "); +// str.append(this.exp.toTypedString()); +// str.append(")"); +// return str.toString(); +// } +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/QuantifiedExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/QuantifiedExp.java new file mode 100644 index 00000000000..9c1549094e1 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/QuantifiedExp.java @@ -0,0 +1,349 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; + +/** + * This abstract class is extended by all quantified expression. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class QuantifiedExp extends AbstractExp implements + Iterable<Variable> { + + /** + * The typed list of the quantified variables. + */ + protected Set<Variable> vars; + + /** + * The quantified expression. + */ + protected Exp exp; + + /** + * Creates a new quantified expression with a specific id, typed list of + * quantified variables and quantified expression. + * + * @param id The id of the list expression. + * @param vars The typed list of quantified variables. + * @param exp The quantified expression. + */ + protected QuantifiedExp(ExpID id, Set<Variable> vars, Exp exp) { + super(id); + this.vars = vars; + this.exp = exp; + } + + /** + * Creates a new quantified expression with a specific id, typed list of + * quantified variables and quantified expression. + * + * @param id The id of the list expression. + * @param exp The quantified expression. + */ + protected QuantifiedExp(ExpID id, Exp exp) { + this(id, new LinkedHashSet<Variable>(), exp); + } + + /** + * Creates a new quantified expression with a specific id, typed list of + * quantified variables and quantified expression. + * + * @param id The id of the list expression. + */ + protected QuantifiedExp(ExpID id) { + this(id, new LinkedHashSet<Variable>(), new AndExp()); + } + + /** + * Adds a new quantified variable to this quantified expression. + * + * @param var the quantified variable to add. + * @return <code>true</code> if the quantified variable was added; + * <code>false</code> otherwise. + */ + public boolean add(Variable var) { + return this.vars.add(var); + } + + /** + * Sets the quantified goal description of this universal expression. + * + * @param exp the quantified expression. The goal description must be a not + * null reference. + */ + public final void setExp(Exp exp) { + this.exp = exp; + } + + /** + * Returns the quantified goal description of this universal expression. + * + * @return the quantified goal description of this universal expression. + */ + public final Exp getExp() { + return this.exp; + } + + /** + * Returns <code>true</code> if this quantified expression is equal to an + * other object, i.e., if the object is a not null reference to an instance + * of the class <code>QuantifiedExpression</code> and both quantified + * expressions have the list of bound variable and quantified expression. + * + * @param obj The reference object with which to compare. + * @return <code>true</code> if this quantified expression is equal to an + * other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof QuantifiedExp) { + QuantifiedExp other = (QuantifiedExp) obj; + return this.getExpID().equals(other.getExpID()) + && this.vars.equals(other.vars) + && this.exp.equals(other.exp); + } + return false; + } + + /** + * Returns the hash code value of this quantified expression. This method is + * supported for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return the hash code value of this quantified expression. + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + return this.getExpID().hashCode() + this.vars.hashCode() + + this.exp.hashCode(); + } + + /** + * Returns an iterator over the bounded variables of the quantified + * expression. + * + * @return an iterator over the bounded variables of the quantified + * expression. + * @see java.lang.Iterable#iterator() + */ + public final Iterator<Variable> iterator() { + return this.vars.iterator(); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * expression. + * + * @param sigma the substitution. + * @return a substituted copy of this expression if all bound variables are not instantiated; the + * quantified copy expression otherwise. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public final Exp apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + QuantifiedExp other = this.clone(); + other.exp = this.exp.apply(sigma); + Iterator<Variable> i = other.vars.iterator(); + while (i.hasNext()) { + Variable var = i.next(); + if (!other.exp.occurs(var)) { + i.remove(); + } + } + return other.vars.isEmpty() ? other.exp : this; + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + * @see pddl4j.exp.Exp#standardize() + */ + public QuantifiedExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public QuantifiedExp standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + Map<String, String> newImages = new LinkedHashMap<String,String>(images); + QuantifiedExp other = this.clone(); + other.vars.clear(); + for (Variable var : this.vars) { + other.add(var.standardizeQuantifiedVariable(newImages)); + } + other.exp = other.exp.standardize(newImages); + for (Map.Entry<String, String> e : newImages.entrySet()) { + if (!images.containsKey(e.getKey())) { + images.put(e.getKey(), Variable.getStandardizedImage(e.getValue())); + } + } + return other; + } + + /** + * Returns <code>true</code> if a term occurs in this quantified + * expression. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this quantified + * expression; <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public final boolean occurs(Term term) { + if (term == null) + throw new NullPointerException(); + return this.exp.occurs(term); + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + return this.exp.isGround(); + } + + /** + * Returns the prenex normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the prenex normal form of this expression. + */ + public Exp toPrenexNormaForm() { + QuantifiedExp pnf = this.standardize(); + pnf.exp = pnf.exp.moveQuantifierOutward(); + return pnf; + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public QuantifiedExp clone() { + QuantifiedExp other = (QuantifiedExp) super.clone(); + other.vars = new LinkedHashSet<Variable>(); + for (Variable var : this.vars) { + other.vars.add(var.clone()); + } + other.exp = this.exp.clone(); + return other; + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + Set<Variable> vars = new LinkedHashSet<Variable>(); + vars.addAll(this.exp.getFreeVariables()); + vars.removeAll(this.vars); + return vars; + } + + /** + * Returns a string representation of the quantified expression. + * + * @return a string representation of the quantified expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(" + this.getExpID().toString().toLowerCase() + " "); + str.append("("); + if (!this.vars.isEmpty()) { + Iterator<Variable> i = this.iterator(); + str.append(i.next().toString()); + while (i.hasNext()) { + str.append(" " + i.next().toString()); + } + } + str.append(")"); + str.append(" "); + str.append(this.exp.toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of the quantified expression. + * + * @return a typed string representation of the quantified expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(" + this.getExpID().toString().toLowerCase() + " "); + str.append("("); + if (!this.vars.isEmpty()) { + Iterator<Variable> i = this.iterator(); + str.append(i.next().toTypedString()); + while (i.hasNext()) { + str.append(" " + i.next().toTypedString()); + } + } + str.append(")"); + str.append(" "); + str.append(this.exp.toTypedString()); + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/WhenExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/WhenExp.java new file mode 100644 index 00000000000..0489e16b208 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/WhenExp.java @@ -0,0 +1,347 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; + +/** + * This class implements a conditional expression of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class WhenExp extends AbstractExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -1373199261710247868L; + + /** + * The condition of the expression. + */ + private Exp condition; + + /** + * The effect of the conditional effect expression. + */ + private Exp effect; + + /** + * Creates a new conditional expression. + * + * @param condition The condition expression. + * @param effect The effect expression. + * @throws NullPointerException if <code>condition == null</code> or + * <code>effect == null</code>. + */ + public WhenExp(Exp condition, Exp effect) { + super(ExpID.WHEN); + if (condition == null || effect == null) + throw new NullPointerException(); + this.condition = condition; + this.effect = effect; + } + + /** + * Creates a new conditional expression. + */ + private WhenExp() { + super(ExpID.WHEN); + this.condition = null; + this.effect = null; + } + + /** + * Returns the condition of this conditional expression. + * + * @return the condition of this conditional expression. + */ + public final Exp getCondition() { + return this.condition; + } + + /** + * Sets a new condition to this this conditional expression. + * + * @param condition the new condition to set. + * @throws NullPointerException if <code>condition == null</code>. + */ + public final void setCondition(Exp condition) { + if (condition == null) + throw new NullPointerException(); + this.condition = condition; + } + + /** + * Returns the effect of this conditional expression. + * + * @return the effect of this conditional expression. + */ + public final Exp getEffect() { + return this.effect; + } + + /** + * Sets a new effect to this conditional expression. + * + * @param effect The effect to set. + * @throws NullPointerException if <code>condition == null</code>. + */ + public final void setEffect(Exp effect) { + if (effect == null) + throw new NullPointerException(); + this.effect = effect; + } + + /** + * Returns <code>true</code> if a term occurs in this when expression. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this when expression; + * <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public final boolean occurs(Term term) { + if (term == null) + throw new NullPointerException(); + return this.condition.occurs(term) || this.effect.occurs(term); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public WhenExp apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + return new WhenExp(this.condition.apply(sigma), + this.effect.apply(sigma)); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + * @see pddl4j.exp.Exp#standardize() + */ + public WhenExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public WhenExp standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + return new WhenExp(this.condition.standardize(images), + this.effect.standardize(images)); + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + return this.condition.isGround() && this.effect.isGround(); + } + + /** + * Returns <code>true</code> if this conditional expression is equal to an + * other object, i.e., if the object is a not null reference to an instance + * of the class <code>WhenExp</code> and both conditional expressions have + * the same condition and effect. + * + * @param obj The reference object with which to compare. + * @return <code>true</code> if this conditional expression is equal to an + * other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof WhenExp) { + WhenExp other = (WhenExp) obj; + return this.getExpID().equals(other.getExpID()) + && this.condition.equals(other.condition) + && this.effect.equals(other.effect); + } + return false; + } + + /** + * Returns a hash code value for the conditional expression. This method is + * supported for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the conditional expression. + */ + public int hashCode() { + return this.getExpID().hashCode() + this.condition.hashCode() + + this.effect.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public WhenExp clone() { + WhenExp other = (WhenExp) super.clone(); + other.condition = this.condition.clone(); + other.effect = this.effect.clone(); + return other; + } + + /** + * Normalize this when expression. The condition is converted into + * disjunctive normal form and effect in conjunctive normal form. + * + * @return a normalize copy of this when expression. + */ + public WhenExp normalize() { + return new WhenExp(this.condition.moveQuantifierOutward().toDisjunctiveNormalForm(), + this.effect.toConjunctiveNormalForm()); + } + + /** + * Returns a copy of this expression such that the quantifiers appear first. + * + * @return a copy of this expression such that the quantifiers appear first. + * @see pddl4j.exp.Exp#moveQuantifierOutward() + */ + public Exp moveQuantifierOutward() { + return new WhenExp(this.condition.moveQuantifierOutward(), + this.effect.moveQuantifierOutward()); + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public WhenExp toDisjunctiveNormalForm() { + return new WhenExp(this.condition.toDisjunctiveNormalForm(), + this.effect.toDisjunctiveNormalForm()); + } + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the conjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + */ + public WhenExp toConjunctiveNormalForm() { + return new WhenExp(this.condition.toConjunctiveNormalForm(), + this.effect.toConjunctiveNormalForm()); + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public WhenExp toNegativeNormalForm() { + return new WhenExp(this.condition.toNegativeNormalForm(), this.effect + .toNegativeNormalForm()); + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + Set<Variable> vars = new LinkedHashSet<Variable>(); + vars.addAll(this.condition.getFreeVariables()); + vars.addAll(this.effect.getFreeVariables()); + return vars; + } + + /** + * Returns a string representation of the conditional expression. + * + * @return a string representation of the conditional expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(when "); + str.append(this.condition.toString()); + str.append(" "); + str.append(this.effect.toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of the conditional expression. + * + * @return a typed string representation of the conditional expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(when "); + str.append(this.condition.toTypedString()); + str.append(" "); + str.append(this.effect.toTypedString()); + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/AbstractActionDef.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/AbstractActionDef.java new file mode 100644 index 00000000000..222a28391f5 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/AbstractActionDef.java @@ -0,0 +1,219 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.action; + + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import pddl4j.exp.term.Term; + +/** + * This class implements the common structures and method shares by all PDDL + * action. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class AbstractActionDef implements ActionDef { + + /** + * The action id. + */ + private ActionID id; + + /** + * The image of this action. + */ + protected String name; + + /** + * The parameters of the action. + */ + protected List<Term> parameters; + + /** + * Creates a new action with a specific image. + * + * @param id the kind of the action. + * @param name The name of the action. The image of an action must be a + * not null reference. + * @throws NullPointerException if <code>id == null || name == null<code>. + */ + protected AbstractActionDef(ActionID id, String name) { + this.id = id; + this.setName(name); + this.parameters = new ArrayList<Term>(); + } + + /** + * Returns the action id of this action. + * + * @return the action id of this action. + * @see pddl4j.exp.action.ActionID + */ + public final ActionID getActionID() { + return this.id; + } + + /** + * Returns the image of the action. + * + * @return the image of this action. + */ + public final String getName() { + return this.name; + } + + /** + * Adds a parameter to this action. + * + * @param param the parameters to add. + * @return <code>true</code> if the parameter was added; + * <code>false</code> otherwise. + * @throws NullPointerException if <code>param == null</code>. + */ + public final boolean add(Term param) { + if (param == null) + throw new NullPointerException(); + return this.parameters.add(param); + } + + /** + * Returns the parameters of the action. + * + * @return the parameters of this action. + */ + public final List<Term> getParameters() { + return this.parameters; + } + + /** + * Sets a new image to this action. + * + * @param name The new name to set. The image of an action must be a not + * null reference. + * @throws NullPointerException if <code>name == null</code>. + */ + public final void setName(String name) { + if (name == null) + throw new NullPointerException(); + this.name = name; + } + + /** + * Returns <code>true</code> if a specified expression occurs in the + * parameters of this action. + * + * @param term the term to be tested. + * @return <code>true</code> if a specified expression occurs in the + * parameters of this action; <code>false</code> otherwise. + * @see pddl4j.exp.Exp#occurs(pddl4j.exp.term.Term) + */ + public final boolean occurs(Term term) { + return this.parameters.contains(term); + } + + /** + * Returns an iterator over the parameters of this action. + * + * @return an iterator over the parameters of this action. + */ + public final Iterator<Term> iterator() { + return this.parameters.iterator(); + } + + /** + * Returns <code>true</code> if the abstract action is ground. + * + * @return <code>true</code> if the abstract action is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public boolean isGround() { + boolean gound = true; + Iterator<Term> i = this.parameters.iterator(); + while (i.hasNext() && gound) { + gound = i.next().isGround(); + } + return gound; + } + + /** + * Returns <code>true</code> if this action is equal to an other + * object, i.e., if the object is a not null instance of the class + * <code>Action</code> and both action have the same name. + * + * @param obj The reference object with which to compare. + * @return <code>true</code> if this action is equal to an other + * object; <code>false</code> otherwise. + */ + public final boolean equals(Object obj) { + if (obj != null && obj instanceof ActionDef) { + Action other = (Action) obj; + return this.getName().equals(other.getName()); + } + return false; + } + + /** + * Returns a hash code value for the action. This method is + * supported for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the strips action. + */ + public final int hashCode() { + return this.getName().hashCode(); + } + + /** + * Returns a deep copy of this abstract action. + * + * @return a deep copy of this abstract action. + * @see pddl4j.exp.AbstractExp#clone() + */ + public AbstractActionDef clone() { + AbstractActionDef other = null; + try { + other = (AbstractActionDef) super.clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + other.parameters = new ArrayList<Term>(); + for (Term param : this.parameters) { + other.parameters.add(param.clone()); + } + return other; + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/Action.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/Action.java new file mode 100644 index 00000000000..b0fc2d953be --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/Action.java @@ -0,0 +1,244 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.action; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Iterator; + +import pddl4j.exp.AndExp; +import pddl4j.exp.Exp; +import pddl4j.exp.term.Term; + +/** + * This class implements a strips action of the pddl language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class Action extends AbstractActionDef { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -991066278473010044L; + + /** + * The preconditions of the action. + */ + private Exp precondition; + + /** + * The effect of the action. + */ + private Exp effect; + + /** + * Creates a new strips action with a specific image. By default the + * precondition is set to an empty conjunctive precondition goal description + * and the effect to an empty proposition effect. + * + * @param name - the name of the action. The image musts be a not reference + * to a string. + * @throws NullPointerException if <code>name == null<code>. + */ + public Action(String name) { + super(ActionID.ACTION, name); + this.precondition = new AndExp(); + this.effect = new AndExp(); + } + + /** + * Returns the precondition of the action. + * + * @return the precondition of the action. + */ + public final Exp getPrecondition() { + return this.precondition; + } + + /** + * Sets the new precondition of the action. + * + * @param pre the new precondition of the action. + * @throws NullPointerException if <code>pre == null</code>. + */ + public final void setPrecondition(Exp pre) { + if (pre == null) + throw new NullPointerException(); + this.precondition = pre; + } + + /** + * Returns the effect of the action. + * + * @return the effect of the action. + * @throws NullPointerException if <code>effect == null</code>. + */ + public final Exp getEffect() { + return this.effect; + } + + /** + * Sets the new effect of the action. + * + * @param effect the new effect of the action. + */ + public final void setEffect(Exp effect) { + if (effect == null) + throw new NullPointerException(); + this.effect = effect; + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public Action standardize() { + Map<String,String> images = new LinkedHashMap<String, String>(); + Action other = this.clone(); + other.parameters.clear(); + for (Term param : this.parameters) { + other.add(param.standardize(images)); + } + other.precondition = this.precondition.standardize(images); + other.effect = this.effect.standardize(images); + return other; + } + + /** + * Normalize this action. This method returns a copy of this action where: + * <ul> + * <li> each variable is standardized,</li> + * <li> precondition expression is convert into disjunctive prenex normal + * form and</li> + * <li> effect expression is is convert into conjunctive prenex normal form.</li> + * <ul> + * + * @return a normalize copy of this action. + * @see pddl4j.exp.Exp#toPrenexNormaForm() + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public Action normalize() { + Action other = (Action) this.standardize(); + other.precondition = other.precondition.moveQuantifierOutward() + .toDisjunctiveNormalForm(); + other.effect = other.effect.moveQuantifierOutward() + .toConjunctiveNormalForm(); + return other; + } + + /** + * Returns <code>true</code> if the action is ground. + * + * @return <code>true</code> if the action is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public boolean isGround() { + return super.isGround() && this.precondition.isGround() + && this.effect.isGround(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public Action clone() { + Action other = (Action) super.clone(); + other.precondition = this.precondition.clone(); + other.effect = this.effect.clone(); + return other; + } + + /** + * Returns a string representation of the action. + * + * @return a string representation of the action. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(:action "); + str.append(this.getName().toString()); + str.append("\n"); + str.append(" :parameters "); + str.append("("); + if (!this.parameters.isEmpty()) { + Iterator<Term> i = this.parameters.iterator(); + Term param = i.next(); + str.append(param.toTypedString()); + while (i.hasNext()) { + str.append(" " + i.next().toTypedString()); + } + } + str.append(")"); + str.append("\n :precondition "); + str.append(this.precondition.toString()); + str.append("\n :effect "); + str.append(this.effect.toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of the action. + * + * @return a typed string representation of the action. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(:action "); + str.append(this.getName().toString()); + str.append("\n"); + str.append(" :parameters "); + str.append("("); + if (!this.parameters.isEmpty()) { + Iterator<Term> i = this.parameters.iterator(); + str.append(i.next().toTypedString()); + while (i.hasNext()) { + str.append(" " + i.next().toTypedString()); + } + } + str.append(")"); + str.append("\n :precondition "); + str.append(this.precondition.toTypedString()); + str.append("\n :effect "); + str.append(this.effect.toTypedString()); + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/ActionDef.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/ActionDef.java new file mode 100644 index 00000000000..41b7132a3bd --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/ActionDef.java @@ -0,0 +1,190 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.action; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import pddl4j.exp.term.Term; + +/** + * This interface is implemented by all type of action defined in the PDDL + * language. + * + * @author Damien Pellier + * @version 1.0 + */ +public interface ActionDef extends Iterable<Term>, Serializable, Cloneable { + + /** + * Returns the action id of this action. + * + * @return the action id of this action. + * @see pddl4j.exp.action.ActionID + */ + ActionID getActionID(); + + /** + * Returns the image of the action. + * + * @return the image of this action. + */ + String getName(); + + /** + * Returns the parameters of the action. + * + * @return the parameters of the action. + */ + List<Term> getParameters(); + + /** + * Adds a parameter to this action. + * + * @param param the parameters to add. + * @return <code>true</code> if the parameter was added; + * <code>false</code> otherwise. + */ + boolean add(Term param); + + /** + * Returns an iterator over the parameters of the action. + * + * @return an iterator over the parameters of the action. + */ + Iterator<Term> iterator(); + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + */ + boolean isGround(); + + /** + * Returns <code>true</code> if this expression is equal to an other + * object, i.e., if the object is a not null instance of the class of the + * expression and both expressions have the same content. + * + * @param obj the reference object with which to compare. + * @return <code>true</code> if this expression is equal to an other + * object; <code>false</code> otherwise. + */ + boolean equals(Object obj); + + /** + * Returns a hash code value for the expression. This method is supported + * for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the expression. + */ + int hashCode(); + + /** + * Returns a string representation of the expression. + * + * @return a string representation of the expression. + */ + String toString(); + + /** + * Returns <code>true</code> if a term occurs in the parameters of this action. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this expression; + * <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + boolean occurs(Term term); + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + ActionDef standardize(); + + /** + * Normalize this action. This method returns a copy of this action where: + * <ul> + * <li> each variable is standardized,</li> + * <li> precondition expression is convert into disjunctive prenex normal + * form and</li> + * <li> effect expression is is convert into conjunctive prenex normal form.</li> + * <ul> + * + * @return a normalize copy of this action. + * @see pddl4j.exp.Exp#toPrenexNormaForm() + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + ActionDef normalize(); + + /** + * Returns a deep copy of this action. Creates and returns a copy of this + * action. The precise meaning of "copy" is as follow: + * + * <pre> + * x.clone() != x + * </pre> + * + * will be true, and that the expression: + * + * <pre> + * x.clone().getClass() == x.getClass() + * </pre> + * + * will be true. While it is the case that: + * + * <pre> + * x.clone().equals(x) + * </pre> + * + * will be true. Finally, note that except type of term expression are + * deeply copy. + * + * @return a deep copy of this expression. + * @see java.lang.Cloneable + */ + ActionDef clone(); + + /** + * Returns a typed string of this action. + * + * @return a typed string of this action. + */ + String toTypedString(); + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/ActionID.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/ActionID.java new file mode 100644 index 00000000000..54a246bb5a1 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/ActionID.java @@ -0,0 +1,48 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.action; + +/** + * This enumeration list all action id used in the pddl language. + * + * @author Damien Pellier + * @version 1.0 + */ +public enum ActionID { + /** + * The action expression id. + */ + ACTION, + /** + * The durative action expression id. + */ + DURATIVE_ACTION, +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/DurativeAction.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/DurativeAction.java new file mode 100644 index 00000000000..035f4ff2cf0 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/DurativeAction.java @@ -0,0 +1,272 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.action; + +import java.util.Map; +import java.util.LinkedHashMap; +import java.util.Iterator; + +import pddl4j.exp.Exp; +import pddl4j.exp.term.Term; + +/** + * This class implements a durative action of the PDDl language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class DurativeAction extends AbstractActionDef { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 7123555664571927698L; + + /** + * The duration constraint of the action. + */ + private Exp constraint; + + /** + * The condition of the durative action. + */ + private Exp condition; + + /** + * The effect of the durative action. + */ + private Exp effect; + + /** + * Creates a new durative action with a specific name. + * + * @param name the name of the durative action. The name must a not null + * reference. + * @throws NullPointerException if <code>name == null</code>. + */ + public DurativeAction(String name) { + super(ActionID.DURATIVE_ACTION, name); + } + + /** + * Returns the duration constraint of the durative action. + * + * @return the duration constraint of the durative action. + */ + public final Exp getConstraint() { + return this.constraint; + } + + /** + * Sets the new duration constraint of the durative action. + * + * @param cons the new duration constraint of the durative action. + * @throws NullPointerException if <code>cons == null</code>. + */ + public final void setConstraint(Exp cons) { + if (cons == null) + throw new NullPointerException(); + this.constraint = cons; + } + + /** + * Returns the condition of the durative action. + * + * @return the condition of the durative action. + */ + public final Exp getCondition() { + return this.condition; + } + + /** + * Sets the new condition of the durative action. + * + * @param cond the new condition of the durative action. + * @throws NullPointerException if <code>cond == null</code>. + */ + public final void setCondition(Exp cond) { + if (cond == null) + throw new NullPointerException(); + this.condition = cond; + } + + /** + * Returns the effect of the durative action. + * + * @return the effect of the durative action. + */ + public final Exp getEffect() { + return this.effect; + } + + /** + * Sets the new effect of the durative action. + * + * @param effect the new effect of the durative action. + * @throws NullPointerException if <code>effect == null</code>. + */ + public final void setEffect(Exp effect) { + if (effect == null) + throw new NullPointerException(); + this.effect = effect; + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. a standardized copy of this expression. + * + * @return a standardized copy of this expression. + */ + public DurativeAction standardize() { + Map<String,String> images = new LinkedHashMap<String, String>(); + DurativeAction other = this.clone(); + other.parameters.clear(); + for (Term param : this.parameters) { + other.add(param.standardize(images)); + } + other.constraint = this.constraint.standardize(images); + other.condition = this.condition.standardize(images); + other.effect = this.effect.standardize(images); + return other; + } + + /** + * Normalize this action. This method returns a copy of this action where: + * <ul> + * <li> each variable is standardized,</li> + * <li> duration constraints expression is convert into conjunctive prenex + * normal form and</li> + * <li> condition expression is convert into disjunctive prenex normal form + * and</li> + * <li> effect expression is is convert into conjunctive prenex normal form.</li> + * <ul> + * + * @return a normalize copy of this action. + * @see pddl4j.exp.Exp#toPrenexNormaForm() + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public DurativeAction normalize() { + DurativeAction other = (DurativeAction) this.standardize(); + other.constraint = other.constraint.moveQuantifierOutward() + .toConjunctiveNormalForm(); + other.condition = other.condition.moveQuantifierOutward() + .toDisjunctiveNormalForm(); + other.effect = other.effect.moveQuantifierOutward() + .toConjunctiveNormalForm(); + return other; + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public boolean isGround() { + return super.isGround() && this.constraint.isGround() + && this.condition.isGround() + && this.effect.isGround(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public DurativeAction clone() { + DurativeAction other = (DurativeAction) super.clone(); + other.constraint = this.constraint.clone(); + other.condition = this.condition.clone(); + other.effect = this.effect.clone(); + return other; + } + + /** + * Returns a string representation of the durative action. + * + * @return a string representation of the durative action. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(:durative-action "); + str.append(this.getName()); + str.append(":parameters "); + str.append("("); + if (!this.parameters.isEmpty()) { + Iterator<Term> i = this.parameters.iterator(); + str.append(i.next().toString()); + while (i.hasNext()) { + str.append(" " + i.next().toString()); + } + } + str.append(")"); + str.append("\n:duration "); + str.append(this.constraint.toString()); + str.append("\n:condition "); + str.append(this.condition.toString()); + str.append("\n:effect "); + str.append(this.effect.toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of the durative action. + * + * @return a typed string representation of the durative action. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(:durative-action "); + str.append(this.getName()); + str.append(":parameters "); + str.append("("); + if (!this.parameters.isEmpty()) { + Iterator<Term> i = this.parameters.iterator(); + str.append(i.next().toTypedString()); + while (i.hasNext()) { + str.append(" " + i.next().toTypedString()); + } + } + str.append(")"); + str.append("\n:duration "); + str.append(this.constraint.toTypedString()); + str.append("\n:condition "); + str.append(this.condition.toTypedString()); + str.append("\n:effect "); + str.append(this.effect.toTypedString()); + str.append(")"); + return str.toString(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/package.html b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/package.html new file mode 100644 index 00000000000..96b6a93e464 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/action/package.html @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title></title> + <meta name="Generator" content="Cocoa HTML Writer"> + <meta name="CocoaVersion" content="824.42"> + <style type="text/css"> + p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times} + </style> +</head> +<body> +<p>This package contains the classes relative to the PDDL action expressions.</p> +</body> +</html> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/Assign.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/Assign.java new file mode 100644 index 00000000000..1f2bebb7eec --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/Assign.java @@ -0,0 +1,110 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.assign; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; + +/** + * This class implements the assign operation "assign" of the pddl language. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class Assign extends AssignOpExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 303729525987701084L; + + /** + * Creates a new "assign" operation with two arguments. + * + * @param arg1 the first argument of the "assign" operation. + * @param arg2 the second argument of the "assign" operation. + * @throws NullPointerException if <code>arg1 == null</code> or + * <code>arg2 == null</code>. + */ + public Assign(Term arg1, Term arg2) { + super(AssignOp.ASSIGN, arg1, arg2); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public Assign apply(Substitution sigma) { + return (Assign) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public Assign standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + */ + public Assign standardize(Map<String, String> images) { + return (Assign) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public Assign clone() { + return (Assign) super.clone(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/AssignOp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/AssignOp.java new file mode 100644 index 00000000000..49c13e4d000 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/AssignOp.java @@ -0,0 +1,61 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.assign; + +/** + * This enumeration defined all the assign operation that can be used in effect + * expression of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public enum AssignOp { + /** + * The assign operator. + */ + ASSIGN, + /** + * The scale up operator. + */ + SCALE_UP, + /** + * The scale down operator. + */ + SCALE_DOWN, + /** + * The increase operator. + */ + INCREASE, + /** + * The decrease operator. + */ + DECREASE; +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/AssignOpExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/AssignOpExp.java new file mode 100644 index 00000000000..c996c08d329 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/AssignOpExp.java @@ -0,0 +1,310 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.assign; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.AbstractExp; +import pddl4j.exp.ExpID; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; +import pddl4j.exp.term.Variable; + +/** + * This class implements an assign operation of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class AssignOpExp extends AbstractExp { + + /** + * The assign operator of this operation. + */ + private AssignOp op; + + /** + * The first argument of the operation. + */ + private Term arg1; + + /** + * The second argument of the operation. + */ + private Term arg2; + + /** + * Creates a new assign operation. + * + * @param op the assign operator of the operation. + * @param arg1 the first argument of the assign operation. + * @param arg2 the second argument of the assign operation. + * @throws NullPointerException if <code>op == null</code> or + * <code>arg1 == null</code> or <code>arg2 == null</code>. + */ + public AssignOpExp(AssignOp op, Term arg1, Term arg2) { + super(ExpID.ASSIGN_OP); + if (op == null || arg1 == null || arg2 == null) + throw new NullPointerException(); + this.op = op; + this.arg1 = arg1; + this.arg2 = arg2; + } + + /** + * Sets a new operator of this assign operation. + * + * @param op the new operator of this assign operation. + * @throws NullPointerException if <code>op == null</code>. + */ + public final void setOp(AssignOp op) { + if (op == null) + throw new NullPointerException(); + this.op = op; + } + + /** + * Returns the operator of this assign operation. + * + * @return the operator of this assign operation. + */ + public final AssignOp getOp() { + return this.op; + } + + /** + * Sets the first argument of this assign operation. + * + * @param arg1 the new first argument of this assign operation to set. + * @throws NullPointerException if <code>arg1 == null</code>. + */ + public final void setArg1(Term arg1) { + if (arg1 == null) + throw new NullPointerException(); + this.arg1 = arg1; + } + + /** + * Returns the first argument of the assign operation. + * + * @return the first argument of the assign operation. + */ + public final Term getArg1() { + return this.arg1; + } + + /** + * Sets the second argument of this assign operation. + * + * @param arg2 the new second argument of this assign operation to set. + * @throws NullPointerException if <code>arg2 == null</code>. + */ + public final void setArg2(Term arg2) { + if (arg2 == null) + throw new NullPointerException(); + this.arg2 = arg2; + } + + /** + * Returns the second argument of the assign operation. + * + * @return the second argument of the assign operation. + */ + public final Term getArg2() { + return this.arg2; + } + + /** + * Returns <code>true</code> if a term occurs in this assign op + * expression. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this assign op + * expression; <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public final boolean occurs(Term term) { + if (term == null) + throw new NullPointerException(); + return this.arg1.occurs(term) || this.arg2.occurs(term); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public AssignOpExp apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + AssignOpExp other = this.clone(); + other.arg1 = this.arg1.apply(sigma); + other.arg2 = this.arg2.apply(sigma); + return other; + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public AssignOpExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public AssignOpExp standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + AssignOpExp other = this.clone(); + other.arg1 = this.arg1.standardize(images); + other.arg2 = this.arg2.standardize(images); + return other; + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + return this.arg1.isGround() && this.arg2.isGround(); + } + + /** + * Returns <code>true</code> if this "assign" operation is equals to an + * other object, i.e., if the object is a not null instance of the class + * <code>AssignOpExp</code> and both operation have the same arguments. + * + * @param obj the object to compare. + * @return <code>true</code> if this "assign" operation is equals to an + * other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof AssignOpExp) { + AssignOpExp other = (AssignOpExp) obj; + return this.getExpID().equals(other.getExpID()) + && this.getOp().equals(other.op) + && this.arg1.equals(other.arg1) + && this.arg2.equals(other.arg2); + } + return false; + } + + /** + * Returns the hash code value of this "assign" operation. + * + * @return the hash code value of this "assign" operation. + */ + public int hashCode() { + return this.getExpID().hashCode() + this.op.hashCode() + + this.arg1.hashCode() + this.arg2.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public AssignOpExp clone() { + AssignOpExp other = (AssignOpExp) super.clone(); + other.arg1 = this.arg1.clone(); + other.arg2 = this.arg2.clone(); + return other; + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + Set<Variable> vars = new LinkedHashSet<Variable>(); + if (this.arg1.getTermID().equals(TermID.VARIABLE)) { + vars.add((Variable) this.arg1); + } + if (this.arg2.getTermID().equals(TermID.VARIABLE)) { + vars.add((Variable) this.arg2); + } + return vars; + } + + /** + * Returns a string representation of this assign operation. + * + * @return a string representation of this assign operation. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(" + this.op.toString().toLowerCase() + " "); + str.append(this.getArg1().toString()); + str.append(" "); + str.append(this.getArg2().toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this assign operation. + * + * @return a typed string representation of this assign operation. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(" + this.op.toString().toLowerCase() + " "); + str.append(this.getArg1().toTypedString()); + str.append(" "); + str.append(this.getArg2().toTypedString()); + str.append(")"); + return str.toString(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/Decrease.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/Decrease.java new file mode 100644 index 00000000000..2ae1d491a2b --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/Decrease.java @@ -0,0 +1,103 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes This + * software is governed by the CeCILL license under French law and abiding by + * the rules of distribution of free software. You can use, modify and/ or + * redistribute the software under the terms of the CeCILL license as circulated + * by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a + * counterpart to the access to the source code and rights to copy, modify and + * redistribute granted by the license, users are provided only with a limited + * warranty and the software's author, the holder of the economic rights, and + * the successive licensors have only limited liability. In this respect, the + * user's attention is drawn to the risks associated with loading, using, + * modifying and/or developing or reproducing the software by the user in light + * of its specific status of free software, that may mean that it is complicated + * to manipulate, and that also therefore means that it is reserved for + * developers and experienced professionals having in-depth computer knowledge. + * Users are therefore encouraged to load and test the software's suitability as + * regards their requirements in conditions enabling the security of their + * systems and/or data to be ensured and, more generally, to use and operate it + * in the same conditions as regards security. The fact that you are presently + * reading this means that you have had knowledge of the CeCILL license and that + * you accept its terms. + */ + +package pddl4j.exp.assign; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; + +/** + * This class implements the assign operation "decrease" of the pddl language. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class Decrease extends AssignOpExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 5208581275117162064L; + + /** + * Creates a new "decrease" assign operation with two arguments. + * + * @param arg1 the first argument of the "decrease" operation. + * @param arg2 the second argument of the "decrease" operation. + * @throws NullPointerException if <code>arg1 == null</code> or + * <code>arg2 == null</code>. + */ + public Decrease(Term arg1, Term arg2) { + super(AssignOp.DECREASE, arg1, arg2); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public Decrease apply(Substitution sigma) { + return (Decrease) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public Decrease standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + */ + public Decrease standardize(Map<String, String> images) { + return (Decrease) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public Decrease clone() { + return (Decrease) super.clone(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/Increase.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/Increase.java new file mode 100644 index 00000000000..7c7c611ca68 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/Increase.java @@ -0,0 +1,104 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes This + * software is governed by the CeCILL license under French law and abiding by + * the rules of distribution of free software. You can use, modify and/ or + * redistribute the software under the terms of the CeCILL license as circulated + * by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a + * counterpart to the access to the source code and rights to copy, modify and + * redistribute granted by the license, users are provided only with a limited + * warranty and the software's author, the holder of the economic rights, and + * the successive licensors have only limited liability. In this respect, the + * user's attention is drawn to the risks associated with loading, using, + * modifying and/or developing or reproducing the software by the user in light + * of its specific status of free software, that may mean that it is complicated + * to manipulate, and that also therefore means that it is reserved for + * developers and experienced professionals having in-depth computer knowledge. + * Users are therefore encouraged to load and test the software's suitability as + * regards their requirements in conditions enabling the security of their + * systems and/or data to be ensured and, more generally, to use and operate it + * in the same conditions as regards security. The fact that you are presently + * reading this means that you have had knowledge of the CeCILL license and that + * you accept its terms. + */ + +package pddl4j.exp.assign; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; + +/** + * This class implements the assign operation "increase" of the pddl language. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class Increase extends AssignOpExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 5208581275117162064L; + + /** + * Creates a new "increase" assign operation with two arguments. + * + * @param arg1 the first argument of the "increase" operation. + * @param arg2 the second argument of the "increase" operation. + * @throws NullPointerException if <code>arg1 == null</code> or + * <code>arg2 == null</code>. + */ + public Increase(Term arg1, Term arg2) { + super(AssignOp.INCREASE, arg1, arg2); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public Increase apply(Substitution sigma) { + return (Increase) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public Increase standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + */ + public Increase standardize(Map<String, String> images) { + return (Increase) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public Increase clone() { + return (Increase) super.clone(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/ScaleDown.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/ScaleDown.java new file mode 100644 index 00000000000..9afee9a4f53 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/ScaleDown.java @@ -0,0 +1,104 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes This + * software is governed by the CeCILL license under French law and abiding by + * the rules of distribution of free software. You can use, modify and/ or + * redistribute the software under the terms of the CeCILL license as circulated + * by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a + * counterpart to the access to the source code and rights to copy, modify and + * redistribute granted by the license, users are provided only with a limited + * warranty and the software's author, the holder of the economic rights, and + * the successive licensors have only limited liability. In this respect, the + * user's attention is drawn to the risks associated with loading, using, + * modifying and/or developing or reproducing the software by the user in light + * of its specific status of free software, that may mean that it is complicated + * to manipulate, and that also therefore means that it is reserved for + * developers and experienced professionals having in-depth computer knowledge. + * Users are therefore encouraged to load and test the software's suitability as + * regards their requirements in conditions enabling the security of their + * systems and/or data to be ensured and, more generally, to use and operate it + * in the same conditions as regards security. The fact that you are presently + * reading this means that you have had knowledge of the CeCILL license and that + * you accept its terms. + */ + +package pddl4j.exp.assign; + +import java.util.Map; +import java.util.LinkedHashMap; + + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; + +/** + * This class implements the assign operation "scale down" of the pddl language. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class ScaleDown extends AssignOpExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 5208581275117162064L; + + /** + * Creates a new "scale down" assign operation with two arguments. + * + * @param arg1 the first argument of the "scale down" operation. + * @param arg2 the second argument of the "scale down" operation. + * @throws NullPointerException if <code>arg1 == null</code> or + * <code>arg2 == null</code>. + */ + public ScaleDown(Term arg1, Term arg2) { + super(AssignOp.SCALE_DOWN, arg1, arg2); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public ScaleDown apply(Substitution sigma) { + return (ScaleDown) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public ScaleDown standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + */ + public ScaleDown standardize(Map<String, String> images) { + return (ScaleDown) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public ScaleDown clone() { + return (ScaleDown) super.clone(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/ScaleUp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/ScaleUp.java new file mode 100644 index 00000000000..8c0c6da23f6 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/ScaleUp.java @@ -0,0 +1,103 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes This + * software is governed by the CeCILL license under French law and abiding by + * the rules of distribution of free software. You can use, modify and/ or + * redistribute the software under the terms of the CeCILL license as circulated + * by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a + * counterpart to the access to the source code and rights to copy, modify and + * redistribute granted by the license, users are provided only with a limited + * warranty and the software's author, the holder of the economic rights, and + * the successive licensors have only limited liability. In this respect, the + * user's attention is drawn to the risks associated with loading, using, + * modifying and/or developing or reproducing the software by the user in light + * of its specific status of free software, that may mean that it is complicated + * to manipulate, and that also therefore means that it is reserved for + * developers and experienced professionals having in-depth computer knowledge. + * Users are therefore encouraged to load and test the software's suitability as + * regards their requirements in conditions enabling the security of their + * systems and/or data to be ensured and, more generally, to use and operate it + * in the same conditions as regards security. The fact that you are presently + * reading this means that you have had knowledge of the CeCILL license and that + * you accept its terms. + */ + +package pddl4j.exp.assign; + +import java.util.Map; +import java.util.LinkedHashMap; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; + +/** + * This class implements the assign operation "scale" of the pddl language. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class ScaleUp extends AssignOpExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 5208581275117162064L; + + /** + * Creates a new "scale up" assign operation with two arguments. + * + * @param arg1 the first argument of the "scale up" operation. + * @param arg2 the second argument of the "scale up" operation. + * @throws NullPointerException if <code>arg1 == null</code> or + * <code>arg2 == null</code>. + */ + public ScaleUp(Term arg1, Term arg2) { + super(AssignOp.SCALE_UP, arg1, arg2); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public ScaleUp apply(Substitution sigma) { + return (ScaleUp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public ScaleUp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + */ + public ScaleUp standardize(Map<String, String> images) { + return (ScaleUp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public ScaleUp clone() { + return (ScaleUp) super.clone(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/package.html b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/package.html new file mode 100644 index 00000000000..0653e5cd926 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/assign/package.html @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title></title> + <meta name="Generator" content="Cocoa HTML Writer"> + <meta name="CocoaVersion" content="824.42"> + <style type="text/css"> + p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times} + </style> +</head> +<body> +<p>This package contains the classes relative to assign expressions of the PDDL language.</p> +</body> +</html> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/AlwaysExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/AlwaysExp.java new file mode 100644 index 00000000000..113b522388e --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/AlwaysExp.java @@ -0,0 +1,138 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.cond; + +import java.util.Map; +import java.util.LinkedHashMap; + +import pddl4j.exp.Exp; +import pddl4j.exp.term.Substitution; + +/** + * This class implements an "always" conditional expression of the PDDL langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public class AlwaysExp extends UnaryCondExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -118526516823423737L; + + /** + * Creates a new conditional "always" expression with a specific expression. + * + * @param arg the expression. The expression must be a not null + * reference. + */ + public AlwaysExp(Exp arg) { + super(Condition.ALWAYS, arg); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public AlwaysExp apply(Substitution sigma) { + return (AlwaysExp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are + * existentially quantified. + * + * @return a standardized copy of this expression. + */ + public AlwaysExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public AlwaysExp standardize(Map<String, String> images) { + return (AlwaysExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public AlwaysExp clone() { + return (AlwaysExp) super.clone(); + } + + /** + * Returns a string representation of this "always" conditional expression. + * + * @return a string representation of this "always" conditional expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(always "); + str.append(this.getArg().toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this "always" conditional expression. + * + * @return a typed string representation of this "always" conditional expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(always "); + str.append(this.getArg().toTypedString()); + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/AlwaysWithinExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/AlwaysWithinExp.java new file mode 100644 index 00000000000..5a1696d588e --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/AlwaysWithinExp.java @@ -0,0 +1,213 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes This + * software is governed by the CeCILL license under French law and abiding by + * the rules of distribution of free software. You can use, modify and/ or + * redistribute the software under the terms of the CeCILL license as circulated + * by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a + * counterpart to the access to the source code and rights to copy, modify and + * redistribute granted by the license, users are provided only with a limited + * warranty and the software's author, the holder of the economic rights, and + * the successive licensors have only limited liability. In this respect, the + * user's attention is drawn to the risks associated with loading, using, + * modifying and/or developing or reproducing the software by the user in light + * of its specific status of free software, that may mean that it is complicated + * to manipulate, and that also therefore means that it is reserved for + * developers and experienced professionals having in-depth computer knowledge. + * Users are therefore encouraged to load and test the software's suitability as + * regards their requirements in conditions enabling the security of their + * systems and/or data to be ensured and, more generally, to use and operate it + * in the same conditions as regards security. The fact that you are presently + * reading this means that you have had knowledge of the CeCILL license and that + * you accept its terms. + */ + +package pddl4j.exp.cond; + +import java.util.Map; +import java.util.LinkedHashMap; + +import pddl4j.exp.Exp; +import pddl4j.exp.fexp.Number; +import pddl4j.exp.term.Substitution; + +/** + * This class implements an "always-within" conditional expression of the PDDL + * language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class AlwaysWithinExp extends BinaryCondExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -8736698454531582219L; + + /** + * The time stamp. + */ + private Number ts; + + /** + * Creates a new conditional "always-within" expression with two specific + * expression arguments. + * + * @param arg1 the first expression argument. The expression must be a not + * null reference. + * @param arg2 the second expression argument. The expression must be a not + * null reference. + * @param ts the new time stamp to this this "always-within" conditional + * expression. The time stamp must be a not null reference and + * its value must be greater than 0. + */ + public AlwaysWithinExp(Exp arg1, Exp arg2, Number ts) { + super(Condition.ALWAYS_WITHIN, arg1, arg2); + this.ts = ts; + } + + /** + * Sets a new time stamp to this this "always-within" conditional + * expression. + * + * @param ts the new time stamp to this this "always-within" conditional + * expression. The time stamp must be a not null reference and + * its value must be greater than 0. + */ + public final void setTimeStamp(Number ts) { + this.ts = ts; + } + + /** + * Returns the time stamp to this this "always-within" conditional + * expression. + * + * @return the time stamp to this this "always-within" conditional + * expression. + */ + public final Number getTimeStamp() { + return this.ts; + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public AlwaysWithinExp apply(Substitution sigma) { + return (AlwaysWithinExp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public AlwaysWithinExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public AlwaysWithinExp standardize(Map<String, String> images) { + return (AlwaysWithinExp) super.standardize(images); + } + + /** + * Returns <code>true</code> if this "always-within" conditional + * expression is equal to an other object, i.e., if the object is a not null + * reference to an instance of the class <code>AlwaysWithinExp</code> and + * both "always-within" conditional expressions have the same two expression + * arguments and the same time stamp. + * + * @param obj the object to compare. + * @return <code>true</code> if this "always-within" conditional + * expression is equal to an other object; <code>false</code> + * otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof AlwaysWithinExp) { + AlwaysWithinExp other = (AlwaysWithinExp) obj; + return super.equals(obj) && this.ts.equals(other.ts); + } + return false; + } + + /** + * Returns the hash code value of this "always-within" conditional + * expression. + * + * @return the hash code value of this "always-within" conditional + * expression. + */ + public int hashCode() { + return this.getExpID().hashCode() + this.getArg1().hashCode() + + this.getArg2().hashCode() + this.ts.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public AlwaysWithinExp clone() { + AlwaysWithinExp other = (AlwaysWithinExp) super.clone(); + other.ts = this.ts.clone(); + return other; + } + + /** + * Returns a string representation of this "always-within" conditional + * expression. + * + * @return a string representation of this "always-within" conditional + * expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(always-within "); + str.append(this.ts.toString()); + str.append(" "); + str.append(this.getArg1().toString()); + str.append(" "); + str.append(this.getArg2().toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this "always-within" conditional + * expression. + * + * @return a typed string representation of this "always-within" conditional + * expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(always-within "); + str.append(this.ts.toTypedString()); + str.append(" "); + str.append(this.getArg1().toTypedString()); + str.append(" "); + str.append(this.getArg2().toTypedString()); + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/AtMostOnceExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/AtMostOnceExp.java new file mode 100644 index 00000000000..684db6df5bf --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/AtMostOnceExp.java @@ -0,0 +1,136 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes This + * software is governed by the CeCILL license under French law and abiding by + * the rules of distribution of free software. You can use, modify and/ or + * redistribute the software under the terms of the CeCILL license as circulated + * by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a + * counterpart to the access to the source code and rights to copy, modify and + * redistribute granted by the license, users are provided only with a limited + * warranty and the software's author, the holder of the economic rights, and + * the successive licensors have only limited liability. In this respect, the + * user's attention is drawn to the risks associated with loading, using, + * modifying and/or developing or reproducing the software by the user in light + * of its specific status of free software, that may mean that it is complicated + * to manipulate, and that also therefore means that it is reserved for + * developers and experienced professionals having in-depth computer knowledge. + * Users are therefore encouraged to load and test the software's suitability as + * regards their requirements in conditions enabling the security of their + * systems and/or data to be ensured and, more generally, to use and operate it + * in the same conditions as regards security. The fact that you are presently + * reading this means that you have had knowledge of the CeCILL license and that + * you accept its terms. + */ + +package pddl4j.exp.cond; + +import java.util.Map; +import java.util.LinkedHashMap; + +import pddl4j.exp.Exp; +import pddl4j.exp.term.Substitution; + +/** + * This class implements an "at-most-once" conditional expression of the PDDL + * language. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class AtMostOnceExp extends UnaryCondExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -118526516823423737L; + + /** + * Creates a new conditional "at-most-once" expression with a specific + * expression. + * + * @param arg the expression. The expression must be a not null reference. + */ + public AtMostOnceExp(Exp arg) { + super(Condition.AT_MOST_ONCE, arg); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public AtMostOnceExp apply(Substitution sigma) { + return (AtMostOnceExp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public AtMostOnceExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public AtMostOnceExp standardize(Map<String, String> images) { + return (AtMostOnceExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public AtMostOnceExp clone() { + return (AtMostOnceExp) super.clone(); + } + + /** + * Returns a string representation of this "at-most-once" conditional + * expression. + * + * @return a string representation of this "at-most-once" conditional + * expression. description. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(at-most-once "); + str.append(this.getArg().toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this "at-most-once" conditional + * expression. + * + * @return a typed string representation of this "at-most-once" conditional + * expression. description. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(at-most-once "); + str.append(this.getArg().toTypedString()); + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/BinaryCondExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/BinaryCondExp.java new file mode 100644 index 00000000000..d8fb43b043f --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/BinaryCondExp.java @@ -0,0 +1,306 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.cond; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.Exp; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; + +/** + * This class implements a binary conditional expression. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class BinaryCondExp extends CondExp { + + /** + * The first expression argument of this conditional binary expression. + */ + private Exp arg1; + + /** + * The second expression argument of this conditional binary expression. + */ + private Exp arg2; + + /** + * Creates a new binary conditional expression with a specific expression. + * + * @param cond The condition of the binary conditional expression. + * @param arg1 the first expression argument. + * @param arg2 the second expression argument. + * @throws NullPointerException if <code>id == null</code> or + * <code>arg1 == null</code> or <code>arg2 == null</code>. + */ + public BinaryCondExp(Condition cond, Exp arg1, Exp arg2) { + super(cond); + if (arg1 == null || arg2 == null) + throw new NullPointerException(); + this.arg1 = arg1; + this.arg2 = arg2; + } + + /** + * Sets the new first expression argument of this binary conditional + * expression. + * + * @param arg1 the first expression argument. + * @throws NullPointerException if <code>arg1 == null</code>. + */ + public final void setArg1(Exp arg1) { + if (arg1 == null) + throw new NullPointerException(); + this.arg1 = arg1; + } + + /** + * Returns the first expression argument of this binary conditional + * expression. + * + * @return the first expression argument of this binary conditional + * expression. + */ + public final Exp getArg1() { + return this.arg1; + } + + /** + * Sets the new second expression argument of this binary conditional + * expression. + * + * @param arg2 the second expression argument. + * @throws NullPointerException if <code>arg2 == null</code>. + */ + public final void setArg2(Exp arg2) { + this.arg2 = arg2; + } + + /** + * Returns the second expression argument of this binary conditional + * expression. + * + * @return the second expression argument of this binary conditional + * expression. + */ + public final Exp getArg2() { + return this.arg2; + } + + /** + * Returns <code>true</code> if a term occurs in this binary conditional + * expression. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this binary conditional + * expression; <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public final boolean occurs(Term term) { + if (term == null) + throw new NullPointerException(); + return this.arg1.occurs(term) || this.arg2.occurs(term); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public BinaryCondExp apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + BinaryCondExp other = this.clone(); + other.arg1 = this.arg1.apply(sigma); + other.arg2 = this.arg2.apply(sigma); + return other; + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are + * existentially quantified. + * + * @return a standardized copy of this expression. + */ + public BinaryCondExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + */ + public BinaryCondExp standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + BinaryCondExp other = this.clone(); + other.arg1 = this.arg1.standardize(images); + other.arg2 = this.arg2.standardize(images); + return other; + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + Set<Variable> vars = new LinkedHashSet<Variable>(); + vars.addAll(this.arg1.getFreeVariables()); + vars.addAll(this.arg2.getFreeVariables()); + return vars; + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + return this.arg1.isGround() && this.arg2.isGround(); + } + + /** + * Returns <code>true</code> if this binary conditional expression is + * equal to an other object, i.e., if the object is a not null reference to + * an instance of the class <code>BinaryCondExp</code> and both binary + * conditional expressions have the same two expression arguments and the + * same time stamp. + * + * @param obj the object to compare. + * @return <code>true</code> if this conditional expression is equal to an + * other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof BinaryCondExp) { + BinaryCondExp other = (BinaryCondExp) obj; + return super.equals(obj) && this.arg1.equals(other.arg1) + && this.arg2.equals(other.arg2); + } + return false; + } + + /** + * Returns the hash code value of this binary conditional expression. + * + * @return the hash code value of this binary conditional expression. + */ + public int hashCode() { + return super.hashCode() + this.arg1.hashCode() + this.arg2.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public BinaryCondExp clone() { + BinaryCondExp other = (BinaryCondExp) super.clone(); + other.arg1 = this.arg1.clone(); + other.arg2 = this.arg2.clone(); + return other; + } + + /** + * Returns a copy of this expression such that the quantifiers appear first. + * + * @return a copy of this expression such that the quantifiers appear first. + * @see pddl4j.exp.Exp#moveQuantifierOutward() + */ + public BinaryCondExp moveQuantifierOutward() { + BinaryCondExp other = (BinaryCondExp) super.clone(); + other.arg1 = this.arg1.moveQuantifierOutward(); + other.arg2 = this.arg2.moveQuantifierOutward(); + return other; + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public BinaryCondExp toDisjunctiveNormalForm() { + BinaryCondExp other = this.clone(); + other.arg1 = this.arg1.toDisjunctiveNormalForm(); + other.arg2 = this.arg2.toDisjunctiveNormalForm(); + return other; + } + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the conjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + */ + public BinaryCondExp toConjunctiveNormalForm() { + BinaryCondExp other = this.clone(); + other.arg1 = this.arg1.toConjunctiveNormalForm(); + other.arg2 = this.arg2.toConjunctiveNormalForm(); + return other; + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public BinaryCondExp toNegativeNormalForm() { + BinaryCondExp other = this.clone(); + other.arg1 = this.arg1.toNegativeNormalForm(); + other.arg2 = this.arg2.toNegativeNormalForm(); + return other; + } +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/CondExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/CondExp.java new file mode 100644 index 00000000000..2c08c850bf3 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/CondExp.java @@ -0,0 +1,98 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.cond; + +import pddl4j.exp.AbstractExp; +import pddl4j.exp.ExpID; + +/** + * This abstract class defines a conditional expression of the pddl language. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class CondExp extends AbstractExp { + + /** + * The condition of this conditional expression. + */ + private Condition condition; + + /** + * Creates a new conditional expression with a specified condition. + * + * @param cond the condition of this expression. + * @throws NullPointerException if <code>condition == null</code>. + */ + protected CondExp(Condition cond) { + super(ExpID.COND_EXP); + this.condition = cond; + } + + /** + * Returns the condition of this conditional expression. + * + * @return the condition of this conditional expression. + */ + public final Condition getCondition() { + return this.condition; + } + + /** + * Returns <code>true</code> if this conditional expression is equal to an + * other object. This method returns <code>true</code> if the object is a + * not null instance of the class <code>CondExp</code> and both + * conditional expression have the same condition. + * + * @param obj the object to be compared. + * @return <code>true</code> if this conditional expression is equal to an + * other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof CondExp) { + CondExp other = (CondExp) obj; + return this.condition.equals(other.condition); + } + return false; + } + + /** + * Returns a hash code value for the conditional expression. This method is + * supported for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the conditional expression. + */ + public int hashCode() { + return super.hashCode() + this.condition.hashCode(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/Condition.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/Condition.java new file mode 100644 index 00000000000..96e9caaa78a --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/Condition.java @@ -0,0 +1,77 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.cond; + +/** + * This enumeration defines all condition that can be express with pddl language. + * + * @author Damien Pellier + * @version 1.0 + */ +public enum Condition { + + /** + * The always condition. + */ + ALWAYS, + /** + * The sometime condition. + */ + SOMETIME, + /** + * The whithin condition. + */ + WITHIN, + /** + * The at most once condition. + */ + AT_MOST_ONCE, + /** + * The some time after condition. + */ + SOMETIME_AFTER, + /** + * The sometime before condition. + */ + SOMETIME_BEFORE, + /** + * The always within condition. + */ + ALWAYS_WITHIN, + /** + * The hold during condition. + */ + HOLD_DURING, + /** + * The hold after econdition. + */ + HOLD_AFTER, +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/HoldAfterExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/HoldAfterExp.java new file mode 100644 index 00000000000..78e93d44702 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/HoldAfterExp.java @@ -0,0 +1,204 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.cond; + +import java.util.Map; +import java.util.LinkedHashMap; + +import pddl4j.exp.Exp; +import pddl4j.exp.fexp.Number; +import pddl4j.exp.term.Substitution; + +/** + * This class implements a "hold-after" conditional expression of the PDDL + * language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class HoldAfterExp extends UnaryCondExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -5875541478330858782L; + + /** + * The time stamp. + */ + private Number ts; + + /** + * Creates a new conditional "hold-after" expression with a specific + * expression. + * + * @param arg the expression. The expression must be a not null reference. + * @param ts the time stamp to this this "hold-after" conditional + * expression. The time stamp must be a not null reference. + */ + public HoldAfterExp(Exp arg, Number ts) { + super(Condition.HOLD_AFTER, arg); + this.ts = ts; + } + + /** + * Sets a new time stamp to this this "hold-after" conditional expression. + * + * @param ts the new time stamp to this this "hold-after" conditional + * expression. The time stamp must be a not null reference. + */ + public final void setTimeStamp(Number ts) { + this.ts = ts; + } + + /** + * Returns the time stamp to this this "hold-after" conditional expression. + * + * @return the time stamp to this this "hold-after" conditional expression. + */ + public final Number getTimeStamp() { + return this.ts; + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public HoldAfterExp apply(Substitution sigma) { + return (HoldAfterExp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public HoldAfterExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public HoldAfterExp standardize(Map<String, String> images) { + return (HoldAfterExp) super.standardize(images); + } + + /** + * Returns <code>true</code> if this "hold-after" conditional expression + * is equal to an other object, i.e., if the object is a not null reference + * to an instance of the class <code>HoldAfterExp</code> and both + * "hold-after" conditional expressions have the same expression and time + * stamp. + * + * @param obj the object to compare. + * @return <code>true</code> if this "hold-after" conditional expression + * is equal to an other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof HoldAfterExp) { + HoldAfterExp other = (HoldAfterExp) obj; + return super.equals(obj) && this.ts.equals(other.ts); + } + return false; + } + + /** + * Returns the hash code value of this "hold-after" conditional expression. + * + * @return the hash code value of this "hold-after" conditional expression. + */ + public int hashCode() { + return super.hashCode() + this.ts.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public HoldAfterExp clone() { + HoldAfterExp other = (HoldAfterExp) super.clone(); + other.ts = this.ts.clone(); + return other; + } + + /** + * Returns a string representation of this "hold-after" conditional + * expression. + * + * @return a string representation of this "hold-after" conditional + * expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(hold-after "); + str.append(this.ts.toString()); + str.append(" "); + str.append(this.getArg().toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this "hold-after" conditional + * expression. + * + * @return a typed string representation of this "hold-after" conditional + * expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(hold-after "); + str.append(this.ts.toTypedString()); + str.append(" "); + str.append(this.getArg().toTypedString()); + str.append(")"); + return str.toString(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/HoldDuringExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/HoldDuringExp.java new file mode 100644 index 00000000000..72a2c2c9f30 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/HoldDuringExp.java @@ -0,0 +1,244 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.cond; + +import java.util.Map; +import java.util.LinkedHashMap; + +import pddl4j.exp.Exp; +import pddl4j.exp.fexp.Number; +import pddl4j.exp.term.Substitution; + +/** + * This class implements an "hold-during" conditional expression of the PDDL + * language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class HoldDuringExp extends UnaryCondExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -8736698454531582219L; + + /** + * The lower bound of the time interval. + */ + private Number lts; + + /** + * The upper bound of the time interval. + */ + private Number uts; + + /** + * Creates a new conditional "hold-during" expression holding in a specific + * time interval. + * + * @param lts the lower bound of the time interval. The time stamp must be a + * not null reference and its value must be greater than 0. + * @param uts the upper bound of the time interval. The time stamp must be a + * not null reference and its value must be greater than 0. + * @param arg the expression. The expression must be a not null reference. + */ + public HoldDuringExp(Number lts, Number uts, Exp arg) { + super(Condition.HOLD_DURING, arg); + this.lts = lts; + this.uts = uts; + } + + /** + * Sets a new lower time stamp bound of this this "hold-during" conditional + * expression. + * + * @param lts the lower new time stamp bound of this this "hold-during" + * conditional expression to set. The time stamp must be a not + * null reference and its value must be greater than 0. + */ + public final void setLowerTimeStamp(Number lts) { + this.lts = lts; + } + + /** + * Returns the lower time stamp bound of this this "hold-during" conditional + * expression. + * + * @return the lower time stamp bound of this this "hold-during" conditional + * expression. + */ + public final Number getLowerTimeStamp() { + return this.lts; + } + + /** + * Sets a new upper time stamp bound of this this "hold-during" conditional + * expression. + * + * @param uts the upper new time stamp bound of this this "hold-during" + * conditional expression to set. The time stamp must be a not + * null reference and its value must be greater than 0. + */ + public final void setUpperTimeStamp(Number uts) { + this.uts = uts; + } + + /** + * Returns the upper time stamp bound of this this "hold-during" conditional + * expression. + * + * @return the upper time stamp bound of this this "hold-during" conditional + * expression. + */ + public final Number getUpperTimeStamp() { + return this.uts; + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public HoldDuringExp apply(Substitution sigma) { + return (HoldDuringExp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public HoldDuringExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + */ + public HoldDuringExp standardize(Map<String, String> images) { + return (HoldDuringExp) super.standardize(images); + } + + /** + * Returns <code>true</code> if this "hold-during" conditional expression + * is equal to an other object, i.e., if the object is a not null reference + * to an instance of the class <code>HoldDuringExp</code> and both + * "hold-during" conditional expressions have the same expression and the + * same time stamp interval. + * + * @param obj the object to compare. + * @return <code>true</code> if this "hold-during" conditional expression + * is equal to an other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof HoldDuringExp) { + HoldDuringExp other = (HoldDuringExp) obj; + return super.equals(obj) + && this.lts.equals(other.lts) + && this.uts.equals(other.uts); + } + return false; + } + + /** + * Returns the hash code value of this "hold-during" conditional expression. + * + * @return the hash code value of this "hold-during" conditional expression. + */ + public int hashCode() { + return super.hashCode() + this.lts.hashCode() + this.uts.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public HoldDuringExp clone() { + HoldDuringExp other = (HoldDuringExp) super.clone(); + other.lts = this.lts.clone(); + other.uts = this.uts.clone(); + return other; + } + + /** + * Returns a string representation of this "hold-during" conditional + * expression. + * + * @return a string representation of this "hold-during" conditional + * expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(hold-during "); + str.append(this.lts.toString()); + str.append(" "); + str.append(this.uts.toString()); + str.append(" "); + str.append(this.getArg().toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this "hold-during" conditional + * expression. + * + * @return a typed string representation of this "hold-during" conditional + * expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(hold-during "); + str.append(this.lts.toTypedString()); + str.append(" "); + str.append(this.uts.toTypedString()); + str.append(" "); + str.append(this.getArg().toTypedString()); + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/SometimeAfterExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/SometimeAfterExp.java new file mode 100644 index 00000000000..478be53813c --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/SometimeAfterExp.java @@ -0,0 +1,147 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.cond; + +import java.util.Map; +import java.util.LinkedHashMap; + +import pddl4j.exp.Exp; +import pddl4j.exp.term.Substitution; + +/** + * This class implements an "sometime-after" conditional expression of the PDDL + * language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class SometimeAfterExp extends BinaryCondExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -118526516823423737L; + + /** + * Creates a new conditional "sometime-after" expression with two specific + * expression arguments. + * + * @param arg1 the first expression argument. The expression must be a not + * null reference. + * @param arg2 the second expression argument. The expression must be a not + * null reference. + */ + public SometimeAfterExp(Exp arg1, Exp arg2) { + super(Condition.SOMETIME_AFTER, arg1, arg2); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public SometimeAfterExp apply(Substitution sigma) { + return (SometimeAfterExp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public SometimeAfterExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + */ + public SometimeAfterExp standardize(Map<String, String> images) { + return (SometimeAfterExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public SometimeAfterExp clone() { + return (SometimeAfterExp) super.clone(); + } + + /** + * Returns a string representation of this "sometime-after" conditional + * expression. + * + * @return a string representation of this "sometime-after" conditional + * expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(sometime-after "); + str.append(this.getArg1().toString()); + str.append(" "); + str.append(this.getArg2().toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this "sometime-after" conditional + * expression. + * + * @return a typed string representation of this "sometime-after" conditional + * expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(sometime-after "); + str.append(this.getArg1().toTypedString()); + str.append(" "); + str.append(this.getArg2().toTypedString()); + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/SometimeBeforeExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/SometimeBeforeExp.java new file mode 100644 index 00000000000..dc2d29d0a3f --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/SometimeBeforeExp.java @@ -0,0 +1,150 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.cond; + +import java.util.Map; +import java.util.LinkedHashMap; + +import pddl4j.exp.Exp; +import pddl4j.exp.term.Substitution; + +/** + * This class implements an "sometime-before" conditional expression of the PDDL + * language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class SometimeBeforeExp extends BinaryCondExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -2826334757834212540L; + + /** + * Creates a new conditional "sometime-before" expression with two specific + * expression arguments. + * + * @param arg1 the first expression argument. The expression must be a not + * null reference. + * @param arg2 the second expression argument. The expression must be a not + * null reference. + */ + public SometimeBeforeExp(Exp arg1, Exp arg2) { + super(Condition.SOMETIME_BEFORE, arg1, arg2); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public SometimeBeforeExp apply(Substitution sigma) { + return (SometimeBeforeExp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public SometimeBeforeExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public SometimeBeforeExp standardize(Map<String, String> images) { + return (SometimeBeforeExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public SometimeBeforeExp clone() { + return (SometimeBeforeExp) super.clone(); + } + + /** + * Returns a string representation of this "sometime-before" conditional + * expression. + * + * @return a string representation of this "sometime-before" conditional + * expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(sometime-before "); + str.append(this.getArg1().toString()); + str.append(" "); + str.append(this.getArg2().toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this "sometime-before" conditional + * expression. + * + * @return a typed string representation of this "sometime-before" conditional + * expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(sometime-before "); + str.append(this.getArg1().toTypedString()); + str.append(" "); + str.append(this.getArg2().toTypedString()); + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/SometimeExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/SometimeExp.java new file mode 100644 index 00000000000..52ff4c14ce6 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/SometimeExp.java @@ -0,0 +1,144 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.cond; + +import java.util.Map; +import java.util.LinkedHashMap; + +import pddl4j.exp.Exp; +import pddl4j.exp.term.Substitution; + +/** + * This class implements an "sometime" conditional expression of the PDDL + * language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class SometimeExp extends UnaryCondExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -118526516823423737L; + + /** + * Creates a new conditional "sometime" expression with a specific + * expression. + * + * @param arg the expression. The expression must be a not null reference. + */ + public SometimeExp(Exp arg) { + super(Condition.SOMETIME, arg); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public SometimeExp apply(Substitution sigma) { + return (SometimeExp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public SometimeExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public SometimeExp standardize(Map<String, String> images) { + return (SometimeExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public SometimeExp clone() { + return (SometimeExp) super.clone(); + } + + /** + * Returns a string representation of this "sometime" conditional + * expression. + * + * @return a string representation of this "sometime" conditional + * expression.goal description. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(sometime "); + str.append(this.getArg().toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this "sometime" conditional + * expression. + * + * @return a typed string representation of this "sometime" conditional + * expression.goal description. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(sometime "); + str.append(this.getArg().toTypedString()); + str.append(")"); + return str.toString(); + } + + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/UnaryCondExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/UnaryCondExp.java new file mode 100644 index 00000000000..2a0f1be0338 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/UnaryCondExp.java @@ -0,0 +1,262 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.cond; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.Exp; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; + +/** + * This class implements an unary conditional expression of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class UnaryCondExp extends CondExp { + + /** + * The goal description of the unary conditional expression. + */ + private Exp arg; + + /** + * Creates a new unary conditional expression with a specific expression. + * + * @param cond The condition of the unary conditional expression. + * @param arg the expression. + * @throws NullPointerException if <code>cond == null</code> or <code>arg == null</code>. + */ + public UnaryCondExp(Condition cond, Exp arg) { + super(cond); + if (arg == null) + throw new NullPointerException(); + this.arg = arg; + } + + /** + * Sets a new goal description to the unary conditional expression + * + * @param arg the new expression to set. + * @throws NullPointerException if <code>arg == null</code>. + */ + public final void setArg(Exp arg) { + if (arg == null) + throw new NullPointerException(); + this.arg = arg; + } + + /** + * Returns the expression of the unary conditional expression. + * + * @return the expression of the unary conditional expression. + */ + public final Exp getArg() { + return this.arg; + } + + /** + * Returns <code>true</code> if a term occurs in this binary conditional + * expression. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this binary conditional + * expression; <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public final boolean occurs(Term term) { + if (term == null) + throw new NullPointerException(); + return this.arg.occurs(term); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public UnaryCondExp apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + UnaryCondExp other = this.clone(); + other.arg = this.arg.apply(sigma); + return other; + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public UnaryCondExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + */ + public UnaryCondExp standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + UnaryCondExp other = this.clone(); + other.arg = this.arg.standardize(images); + return other; + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + Set<Variable> vars = new LinkedHashSet<Variable>(); + vars.addAll(this.arg.getFreeVariables()); + return vars; + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + return this.arg.isGround(); + } + + /** + * Returns <code>true</code> if this unary conditional expression is + * equal to an other object, i.e., if the object is a not null reference to + * an instance of the class <code>UnaryConExp</code> and both + * conditional expressions have the same expression. + * + * @param obj the object to compare. + * @return <code>true</code> if this unary conditional expression is + * equal to an other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof UnaryCondExp) { + UnaryCondExp other = (UnaryCondExp) obj; + return super.equals(obj) && this.arg.equals(other.arg); + } + return false; + } + + /** + * Returns the hash code value of this unary conditional expression. + * + * @return the hash code value of this unary conditional expression. + */ + public int hashCode() { + return super.hashCode() + this.arg.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public UnaryCondExp clone() { + UnaryCondExp other = (UnaryCondExp) super.clone(); + other.arg = this.arg.clone(); + return other; + } + + /** + * Returns a copy of this expression such that the quantifiers appear first. + * + * @return a copy of this expression such that the quantifiers appear first. + * @see pddl4j.exp.Exp#moveQuantifierOutward() + */ + public UnaryCondExp moveQuantifierOutward() { + UnaryCondExp other = (UnaryCondExp) super.clone(); + other.arg = this.arg.moveQuantifierOutward(); + return other; + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public UnaryCondExp toDisjunctiveNormalForm() { + UnaryCondExp other = this.clone(); + other.arg = this.arg.toDisjunctiveNormalForm(); + return other; + } + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the conjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + */ + public UnaryCondExp toConjunctiveNormalForm() { + UnaryCondExp other = this.clone(); + other.arg = this.arg.toConjunctiveNormalForm(); + return other; + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public UnaryCondExp toNegativeNormalForm() { + UnaryCondExp other = this.clone(); + other.arg = this.arg.toNegativeNormalForm(); + return other; + } +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/WithinExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/WithinExp.java new file mode 100644 index 00000000000..e2ef78fe6e0 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/WithinExp.java @@ -0,0 +1,196 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.cond; + +import java.util.Map; +import java.util.LinkedHashMap; + +import pddl4j.exp.Exp; +import pddl4j.exp.fexp.Number; +import pddl4j.exp.term.Substitution; + +/** + * This class implements an "within" conditional expression of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class WithinExp extends UnaryCondExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -118526516823423737L; + + /** + * The time stamp. + */ + private Number ts; + + /** + * Creates a new conditional "within" expression with a specific expression. + * + * @param arg the expression. The expression must be a not null reference. + * @param ts the time stamp to this this "within" conditional expression. + * The time stamp must be a not null reference. + */ + public WithinExp(Exp arg, Number ts) { + super(Condition.WITHIN, arg); + this.ts = ts; + } + + /** + * Sets a new time stamp to this this "within" conditional expression. + * + * @param ts the new time stamp to this this "within" conditional + * expression. The time stamp must be a not null reference. + */ + void setTimeStamp(Number ts) { + this.ts = ts; + } + + /** + * Returns the time stamp to this this "within" conditional expression. + * + * @return the time stamp to this this "within" conditional expression. + */ + public Number getTimeStamp() { + return this.ts; + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public WithinExp apply(Substitution sigma) { + return (WithinExp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public WithinExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public WithinExp standardize(Map<String, String> images) { + return (WithinExp) super.standardize(images); + } + + /** + * Returns <code>true</code> if this "within" conditional expression is + * equal to an other object, i.e., if the object is a not null reference to + * an instance of the class <code>WithinExp</code> and both "within" + * conditional expressions have the same expression and time stamp. + * + * @param obj the object to compare. + * @return <code>true</code> if this "within" conditional expression is + * equal to an other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof WithinExp) { + WithinExp other = (WithinExp) obj; + return super.equals(obj) && this.ts.equals(other.ts); + } + return false; + } + + /** + * Returns the hash code value of this "within" conditional expression. + * + * @return the hash code value of this "within" conditional expression. + */ + public int hashCode() { + return this.getExpID().hashCode() + this.getArg().hashCode() + + this.ts.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public WithinExp clone() { + WithinExp other = (WithinExp) super.clone(); + other.ts = this.ts.clone(); + return other; + } + + /** + * Returns a string representation of this "within" conditional expression. + * + * @return a string representation of this "within" conditional expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(within "); + str.append(this.ts.toString()); + str.append(" "); + str.append(this.getArg().toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this "within" conditional expression. + * + * @return a typed string representation of this "within" conditional expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(within "); + str.append(this.ts.toTypedString()); + str.append(" "); + str.append(this.getArg().toTypedString()); + str.append(")"); + return str.toString(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/package.html b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/package.html new file mode 100644 index 00000000000..a5eb1ae3169 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/cond/package.html @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title></title> + <meta name="Generator" content="Cocoa HTML Writer"> + <meta name="CocoaVersion" content="824.42"> + <style type="text/css"> + p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times} + </style> +</head> +<body> +<p>This package contains the classes relative to conditional expressions of the PDDL language.</p> +</body> +</html> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/Comp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/Comp.java new file mode 100644 index 00000000000..4232cb3d2da --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/Comp.java @@ -0,0 +1,84 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fcomp; + +/** + * This enumeration defined the different kinds of the binary comparaison operator used in PDDL langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public enum Comp { + + /** + * The greater binary comparaison operator. + */ + GREATER(">"), + /** + * The greater or equal binary comparaison operator. + */ + GEQUAL(">="), + /** + * The less binary comparaison operator. + */ + LESS("<"), + /** + * The less or equal binary comparaison operator. + */ + LEQUAL("<="), + /** + * The equal binary comparaison operator. + */ + EQUAL("="); + + /** + * The image of the binary comparaison operator in the PDDL langage. + */ + private String image; + + /** + * Creates a new binary comparaison operator with a specific image. + * + * @param image the image of the the binary comparaison operator in the PDDL langage. + */ + private Comp(String image) { + this.image = image; + } + + /** + * Returns a string representation of this binary comparaison operator. + * + * @return a string representation of this binary comparaison operator. + */ + public String toString() { + return this.image; + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/EqualComp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/EqualComp.java new file mode 100644 index 00000000000..e818673093c --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/EqualComp.java @@ -0,0 +1,173 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fcomp; + +import java.util.Map; +import java.util.LinkedHashMap; + +import pddl4j.EvaluationException; +import pddl4j.exp.InitEl; +import pddl4j.exp.fexp.Number; +import pddl4j.exp.fexp.OpExp; +import pddl4j.exp.term.Constant; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; + +/** + * This class implements the equality comparaison function add of the pddl + * language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class EqualComp extends FCompExp implements InitEl { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -8369304517135857251L; + + /** + * Creates a new empty equality compared function with two arguments. + * + * @param arg1 the first argument of the equality compared function. + * @param arg2 the second argument of the equality compared function. + * @throws NullPointerException if <code>arg1 == null</code> or + * <code>arg2 == null</code>. + */ + public EqualComp(Term arg1, Term arg2) { + super(Comp.EQUAL, arg1, arg2); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public EqualComp apply(Substitution sigma) { + return (EqualComp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public EqualComp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public EqualComp standardize(Map<String, String> images) { + return (EqualComp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public EqualComp clone() { + return (EqualComp) super.clone(); + } + + /** + * Returns <code>true</code> if this compared expression is evaluable. + * In the general case, an compared expression is evaluable if it is + * ground and its arguments are recursively either a number either a + * aritmetic function. In the case of the equality, a compared expression + * is also evaluable if the arguments of the expression are constant + * terms. + * + * @return <code>true</code> if this compared expression is evaluable; + * <code>false</code> otherwise. + */ + public boolean isEvaluable() { + return super.isEvaluable() ? true : + this.getArg1().getTermID().equals(TermID.CONSTANT) + && this.getArg2().getTermID().equals(TermID.CONSTANT); + } + + /** + * Evaluates this compared expression. + * + * @return the result of the evaluation. + * @throws EvaluationException if the compared expression is not ground or + * if an numeric error occurs during the evaluation of an + * numeric error. + * @see pddl4j.exp.fcomp.FCompExp#isEvaluable() + */ + public boolean evaluate() throws EvaluationException { + if (super.isEvaluable()) { + Number op1 = null; + if (this.getArg1().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg1(); + op1 = func.evaluate(); + } else { + op1 = (Number) this.getArg1(); + } + Number op2 = null; + if (this.getArg2().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg2(); + op2 = func.evaluate(); + } else { + op2 = (Number) this.getArg1(); + } + return op1.equals(op2); + } else if (this.getArg1().getTermID().equals(TermID.CONSTANT) + && this.getArg2().getTermID().equals(TermID.CONSTANT)) { + Constant op1 = (Constant) this.getArg1(); + Constant op2 = (Constant) this.getArg2(); + return op1.equals(op2); + } else { + throw new EvaluationException("comparaison function " + + this.toString() + ": is not evaluable"); + } + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/FCompExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/FCompExp.java new file mode 100644 index 00000000000..95156071a36 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/FCompExp.java @@ -0,0 +1,358 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fcomp; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import pddl4j.EvaluationException; +import pddl4j.exp.AbstractExp; +import pddl4j.exp.ExpID; +import pddl4j.exp.fexp.OpExp; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; +import pddl4j.exp.term.Variable; + +/** + * This class implements a compared function. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class FCompExp extends AbstractExp { + + /** + * The binary operator compared of this compared function. + */ + private Comp op; + + /** + * The first argument of the compared function. + */ + private Term arg1; + + /** + * The second argument of the compared function. + */ + private Term arg2; + + /** + * Creates a new compared function. + * + * @param op the compared operator of the function. + * @param arg1 the first argument of the compared function. + * @param arg2 the second argument of the compared function. + * @throws NullPointerException if <code>op == null</code> or arg1 == null</code> + * or <code>arg2 == null</code>. + */ + protected FCompExp(Comp op, Term arg1, Term arg2) { + super(ExpID.F_COMP); + if (op == null || arg1 == null || arg2 == null) + throw new NullPointerException(); + this.op = op; + this.arg1 = arg1; + this.arg2 = arg2; + } + + /** + * Sets a new binary compared operator of this compared function. + * + * @param op the new binary compared operator of this compared + * function. + * @throws NullPointerException if <code>op == null</code>. + */ + public final void setOp(Comp op) { + if (op == null) + throw new NullPointerException(); + this.op = op; + } + + /** + * Returns the binary compared operator of this compared function. + * + * @return the binary compared operator of this compared function. + */ + public final Comp getOp() { + return this.op; + } + + /** + * Sets the first argument of this compared function. + * + * @param arg1 The new first argument of this compared function to set. + * @throws NullPointerException if <code>arg1 == null</code>. + */ + public final void setArg1(Term arg1) { + if (arg1 == null) + throw new NullPointerException(); + this.arg1 = arg1; + } + + /** + * Returns the first argument of the compared function. + * + * @return the first argument of the compared function. + */ + public final Term getArg1() { + return this.arg1; + } + + /** + * Sets the second argument of this compared function. + * + * @param arg - the new second argument of this compared function to set. + * @throws NullPointerException if <code>arg2 == null</code>. + */ + public final void setArg2(Term arg) { + if (arg2 == null) + throw new NullPointerException(); + this.arg2 = arg; + } + + /** + * Returns the second argument of the compared function. + * + * @return the second argument of the compared function. + */ + public final Term getArg2() { + return this.arg2; + } + + /** + * Returns <code>true</code> if a term occurs in this compared + * function. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this compared + * function; <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public final boolean occurs(Term term) { + if (term == null) + throw new NullPointerException(); + return this.arg1.occurs(term) || this.arg2.occurs(term); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public FCompExp apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + FCompExp other = this.clone(); + other.arg1 = this.arg1.apply(sigma); + other.arg2 = this.arg2.apply(sigma); + return other; + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + */ + public FCompExp standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + FCompExp other = this.clone(); + other.arg1 = this.arg1.standardize(images); + other.arg2 = this.arg2.standardize(images); + return other; + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + Set<Variable> vars = new LinkedHashSet<Variable>(); + vars.addAll(this.arg1.getFreeVariables()); + vars.addAll(this.arg2.getFreeVariables()); + return vars; + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + return this.arg1.isGround() && this.arg2.isGround(); + } + + /** + * Evaluates this compared expression. + * + * @return the result of the evaluation. + * @throws EvaluationException if the compared expression is not ground or + * if an numeric error occurs during the evaluation of an + * numeric error. + * @see pddl4j.exp.fcomp.FCompExp#isEvaluable() + */ + public abstract boolean evaluate() throws EvaluationException; + + /** + * Returns <code>true</code> if this compared expression is evaluable. + * In the general case, an compared expression is evaluable if it is + * ground and its arguments are recursively either a number either a + * arithmetic function. In the case of the equality, a compared expression + * is also evaluable if the arguments of the expression are constant + * terms. + * + * @return <code>true</code> if this compared expression is evaluable; + * <code>false</code> otherwise. + */ + public boolean isEvaluable() { + boolean evaluable = this.isGround(); + ArrayList<Term> arguments = new ArrayList<Term>(); + arguments.add(this.arg1); + arguments.add(this.arg2); + Iterator<Term> i = arguments.iterator(); + while (i.hasNext() && evaluable) { + Term arg = i.next(); + if (arg.getTermID().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) arg; + evaluable = func.isEvaluable(); + } else if (arg.getTermID().equals(TermID.NUMBER)) { + evaluable = true; + } else { + evaluable = false; + } + } + return evaluable; + } + + /** + * Returns <code>true</code> if this compared function is + * equals to an other object, i.e., if the object is a not null instance of + * the class <code>FCompExp</code> and both function have the same + * arguments. + * + * @param obj the object to compare. + * @return <code>true</code> if this compared function is + * equals to an other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof FCompExp) { + FCompExp other = (FCompExp) obj; + return super.equals(other) + && this.getOp().equals(other.getOp()) + && this.arg1.equals(other.arg1) + && this.arg2.equals(other.arg2); + } + return false; + } + + /** + * Returns the hash code value of this compared function. + * + * @return the hash code value of this compared function. + */ + public int hashCode() { + return super.hashCode() + this.getOp().hashCode() + + this.arg1.hashCode() + this.arg2.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public FCompExp clone() { + FCompExp other = (FCompExp) super.clone(); + other.arg1 = this.arg1.clone(); + other.arg2 = this.arg2.clone(); + return other; + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public FCompExp toNegativeNormalForm() { + return this.clone(); + } + + /** + * Returns a string representation of this compared function. + * + * @return a string representation of compared function. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("("); + str.append(this.getOp().toString().toLowerCase()); + str.append(" "); + str.append(this.getArg1().toString()); + str.append(" "); + str.append(this.getArg2().toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of compared function. + * + * @return a typed string representation of compared function. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("("); + str.append(this.getOp().toString().toLowerCase()); + str.append(" "); + str.append(this.getArg1().toTypedString()); + str.append(" "); + str.append(this.getArg2().toTypedString()); + str.append(")"); + return str.toString(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/GEqualComp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/GEqualComp.java new file mode 100644 index 00000000000..6dbc7f616a1 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/GEqualComp.java @@ -0,0 +1,168 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fcomp; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.EvaluationException; +import pddl4j.exp.fexp.Number; +import pddl4j.exp.fexp.OpExp; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; + +/** + * This class implements the greater or equal compared function add of the + * pddl language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class GEqualComp extends FCompExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 5536231350872149827L; + + /** + * Creates a new greater or equal compared function with two arguments. + * + * @param arg1 the first argument of the greater or equal compared + * function. + * @param arg2 the second argument of the greater or equal compared + * function. + * @throws NullPointerException if <code>arg1 == null</code> or + * <code>arg2 == null</code>. + */ + public GEqualComp(Term arg1, Term arg2) { + super(Comp.GEQUAL, arg1, arg2); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public GEqualComp apply(Substitution sigma) { + return (GEqualComp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public GEqualComp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public GEqualComp standardize(Map<String, String> images) { + return (GEqualComp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public GEqualComp clone() { + return (GEqualComp) super.clone(); + } + + /** + * Returns <code>true</code> if this compared expression is evaluable. + * In the general case, an compared expression is evaluable if it is + * ground and its arguments are recursively either a number either a + * arithmetic function. In the case of the equality, a compared expression + * is also evaluable if the arguments of the expression are constant + * terms. + * + * @return <code>true</code> if this compared expression is evaluable; + * <code>false</code> otherwise. + */ + public boolean isEvaluable() { + return super.isEvaluable(); + } + + /** + * Evaluates this compared expression. + * + * @return the result of the evaluation. + * @throws EvaluationException if the compared expression is not ground or + * if an numeric error occurs during the evaluation of an + * numeric error. + * @see pddl4j.exp.fcomp.FCompExp#isEvaluable() + */ + public boolean evaluate() throws EvaluationException { + if (this.isEvaluable()) { + Number op1 = null; + if (this.getArg1().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg1(); + op1 = func.evaluate(); + } else { + op1 = (Number) this.getArg1(); + } + Number op2 = null; + if (this.getArg2().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg2(); + op2 = func.evaluate(); + } else { + op2 = (Number) this.getArg1(); + } + return op1.getValue() >= op2.getValue(); + } else { + throw new EvaluationException("comparaison function " + + this.toString() + ": is not evaluable"); + } + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/GreaterComp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/GreaterComp.java new file mode 100644 index 00000000000..e92b2b84d7f --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/GreaterComp.java @@ -0,0 +1,165 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fcomp; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.EvaluationException; +import pddl4j.exp.fexp.Number; +import pddl4j.exp.fexp.OpExp; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; + +/** + * This class implements the greater compared function add of the pddl + * language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class GreaterComp extends FCompExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -478025774168437367L; + + /** + * Creates a new greater compared function with two arguments. + * + * @param arg1 the first argument of the greater compared function. + * @param arg2 the second argument of the greater compared function. + * @throws NullPointerException if <code>arg1 == null</code> or + * <code>arg2 == null</code>. + */ + public GreaterComp(Term arg1, Term arg2) { + super(Comp.GREATER, arg1, arg2); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public GreaterComp apply(Substitution sigma) { + return (GreaterComp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public GreaterComp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public GreaterComp standardize(Map<String, String> images) { + return (GreaterComp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public GreaterComp clone() { + return (GreaterComp) super.clone(); + } + + /** + * Returns <code>true</code> if this comparaison expression is evaluable. + * In the general case, an comparaison expression is evaluable if it is + * ground and its arguments are recursively either a number either a + * aritmetic function. In the case of the equality, a comparaison expression + * is also evaluable if the arguments of the expression are constant + * terms. + * + * @return <code>true</code> if this comparaison expression is evaluable; + * <code>false</code> otherwise. + */ + public boolean isEvaluable() { + return super.isEvaluable(); + } + + /** + * Evaluates this comparaison expression. + * + * @return the result of the evaluation. + * @throws EvaluationException if the comparaison expression is not ground or + * if an numeric error occurs during the evaluation of an + * numeric error. + * @see pddl4j.exp.fcomp.FCompExp#isEvaluable() + */ + public boolean evaluate() throws EvaluationException { + if (this.isEvaluable()) { + Number op1 = null; + if (this.getArg1().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg1(); + op1 = func.evaluate(); + } else { + op1 = (Number) this.getArg1(); + } + Number op2 = null; + if (this.getArg2().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg2(); + op2 = func.evaluate(); + } else { + op2 = (Number) this.getArg1(); + } + return op1.getValue() > op2.getValue(); + } else { + throw new EvaluationException("comparaison function " + + this.toString() + ": is not evaluable"); + } + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/LEqualComp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/LEqualComp.java new file mode 100644 index 00000000000..4dec09389c4 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/LEqualComp.java @@ -0,0 +1,165 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fcomp; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.EvaluationException; +import pddl4j.exp.fexp.Number; +import pddl4j.exp.fexp.OpExp; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; + +/** + * This class implements the less or equal compared function add of the pddl + * language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class LEqualComp extends FCompExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 5536231350872149827L; + + /** + * Creates a new less or equal compared function with two arguments. + * + * @param arg1 the first argument of the less or equal compared function. + * @param arg2 the second argument of the less or equal compared + * @throws NullPointerException if <code>arg1 == null</code> or + * <code>arg2 == null</code>. + */ + public LEqualComp(Term arg1, Term arg2) { + super(Comp.LEQUAL, arg1, arg2); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public LEqualComp apply(Substitution sigma) { + return (LEqualComp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public LEqualComp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public LEqualComp standardize(Map<String, String> images) { + return (LEqualComp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public LEqualComp clone() { + return (LEqualComp) super.clone(); + } + + /** + * Returns <code>true</code> if this compared expression is evaluable. + * In the general case, an compared expression is evaluable if it is + * ground and its arguments are recursively either a number either a + * arithmetic function. In the case of the equality, a compared expression + * is also evaluable if the arguments of the expression are constant + * terms. + * + * @return <code>true</code> if this compared expression is evaluable; + * <code>false</code> otherwise. + */ + public boolean isEvaluable() { + return super.isEvaluable(); + } + + /** + * Evaluates this compared expression. + * + * @return the result of the evaluation. + * @throws EvaluationException if the compared expression is not ground or + * if an numeric error occurs during the evaluation of an + * numeric error. + * @see pddl4j.exp.fcomp.FCompExp#isEvaluable() + */ + public boolean evaluate() throws EvaluationException { + if (this.isEvaluable()) { + Number op1 = null; + if (this.getArg1().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg1(); + op1 = func.evaluate(); + } else { + op1 = (Number) this.getArg1(); + } + Number op2 = null; + if (this.getArg2().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg2(); + op2 = func.evaluate(); + } else { + op2 = (Number) this.getArg1(); + } + return op1.getValue() <= op2.getValue(); + } else { + throw new EvaluationException("comparaison function " + + this.toString() + ": is not evaluable"); + } + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/LessComp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/LessComp.java new file mode 100644 index 00000000000..b788a319022 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/LessComp.java @@ -0,0 +1,165 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fcomp; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.EvaluationException; +import pddl4j.exp.fexp.Number; +import pddl4j.exp.fexp.OpExp; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; + +/** + * This class implements the less compared function add of the pddl language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class LessComp extends FCompExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 3352652575004530974L; + + /** + * Creates a new less compared function with two arguments. + * + * @param arg1 the first argument of the less compared function. + * @param arg2 the second argument of the less compared function. + * @throws NullPointerException if <code>arg1 == null</code> or + * <code>arg2 == null</code>. + */ + public LessComp(Term arg1, Term arg2) { + super(Comp.LESS, arg1, arg2); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public LessComp apply(Substitution sigma) { + return (LessComp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public LessComp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public LessComp standardize(Map<String, String> images) { + return (LessComp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public LessComp clone() { + return (LessComp) super.clone(); + } + + /** + * Returns <code>true</code> if this compared expression is evaluable. + * In the general case, an compared expression is evaluable if it is + * ground and its arguments are recursively either a number either a + * arithmetic function. In the case of the equality, a compared expression + * is also evaluable if the arguments of the expression are constant + * terms. + * + * @return <code>true</code> if this compared expression is evaluable; + * <code>false</code> otherwise. + */ + public boolean isEvaluable() { + return super.isEvaluable(); + } + + /** + * Evaluates this compared expression. + * + * @return the result of the evaluation. + * @throws EvaluationException if the compared expression is not ground or + * if an numeric error occurs during the evaluation of an + * numeric error.` + * @see pddl4j.exp.fcomp.FCompExp#isEvaluable() + */ + public boolean evaluate() throws EvaluationException { + if (this.isEvaluable()) { + Number op1 = null; + if (this.getArg1().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg1(); + op1 = func.evaluate(); + } else { + op1 = (Number) this.getArg1(); + } + Number op2 = null; + if (this.getArg2().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg2(); + op2 = func.evaluate(); + } else { + op2 = (Number) this.getArg1(); + } + return op1.getValue() < op2.getValue(); + } else { + throw new EvaluationException("comparaison function " + + this.toString() + ": is not evaluable"); + } + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/package.html b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/package.html new file mode 100644 index 00000000000..8e2f83001cc --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fcomp/package.html @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title></title> + <meta name="Generator" content="Cocoa HTML Writer"> + <meta name="CocoaVersion" content="824.42"> + <style type="text/css"> + p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times} + </style> +</head> +<body> +<p>This package contains the classes relative to compared functions expressions of the PDDL language.</p> +</body> +</html> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryAdd.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryAdd.java new file mode 100644 index 00000000000..6e6e97dbf29 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryAdd.java @@ -0,0 +1,114 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fexp; + +import pddl4j.EvaluationException; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; + +/** + * This class implements the add arithmetic function. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class BinaryAdd extends BinaryOp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -7132824733656820244L; + + /** + * Creates a new add arithmetic function with two specified arguments. + * + * @param arg1 the first argument of the add function. + * @param arg2 the second argument of the add function. + * @throws NullPointerException if <code>arg1 == null</code> or + * <code>arg2 == null</code>. + */ + public BinaryAdd(Term arg1, Term arg2) { + super(Op.ADD, arg1, arg2); + } + + /** + * Return a deep copy of this binary add arithmetic function. + * + * @return a deep copy of this binary add arithmetic function. + * @see pddl4j.exp.term.Term#clone() + */ + public BinaryAdd clone() { + return (BinaryAdd) super.clone(); + } + + /** + * Evaluates this binary add arithmetic function. + * + * @return the result of the evaluation. + * @throws EvaluationException if the function is not evaluable or if an + * arithmetic error occurs during the evaluation. + * @see pddl4j.exp.fexp.OpExp#isEvaluable() + */ + public Number evaluate() throws EvaluationException { + if (!this.isGround()) + throw new EvaluationException("arithmetic function " + + this.toString() + " not ground"); + try { + Number arg1 = null; + if (this.getArg1().getTermID().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg1(); + arg1 = func.evaluate(); + } else if (this.getArg1().getTermID().equals(TermID.NUMBER)) { + arg1 = (Number) this.getArg1(); + } else { + throw new EvaluationException("arithmetic function " + + this.toString() + ": argument " + this.getArg1() + + " is not evaluable"); + } + Number arg2 = null; + if (this.getArg2().getTermID().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg2(); + arg2 = func.evaluate(); + } else if (this.getArg2().getTermID().equals(TermID.NUMBER)) { + arg2 = (Number) this.getArg2(); + } else { + throw new EvaluationException("arithmetic function " + + this.toString() + ": argument " + this.getArg2() + + " is not evaluable"); + } + return new Number(arg1.getValue() + arg2.getValue()); + } catch (ArithmeticException e) { + throw new EvaluationException("arithmetic function " + + this.toString() + ": " + e.getMessage(), e); + } + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryDivide.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryDivide.java new file mode 100644 index 00000000000..bc730552be7 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryDivide.java @@ -0,0 +1,114 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fexp; + +import pddl4j.EvaluationException; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; + +/** + * This class implements the divide arithmetic function. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class BinaryDivide extends BinaryOp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 8265356137201795002L; + + /** + * Creates a new divide arithmetic function with two arguments. + * + * @param arg1 the first argument of the divide function. + * @param arg2 the second argument of the divide function. + * @throws NullPointerException if <code>arg1 == null</code> or + * <code>arg2 == null</code>. + */ + public BinaryDivide(Term arg1, Term arg2) { + super(Op.DIVIDE, arg1, arg2); + } + + /** + * Return a deep copy of this binary divide arithmetic function. + * + * @return a deep copy of this binary divide arithmetic function. + * @see pddl4j.exp.term.Term#clone() + */ + public BinaryDivide clone() { + return (BinaryDivide) super.clone(); + } + + /** + * Evaluates this binary divide arithmetic function. + * + * @return the result of the evaluation. + * @throws EvaluationException if the function is not evaluable or if an + * arithmetic error occurs during the evaluation. + * @see pddl4j.exp.fexp.OpExp#isEvaluable() + */ + public Number evaluate() throws EvaluationException { + if (!this.isGround()) + throw new EvaluationException("arithmetic function " + + this.toString() + " not ground"); + try { + Number arg1 = null; + if (this.getArg1().getTermID().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg1(); + arg1 = func.evaluate(); + } else if (this.getArg1().getTermID().equals(TermID.NUMBER)) { + arg1 = (Number) this.getArg1(); + } else { + throw new EvaluationException("arithmetic function " + + this.toString() + ": argument " + this.getArg1() + + " is not evaluable"); + } + Number arg2 = null; + if (this.getArg2().getTermID().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg2(); + arg2 = func.evaluate(); + } else if (this.getArg2().getTermID().equals(TermID.NUMBER)) { + arg2 = (Number) this.getArg2(); + } else { + throw new EvaluationException("arithmetic function " + + this.toString() + ": argument " + this.getArg2() + + " is not evaluable"); + } + return new Number(arg1.getValue() / arg2.getValue()); + } catch (ArithmeticException e) { + throw new EvaluationException("arithmetic function " + + this.toString() + ": " + e.getMessage(), e); + } + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryMultiply.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryMultiply.java new file mode 100644 index 00000000000..41ecc924e30 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryMultiply.java @@ -0,0 +1,114 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fexp; + +import pddl4j.EvaluationException; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; + +/** + * This class implements the numeric operation multiply of the pddl langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class BinaryMultiply extends BinaryOp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 7717661917841761928L; + + /** + * Creates a new multiply numeric operation with two arguements. + * + * @param arg1 the first argument of the multiply operation. The arguement + * must be a not null reference. + * @param arg2 the second argument of the multiply operation. The arguement + * must be a not null reference. + */ + public BinaryMultiply(final Term arg1, final Term arg2) { + super(Op.MULTIPLY, arg1, arg2); + } + + /** + * Return a deep copy of this binary operation. + * + * @return a deep copy of this binary operation. + * @see pddl4j.exp.term.Term#clone() + */ + public BinaryMultiply clone() { + return (BinaryMultiply) super.clone(); + } + + /** + * Evaluates this binary multiply arithmetic expression. + * + * @return the result of the evaluation. + * @throws EvaluationException if the function is not evaluable or if an + * arithmetic error occurs during the evaluation. + * @see pddl4j.exp.fexp.OpExp#isEvaluable() + */ + public Number evaluate() throws EvaluationException { + if (!this.isGround()) + throw new EvaluationException("arithmetic function " + + this.toString() + " not ground"); + try { + Number arg1 = null; + if (this.getArg1().getTermID().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg1(); + arg1 = func.evaluate(); + } else if (this.getArg1().getTermID().equals(TermID.NUMBER)) { + arg1 = (Number) this.getArg1(); + } else { + throw new EvaluationException("arithmetic function " + + this.toString() + ": argument " + this.getArg1() + + " is not evaluable"); + } + Number arg2 = null; + if (this.getArg2().getTermID().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg2(); + arg2 = func.evaluate(); + } else if (this.getArg2().getTermID().equals(TermID.NUMBER)) { + arg2 = (Number) this.getArg2(); + } else { + throw new EvaluationException("arithmetic function " + + this.toString() + ": argument " + this.getArg2() + + " is not evaluable"); + } + return new Number(arg1.getValue() * arg2.getValue()); + } catch (ArithmeticException e) { + throw new EvaluationException("arithmetic function " + + this.toString() + ": " + e.getMessage(), e); + } + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryOp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryOp.java new file mode 100644 index 00000000000..9d3bd298267 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinaryOp.java @@ -0,0 +1,96 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fexp; + +import pddl4j.exp.term.Term; + +/** + * This class implements an binary arithmetic function. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class BinaryOp extends OpExp { + + /** + * Creates a new binary arithemtic function with a specified operator and two arguments. + * + * @param op The arthemitic operator of the function. + * @param arg1 The first argument of the function. + * @param arg2 The second argument of the function. + * @throws NullPointerException if <code>arg1 == null</code> or + * <code>arg2 == null</code>. + */ + protected BinaryOp(Op op, Term arg1, Term arg2) { + super(op); + super.add(arg1); + super.add(arg2); + } + + /** + * Sets the fisrt argument of this arithmetic operation. + * + * @param arg1 the new fisrt argument of this arithmetic function. + * @throws NullPointerException if <code>arg1 == null</code>. + */ + public final void setArg1(Term arg1) { + super.set(0, arg1); + } + + /** + * Returns the fisrt argument of the arithmetic operation. + * + * @return the fisrt argument of the arithmetic operation. + */ + public final Term getArg1() { + return super.get(0); + } + + /** + * Sets the second argument of this arithmetic operation. + * + * @param arg2 the new second argument of this arithmetic function. + * @throws NullPointerException if <code>arg2 == null</code>. + */ + public final void setArg2(Term arg2) { + super.set(1, arg2); + } + + /** + * Returns the second argument of the arithmetic function. + * + * @return the second argument of the arithmetic function. + */ + public final Term getArg2() { + return super.get(1); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinarySubstract.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinarySubstract.java new file mode 100644 index 00000000000..b9fd2d3382f --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/BinarySubstract.java @@ -0,0 +1,113 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fexp; + +import pddl4j.EvaluationException; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; + +/** + * This class implements the numeric operation substract of the pddl langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class BinarySubstract extends BinaryOp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 7499736600667370526L; + + /** + * Creates a new substract numeric operation with two arguements. + * + * @param arg1 the first argument of the substract operation. The arguement + * must be a not null reference. + * @param arg2 the second argument of the substract operation. The arguement + * must be a not null reference. + */ + public BinarySubstract(Term arg1, Term arg2) { + super(Op.SUBSTRACT, arg1, arg2); + } + + /** + * Return a deep copy of this binary operation. + * + * @return a deep copy of this binary operation. + * @see pddl4j.exp.term.Term#clone() + */ + public BinarySubstract clone() { + return (BinarySubstract) super.clone(); + } + + /** + * Evaluates this binary substract arithmetic expression. + * + * @return the result of the evaluation. + * @throws EvaluationException if the function is not evaluable or if an + * arithmetic error occurs during the evaluation. + * @see pddl4j.exp.fexp.OpExp#isEvaluable() + */ + public Number evaluate() throws EvaluationException { + if (!this.isGround()) + throw new EvaluationException("arithmetic function " + + this.toString() + " not ground"); + try { + Number arg1 = null; + if (this.getArg1().getTermID().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg1(); + arg1 = func.evaluate(); + } else if (this.getArg1().getTermID().equals(TermID.NUMBER)) { + arg1 = (Number) this.getArg1(); + } else { + throw new EvaluationException("arithmetic function " + + this.toString() + ": argument " + this.getArg1() + + " is not evaluable"); + } + Number arg2 = null; + if (this.getArg2().getTermID().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) this.getArg2(); + arg2 = func.evaluate(); + } else if (this.getArg2().getTermID().equals(TermID.NUMBER)) { + arg2 = (Number) this.getArg2(); + } else { + throw new EvaluationException("arithmetic function " + + this.toString() + ": argument " + this.getArg2() + + " is not evaluable"); + } + return new Number(arg1.getValue() - arg2.getValue()); + } catch (ArithmeticException e) { + throw new EvaluationException("arithmetic function " + + this.toString() + ": " + e.getMessage(), e); + } + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/FExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/FExp.java new file mode 100644 index 00000000000..cb540b60b17 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/FExp.java @@ -0,0 +1,394 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fexp; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import pddl4j.EvaluationException; +import pddl4j.exp.term.AbstractTerm; +import pddl4j.exp.term.BindingException; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; +import pddl4j.exp.term.Variable; +import pddl4j.exp.type.TypeSet; + +/** + * This class implements a function expression in the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class FExp extends AbstractTerm implements Iterable<Term> { + + /** + * The serial version id of this class. + */ + private static final long serialVersionUID = -2343417682285770327L; + + /** + * The list of the arguments of this function head. + */ + private ArrayList<Term> arguments; + + /** + * Create an empty function with a specific functor. + * + * @param id the term id of this function. + * @param functor The function functor. + * @throws NullPointerException if <code>id == null</code> or + * <code>functor == null</code> or <code>type == null</code>. + */ + protected FExp(TermID id, String functor) { + super(id, functor); + this.arguments = new ArrayList<Term>(); + } + + /** + * Create an empty function with a specific functor. + * + * @param id the term id of this function. + * @param functor The function functor. + * @param type the type of this function. + * @throws NullPointerException if <code>id == null</code> or + * <code>functor == null</code> or <code>type == null</code>. + */ + protected FExp(TermID id, String functor, TypeSet type) { + super(id, functor, type); + this.arguments = new ArrayList<Term>(); + } + + /** + * Adds a new argument to this function. + * + * @param arg The argument to add. + * @return <code>true</code> if the arg was added; <code>false</code> + * otherwise. + * @throws NullPointerException if <code>arg == null</code>. + */ + protected boolean add(Term arg) { + return this.arguments.add(arg); + } + + /** + * Returns the argument at the specified position in this function. + * + * @param index index of the argument to return. + * @return the argument at the specified position in this function. + * @throws IndexOutOfBoundsException if the index is out of range + * (<code>index < 0 || index >= getArity()</code>). + */ + protected Term get(int index) { + return this.arguments.get(index); + } + + /** + * Replaces the argument at the specified position in this function with the + * specified term. + * + * @param index index of the argument to replace. + * @param arg argument to be stored at the specified position. + * @return the argument previously at the specified position. + * @throws IndexOutOfBoundsException if the index is out of range (<code>index < 0 || index >= getArity()</code>). + * @throws NullPointerException if <code>arg == null</code>. + */ + protected Term set(int index, Term arg) { + return this.arguments.set(index, arg); + } + + /** + * Returns the arity of this function. + * + * @return the arity of this function. + */ + public final int getArity() { + return this.arguments.size(); + } + + /** + * Returns <code>true</code> if a expression occurs in this function. + * + * @param term the term to be tested. + * @return <code>true</code> if a expression occurs in this function; + * <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public final boolean occurs(Term term) { + if (term == null) + throw new NullPointerException(); + boolean occurs = false; + Iterator<Term> i = this.iterator(); + while (i.hasNext() && !occurs) { + occurs = i.next().occurs(term); + } + return occurs; + } + + /** + * Returns <code>true</code> if this function expression is ground. + * + * @return <code>true</code> if this function expression is ground; + * <code>false</code> otherwise. + */ + public final boolean isGround() { + boolean ground = true; + Iterator<Term> i = this.iterator(); + while (i.hasNext() && ground) { + ground = i.next().isGround(); + } + return ground; + } + + /** + * Substitutes all occurrences of the variables that occur in this term and + * that are bound in the substitution by its binding term. This method + * modify the content of the term on which it is applied. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + * @throws EvaluationException if a ground arithmetic function occurs in + * this function expression and its evaluation fails. + */ + public Term apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + FExp other = this.clone(); + other.arguments.clear(); + for (Term arg : this.arguments) { + other.add(arg.apply(sigma)); + } + return other; + } + + /** + * Standardizes this function expression. Remember that free variables are + * existentially quantified. + * + * @return a standardized copy of this expression. + */ + public FExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized.Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + */ + public FExp standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + FExp other = this.clone(); + other.arguments.clear(); + for (Term arg : this.arguments) { + other.add(arg.standardize(images)); + } + return other; + } + + /** + * Returns an iterator over a set of arguments contained in this function. + * + * @return an iterator over a set of arguments contained in this function. + */ + public final Iterator<Term> iterator() { + return this.arguments.iterator(); + } + + /** + * Unify this term with an other specified term. Note, call unify does not modify + * the parameters of this method. + * + * @param term the term to unify with. + * @return The substitution that defines the binding constraints needed to + * unify this term with the other term or <code>null</code> if no + * binding constraints allows to unify the two terms. + * @see pddl4j.exp.term.Term#unify(Term, Substitution) + * @throws BindingException if the term to unify with this function is a + * function with the same symbol and the same arity and has an + * incompatible type, i.e., + * <code>!this.getTypeSet().getSubTypes().containsAll(term.getTypeSet().getSubTypes())</code>. + */ + public final Substitution unify(Term term) { + return this.unify(term, new Substitution()); + } + + /** + * Unify this term with an other specified term by taking into account a + * specified set of binding constraints. Note, call unify does not modify + * the parameters of this method. + * + * @param term the term to unify with. + * @param sigma the substitution containing the binding constraints. + * @return The substitution that defines the binding constraints needed to + * unify this term with the other term or <code>null</code> if no + * binding constraints allows to unify the two terms. + * @throws BindingException if the term to unify with this function is a + * function with the same symbol and the same arity and has an + * incompatible type, i.e., + * <code>!this.getTypeSet().getSubTypes().containsAll(term.getTypeSet().getSubTypes())</code>. + */ + public final Substitution unify(Term term, Substitution sigma) { + if (term.getTermID().equals(TermID.VARIABLE)) { + return term.unify(this, sigma); + } else { + FExp func = (FExp) term; + if (func.getImage().equals(this.getImage()) + && func.getArity() == this.getArity()) { + if (this.getTypeSet().getSubTypes().containsAll( + func.getTypeSet().getSubTypes())) { + Substitution theta = sigma.clone(); + int i = 0; + boolean failure = false; + while (i < this.getArity() && !failure) { + Term tthis = this.arguments.get(i); + Term tother = func.arguments.get(i); + Substitution gamma = tthis.unify(tother, theta); + if (gamma == null) { + failure = true; + } else { + theta.compose(gamma); + } + i++; + } + return failure ? null : theta; + } else { + throw new BindingException("cannot bind " + + this.toTypedString() + " with " + + term.toTypedString() + ": imcompatible type"); + } + } + } + return null; + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + Set<Variable> vars = new LinkedHashSet<Variable>(); + for (Term arg : this) { + vars.addAll(arg.getFreeVariables()); + } + return vars; + } + + /** + * Returns <code>true</code> if this function is equals to an other + * object, i.e., if the object is a not null instance of the class + * <code>FExp</code> and both function have the same functor and the + * same arguments. + * + * @param obj the object to compare. + * @return <code>true</code> if this function head is equals to an other + * object; <code>false</code> otherwise. + */ + public boolean equals(final Object obj) { + if (obj != null && obj instanceof FExp) { + final FExp other = (FExp) obj; + return super.equals(obj) && this.arguments.equals(other.arguments); + } + return false; + } + + /** + * Returns the hash code value of this function head. + * + * @return the hash code value of this function head. + */ + public int hashCode() { + return super.hashCode() + this.arguments.hashCode(); + } + + /** + * Return a deep copy of this function. + * + * @return a deep copy of this function. + * @see pddl4j.exp.term.AbstractTerm#clone() + */ + public FExp clone() { + FExp other = (FExp) super.clone(); + other.arguments = new ArrayList<Term>(); + for (Term arg : this.arguments) { + other.arguments.add(arg.clone()); + } + return other; + } + + /** + * Returns a string representation of this function. + * + * @return a string representation of this function + */ + public String toString() { + final StringBuilder str = new StringBuilder(); + str.append("("); + str.append(this.getImage().toString()); + for (Term t : this.arguments) { + str.append(" " + t.toString()); + } + str.append(")"); + return str.toString(); + } + + /** + * Returns typed string representation of this function. + * + * @return typed string representation of this function. + */ + public String toTypedString() { + final StringBuilder str = new StringBuilder(); + str.append("("); + str.append(this.getImage()); + for (Term t : this.arguments) { + str.append(" " + t.toTypedString()); + } + str.append(")"); + str.append(" - "); + str.append(this.getTypeSet().toString()); + return str.toString(); + } + + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/FHead.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/FHead.java new file mode 100644 index 00000000000..642374998ba --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/FHead.java @@ -0,0 +1,144 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fexp; + +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; +import pddl4j.exp.type.Type; +import pddl4j.exp.type.TypeSet; + +/** + * This class implements a function head of the PDDL langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class FHead extends FExp { + + /** + * The serial version id of this class. + */ + private static final long serialVersionUID = -2343417682285770327L; + + /** + * Create an empty function head with a specific functor. + * + * @param functor the function functor. + * @param type the type of this function. + * @throws NullPointerException if <code>functor == null</code> or + * <code>type == null</code>. + */ + public FHead(String functor, TypeSet type) { + super(TermID.FUNCTION, functor, type); + } + + /** + * Create an empty function head with a specific functor. + * + * @param functor the function functor. + * @param type the type of this function head. + * @throws NullPointerException if <code>functor == null</code> + */ + public FHead(String functor, Type type) { + super(TermID.FUNCTION, functor, new TypeSet(type)); + } + + /** + * Adds a new argument to this function. + * + * @param arg The argument to add. + * @return <code>true</code> if the arg was added; <code>false</code> + * otherwise. + * @throws NullPointerException if <code>arg == null</code>. + */ + public boolean add(Term arg) { + return super.add(arg); + } + + /** + * Returns the argument at the specified position in this function. + * + * @param index index of the argument to return. + * @return the argument at the specified position in this function. + * @throws IndexOutOfBoundsException if the index is out of range + * (<code>index < 0 || index >= getArity()</code>). + */ + public Term get(int index) { + return super.get(index); + } + + /** + * Replaces the argument at the specified position in this function with the + * specified term. + * + * @param index index of the argument to replace. + * @param arg argument to be stored at the specified position. + * @return the argument previously at the specified position. + * @throws IndexOutOfBoundsException if the index is out of range (<code>index < 0</code> + * or <code>index >= getArity()</code>). + * @throws NullPointerException if <code>arg == null</code>. + */ + public Term set(int index, Term arg) { + return super.set(index, arg); + } + + /** + * Sets a new type of this function. + * + * @param type the type to set. + * @throws NullPointerException if <code>type == null</code>. + */ + public void setTypeSet(TypeSet type) { + super.setTypeSet(type); + } + + + /** + * Standardizes all occurences of the variables that occur in this + * term. + * + * @return this term. + */ + public FHead standardize() { + return (FHead) super.standardize(); + } + + /** + * Returns a deep copy of this arithmetic function. + * + * @return a deep copy of this arithmetic function. + * @see pddl4j.exp.AbstractExp#clone() + */ + public FHead clone() { + return (FHead) super.clone(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/NArityAdd.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/NArityAdd.java new file mode 100644 index 00000000000..56e4608dbf5 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/NArityAdd.java @@ -0,0 +1,100 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fexp; + +import pddl4j.EvaluationException; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; + +/** + * This class implements the n-arity arithmetic function add. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class NArityAdd extends NArityOp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 2899553544531715200L; + + /** + * Creates a new divide numeric function without arguments. + */ + public NArityAdd() { + super(Op.ADD); + } + + /** + * Return a deep copy of this function. + * + * @return a shallow copy of this function. + * @see pddl4j.exp.term.AbstractTerm#clone() + */ + public NArityAdd clone() { + return (NArityAdd) super.clone(); + } + + /** + * Evaluates this add arithmetic expression. + * + * @return the result of the evaluation. + * @throws EvaluationException if the function is not evaluable or if an + * arithmetic error occurs during the evaluation. + * @see pddl4j.exp.fexp.OpExp#isEvaluable() + */ + public Number evaluate() throws EvaluationException { + if (!this.isGround()) + throw new EvaluationException("arithmetic function " + + this.toString() + " not ground"); + try { + double result = 0; + for (Term arg : this) { + if (arg.getTermID().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) arg; + result += func.evaluate().getValue(); + } else if (arg.getTermID().equals(TermID.NUMBER)) { + result += ((Number) arg).getValue(); + } else { + throw new EvaluationException("arithmetic function " + + this.toString() + ": argument " + arg + + " is not evaluable"); + } + } + return new Number(result); + } catch (ArithmeticException e) { + throw new EvaluationException("arithmetic function " + + this.toString() + ": " + e.getMessage(), e); + } + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/NArityMultiply.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/NArityMultiply.java new file mode 100644 index 00000000000..d495e6f0383 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/NArityMultiply.java @@ -0,0 +1,100 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fexp; + +import pddl4j.EvaluationException; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; + +/** + * This class implements the n-arity arithmetic function multiply. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class NArityMultiply extends NArityOp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 2899553544531715200L; + + /** + * Creates a new divide numeric function without arguments. + */ + public NArityMultiply() { + super(Op.MULTIPLY); + } + + /** + * Return a deep copy of this function. + * + * @return a deep copy of this function. + * @see pddl4j.exp.term.Term#clone() + */ + public NArityMultiply clone() { + return (NArityMultiply) super.clone(); + } + + /** + * Evaluates this multiply arithmetic expression. + * + * @return the result of the evaluation. + * @throws EvaluationException if the function is not evaluable or if an + * arithmetic error occurs during the evaluation. + * @see pddl4j.exp.fexp.OpExp#isEvaluable() + */ + public Number evaluate() throws EvaluationException { + if (!this.isGround()) + throw new EvaluationException("arithmetic function " + + this.toString() + " not ground"); + try { + double result = 1; + for (Term arg : this) { + if (arg.getTermID().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) arg; + result *= func.evaluate().getValue(); + } else if (arg.getTermID().equals(TermID.NUMBER)) { + result *= ((Number) arg).getValue(); + } else { + throw new EvaluationException("arithmetic function " + + this.toString() + ": argument " + arg + + " is not evaluable"); + } + } + return new Number(result); + } catch (ArithmeticException e) { + throw new EvaluationException("arithmetic function " + + this.toString() + ": " + e.getMessage(), e); + } + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/NArityOp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/NArityOp.java new file mode 100644 index 00000000000..a207ed08135 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/NArityOp.java @@ -0,0 +1,91 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fexp; + +import pddl4j.exp.term.Term; + +/** + * This class implements an numeric function od arity n of the PDDL langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class NArityOp extends OpExp { + + /** + * Creates a new arithmetic expression. + * + * @param op the arithmetic operator. + * @throws NullPointerException if <code>op == null</code>. + */ + protected NArityOp(Op op) { + super(op); + } + + /** + * Adds a new argument to this function. + * + * @param arg The argument to add. + * @return <code>true</code> if the arg was added; <code>false</code> + * otherwise. + * @throws NullPointerException if <code>arg == null</code>. + */ + public final boolean add(Term arg) { + return super.add(arg); + } + + /** + * Returns the argument at the specified position in this function. + * + * @param index index of the argument to return. + * @return the argument at the specified position in this function. + * @throws IndexOutOfBoundsException if the index is out of range + * (<code>index < 0 || index >= getArity()</code>). + */ + public final Term get(int index) { + return super.get(index); + } + + /** + * Replaces the argument at the specified position in this function with the + * specified term. + * + * @param index index of the argument to replace. + * @param arg argument to be stored at the specified position. + * @return the argument previously at the specified position. + * @throws IndexOutOfBoundsException if the index is out of range + * (<code>index < 0 || index >= getArity()</code>). + * @throws NullPointerException if <code>arg == null</code>. + */ + public final Term set(int index, Term arg) { + return super.set(index, arg); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/Number.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/Number.java new file mode 100644 index 00000000000..6ade360dafa --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/Number.java @@ -0,0 +1,146 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fexp; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.exp.term.TermID; +import pddl4j.exp.type.Type; +import pddl4j.exp.type.TypeSet; + +/** + * This class implements a number in the PDDL langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class Number extends FExp implements Comparable<Number> { + + /** + * The serial version id of this class. + */ + private static final long serialVersionUID = 6081884046144807572L; + + /** + * Create a new number with a specific value. + * + * @param value the value set to this number. + */ + public Number(double value) { + super(TermID.NUMBER, String.valueOf(value), new TypeSet(Type.NUMBER)); + } + + /** + * Create a new number with a default value set to 0.0. + */ + public Number() { + this(0.0); + } + + /** + * Returns the double value of this number. + * + * @return the double value of this number. + * @throws NumberFormatException if the constant is not numeric. + */ + public double getValue() { + return Double.parseDouble(this.getImage()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public Number standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public Number standardize(Map<String, String> images) { + return (Number) super.standardize(images); + } + + /** + * Compares this number with the specified number for order. Returns a + * negative integer, zero, or a positive integer as this number is less + * than, equal to, or greater than the specified number. + * + * @param num the number to be compared. + * @return a negative integer, zero, or a positive integer as this number is + * less than, equal to, or greater than the specified object. + */ + public int compareTo(Number num) { + return new Double(this.getValue()).compareTo(new Double(num.getValue())); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public Number clone() { + return (Number) super.clone(); + } + + /** + * Returns a string representation of this number. + * + * @return a string representation of this number. + */ + public String toString() { + return this.getImage(); + } + + /** + * Returns a types string representation of this number. + * + * @return a typed string representation of this number. + */ + public String toTypedString() { + return this.getImage() + " - " + this.getTypeSet(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/Op.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/Op.java new file mode 100644 index 00000000000..50b17f79d09 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/Op.java @@ -0,0 +1,79 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fexp; + +/** + * This enumeration defines the different operator of the PDDL langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public enum Op { + /** + * The add operator. + */ + ADD("+"), + /** + * The substract operator. + */ + SUBSTRACT("-"), + /** + * The multiply operator. + */ + MULTIPLY("*"), + /** + * The divide operator. + */ + DIVIDE("/"); + + /** + * The image of the operator of the PDDL langage. + */ + private String image; + + /** + * Creates a new operator with a specific image. + * + * @param image the image of the the operator in the PDDL langage. + */ + private Op(String image) { + this.image = image; + } + + /** + * Returns a string representation of this operator. + * + * @return a string representation of this operator. + */ + public String toString() { + return this.image; + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/OpExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/OpExp.java new file mode 100644 index 00000000000..f3b4e7718ee --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/OpExp.java @@ -0,0 +1,148 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.fexp; + +import java.util.Iterator; + +import pddl4j.EvaluationException; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.TermID; +import pddl4j.exp.type.Type; +import pddl4j.exp.type.TypeSet; + +/** + * This class implements an arithmetic function. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class OpExp extends FExp { + + /** + * The operator of this arithmetic function. + */ + private Op op; + + /** + * Creates a new arithmetic function with a specified operator. + * + * @param op The arithmetic operator of the function. + * @throws NullPointerException if <code>op == null</code>. + */ + protected OpExp(Op op) { + super(TermID.ARITHMETIC_FUNCTION, op.toString(), new TypeSet(Type.NUMBER)); + this.setOp(op); + } + + /** + * Returns the operator of this arithmetic function. + * + * @return the operator of this arithmetic function. + */ + public final Op getOp() { + return this.op; + } + + /** + * Sets a new operator to this arithmetic function. + * + * @param op the new op to set. + * @throws NullPointerException if <code>op == null</code. + */ + protected void setOp(Op op) { + if (op == null) + throw new NullPointerException(); + this.op = op; + } + + /** + * Returns a deep copy of this arithmetic function. + * + * @return a deep copy of this arithmetic function. + * @see pddl4j.exp.AbstractExp#clone() + */ + public OpExp clone() { + return (OpExp) super.clone(); + } + + /** + * Substitutes all occurrences of the variables that occur in this term and + * that are bound in the substitution by its binding term. This method + * modify the content of the term on which it is applied. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + * @throws EvaluationException if this arithmetic function is ground after + * applying the substitution and its evaluation fails. + */ + public Term apply(Substitution sigma) { + OpExp other = (OpExp) super.apply(sigma); + return other.isEvaluable() ? other.evaluate() : other; + } + + /** + * Returns <code>true</code> if this arithmetic function is evaluable. + * Specially, an arithmetic function is evaluable if it is gound and its + * arguments are recursively either a number either a aritmetic function. + * + * @return <code>true</code> if this arithmetic function is evaluable; + * <code>false</code> otherwise. + */ + public final boolean isEvaluable() { + boolean evaluable = this.isGround(); + Iterator<Term> i = this.iterator(); + while (i.hasNext() && evaluable) { + Term arg = i.next(); + if (arg.getTermID().equals(TermID.ARITHMETIC_FUNCTION)) { + OpExp func = (OpExp) arg; + evaluable = func.isEvaluable(); + } else if (arg.getTermID().equals(TermID.NUMBER)) { + evaluable = true; + } else { + evaluable = false; + } + } + return evaluable; + } + + /** + * Evaluates this arithmetic expression. + * + * @return the result of the evaluation. + * @throws EvaluationException if the arithemtic expression is not ground or + * if an numeric error occurs during the evaluation of an + * numeric error. + */ + public abstract Number evaluate() throws EvaluationException; + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/package.html b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/package.html new file mode 100644 index 00000000000..75b38d40ba1 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/fexp/package.html @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title></title> + <meta name="Generator" content="Cocoa HTML Writer"> + <meta name="CocoaVersion" content="824.42"> + <style type="text/css"> + p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times} + </style> +</head> +<body> +<p>This package contains the classes relative to functions expressions of the PDDL langage.</p> +</body> +</html> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/MaximizeExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/MaximizeExp.java new file mode 100644 index 00000000000..9505fc1df03 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/MaximizeExp.java @@ -0,0 +1,112 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.metric; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; + +/** + * This class defines the maximize expression used in metric + * specification of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class MaximizeExp extends MetricExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 4996915242134602557L; + + /** + * Creates a new maximize expression. + * + * @param exp the term expression to maximize. + * @throws NullPointerException if <code>exp == null</code>. + */ + public MaximizeExp(Term exp) { + super(Optimization.MAXIMIZE, exp); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public MaximizeExp apply(Substitution sigma) { + return (MaximizeExp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public MaximizeExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public MaximizeExp standardize(Map<String, String> images) { + return (MaximizeExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public MaximizeExp clone() { + return (MaximizeExp) super.clone(); + } +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/MetricExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/MetricExp.java new file mode 100644 index 00000000000..9b1ae08d94e --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/MetricExp.java @@ -0,0 +1,247 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.metric; + +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.AbstractExp; +import pddl4j.exp.ExpID; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; + +/** + * This abstract class defines the optimization expression used in metric + * specification of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class MetricExp extends AbstractExp { + + /** + * The optimization. + */ + private Optimization optimization; + + /** + * The term expression to optimize. + */ + private Term exp; + + /** + * Creates a new optimization expression. + * + * @param optimization the optimization of the expression. + * @param exp the function to optimize. + * @throws NullPointerException if <code>optimization == null</code> or + * <code>exp == null</code>. + */ + public MetricExp(Optimization optimization, Term exp) { + super(ExpID.METRIC_EXP); + if (optimization == null || exp == null) + throw new NullPointerException(); + this.optimization = optimization; + this.exp = exp; + } + + /** + * Returns the term expression to optimize. + * + * @return the term expression to optimize. + */ + public final Optimization getOptimization() { + return this.optimization; + } + + /** + * Returns the term expression to optimize. + * + * @return the term expression to optimize. + */ + public final Term getExp() { + return this.exp; + } + + /** + * Sets a new term expression to optimize. + * + * @param exp the new term expression to optimize. + * @throws NullPointerException if <code>exp == null</code>. + */ + public final void setExp(Term exp) { + if (exp == null) + throw new NullPointerException(); + this.exp = exp; + } + + /** + * Returns <code>true</code> if a term occurs in this metric expression. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this metric expression; + * <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public final boolean occurs(Term term) { + if (term == null) + throw new NullPointerException(); + return this.exp.occurs(term); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public MetricExp apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + MetricExp other = this.clone(); + other.exp = this.exp.apply(sigma); + return other; + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null</code>. + */ + public MetricExp standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + MetricExp other = this.clone(); + other.exp = this.exp.standardize(images); + return other; + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + Set<Variable> vars = new LinkedHashSet<Variable>(); + vars.addAll(this.exp.getFreeVariables()); + return vars; + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + return this.exp.isGround(); + } + + /** + * Returns <code>true</code> if the maximize expression is equal to + * an other object, i.e., if the object is a not null reference to an + * instance of the class <code>MaximizeExp</code> and both maximize + * expressions contain the same expression to maximize. + * + * @param obj The reference object with which to compare. + * @return <code>true</code> if the maximize expression equal to an + * other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof MetricExp) { + MetricExp other = (MetricExp) obj; + return this.getExpID().equals(other.getExpID()) + && this.exp.equals(other.exp); + } + return false; + } + + /** + * Returns a hash code value for the maximize expression. This method + * is supported for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the effect goal description. + */ + public int hashCode() { + return this.getExpID().hashCode() + this.exp.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public MetricExp clone() { + MetricExp other = (MetricExp) super.clone(); + other.exp.clone(); + return other; + } + + /** + * Returns a string representation of this metric expression. + * + * @return a string representation of this metric expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(:metric " + this.optimization.toString().toLowerCase() + " "); + str.append(this.getExp().toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this metric expression. + * + * @return a typed string representation of this metric expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(:metric " + this.optimization.toString().toLowerCase() + " "); + str.append(this.getExp().toTypedString()); + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/MinimizeExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/MinimizeExp.java new file mode 100644 index 00000000000..2a65d7c0786 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/MinimizeExp.java @@ -0,0 +1,112 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.metric; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; + +/** + * This class defines the minimize expression used in metric + * specification of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class MinimizeExp extends MetricExp { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 3422169319365697377L; + + /** + * Creates a new minimize expression with a specified function. + * + * @param exp the term expression to minimize. + * @throws NullPointerException if <code>exp == null</code>. + */ + public MinimizeExp(Term exp) { + super(Optimization.MINIMIZE, exp); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public MinimizeExp apply(Substitution sigma) { + return (MinimizeExp) super.apply(sigma); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public MinimizeExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public MinimizeExp standardize(Map<String, String> images) { + return (MinimizeExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public MinimizeExp clone() { + return (MinimizeExp) super.clone(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/Optimization.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/Optimization.java new file mode 100644 index 00000000000..4060e2f1532 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/Optimization.java @@ -0,0 +1,49 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.metric; + +/** + * This enumeration defines all the types of optimization of the PDDL langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public enum Optimization { + /** + * The maximize optimization. + */ + MAXIMIZE, + /** + * The minimize optimization. + */ + MINIMIZE, + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/package.html b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/package.html new file mode 100644 index 00000000000..b66480321fe --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/metric/package.html @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title></title> + <meta name="Generator" content="Cocoa HTML Writer"> + <meta name="CocoaVersion" content="824.42"> + <style type="text/css"> + p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times} + </style> +</head> +<body> +<p>This package contains the classes relative to metric expressions used in PDDL language.</p> +</body> +</html> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/package.html b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/package.html new file mode 100644 index 00000000000..2f6b5cb5018 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/package.html @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title></title> + <meta name="Generator" content="Cocoa HTML Writer"> + <meta name="CocoaVersion" content="824.42"> + <style type="text/css"> + p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times} + </style> +</head> +<body> +<p>This package contains the classes relative to the PDDL expressions.</p> +</body> +</html> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/AbstractTerm.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/AbstractTerm.java new file mode 100644 index 00000000000..f013d3ecb76 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/AbstractTerm.java @@ -0,0 +1,237 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.term; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.AbstractExp; +import pddl4j.exp.ExpID; +import pddl4j.exp.type.Type; +import pddl4j.exp.type.TypeSet; + +/** + * This abstract class implements the common part of all term used in PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class AbstractTerm extends AbstractExp implements Term { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 4052803386962040209L; + + /** + * The image of the term. + */ + private String image; + + /** + * The type of the term. + */ + private TypeSet type; + + /** + * The term id of this term. + */ + private TermID id; + + /** + * Creates a new term with a specified term id, image type and gound flag + * property. + * + * @param id The id expression of this term. + * @param image the image of the term. + * @throws NullPointerException if <code>id == null</code> or + * <code>image == null</code> or <code>type == null</code>. + */ + protected AbstractTerm(TermID id, String image) { + super(ExpID.TERM); + this.id = id; + this.setImage(image); + Map<String, Set<String>> type = new LinkedHashMap<String,Set<String>>(); + type.put(Type.OBJECT_SYMBOL, new LinkedHashSet<String>()); + this.setTypeSet(new TypeSet(new Type(Type.OBJECT_SYMBOL, type))); + } + + /** + * Creates a new term with a specified term id, image type and ground flag + * property. + * + * @param id The id expression of this term. + * @param image the image of the term. + * @param type the type of this term. + * @throws NullPointerException if <code>id == null</code> or + * <code>image == null</code> or <code>type == null</code>. + */ + protected AbstractTerm(TermID id, String image, TypeSet type) { + super(ExpID.TERM); + this.id = id; + this.setImage(image); + this.setTypeSet(type); + } + + /** + * Returns the term id of this term. + * + * @return the expression id of this term. + */ + public final TermID getTermID() { + return this.id; + } + + /** + * Returns the image of this term. + * + * @return the image of this term. + */ + public final String getImage() { + return this.image; + } + + /** + * Sets a new image to this term. + * + * @param image the new image of the term. + * @throws NullPointerException if <code>image == null</code>. + */ + protected void setImage(String image) { + if (image == null) + throw new NullPointerException(); + this.image = image; + } + + /** + * Returns the type of the term. + * + * @return the type of the term. + */ + public final TypeSet getTypeSet() { + return this.type; + } + + /** + * Sets a new type to this term. + * + * @param type the new type to set to this term. + * @throws NullPointerException if <code>type == null</code>. + */ + protected void setTypeSet(TypeSet type) { + if (type == null) + throw new NullPointerException(); + this.type = type; + } + + /* /** + * Returns <code>true</code> if this term is an instance of a specified + * type. Specially, this method returns <code>true</code> if the type + * of this term is the equal to the specified type or if the type of this + * term is a subtype of the specified type. + * + * @param type the type. + * @return <code>true</code> if this type is an instance of a specified + * type; <code>false</code> otherwise. + * @throws NullPointerException if <code>type == null</code>. + */ + /* public boolean isInstanceOf(Type type) { + if (type == null) + throw new NullPointerException(); + return this.gequals(type) || type.getAllSubTypes().contains(this); + }*/ + + /** + * Returns a deep copy of this term. + * + * @return a deep copy of this term. + * @see java.lang.Cloneable + */ + public AbstractTerm clone() { + AbstractTerm other = (AbstractTerm) super.clone(); + other.type = this.type.clone(); + return other; + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public Term toNegativeNormalForm() { + return this.clone(); + } + + /** + * Returns <code>true</code> if this term is equals to an other object, + * i.e., if the object is a not null instance of the class + * <code>AbstractTerm</code> and both term have the same image. + * + * @param obj the object to compare. + * @return <code>true</code> if this function head is equals to an other + * object; <code>false</code> otherwise. + */ + public boolean equals(final Object obj) { + if (obj != null && obj instanceof AbstractTerm) { + final AbstractTerm other = (AbstractTerm) obj; + return super.equals(other) && this.id.equals(other.id) + && this.getImage().equals(other.getImage()); + } + return false; + } + + /** + * Returns the hash code value of this term. This method is supported + * for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return the hash code value of this term. + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + return super.hashCode() + this.id.hashCode() + this.getImage().hashCode(); + } + + /** + * Returns <code>true</code> if this term is numeric. + * + * @return <code>true</code> if this term is numeric; <code>false</code> + * otherwise. + */ + /*public final boolean isNumeric() { + return this.type.isNumber(); + }*/ +} +
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/BindingException.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/BindingException.java new file mode 100644 index 00000000000..c0c05fcee10 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/BindingException.java @@ -0,0 +1,99 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.term; + +/** + * BindingException is thrown if an attempt is made to bind a exp to a symbolic + * or numeric constant. + * + * @author Damien Pellier + * @version 1.0 + */ +public class BindingException extends RuntimeException { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -4600701161512855951L; + + /** + * Creates a new binding exception. with null as its detail message. The + * cause is not initialized, and may subsequently be initialized by a call + * to <code>Throwable.initCause(java.lang.Throwable)</code>. + */ + public BindingException() { + super(); + } + + /** + * Creates a new binding exception with the specified detail message and + * cause. + * + * @param message the detail message (which is saved for later retrieval by + * the <code>Throwable.getMessage() method</code>). + * @param cause the cause (which is saved for later retrieval by the + * <code>Throwable.getCause()</code> method). (A + * <code>null</code> value is permitted, and indicates that the + * cause is nonexistent or unknown.) + */ + public BindingException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Creates a new binding exception with the specified detail message. The + * cause is not initialized, and may subsequently be initialized by a call + * to <code>Throwable.initCause(java.lang.Throwable)</code>. + * + * @param message the detail message (which is saved for later retrieval by + * the Throwable.getMessage() method). + */ + public BindingException(String message) { + super(message); + } + + /** + * Creates a new binding exception with the specified cause and a detail + * message of <code>(cause==null ? null : cause.toString())</code> (which + * typically contains the class and detail message of cause). This + * constructor is useful for exceptions that are little more than wrappers + * for other throwables (for example, <code>PrivilegedActionException</code>). + * + * @param cause the cause (which is saved for later retrieval by the + * <code>Throwable.getCause()</code> method). (A + * <code>null</code> value is permitted, and indicates that the + * cause is nonexistent or unknown.) + */ + public BindingException(Throwable cause) { + super(cause); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Constant.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Constant.java new file mode 100644 index 00000000000..1427fa29aac --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Constant.java @@ -0,0 +1,168 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.term; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.exp.fexp.FExp; +import pddl4j.exp.type.Type; +import pddl4j.exp.type.TypeSet; + +/** + * This class implements a constant. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class Constant extends FExp implements Comparable<Constant> { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -8580834206648477520L; + + /** + * Creates a new constant of type object with a specified image. + * + * @param image the image of the constant. + * @throws NullPointerException if <code>image == null</code>. + */ + public Constant(String image) { + super(TermID.CONSTANT, image); + } + + /** + * Creates a new constant of type object with a specified image. + * + * @param image the image of the constant. + * @param type the type of this constant. + * @throws NullPointerException if <code>image == null</code>. + */ + public Constant(String image, Type type) { + super(TermID.CONSTANT, image, new TypeSet(type)); + } + + /** + * Creates a new constant with a specified image and type. + * + * @param image the image of the constant. + * @param type the type of this constant. + * @throws NullPointerException if <code>image == null</code> or + * <code>type == null</code>. + */ + public Constant(String image, TypeSet type) { + super(TermID.CONSTANT, image, type); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * term. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public Constant standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * term. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this term. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + */ + public Constant standardize(Map<String, String> images) { + return (Constant) super.standardize(images); + } + + /** + * Returns a string representation of this constant. + * + * @return a string representation of this constant. + */ + public String toString() { + return this.getImage(); + } + + /** + * Returns a typed string representation of this constant. + * + * @return a typed string representation of this constant. + */ + public String toTypedString() { + return this.getImage() + " - " + this.getTypeSet(); + } + + /** + * Compares this constant with the specified constant for order. Returns a + * negative integer, zero, or a positive integer as this constant is less + * than, equal to, or greater than the specified constant according to the + * lexicographic order. + * + * @param cst the constant to be compared. + * @return a negative integer, zero, or a positive integer as this number is + * less than, equal to, or greater than the specified object. + * @throws NullPointerException if <code>cst == null</code>. + */ + public int compareTo(Constant cst) { + return this.getImage().compareTo(cst.getImage()); + } + + /** + * Sets a new type of this constant. + * + * @param type the type to set. + * @throws NullPointerException if <code>type == null</code>. + */ + public void setTypeSet(TypeSet type) { + super.setTypeSet(type); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public Constant clone() { + return (Constant) super.clone(); + } + + + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Substitution.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Substitution.java new file mode 100644 index 00000000000..e544ee419cc --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Substitution.java @@ -0,0 +1,309 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.term; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.term.Substitution.Binding; + + +/** + * This class implements a substitution. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class Substitution implements Serializable, Cloneable, Iterable<Binding> { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 419929317756003422L; + + /** + * The list of binding contained in the substitution. + */ + private Map<Variable, Term> binding; + + /** + * Creates a new substitution. + */ + public Substitution() { + this.binding = new LinkedHashMap<Variable, Term>(); + } + + /** + * Bind a specified variable to an other term in this substitution. If the + * substitution previously contained a mapping term for the variable, the + * old term value is replaced. + * + * @param var the variable to bind. + * @param term the term to be bound to <code>var</code>. + * @return the previous term value associated with <code>var</code>, + * or <tt>null</tt> if there was no mapping term for <code>var</code>. + * @throws NullPointerException if <code>var == null || term == null</code>. + */ + public Term bind(final Variable var, final Term term) { + if (var == null || term == null) + throw new NullPointerException(); + /*if (!var.getTypeSet().getSubTypes().containsAll(term.getTypeSet().getSubTypes())) { + throw new BindingException("\"" + var.toTypedString() + "\" with \"" + term.toTypedString() + "\""); + }*/ + Term oldBinding = this.binding.get(var); + this.binding.put(var, term); + return oldBinding; + } + + /** + * Returns <code>true</code> if a specified variable occurs in this + * substitution. + * + * @param var the variable to be tested. + * @return <code>true</code> if a specified variable occurs in this + * substitution; <code>false</code> otherwise. + */ + public boolean occurs(Variable var) { + return this.binding.get(var) != null; + } + + /** + * Composes this substitution with an other one. + * + * @param sigma the substitution to compose. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public void compose(final Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + for (Map.Entry<Variable, Term> e : this.binding.entrySet()) { + this.binding.put(e.getKey(), e.getValue().apply(sigma)); + } + this.binding.putAll(sigma.binding); + } + + /** + * Returns the term to which a specific variable is bound. + * + * @param var the exp bound. + * @return <tt>null</tt> if the variable is not bound or the binding exp. + * @throws NullPointerException if <code>var == null</code>. + */ + public Term getBinding(final Variable var) { + if (var == null) + throw new NullPointerException(); + return this.binding.get(var); + } + + /** + * Returns a deep copy of the subtitution. + * + * @return a deep copy of the subtitution. + */ + public Substitution clone() { + try { + Substitution other = (Substitution) super.clone(); + other.binding = new LinkedHashMap<Variable, Term>(); + for (Map.Entry<Variable, Term> e : this.binding.entrySet()) { + other.binding.put(e.getKey().clone(), e.getValue().clone()); + } + return other; + } catch (CloneNotSupportedException e) { + throw new Error(); + } + } + + /** + * Returns a string representation of the substitution. + * + * @return a string representation of the substitution. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("["); + if (!this.binding.isEmpty()) { + Iterator<Map.Entry<Variable, Term>> i = this.binding.entrySet().iterator(); + Map.Entry<Variable, Term> e = i.next(); + str.append(e.getKey() + "/" + e.getValue().toString()); + while (i.hasNext()) { + e = i.next(); + str.append(", " + e.getKey() + "/" + e.getValue().toString()); + } + } + str.append("]"); + return str.toString(); + + } + + /** + * Returns a typed string representation of the substitution. + * + * @return a typed string representation of the substitution. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("["); + if (!this.binding.isEmpty()) { + Iterator<Map.Entry<Variable, Term>> i = this.binding.entrySet().iterator(); + Map.Entry<Variable, Term> e = i.next(); + str.append(e.getKey() + ":" + e.getKey().getTypeSet() + "/" + + e.getValue().toString() + ":" + + e.getValue().getTypeSet()); + while (i.hasNext()) { + e = i.next(); + str.append(", " + e.getKey() + ":" + e.getKey().getTypeSet() + "/" + + e.getValue().toString() + ":" + + e.getValue().getTypeSet()); + } + } + str.append("]"); + return str.toString(); + + } + + /** + * Returns the size of the substitution. + * + * @return the size of the substitution. + */ + public int size() { + return this.binding.size(); + } + + /** + * Returns an iterator over the binding of the substitution. + * + * @return an iterator over the binding of the substitution. + * @see java.lang.Iterable#iterator() + */ + public Iterator<Binding> iterator() { + Set<Binding> bindings = new LinkedHashSet<Binding>(); + for (Map.Entry<Variable, Term> e : this.binding.entrySet()) { + bindings.add(new Binding(e.getKey(), e.getValue())); + } + return bindings.iterator(); + } + + /** + * This inner class defines a binding between a variable and a term. + * + * @author Damien Pellier + * @version 1.0 + */ + public final class Binding implements Serializable { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -3705403616252264846L; + + /** + * The variable. + */ + private Variable var; + + /** + * The term. + */ + private Term term; + + /** + * Creates a new binding term. + * + * @param var the binding variable. + * @param term the binding value. + * @throws NullPointerException if <code>var == null || term == null</code. + */ + private Binding(Variable var, Term term) { + this.var = var; + this.term = term; + } + + /** + * Returns the binding variable. + * + * @return the binding variable. + */ + public Variable getVariable() { + return this.var; + } + + /** + * Returns the binding term value. + * + * @return the binding term value. + */ + public Term getTerm() { + return this.term; + } + + /** + * Returns <code>true</code> if this binding is equal to a other + * object. This method return <code>true</code> if the object is a not + * <code>null</code> instance of the class <code>Binding</code> and + * the both attribute of the class are equal. + * + * @param obj the object to be tested. + * @return <code>true</code> if this binding is equal to a other + * object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj.getClass().equals(this.getClass())) { + Binding other = (Binding) obj; + return this.var.equals(other.var) + && this.term.equals(other.term); + } + return false; + } + + /** + * Returns the hash code value this binding. + * + * @return the hash code value this binding. + */ + public int hashCode() { + return this.var.hashCode() + this.term.hashCode(); + } + + /** + * Returns a string representation of this binding. + * + * @return a string representation od this binding. + */ + public String toString() { + return this.var.toString() + "/" + this.term.toString(); + } + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Term.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Term.java new file mode 100644 index 00000000000..216695b3d7c --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Term.java @@ -0,0 +1,163 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.term; + +import java.util.Map; + +import pddl4j.exp.Exp; +import pddl4j.exp.type.TypeSet; + +/** + * This interface define all the method applicable to a PDDL term. + * + * @author Damien Pellier + * @version 1.0 + */ +public interface Term extends Exp, Cloneable { + + /** + * Return the image of this term. + * + * @return the image of this term. + */ + String getImage(); + + /** + * Returns the type of this term. + * + * @return the type of this term. + */ + TypeSet getTypeSet(); + + /** + * Returns a typed representation of this term. + * + * @return a typed representation of this term. + */ + String toTypedString(); + + /** + * Unify this term with an other specified term. Note, call unify does not + * modify the parameters of this method. + * + * @param term the term to unify with. + * @return The substitution that defines the binding constraints needed to + * unify this term with the other term or <code>null</code> if no + * binding constraints allows to unify the two terms. + */ + Substitution unify(final Term term); + + /** + * Unify this term with an other specified term by taking into account a + * specified set of binding constraints. Note, call unify does not modify + * the parameters of this method. + * + * @param term the term to unify with. + * @param sigma the substitution containing the binding constraints. + * @return The substitution that defines the binding constraints needed to + * unify this term with the other term or <code>null</code> if no + * binding constraints allows to unify the two terms. + */ + Substitution unify(final Term term, final Substitution sigma); + + /** + * Creates and returns a copy of this term expression. + * + * @return a clone of this term expression instance. + * @see pddl4j.exp.Exp#clone() + */ + Term clone(); + + /** + * Returns the term id of this term. + * + * @return the term id of this term. + * @see pddl4j.exp.term.TermID + */ + TermID getTermID(); + + /** + * Returns <code>true</code> if this term is numeric. + * + * @return <code>true</code> if this term is numeric; <code>false</code> + * otherwise. + */ + //boolean isNumeric(); + + /** + * Substitutes all occurrences of the variables that occur in this + * term and that are bound in the substitution by its binding term. + * This method modify the content of the term on which it is applied. + * + * @param sigma the substitution. + * @return the substituted term. + */ + public Term apply(Substitution sigma); + + /** + * Returns <code>true</code> if a term occurs in this term. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this expression; + * <code>false</code> otherwise. + */ + boolean occurs(Term term); + + /** + * Returns <code>true</code> if the term is ground. + * + * @return <code>true</code> if the term is ground; + * <code>false</code>otherwise. + */ + boolean isGround(); + + /** + * Standardizes all occurrences of the variables that occur in this + * term. + * + * @return this term. + */ + Term standardize(); + + /** + * Standardizes all occurrences of the variables that occur in this + * term. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. a + * standardized copy of this expression. Remember that free variables are + * existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this term. + */ + Term standardize(Map<String, String> images); + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/TermID.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/TermID.java new file mode 100644 index 00000000000..5d82eaeca9d --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/TermID.java @@ -0,0 +1,60 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.term; + +/** + * This enumeration defined all the type of terms. + * + * @author Damien Pellier + * @version 1.0 + */ +public enum TermID { + /** + * The constant term id. + */ + CONSTANT, + /** + * The variable term id. + */ + VARIABLE, + /** + * The function term id. + */ + FUNCTION, + /** + * The number term id. + */ + NUMBER, + /** + * The arithmetic function term id. + */ + ARITHMETIC_FUNCTION, +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Variable.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Variable.java new file mode 100644 index 00000000000..6b632624884 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/Variable.java @@ -0,0 +1,364 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.term; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.type.Type; +import pddl4j.exp.type.TypeSet; + +/** + * This class implements a variable. + * + * @author Damien Pellier + * @version 1.0 + */ +public class Variable extends AbstractTerm { + + /** + * The default class version id. + */ + private static final long serialVersionUID = -6404872183241547003L; + + /** + * Creates a new variable of type object with a specified image. + * + * @param image the image of the variable. + * @throws NullPointerException if <code>image == null</code>. + */ + public Variable(String image) { + super(TermID.VARIABLE, "?" + image); + } + + /** + * Creates a new variable of type object with a specified image. + * + * @param image the image of the variable. + * @param type the type of the variable. + * @throws NullPointerException if <code>image == null</code>. + */ + public Variable(String image, Type type) { + super(TermID.VARIABLE, "?" + image, new TypeSet(type)); + } + + /** + * Creates a new variable with a specified image and type. + * + * @param image the image of the variable. + * @param type the type of this variable. + * @throws NullPointerException if <code>image == null</code> or + * <code>type == null</code>. + */ + public Variable(String image, TypeSet type) { + super(TermID.VARIABLE, "?" + image, type); + } + + /** + * Returns the binding term to this variable in the specified substitution + * or this variable is the variable is not bind the substitution. + * + * @param sigma the substitution. + * @return the substituted term or a copy of this variable if there is no + * binding term for this variable in the substitution. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public Term apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + Term value = sigma.getBinding(this); + return value != null ? value : this.clone(); + } + + /** + * Sets a new type of this variable. + * + * @param type the type to set. + * @throws NullPointerException if <code>type == null</code>. + */ + public void setTypeSet(TypeSet type) { + super.setTypeSet(type); + } + + /** + * Returns <code>true</code> if a term occurs in this term. This method + * returns <code>true</code> if and only if the term is equal to this + * variable. + * + * @param term the term to be tested. + * @return <code>true</code> if and only if the term is equal to this + * variable; <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public boolean occurs(Term term) { + if (term == null) + throw new NullPointerException(); + return this.equals(term); + } + + /** + * Returns <code>true</code> if this variable is ground. + * + * @return <code>true</code> if this variable is ground; <code>false</code> + * otherwise. + */ + public boolean isGround() { + return false; + } + + /** + * Unify this variable with an other specified term. Note, called unify does + * not modify the parameters of this method. + * + * @param term the term to unify with. + * @return The substitution that defines the binding constraints needed to + * unify this term with the other term or <code>null</code> if no + * binding constraints allows to unify the two terms. + * @throws BindingException if the term to unify with this variable is a + * variable with the same symbol as this variable and has an + * incompatible type, i.e., + * <code>!this.getTypeSet().getSubTypes().containsAll(term.getTypeSet().getSubTypes())</code>. + * @see pddl4j.exp.term.Term#unify(Term, Substitution) + */ + public Substitution unify(Term term) { + return this.unify(term, new Substitution()); + } + + /** + * Unify this variable with an other specified term by taking into account a + * specified set of binding constraints. Note, called unify does not modify + * the parameters of this method. + * + * @param term the term to unify with this variable. + * @param sigma the substitution containing the binding constraints. + * @return The substitution that defines the binding constraints needed to + * unify this term with the other term or <code>null</code> if no + * binding constraints allows to unify the two terms. + * @throws BindingException if the term to unify with this variable is a + * variable with the same symbol as this variable and has an + * incompatible type, i.e., + * <code>!this.getTypeSet().getSubTypes().containsAll(term.getTypeSet().getSubTypes())</code>. + */ + public Substitution unify(final Term term, final Substitution sigma) { + Substitution theta = sigma.clone(); + Term binding = theta.getBinding(this); + if (binding != null) { + return binding.unify(term, sigma); + } else { + if (term.getTermID().equals(TermID.VARIABLE)) { + if (term.getImage().equals(this.getImage())) { + if (this.getTypeSet().getSubTypes().containsAll( + term.getTypeSet().getSubTypes())) { + return theta; + } else { + throw new BindingException("cannot bind " + + this.toTypedString() + " with " + + term.toTypedString() + + ": imcompatible type"); + } + } else { + TypeSet infinum = this.getTypeSet().infimum( + term.getTypeSet()); + if (!infinum.isEmpty()) { + Variable var = (Variable) term.clone(); + var.setTypeSet(infinum); + theta.bind(this, var); + return theta; + } + } + } else { + if (!term.occurs(this)) { + if (this.getTypeSet().getSubTypes().containsAll( + term.getTypeSet().getSubTypes())) { + theta.bind(this, term); + return theta; + } + } + } + } + return null; + } + + /** + * Standardize this variable. + * + * @return this expression. + */ + public Variable standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes a quantified variable. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return this expression. + * @throws NullPointerException if <code>images == null</code>. + */ + public Variable standardizeQuantifiedVariable(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + String newImage = images.get(this.getImage()); + if (newImage == null) { + String oldImage = this.getImage(); + newImage = Variable.getStandardizedImage(oldImage); + images.put(oldImage, newImage); + } else { + String oldImage = newImage; + newImage = Variable.getStandardizedImage(oldImage); + images.put(this.getImage(), newImage); + } + Variable var = this.clone(); + var.setImage(newImage); + return var; + } + + /** + * Standardizes this variable. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return this expression. + * @throws NullPointerException if <code>images == null</code>. + */ + public Variable standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + String newImage = images.get(this.getImage()); + if (newImage == null) { + String oldImage = this.getImage(); + newImage = Variable.getStandardizedImage(oldImage); + images.put(oldImage, newImage); + } + Variable var = this.clone(); + var.setImage(newImage); + return var; + } + + /** + * Returns the standardized name of a variable from its specified image. + * + * @param image the image. + * @return the standardized name of a variable from its specified image. + */ + public static String getStandardizedImage(String image) { + String newImage = new String(); + String[] str = image.split("_"); + if (str.length == 2) { + long index = Long.parseLong(str[1]); + index++; + newImage = str[0] + "_" + index; + + } else { + newImage = str[0] + "_0"; + } + return newImage; + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + Set<Variable> vars = new LinkedHashSet<Variable>(); + vars.add(this); + return vars; + } + + /** + * Returns <code>true</code> if this variable is equals to an other + * object. This method return <code>true</code> if the object is a not + * null instance of the class <code>Variable</code> and both variable have + * the same image. + * + * @param obj the object to compare. + * @return <code>true</code> if this variable is equals to an other + * object; <code>false</code> otherwise. + */ + public boolean equals(final Object obj) { + if (obj != null && obj instanceof Variable) { + return super.equals(obj); + } + return false; + } + + /** + * Return a deep copy of this variable. + * + * @return a deep copy of this variable. + * @see pddl4j.exp.term.AbstractTerm#clone() + */ + public Variable clone() { + return (Variable) super.clone(); + } + + /** + * Returns a string representation of this variable. + * + * @return a string representation of this variable. + */ + public String toString() { + return this.getImage(); + } + + /** + * Returns typed string representation of this variable. + * + * @return typed string representation of this variable. + */ + public final String toTypedString() { + return this.getImage() + " - " + this.getTypeSet().toString(); + } + + /** + * The timed variable symbol. + */ + public static final String DURATIVE_VARIABLE = "duration"; + + /** + * The continus variable symbol. + */ + public static final String CONTINOUS_VARIABLE = "#t"; + + /** + * The metric variable symbol. + */ + public static final String TOTAL_TIME = "?total-time"; + + /** + * The violated preference variable symbol. + */ + public static final String VIOLATED_PREF_VARIABLE = "?violated-pref-"; +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/package.html b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/package.html new file mode 100644 index 00000000000..7a5385cd2e4 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/term/package.html @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title></title> + <meta name="Generator" content="Cocoa HTML Writer"> + <meta name="CocoaVersion" content="824.42"> + <style type="text/css"> + p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times} + </style> +</head> +<body> +<p>This package contains the classes relative to term expressions of the PDDL language.</p> +</body> +</html> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/AtEndTimedExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/AtEndTimedExp.java new file mode 100644 index 00000000000..749bfb2a40c --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/AtEndTimedExp.java @@ -0,0 +1,123 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.time; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.exp.Exp; + +/** + * This class implements a "at end" timed expression. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class AtEndTimedExp extends AtTimedExp { + + /** + * The serial id version of the class. + */ + private static final long serialVersionUID = 6680338005108742999L; + + /** + * Creates a new "at end" timed expression with a specific expression. + * + * @param exp The timed expression. + * @throws NullPointerException if <code>exp == null</code>. + */ + public AtEndTimedExp(Exp exp) { + super(TimeSpecifier.END, exp); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public AtEndTimedExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. + * Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public AtEndTimedExp standardize(Map<String, String> images) { + return (AtEndTimedExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public AtEndTimedExp clone() { + return (AtEndTimedExp) super.clone(); + } + + /** + * Returns a string representation of this "at end" timed expression. + * + * @return a string representation of this "at end" timed expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(at end"); + str.append(this.exp.toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this "at end" timed expression. + * + * @return a typed string representation of this "at end" timed expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(at end"); + str.append(this.exp.toTypedString()); + str.append(")"); + return str.toString(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/AtStartTimedExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/AtStartTimedExp.java new file mode 100644 index 00000000000..8e26414719d --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/AtStartTimedExp.java @@ -0,0 +1,124 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.time; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.exp.Exp; + +/** + * This class implements a "at start" timed expression of the PDDL langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public class AtStartTimedExp extends AtTimedExp { + + /** + * The serial id version of the class. + */ + private static final long serialVersionUID = 6680338005108742999L; + + /** + * Creates a new "at start" timed expression with a specific expression. + * + * @param exp The timed expression. + * @throws NullPointerException if <code>exp == null</code>. + */ + public AtStartTimedExp(Exp exp) { + super(TimeSpecifier.START, exp); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public AtStartTimedExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. + * Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public AtStartTimedExp standardize(Map<String, String> images) { + return (AtStartTimedExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public AtStartTimedExp clone() { + return (AtStartTimedExp) super.clone(); + } + + /** + * Returns a string representation of this "at start" timed expression. + * + * @return a string representation of this "at start" timed expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(at start"); + str.append(this.exp.toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this "at start" timed expression. + * + * @return a typed string representation of this "at start" timed expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(at start"); + str.append(this.exp.toTypedString()); + str.append(")"); + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/AtTimedExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/AtTimedExp.java new file mode 100644 index 00000000000..9ec8c183b5c --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/AtTimedExp.java @@ -0,0 +1,120 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.time; + +import pddl4j.exp.Exp; + +/** + * This class implements an "at" timed expression of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class AtTimedExp extends TimedExp { + + /** + * The time specifier of the "at" timed expression. + */ + protected TimeSpecifier specifier; + + /** + * Creates a new "at" timed expression with a specific time specifier and + * expression. + * + * @param specifier The time specifier of the timed expression. + * @param exp The timed expression.. + * @throws NullPointerException if <code>specifier == null</code> of + * <code> exp == null</code>. + */ + protected AtTimedExp(TimeSpecifier specifier, Exp exp) { + super(TimedExpID.AT, exp); + this.specifier = specifier; + } + + /** + * Returns the time specifier of the expression. + * + * @return the time specifier of the expression. + */ + public final TimeSpecifier getTimeSpecifier() { + return this.specifier; + } + + /** + * Sets a new time specifier to the expression. + * + * @param specifier The new specifier to set. + * @throws NullPointerException if <code>specifier == null</code>. + */ + public final void setTimeSpecifier(TimeSpecifier specifier) { + this.specifier = specifier; + } + + /** + * Returns <code>true</code> if the "at" timed expression is equal to + * an other object, i.e., if the object is a not null reference to an + * instance of the class <code>AtEndTimedExp</code> and both "at start" + * timed expressions contain the same timed expression. + * + * @param obj - the reference object with which to compare. + * @return <code>true</code> if the "at" timed expression equal to an + * other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj instanceof AtTimedExp) { + AtTimedExp other = (AtTimedExp) obj; + return super.equals(obj) && this.specifier.equals(other.specifier); + } + return false; + } + + /** + * Returns a hash code value for the "at" timed expression. This method + * is supported for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the at timed expression. + */ + public int hashCode() { + return super.hashCode() + this.specifier.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public AtTimedExp clone() { + return (AtTimedExp) super.clone(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/Interval.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/Interval.java new file mode 100644 index 00000000000..2a37afbe6f4 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/Interval.java @@ -0,0 +1,44 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.time; + +/** + * This enumeration defines all type of timed interval used in PDDL langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public enum Interval { + /** + * The all timed interval. + */ + ALL; +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/OverAllTimedExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/OverAllTimedExp.java new file mode 100644 index 00000000000..8766ecc6140 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/OverAllTimedExp.java @@ -0,0 +1,124 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.time; + +import java.util.LinkedHashMap; +import java.util.Map; + +import pddl4j.exp.Exp; + +/** + * This class implements an "over all" timed expression of the PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class OverAllTimedExp extends OverTimedExp { + + /** + * The serial id version of the class. + */ + private static final long serialVersionUID = 5674054849424501507L; + + /** + * Creates a new "over all" timed expression with a specific timed + * description. + * + * @param exp the timed expression. + * @throws NullPointerException if <code>exp == null</code>. + */ + public OverAllTimedExp(Exp exp) { + super(Interval.ALL, exp); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public OverAllTimedExp standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. The bound argument is used to store the bound variables. + * Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if + * <code>images == null || bound == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public OverAllTimedExp standardize(Map<String, String> images) { + return (OverAllTimedExp) super.standardize(images); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public OverAllTimedExp clone() { + return (OverAllTimedExp) super.clone(); + } + + /** + * Returns a string representation of this "over all" timed expression. + * + * @return a string representation of this "over all" timed expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(over all "); + str.append(this.exp.toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this "over all" timed expression. + * + * @return a type string representation of this "over all" timed expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(over all "); + str.append(this.exp.toTypedString()); + str.append(")"); + return str.toString(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/OverTimedExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/OverTimedExp.java new file mode 100644 index 00000000000..c3595b0a12d --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/OverTimedExp.java @@ -0,0 +1,123 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.time; + +import pddl4j.exp.Exp; + +/** + * This class implements an "over" timed expression of the PDDL langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class OverTimedExp extends TimedExp { + + /** + * The time specifier of the "over" timed expression. + */ + protected Interval interval; + + /** + * Creates a new "over" timed expression with a specific interval and + * expression. + * + * @param interval The interval of the timed expression. + * @param exp The timed expression. + * @throws NullPointerException if <code>interval == null</code> or + * <code>exp == null</code>. + */ + protected OverTimedExp(Interval interval, Exp exp) { + super(TimedExpID.OVER, exp); + if (interval == null) + throw new NullPointerException(); + this.interval = interval; + } + + /** + * Returns the interval of the timed expression. + * + * @return the interval of the timed expression. + */ + public final Interval getInterval() { + return this.interval; + } + + /** + * Sets a new interval to the timed expression. + * + * @param interval The new interval to set. + * @throws NullPointerException if <code>interval == null</code>. + */ + public final void setTimeSpecifier(Interval interval) { + if (interval == null) + throw new NullPointerException(); + this.interval = interval; + } + + /** + * Returns <code>true</code> if the "over" timed expression is equal + * to an other object, i.e., if the object is a not null reference to an + * instance of the class <code>OverTimedExp</code> and both "over all" + * timed expression contain the same timed expression. + * + * @param obj The reference object with which to compare. + * @return <code>true</code> if the "over" timed expression equal to + * an other object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && this.getClass().equals(obj.getClass())) { + OverTimedExp other = (OverTimedExp) obj; + return super.equals(obj) && this.interval.equals(other.interval); + } + return false; + } + + /** + * Returns a hash code value for the "over" timed expression. This + * method is supported for the benefit of hashtables such as those provided + * by <code>java.util.Hashtable</code>. + * + * @return a hash code value for the over timed expression. + */ + public int hashCode() { + return super.hashCode() + this.interval.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public OverTimedExp clone() { + return (OverTimedExp) super.clone(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimeSpecifier.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimeSpecifier.java new file mode 100644 index 00000000000..b2168049f38 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimeSpecifier.java @@ -0,0 +1,48 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.time; + +/** + * This enumeration defines all time specifier used in PDDL langage. + * + * @author Damien Pellier + * @version 1.0 + */ +public enum TimeSpecifier { + /** + * The start time specifier. + */ + START, + /** + * The end time specifier. + */ + END; +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimedExp.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimedExp.java new file mode 100644 index 00000000000..e67275f5528 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimedExp.java @@ -0,0 +1,275 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.time; + +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import pddl4j.exp.AbstractExp; +import pddl4j.exp.Exp; +import pddl4j.exp.ExpID; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; +import pddl4j.exp.term.Variable; + +/** + * The abstract generic class implements the common methods of all timed + * expression. + * + * @author Damien Pellier + * @version 1.0 + */ +public abstract class TimedExp extends AbstractExp { + + /** + * The timed expression id of this times expression. + */ + private TimedExpID id; + + /** + * The expression contained in this timed expression. + */ + protected Exp exp; + + /** + * Creates a new timed goal description expression with a specific id and an + * expression. + * + * @param id The timed expression id of the expression. + * @param exp The timed expression. + * @throws NullPointerException if <code>id == null</code> or + * <code> exp == null</code>. + */ + protected TimedExp(TimedExpID id, Exp exp) { + super(ExpID.TIMED_EXP); + if (exp == null) + throw new NullPointerException(); + this.id = id; + this.exp = exp; + } + + /** + * Returns the timed expression id of this times expression. + * + * @return the timed expression id of this times expression. + * @see pddl4j.exp.time.TimedExpID + */ + public final TimedExpID getTimeExpID() { + return this.id; + } + + /** + * Returns the expression contained in the timed expression. + * + * @return the expression contained in the timed expression. + */ + public Exp getExp() { + return this.exp; + } + + /** + * Sets a new expression contained in the timed expression. + * + * @param exp the new expression to set. + * @throws NullPointerException if <code>exp == null</code>. + */ + public final void setExp(Exp exp) { + if (exp == null) + throw new NullPointerException(); + this.exp = exp; + } + + /** + * Returns <code>true</code> if a term occurs in this timed expression. + * + * @param term the term to be tested. + * @return <code>true</code> if a term occurs in this timed expression; + * <code>false</code> otherwise. + * @throws NullPointerException if <code>term == null</code>. + */ + public final boolean occurs(Term term) { + if (term == null) + throw new NullPointerException(); + return this.exp.occurs(term); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public TimedExp apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + TimedExp other = this.clone(); + other.exp = this.exp.apply(sigma); + return other; + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public TimedExp standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + TimedExp other = this.clone(); + other.exp = this.exp.standardize(images); + return other; + } + + /** + * Returns the set of free variables of this expression. + * + * @return the set of free variables of this expression. + */ + public Set<Variable> getFreeVariables() { + Set<Variable> vars = new LinkedHashSet<Variable>(); + vars.addAll(this.exp.getFreeVariables()); + return vars; + } + + /** + * Returns <code>true</code> if the expression is ground. + * + * @return <code>true</code> if the expression is ground; + * <code>false</code>otherwise. + * @see pddl4j.exp.Exp#isGround() + */ + public final boolean isGround() { + return this.exp.isGround(); + } + + /** + * Returns <code>true</code> if the timed expression is equal to an other + * object. This method returns <code>true</code> if the object is a not + * null reference to an instance of the class <code>TimedExp</code> and + * both timed expression have the same timed expression id and the same + * expression. + * + * @param obj The reference object with which to compare. + * @return <code>true</code> if the timed expression equal to an other + * object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && this.getClass().equals(obj.getClass())) { + TimedExp other = (TimedExp) obj; + return super.equals(obj) && this.exp.equals(other.exp); + } + return false; + } + + /** + * Returns a hash code value for the timed expression. This method is + * supported for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the timed expression. + */ + public int hashCode() { + return super.hashCode() + this.exp.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public TimedExp clone() { + TimedExp other = (TimedExp) super.clone(); + other.exp = this.exp.clone(); + return other; + } + + /** + * Returns a copy of this expression such that the quantifiers appear first. + * + * @return a copy of this expression such that the quantifiers appear first. + * @see pddl4j.exp.Exp#moveQuantifierOutward() + */ + public Exp moveQuantifierOutward() { + TimedExp other = (TimedExp) super.clone(); + other.exp = this.exp.moveQuantifierOutward(); + return other; + } + + /** + * Return the disjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the disjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toDisjunctiveNormalForm() + */ + public TimedExp toDisjunctiveNormalForm() { + TimedExp other = this.clone(); + other.exp = this.exp.toDisjunctiveNormalForm(); + return other; + } + + /** + * Returns the conjunctive normal form of this expression. Note, the + * expression returned is a copy. + * + * @return the conjunctive normal form of this expression. + * @see pddl4j.exp.Exp#toConjunctiveNormalForm() + */ + public TimedExp toConjunctiveNormalForm() { + TimedExp other = this.clone(); + other.exp = this.exp.toConjunctiveNormalForm(); + return other; + } + + /** + * Returns the negative normal form of this expression. Note, the expression + * returned is a copy. + * + * @return the negative normal form of this expression. + * @see pddl4j.exp.Exp#toNegativeNormalForm() + */ + public TimedExp toNegativeNormalForm() { + TimedExp other = this.clone(); + other.exp = this.exp.toNegativeNormalForm(); + return other; + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimedExpID.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimedExpID.java new file mode 100644 index 00000000000..9a41a8a7874 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimedExpID.java @@ -0,0 +1,52 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.time; + +/** + * This enumeration defines all the time expression id. + * + * @author Damien Pellier + * @version 1.0 + */ +public enum TimedExpID { + /** + * The at time expression id. + */ + AT, + /** + * The over time expression id. + */ + OVER, + /** + * The literal time expression id. + */ + LITERAL +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimedLiteral.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimedLiteral.java new file mode 100644 index 00000000000..f48b4fb84cc --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/TimedLiteral.java @@ -0,0 +1,272 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.time; + +import java.util.LinkedHashMap; +import java.util.Iterator; +import java.util.Map; + +import pddl4j.exp.Literal; +import pddl4j.exp.fexp.Number; +import pddl4j.exp.term.Substitution; +import pddl4j.exp.term.Term; + +/** + * This class implements a timed literal used in initial state definition of the + * PDDL language. + * + * @author Damien Pellier + * @version 1.0 + */ +public class TimedLiteral extends TimedExp implements Literal { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -1735624931301766305L; + + /** + * The time stamp of the timed literal. + */ + private Number ts; + + /** + * Creates a new timed literal with a literal. + * + * @param time the time stamp of the timed literal. + * @param literal the literal of the timed literal. + * @throws NullPointerException if <code>time == null</code> or + * <code>literal == null</code>. + * @throws IllegalArgumentException if <code>time.getValue() < 0</code>. + */ + public TimedLiteral(Number time, Literal literal) { + super(TimedExpID.LITERAL, literal); + if (time == null || literal == null) + throw new NullPointerException(); + if (time.getValue() < 0) + throw new IllegalArgumentException(); + this.ts = time; + } + + /** + * Returns the literal contained in the timed expression. + * + * @return the literal contained in the timed expression. + */ + public Literal getExp() { + return (Literal) this.exp; + } + + /** + * Returns the time stamp of the timed literal. + * + * @return the time stamp of the timed literal. + */ + public Number getTimeStamp() { + return this.ts; + } + + /** + * Sets a new time stamp to the timed literal. + * + * @param time the new time stamp to set.. + * @throws NullPointerException if <code>time == null</code> or + * <code>literal == null</code>. + * @throws IllegalArgumentException if <code>time.getValue() < 0</code>. + */ + public void setTimeStamp(Number time) { + if (time == null) + throw new NullPointerException(); + if (time.getValue() < 0) + throw new IllegalArgumentException(); + this.ts = time; + } + + /** + * Adds a new term to the timed literal. + * + * @param term the term to add. + * @return <code>true</code> if the term was added; + * <code>false</code otherwise. + * @throws NullPointerException if <code>term == null</code>. + * @see pddl4j.exp.Literal#add(pddl4j.exp.term.Term) + */ + public boolean add(Term term) { + return this.getExp().add(term); + } + + /** + * Returns the arity of the timed literal. + * + * @return the arity of the timed literal. + * @see pddl4j.exp.Literal#getArity() + */ + public int getArity() { + return this.getExp().getArity(); + } + + /** + * Returns the predicate of the timed literal. + * + * @return the predicate of the timed literal. + * @see pddl4j.exp.Literal#getPredicate() + */ + public String getPredicate() { + return this.getExp().getPredicate(); + } + + /** + * Returns a iterator over the expression of the timed literal. + * + * @return a iterator over the expression of the timed literal. + * @see java.lang.Iterable#iterator() + */ + public Iterator<Term> iterator() { + return this.getExp().iterator(); + } + + /** + * Substitutes all occurrences of the variables that occur in this + * expression and that are mapped in the substitution by its binding + * term. + * + * @param sigma the substitution. + * @return a substituted copy of this expression. + * @throws NullPointerException if <code>sigma == null</code>. + */ + public TimedLiteral apply(Substitution sigma) { + if (sigma == null) + throw new NullPointerException(); + return new TimedLiteral(this.getTimeStamp().clone(), + (Literal) this.getExp().apply(sigma)); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. Remember that free variables are existentially quantified. + * + * @return a standardized copy of this expression. + */ + public TimedLiteral standardize() { + return this.standardize(new LinkedHashMap<String, String>()); + } + + /** + * Standardizes all occurrences of the variables that occur in this + * expression. The map argument is used to store the variable already + * standardized. Remember that free variables are existentially quantified. + * + * @param images the object that maps old variable images to the standardize + * image. + * @return a standardized copy of this expression. + * @throws NullPointerException if <code>images == null</code>. + * @see pddl4j.exp.Exp#standardize(Map) + */ + public TimedLiteral standardize(Map<String, String> images) { + if (images == null) + throw new NullPointerException(); + return new TimedLiteral(this.getTimeStamp().clone(), (Literal) this + .getExp().standardize(images)); + } + + /** + * Returns <code>true</code> if the timed literal is equal to an other + * object, i.e., if the object is a not null reference to an instance of the + * class <code>TimedLiteral</code> and both timed literals have the same + * time stamp and literal expression. + * + * @param obj The reference object with which to compare. + * @return <code>true</code> if the timed literal equal to an other + * object; <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && this.getClass().equals(obj.getClass())) { + TimedLiteral other = (TimedLiteral) obj; + return super.equals(obj) && this.ts.equals(other.ts); + } + return false; + } + + /** + * Returns a hash code value for the timed literal. This method is supported + * for the benefit of hash tables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return a hash code value for the effect goal description. + */ + public int hashCode() { + return super.hashCode() + this.ts.hashCode(); + } + + /** + * Creates and returns a copy of this expression. + * + * @return a clone of this expression instance. + * @see pddl4j.exp.Exp#clone() + */ + public TimedLiteral clone() { + TimedLiteral other = (TimedLiteral) super.clone(); + other.ts = this.ts.clone(); + return other; + } + + /** + * Returns a string representation of this "at start" timed expression. + * + * @return a string representation of this "at start" timed expression. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("(at "); + str.append(this.ts.toString()); + str.append(" "); + str.append(this.getExp().toString()); + str.append(")"); + return str.toString(); + } + + /** + * Returns a typed string representation of this "at start" timed + * expression. + * + * @return a typed string representation of this "at start" timed + * expression. + */ + public String toTypedString() { + StringBuffer str = new StringBuffer(); + str.append("(at "); + str.append(this.ts.toTypedString()); + str.append(" "); + str.append(this.getExp().toTypedString()); + str.append(")"); + return str.toString(); + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/package.html b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/package.html new file mode 100644 index 00000000000..59850a41cd0 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/time/package.html @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title></title> + <meta name="Generator" content="Cocoa HTML Writer"> + <meta name="CocoaVersion" content="824.42"> + <style type="text/css"> + p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times} + </style> +</head> +<body> +<p>This package contains the classes relative to time constraints expressions of the PDDL language.</p> +</body> +</html> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/Type.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/Type.java new file mode 100644 index 00000000000..f26d5b7071c --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/Type.java @@ -0,0 +1,321 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.type; + +import java.io.Serializable; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; +import java.util.Stack; +import java.util.Map.Entry; + +/** + * This class implements a type. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class Type implements Serializable { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -3938534221059491043L; + + /** + * The object type symbol. + */ + public static final String OBJECT_SYMBOL = "object"; + + /** + * The number type symbol. + */ + public static final String NUMBER_SYMBOL = "number"; + + /** + * The number primitive type. + */ + public static final Type NUMBER = new Type(Type.NUMBER_SYMBOL); + + /** + * The image of this type. + */ + private String image; + + /** + * The list of subtypes of this types. + */ + private Map<String, Set<String>> subTypes; + + /** + * The list of super types of this types. + */ + private Map<String, Set<String>> superTypes; + + /** + * Creates a new type with a specific image and type hierachy. + * + * @param image the image of the type. + * @param hierarchy the type hierachy. + * @throws NullPointerException if <code>image == null</code> or + * <code>hierarchy == null</code>. + * @throws TypingException if the type hierarchy specified is not + * consistant. A type hierarchy is consistant if it does not + * contain cycle and all types inherite from object except the + * primitive type number. + */ + public Type(String image, Map<String, Set<String>> hierarchy) { + if (image == null || hierarchy == null) + throw new NullPointerException(); + this.image = image; + this.superTypes = new LinkedHashMap<String, Set<String>>(); + this.subTypes = new LinkedHashMap<String, Set<String>>(); + if (!this.checkTypeHierarchy(hierarchy)) { + throw new TypingException(this); + } + for (Entry<String, Set<String>> e : hierarchy.entrySet()) { + String typeImg = e.getKey(); + this.subTypes.put(e.getKey(), e.getValue()); + for (String st : e.getValue()) { + Set<String> stSet = this.superTypes.get(st); + if (stSet == null) { + stSet = new LinkedHashSet<String>(); + this.superTypes.put(st, stSet); + } + stSet.add(e.getKey()); + } + } + this.superTypes.put(Type.OBJECT_SYMBOL, new LinkedHashSet<String>()); + } + + /** + * Creates a new type with a specific image. This type is considered as a + * primitive type because no type hierarchy is specified. Consequencely, + * this type has no sub type and no super type and is final. + * + * @param image the image of the type. + * @throws NullPointerException if <code>image == null</code>. + */ + private Type(String image) { + this.image = image; + this.superTypes = new LinkedHashMap<String, Set<String>>(); + this.subTypes = new LinkedHashMap<String, Set<String>>(); + this.subTypes.put(image, new LinkedHashSet<String>()); + this.superTypes.put(image, new LinkedHashSet<String>()); + } + + /** + * Returns the image of this type. + * + * @return the image of this type. + */ + public String getImage() { + return this.image; + } + + /** + * Returns <code>true</code> if this type is final, i.e., has no subtype. + * + * @return <code>true</code> if this type is final, i.e., has no subtype; + * <code>false</code> otherwise. + */ + public boolean isFinal() { + return this.subTypes.get(this.image) == null + || this.subTypes.get(this.image).isEmpty(); + } + + /** + * Returns the set of sub-types of this type. + * + * @return the set of sub-types of this type. + */ + public Set<Type> getSuperTypes() { + Set<Type> types = new LinkedHashSet<Type>(); + Set<String> images = this.superTypes.get(this.image); + for (String img : images) { + Type type = new Type(img); + type.subTypes = this.subTypes; + type.superTypes = this.superTypes; + types.add(type); + } + return types; + } + + /** + * Returns the set of super-types of this type. + * + * @return the set of super-types of this type. + */ + public Set<Type> getSubTypes() { + Set<Type> types = new LinkedHashSet<Type>(); + Set<String> images = this.subTypes.get(this.image); + for (String img : images) { + Type type = new Type(img); + type.subTypes = this.subTypes; + type.superTypes = this.superTypes; + types.add(type); + } + return types; + } + + /** + * Returns the set of all sub-types of this type. + * + * @return the set of all sub-types of this type. + */ + public Set<Type> getAllSuperTypes() { + Set<Type> superTypes = new LinkedHashSet<Type>(); + Set<Type> types = this.getSuperTypes(); + superTypes.addAll(types); + for (Type st : types) { + superTypes.addAll(st.getAllSuperTypes()); + } + return superTypes; + } + + /** + * Returns the set of all super-types of this type. + * + * @return the set of all super-types of this type. + */ + public Set<Type> getAllSubTypes() { + Set<Type> subTypes = new LinkedHashSet<Type>(); + Set<Type> types = this.getSubTypes(); + subTypes.addAll(types); + for (Type st : types) { + subTypes.addAll(st.getAllSubTypes()); + } + return subTypes; + } + + /** + * Returns <code>true</code> if this type is equals to an other object. + * This method return <code>true</code> if the object is a not null + * instance of the class <code>Type</code> and both type have the same + * image. + * + * @param obj the object to compare. + * @return <code>true</code> if this type is equals to an other object; + * <code>false</code> otherwise. + */ + public boolean equals(Object obj) { + if (obj != null && obj.getClass().equals(this.getClass())) { + Type other = (Type) obj; + return this.image.equals(other.image); + } + return false; + } + + /** + * Returns the hash code value of this type. This method is supported + * for the benefit of hashtables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return the hash code value of this type. + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + return this.image.hashCode(); + } + + /** + * Returns a string representation of this type. + * + * @return a string representation of this type. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + str.append(this.image); + /*str.append("["); + if (!this.subTypes.isEmpty()) { + Iterator<Type> i = this.subTypes.iterator(); + str.append(i.next().image); + while (i.hasNext()) { + str.append(" " + i.next().image); + } + } + str.append("]["); + if (!this.superTypes.isEmpty()) { + Iterator<Type> i = this.superTypes.iterator(); + str.append(i.next().image); + while (i.hasNext()) { + str.append(" " + i.next().image); + } + } + str.append("]");*/ + return str.toString(); + } + + + /** + * Checks the consistance of the type hierarchy. A type hierarchy is + * consistance if the hierarchy does not contain cycle and all types + * inherite from object except the primitive type number. + * + * @param hierarchy the type hierarchy. + * @return <code>true</code> if the type hierarchy is consistant; + * <code>false</code> otherwise. + */ + private boolean checkTypeHierarchy(Map<String, Set<String>> hierarchy) { + Set<String> explored = new LinkedHashSet<String>(); + if (hierarchy.containsKey(Type.OBJECT_SYMBOL)) { + Stack<String> stack = new Stack<String>(); + stack.push(Type.OBJECT_SYMBOL); + Set<String> prefix = new LinkedHashSet<String>(); + boolean consistant = true; + while (!stack.isEmpty() && consistant) { + String type = stack.pop(); + explored.add(type); + Set<String> children = hierarchy.get(type); + if (children.isEmpty()) { + prefix.remove(type); + } else { + consistant = prefix.add(type); + if (!consistant) { + } + for (String child : children) { + stack.push(child); + + } + } + } + Set<String> types = new LinkedHashSet<String>(hierarchy.keySet()); + types.removeAll(explored); + return consistant + && (types.isEmpty() || (types.size() == 1 && + types.contains(Type.NUMBER_SYMBOL))); + } + return false; + } + + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/TypeSet.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/TypeSet.java new file mode 100644 index 00000000000..fafaf3e47b8 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/TypeSet.java @@ -0,0 +1,305 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.type; + +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.Set; + +/** + * This class implements a type set. + * + * @author Damien Pellier + * @version 1.0 + */ +public final class TypeSet implements Iterable<Type>, Cloneable { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = -3938534221059491043L; + + /** + * The list of types. + */ + private Set<Type> types; + + /** + * Creates a new type set containing a specified type. + * + * @param type the type. + * @throws NullPointerException if <code>type == null</code>. + */ + public TypeSet(Type type) { + if (type == null) + throw new NullPointerException(); + this.types = new LinkedHashSet<Type>(); + this.types.add(type); + } + + /** + * Creates a new empty type set. + */ + public TypeSet() { + this.types = new LinkedHashSet<Type>(); + } + + /** + * Adds a type to this type set. + * + * @param type the type to add. + * @return <code>true</code> if the was added; <code>false</code> otherwise. + * @throws NullPointerException if <code>type == null</code>. + */ + public boolean add(Type type) { + if (type == null) + throw new NullPointerException(); + return this.types.add(type); + } + + /** + * Removes a type to this type set. + * + * @param type the type to remove. + * @return <code>true</code> if the type was removed; <code>false</code> + * otherwise. + * @throws NullPointerException if <code>type == null</code>. + */ + public boolean remove(Type type) { + if (type == null) + throw new NullPointerException(); + return this.types.remove(type); + } + + /** + * Returns an iterator over the primitive type contained in this type. + * + * @return an iterator over the primitive type contained in this type. + */ + public Iterator<Type> iterator() { + return this.types.iterator(); + } + + /** + * Returns <code>true</code> if this type set is empty. + * + * @return <code>true</code> if this type set is empty; <code>false</code> + * otherwise. + */ + public boolean isEmpty() { + return this.types.isEmpty(); + } + + /** + * Return the sub-types if this type set. + * + * @return the sub-types if this type set. + */ + public Set<Type> getSubTypes() { + Set<Type> subTypes = new LinkedHashSet<Type>(this.types); + for (Type t : this.types) { + subTypes.addAll(t.getAllSubTypes()); + } + return subTypes; + } + + /** + * Return the super-types if this type set. + * + * @return the super-types if this type set. + */ + public Set<Type> getSuperTypes() { + Set<Type> superTypes = new LinkedHashSet<Type>(this.types); + for (Type t : this.types) { + superTypes.addAll(t.getAllSuperTypes()); + } + return superTypes; + } + + + /** + * Returns <code>true</code> if this type set is an instance of an other + * type set. + * + * @param typeSet the other type set. + * @return <code>true</code> if this type set is an instance of an other + * type set; <code>false</code> otherwise. + */ + public boolean isInstanceOf(TypeSet typeSet) { + Set<Type> thisSet = new LinkedHashSet<Type>(this.types); + thisSet.addAll(this.getSubTypes()); + Set<Type> otherSet = new LinkedHashSet<Type>(typeSet.types); + otherSet.addAll(typeSet.getSubTypes()); + return thisSet.containsAll(otherSet); + } + + /** + * Returns <code>true</code> if this type set contains only the object + * type. + * + * @return <code>true</code> if this type set contains only the object + * type; <code>false</code> otherwise. + */ + public boolean isObject() { + return this.types.size() == 1 + && this.types.iterator().next().getImage().equals(Type.OBJECT_SYMBOL); + } + + /** + * Returns <code>true</code> if this type set contains only the number + * type. + * + * @return <code>true</code> if this type set contains only the number + * type; <code>false</code> otherwise. + */ + public boolean isNumber() { + return this.types.size() == 1 + && this.types.iterator().next().getImage().equals(Type.NUMBER_SYMBOL); + } + + /** + * Returns the infinum type set between this type set and a specified type + * set. + * + * @param ts the type set. + * @return the infinum type set between this type set and a specified type + * set. + * @throws NullPointerException if <code>ts == null</code>. + */ + public TypeSet infimum(TypeSet ts) { + if (ts == null) + throw new NullPointerException(); + TypeSet ts1 = new TypeSet(); + ts1.types = new LinkedHashSet<Type>(this.types); + ts1.types.removeAll(ts.types); + + TypeSet ts2 = new TypeSet(); + ts2.types = new LinkedHashSet<Type>(ts.types); + ts2.types.removeAll(this.types); + + TypeSet infinum = new TypeSet(); + infinum.types = new LinkedHashSet<Type>(this.types); + infinum.types.retainAll(ts.types); + + Set<Type> st = ts1.getSubTypes(); + st.retainAll(ts2.getSubTypes()); + infinum.types.addAll(st); + return infinum; + } + + /** + * Returns <code>true</code> if this type set intersection a specified + * type set. + * + * @param typeSet the type set to be tested. + * @return <code>true</code> if this type set intersection a specified + * type set; <code>false</code> otherwise. + * @throws NullPointerException if <code>typeSet == null</code>. + */ + public boolean intersect(TypeSet typeSet) { + if (typeSet == null) + throw new NullPointerException(); + Set<Type> types = new LinkedHashSet<Type>(this.types); + types.addAll(this.getSubTypes()); + return types.retainAll(typeSet.types); + } + + + /** + * Returns <code>true</code> if this type is equals to an other object. + * This method returns <code>true</code> if the object is a not null + * instance of the class <code>TypeSet</code> and contains the same types. + * + * @param obj the object to compare. + * @return <code>true</code> if this type is equals to an other object; + * <code>false</code> otherwise. + * @see pddl4j.exp.type.Type + */ + public boolean equals(Object obj) { + if (obj != null && obj.getClass().equals(this.getClass())) { + TypeSet other = (TypeSet) obj; + return this.types.equals(other.types); + } + return false; + } + + /** + * Returns the hash code value of this type set. This method is supported + * for the benefit of hashtables such as those provided by + * <code>java.util.Hashtable</code>. + * + * @return the hash code value of this type set. + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + return this.types.hashCode(); + } + + /** + * Return a shallow copy of this type set. + * + * @return a shallow copy of this type set. + */ + public TypeSet clone() { + try { + TypeSet other = (TypeSet) super.clone(); + other.types = new LinkedHashSet<Type>(); + for (Type type : this.types) { + other.types.add(type); + } + return other; + } catch (CloneNotSupportedException e) { + throw new Error(); + } + } + + /** + * Returns a string representation of this type. + * + * @return a string representation of this type. + */ + public String toString() { + StringBuffer str = new StringBuffer(); + if (this.types.size() == 0) { + str.append("empty-type"); + } else if (this.types.size() == 1) { + str.append(this.types.iterator().next().toString()); + } else { + str.append("(either"); + for (Type t : this.types) { + str.append(" " + t.toString()); + } + str.append(")"); + } + return str.toString(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/TypingException.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/TypingException.java new file mode 100644 index 00000000000..b8c6846d625 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/TypingException.java @@ -0,0 +1,101 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.exp.type; + +/** + * A typing exception is thrown if an attempt is made to create a type with a + * inconsistant type hierarchy. A type hierarchy is consistant if it does not + * contain cycle and all types inherite from object except the primitive type + * number. + * + * @author Damien Pellier + * @version 1.0 + */ +public class TypingException extends RuntimeException { + + /** + * The serial version id of the class. + */ + private static final long serialVersionUID = 6846672849363008483L; + + /** + * The inconsistant type. + */ + private Type type; + + /** + * Creates a new typing exception. with null as its detail message. The + * cause is not initialized, and may subsequently be initialized by a call + * to <code>Throwable.initCause(java.lang.Throwable)</code>. + * + * @param type the inconsitant type. + */ + public TypingException(Type type) { + super(); + this.type = type; + } + + /** + * Creates a new typing exception with the specified cause and a detail + * message of <code>(cause==null ? null : cause.toString())</code> (which + * typically contains the class and detail message of cause). This + * constructor is useful for exceptions that are little more than wrappers + * for other throwables (for example, <code>PrivilegedActionException</code>). + * + * @param type the inconsistant type. + * @param cause the cause (which is saved for later retrieval by the + * <code>Throwable.getCause()</code> method). (A + * <code>null</code> value is permitted, and indicates that the + * cause is nonexistent or unknown.) + */ + public TypingException(Type type, Throwable cause) { + super(cause); + } + + /** + * Returns the typing source of this exception. + * + * @return the typing source of this exception. + */ + public Type getType() { + return this.type; + } + + /** + * Returns a string representation of this typing exception. + * + * @return a string representation of this typing exception. + */ + public String toString() { + return this.getClass().getName() + ": type hierachy of " + + this.type.toString() + " is insconsistant"; + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/package.html b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/package.html new file mode 100644 index 00000000000..f6a75351533 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/exp/type/package.html @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title></title> + <meta name="Generator" content="Cocoa HTML Writer"> + <meta name="CocoaVersion" content="824.42"> + <style type="text/css"> + p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times} + </style> +</head> +<body> +<p>This package contains the classes relative to type of the PDDL language.</p> +</body> +</html> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/JJTLexerState.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/JJTLexerState.java new file mode 100644 index 00000000000..5faff56e85c --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/JJTLexerState.java @@ -0,0 +1,123 @@ +/* Generated By:JavaCC: Do not edit this line. JJTLexerState.java Version 4.1d1 */ +package pddl4j.lexer; + +public class JJTLexerState { + private java.util.List nodes; + private java.util.List marks; + + private int sp; // number of nodes on stack + private int mk; // current mark + private boolean node_created; + + public JJTLexerState() { + nodes = new java.util.ArrayList(); + marks = new java.util.ArrayList(); + sp = 0; + mk = 0; + } + + /* Determines whether the current node was actually closed and + pushed. This should only be called in the final user action of a + node scope. */ + public boolean nodeCreated() { + return node_created; + } + + /* Call this to reinitialize the node stack. It is called + automatically by the parser's ReInit() method. */ + public void reset() { + nodes.clear(); + marks.clear(); + sp = 0; + mk = 0; + } + + /* Returns the root node of the AST. It only makes sense to call + this after a successful parse. */ + public Node rootNode() { + return (Node)nodes.get(0); + } + + /* Pushes a node on to the stack. */ + public void pushNode(Node n) { + nodes.add(n); + ++sp; + } + + /* Returns the node on the top of the stack, and remove it from the + stack. */ + public Node popNode() { + if (--sp < mk) { + mk = ((Integer)marks.remove(marks.size()-1)).intValue(); + } + return (Node)nodes.remove(nodes.size()-1); + } + + /* Returns the node currently on the top of the stack. */ + public Node peekNode() { + return (Node)nodes.get(nodes.size()-1); + } + + /* Returns the number of children on the stack in the current node + scope. */ + public int nodeArity() { + return sp - mk; + } + + + public void clearNodeScope(Node n) { + while (sp > mk) { + popNode(); + } + mk = ((Integer)marks.remove(marks.size()-1)).intValue(); + } + + + public void openNodeScope(Node n) { + marks.add(new Integer(mk)); + mk = sp; + n.jjtOpen(); + } + + + /* A definite node is constructed from a specified number of + children. That number of nodes are popped from the stack and + made the children of the definite node. Then the definite node + is pushed on to the stack. */ + public void closeNodeScope(Node n, int num) { + mk = ((Integer)marks.remove(marks.size()-1)).intValue(); + while (num-- > 0) { + Node c = popNode(); + c.jjtSetParent(n); + n.jjtAddChild(c, num); + } + n.jjtClose(); + pushNode(n); + node_created = true; + } + + + /* A conditional node is constructed if its condition is true. All + the nodes that have been pushed since the node was opened are + made children of the conditional node, which is then pushed + on to the stack. If the condition is false the node is not + constructed and they are left on the stack. */ + public void closeNodeScope(Node n, boolean condition) { + if (condition) { + int a = nodeArity(); + mk = ((Integer)marks.remove(marks.size()-1)).intValue(); + while (a-- > 0) { + Node c = popNode(); + c.jjtSetParent(n); + n.jjtAddChild(c, a); + } + n.jjtClose(); + pushNode(n); + node_created = true; + } else { + mk = ((Integer)marks.remove(marks.size()-1)).intValue(); + node_created = false; + } + } +} +/* JavaCC - OriginalChecksum=ef2ae28cdbf502b5fc736a3e8c854612 (do not edit this line) */ diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/Lexer.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/Lexer.java new file mode 100644 index 00000000000..d072f722e18 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/Lexer.java @@ -0,0 +1,14859 @@ +/* Generated By:JJTree&JavaCC: Do not edit this line. Lexer.java */ +package pddl4j.lexer; + +import java.io.File; +import pddl4j.ErrorManager; + +public class Lexer/* @bgen(jjtree) */implements LexerTreeConstants, + LexerConstants {/* @bgen(jjtree) */ + protected JJTLexerState jjtree = new JJTLexerState(); + private ErrorManager mgr; + private File file; + + private static final int[] BLOCKS = { REQUIREMENTS, TYPES, CONSTANTS, + PREDICATES, FUNCTIONS, ACTION, DURATIVE_ACTION, DERIVED, OBJECTS, + INIT, GOAL, METRIC, EOF }; + + private boolean isBlock(int token) { + int i = 0; + while (i < BLOCKS.length && (BLOCKS[i] != token)) + i++; + return i == BLOCKS.length; + } + + private void error(Throwable e, int line, int column) throws ParseException { + String message = new String(); + if (e.getClass().equals(TokenMgrError.class)) { + String[] tmp = e.getMessage().split(" "); + int l = -1; + int c = -1; + int i = 0; + for (i = 0; i < tmp.length; i++) { + if (tmp[i].equals("line") && i + 1 < tmp.length) { + l = Integer.parseInt(tmp[i + 1].substring(0, tmp[i + 1] + .length() - 1)); + } + if (tmp[i].equals("column") && i + 1 < tmp.length) { + c = Integer.parseInt(tmp[i + 1].substring(0, tmp[i + 1] + .length() - 1)); + } + } + message = e.getMessage().split(". ")[1]; + this.mgr.logLexicalError(message, this.file, l, c); + } else if (e.getClass().equals(ParseException.class)) { + ParseException pe = (ParseException) e; + message = generateErrorMesssage(pe); + this.mgr.logLexicalError(message, this.file, + pe.currentToken.beginLine, pe.currentToken.beginColumn); + } else if (e instanceof NullPointerException) { + // Do nothing + } else { + e.printStackTrace(); + throw new ParseException(e.getMessage()); + } + this.skipToNextBlock(); + } + + private void skipToNextBlock() { + Token t; + Token t2; + do { + t = getNextToken(); + t2 = getToken(2); + + } while (t2 != null && isBlock(t2.kind)); + } + + public void setErrorManager(ErrorManager mgr) { + this.mgr = mgr; + } + + public void setFile(File file) { + this.file = file; + } + + /** + * Creates the error message from a specific parse exception. + * + * @param pe + * the parse exception. + * @return the error message. + */ + private String generateErrorMesssage(ParseException pe) { + StringBuffer expected = new StringBuffer(); + boolean expectedSeq = false; + int maxSize = 0; + for (int i = 0; i < pe.expectedTokenSequences.length; i++) { + if (maxSize < pe.expectedTokenSequences[i].length) { + maxSize = pe.expectedTokenSequences[i].length; + } + for (int j = 0; j < pe.expectedTokenSequences[i].length; j++) { + expected.append(pe.tokenImage[pe.expectedTokenSequences[i][j]]) + .append(" "); + expectedSeq = true; + } + if (pe.expectedTokenSequences[i][pe.expectedTokenSequences[i].length - 1] != 0) { + expected.append("..."); + } + if (i < pe.expectedTokenSequences.length - 1) { + expected.append("\n").append(" "); + } + } + String retval = "unexpected token \"" + pe.currentToken.next.image + + "\"."; + if (expectedSeq) { + if (pe.expectedTokenSequences.length == 1) { + retval += "\nWas expecting:" + "\n" + " "; + } else { + retval += "\nWas expecting one of:" + "\n" + " "; + } + retval += expected.toString(); + } + return retval; + } + + final public SimpleNode parse() throws ParseException { + /* @bgen(jjtree) ROOT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTROOT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = null; + try { + try { + if (jj_2_1(4)) { + t = domain(); + } else if (jj_2_2(4)) { + t = problem(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.mgr.logLexicalError("Lexical error file (" + + file.getName() + ") : to many errors", file); + { + if (true) + throw new ParseException(e.getMessage()); + } + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return jjtn000; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token domain() throws ParseException { + /* @bgen(jjtree) DOMAIN */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDOMAIN); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(DEFINE); + jj_consume_token(LPAREN); + jj_consume_token(DOMAIN); + domain_name(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + try { + if (jj_2_3(2)) { + t = require_def(); + } else { + ; + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + try { + if (jj_2_4(2)) { + t = type_def(); + } else { + ; + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + try { + if (jj_2_5(2)) { + t = constants_def(); + } else { + ; + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + try { + if (jj_2_6(2)) { + t = predicates_def(); + } else { + ; + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + try { + if (jj_2_7(2)) { + t = functions_def(); + } else { + ; + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + try { + if (jj_2_8(2)) { + t = constraints(); + } else { + ; + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + try { + label_1: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[0] = jj_gen; + break label_1; + } + t = structure_def(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + try { + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token require_def() throws ParseException { + /* @bgen(jjtree) REQUIRE_DEF */ + SimpleNode jjtn000 = new SimpleNode(this, JJTREQUIRE_DEF); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(REQUIREMENTS); + label_2: while (true) { + require_key(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case STRIPS: + case TYPING: + case NEGATIVE_PRECONDITIONS: + case DISJUNCTIVE_PRECONDITIONS: + case EQUALITY: + case EXISTENTIAL_PRECONDITIONS: + case UNIVERSAL_PRECONDITIONS: + case QUANTIFIED_PRECONDITIONS: + case CONDITIONAL_EFFECTS: + case FLUENTS: + case ADL: + case DURATIVE_ACTIONS: + case DERIVED_PREDICATES: + case TIMED_INITIAL_LITERALS: + case PREFERENCES: + case CONSTRAINTS: + case CONTINUS_EFFECTS: + case DURATION_INEQUALITIES: + ; + break; + default: + jj_la1[1] = jj_gen; + break label_2; + } + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token require_key() throws ParseException { + /* @bgen(jjtree) REQUIRE_KEY */ + SimpleNode jjtn000 = new SimpleNode(this, JJTREQUIRE_KEY); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case STRIPS: + t = jj_consume_token(STRIPS); + break; + case TYPING: + t = jj_consume_token(TYPING); + break; + case NEGATIVE_PRECONDITIONS: + t = jj_consume_token(NEGATIVE_PRECONDITIONS); + break; + case DISJUNCTIVE_PRECONDITIONS: + t = jj_consume_token(DISJUNCTIVE_PRECONDITIONS); + break; + case EQUALITY: + t = jj_consume_token(EQUALITY); + break; + case EXISTENTIAL_PRECONDITIONS: + t = jj_consume_token(EXISTENTIAL_PRECONDITIONS); + break; + case UNIVERSAL_PRECONDITIONS: + t = jj_consume_token(UNIVERSAL_PRECONDITIONS); + break; + case QUANTIFIED_PRECONDITIONS: + t = jj_consume_token(QUANTIFIED_PRECONDITIONS); + break; + case CONDITIONAL_EFFECTS: + t = jj_consume_token(CONDITIONAL_EFFECTS); + break; + case FLUENTS: + t = jj_consume_token(FLUENTS); + break; + case ADL: + t = jj_consume_token(ADL); + break; + case DURATIVE_ACTIONS: + t = jj_consume_token(DURATIVE_ACTIONS); + break; + case DERIVED_PREDICATES: + t = jj_consume_token(DERIVED_PREDICATES); + break; + case TIMED_INITIAL_LITERALS: + t = jj_consume_token(TIMED_INITIAL_LITERALS); + break; + case PREFERENCES: + t = jj_consume_token(PREFERENCES); + break; + case CONSTRAINTS: + t = jj_consume_token(CONSTRAINTS); + break; + case CONTINUS_EFFECTS: + t = jj_consume_token(CONTINUS_EFFECTS); + break; + case DURATION_INEQUALITIES: + t = jj_consume_token(DURATION_INEQUALITIES); + break; + default: + jj_la1[2] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setImage(t.image); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token type_def() throws ParseException { + /* @bgen(jjtree) TYPE_DEF */ + SimpleNode jjtn000 = new SimpleNode(this, JJTTYPE_DEF); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(TYPES); + typed_list(LexerTreeConstants.JJTPRIMITIVE_TYPE); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token typed_list(int type) throws ParseException { + /* @bgen(jjtree) TYPED_LIST */ + SimpleNode jjtn000 = new SimpleNode(this, JJTTYPED_LIST); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (type == LexerTreeConstants.JJTPRIMITIVE_TYPE) { + label_3: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case NUMBER_TYPE: + case OBJECT_TYPE: + case SYMBOL: + ; + break; + default: + jj_la1[3] = jj_gen; + break label_3; + } + t = primitive_type(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SUB: + jj_consume_token(SUB); + type(); + typed_list(type); + break; + default: + jj_la1[4] = jj_gen; + ; + } + } else if (type == LexerTreeConstants.JJTCONSTANT) { + label_4: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SYMBOL: + ; + break; + default: + jj_la1[5] = jj_gen; + break label_4; + } + t = constant(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SUB: + jj_consume_token(SUB); + type(); + typed_list(type); + break; + default: + jj_la1[6] = jj_gen; + ; + } + } else if (type == LexerTreeConstants.JJTVARIABLE) { + label_5: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case 104: + ; + break; + default: + jj_la1[7] = jj_gen; + break label_5; + } + t = variable(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SUB: + jj_consume_token(SUB); + type(); + typed_list(type); + break; + default: + jj_la1[8] = jj_gen; + ; + } + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + if (t != null) { + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setTypeId(LexerTreeConstants.JJTVARIABLE); + } + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token type() throws ParseException { + /* @bgen(jjtree) TYPE */ + SimpleNode jjtn000 = new SimpleNode(this, JJTTYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + t = jj_consume_token(LPAREN); + jj_consume_token(EITHER); + label_6: while (true) { + primitive_type(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case NUMBER_TYPE: + case OBJECT_TYPE: + case SYMBOL: + ; + break; + default: + jj_la1[9] = jj_gen; + break label_6; + } + } + jj_consume_token(RPAREN); + break; + case NUMBER_TYPE: + case OBJECT_TYPE: + case SYMBOL: + t = primitive_type(); + break; + default: + jj_la1[10] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token primitive_type() throws ParseException { + /* @bgen(jjtree) PRIMITIVE_TYPE */ + SimpleNode jjtn000 = new SimpleNode(this, JJTPRIMITIVE_TYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case OBJECT_TYPE: + t = jj_consume_token(OBJECT_TYPE); + break; + case NUMBER_TYPE: + t = jj_consume_token(NUMBER_TYPE); + break; + case SYMBOL: + t = jj_consume_token(SYMBOL); + break; + default: + jj_la1[11] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setImage(t.image); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token constants_def() throws ParseException { + /* @bgen(jjtree) CONSTANT_DEF */ + SimpleNode jjtn000 = new SimpleNode(this, JJTCONSTANT_DEF); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(CONSTANTS); + typed_list(LexerTreeConstants.JJTCONSTANT); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token constant() throws ParseException { + /* @bgen(jjtree) CONSTANT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTCONSTANT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + t = jj_consume_token(SYMBOL); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setImage(t.image); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token predicates_def() throws ParseException { + /* @bgen(jjtree) PREDICATE_DEF */ + SimpleNode jjtn000 = new SimpleNode(this, JJTPREDICATE_DEF); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(PREDICATES); + label_7: while (true) { + atomic_formula_skeleton(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[12] = jj_gen; + break label_7; + } + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token atomic_formula_skeleton() throws ParseException { + /* @bgen(jjtree) ATOMIC_FORMULA_SKELETON */ + SimpleNode jjtn000 = new SimpleNode(this, JJTATOMIC_FORMULA_SKELETON); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + t = jj_consume_token(LPAREN); + predicate(); + typed_list(LexerTreeConstants.JJTVARIABLE); + jj_consume_token(RPAREN); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token predicate() throws ParseException { + /* @bgen(jjtree) PREDICATE */ + SimpleNode jjtn000 = new SimpleNode(this, JJTPREDICATE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SYMBOL: + t = jj_consume_token(SYMBOL); + break; + case AT: + t = jj_consume_token(AT); + break; + default: + jj_la1[13] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setImage(t.image); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token variable() throws ParseException { + /* @bgen(jjtree) VARIABLE */ + SimpleNode jjtn000 = new SimpleNode(this, JJTVARIABLE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + jj_consume_token(104); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SYMBOL: + t = jj_consume_token(SYMBOL); + break; + case OBJECT_TYPE: + t = jj_consume_token(OBJECT_TYPE); + break; + case NUMBER_TYPE: + t = jj_consume_token(NUMBER_TYPE); + break; + default: + jj_la1[14] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setImage(t.image); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token functions_def() throws ParseException { + /* @bgen(jjtree) FUNCTION_DEF */ + SimpleNode jjtn000 = new SimpleNode(this, JJTFUNCTION_DEF); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(FUNCTIONS); + function_typed_list(LexerTreeConstants.JJTATOMIC_FUNCTION_SKELETON); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token atomic_function_skeleton() throws ParseException { + /* @bgen(jjtree) ATOMIC_FUNCTION_SKELETON */ + SimpleNode jjtn000 = new SimpleNode(this, JJTATOMIC_FUNCTION_SKELETON); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + t = jj_consume_token(LPAREN); + functor(); + typed_list(LexerTreeConstants.JJTVARIABLE); + jj_consume_token(RPAREN); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token functor() throws ParseException { + /* @bgen(jjtree) FUNCTOR */ + SimpleNode jjtn000 = new SimpleNode(this, JJTFUNCTOR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + t = jj_consume_token(SYMBOL); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setImage(t.image); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token function_typed_list(int type) throws ParseException { + /* @bgen(jjtree) FUNCTION_TYPED_LIST */ + SimpleNode jjtn000 = new SimpleNode(this, JJTFUNCTION_TYPED_LIST); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + label_8: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[15] = jj_gen; + break label_8; + } + t = atomic_function_skeleton(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SUB: + jj_consume_token(SUB); + function_type(); + function_typed_list(type); + break; + default: + jj_la1[16] = jj_gen; + ; + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + if (t != null) { + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + } + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token function_type() throws ParseException { + /* @bgen(jjtree) FUNCTION_TYPE */ + SimpleNode jjtn000 = new SimpleNode(this, JJTFUNCTION_TYPE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + t = jj_consume_token(NUMBER_TYPE); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setImage(t.image); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token con_gd() throws ParseException { + /* @bgen(jjtree) CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTCON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_9(2)) { + t = and_con_gd(); + } else if (jj_2_10(2)) { + t = forall_con_gd(); + } else if (jj_2_11(2)) { + t = at_end_con_gd(); + } else if (jj_2_12(2)) { + t = always_con_gd(); + } else if (jj_2_13(2)) { + t = sometime_con_gd(); + } else if (jj_2_14(2)) { + t = within_con_gd(); + } else if (jj_2_15(2)) { + t = at_most_once_con_gd(); + } else if (jj_2_16(2)) { + t = sometime_after_con_gd(); + } else if (jj_2_17(2)) { + t = sometime_before_con_gd(); + } else if (jj_2_18(2)) { + t = always_within_con_gd(); + } else if (jj_2_19(2)) { + t = hold_during_con_gd(); + } else if (jj_2_20(2)) { + t = hold_after_con_gd(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token and_con_gd() throws ParseException { + /* @bgen(jjtree) AND_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAND_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AND); + label_9: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[17] = jj_gen; + break label_9; + } + con_gd(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token forall_con_gd() throws ParseException { + /* @bgen(jjtree) FORALL_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTFORALL_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(FORALL); + jj_consume_token(LPAREN); + typed_list(LexerTreeConstants.JJTVARIABLE); + jj_consume_token(RPAREN); + con_gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_end_con_gd() throws ParseException { + /* @bgen(jjtree) AT_END_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAT_END_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AT); + jj_consume_token(END); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token always_con_gd() throws ParseException { + /* @bgen(jjtree) ALWAYS_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTALWAYS_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(ALWAYS); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token sometime_con_gd() throws ParseException { + /* @bgen(jjtree) SOMETIME_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTSOMETIME_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(SOMETIME); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token within_con_gd() throws ParseException { + /* @bgen(jjtree) WITHIN_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTWITHIN_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(WITHIN); + jj_consume_token(NUMBER); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_most_once_con_gd() throws ParseException { + /* @bgen(jjtree) AT_MOST_ONCE_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAT_MOST_ONCE_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AT_MOST_ONCE); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token sometime_after_con_gd() throws ParseException { + /* @bgen(jjtree) SOMETIME_AFTER_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTSOMETIME_AFTER_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(SOMETIME_AFTER); + gd(); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token sometime_before_con_gd() throws ParseException { + /* @bgen(jjtree) SOMETIME_BEFORE_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTSOMETIME_BEFORE_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(SOMETIME_BEFORE); + gd(); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token always_within_con_gd() throws ParseException { + /* @bgen(jjtree) ALWAYS_WITHIN_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTALWAYS_WITHIN_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(ALWAYS_WITHIN); + jj_consume_token(NUMBER); + gd(); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token hold_during_con_gd() throws ParseException { + /* @bgen(jjtree) HOLD_DURING_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTHOLD_DURING_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(HOLD_DURING); + jj_consume_token(NUMBER); + jj_consume_token(NUMBER); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token hold_after_con_gd() throws ParseException { + /* @bgen(jjtree) HOLD_AFTER_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTHOLD_AFTER_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(HOLD_AFTER); + jj_consume_token(NUMBER); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token gd() throws ParseException { + /* @bgen(jjtree) GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTGD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_21(2)) { + t = atomic_formula(LexerTreeConstants.JJTTERM); + } else if (jj_2_22(2)) { + t = and_gd(); + } else if (jj_2_23(2)) { + t = or_gd(); + } else if (jj_2_24(2)) { + t = not_gd(); + } else if (jj_2_25(2)) { + t = imply_gd(); + } else if (jj_2_26(2)) { + t = exists_gd(); + } else if (jj_2_27(2)) { + t = forall_gd(); + } else if (jj_2_28(2)) { + t = f_comp(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token and_gd() throws ParseException { + /* @bgen(jjtree) AND_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAND_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AND); + label_10: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[18] = jj_gen; + break label_10; + } + gd(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token or_gd() throws ParseException { + /* @bgen(jjtree) OR_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTOR_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(OR); + label_11: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[19] = jj_gen; + break label_11; + } + gd(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token not_gd() throws ParseException { + /* @bgen(jjtree) NOT_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTNOT_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(NOT); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token imply_gd() throws ParseException { + /* @bgen(jjtree) IMPLY_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTIMPLY_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(IMPLY); + gd(); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token exists_gd() throws ParseException { + /* @bgen(jjtree) EXISTS_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTEXISTS_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(EXISTS); + jj_consume_token(LPAREN); + typed_list(LexerTreeConstants.JJTVARIABLE); + jj_consume_token(RPAREN); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token forall_gd() throws ParseException { + /* @bgen(jjtree) FORALL_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTFORALL_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(FORALL); + jj_consume_token(LPAREN); + typed_list(LexerTreeConstants.JJTVARIABLE); + jj_consume_token(RPAREN); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token atomic_formula(int type) throws ParseException { + /* @bgen(jjtree) ATOMIC_FORMULA */ + SimpleNode jjtn000 = new SimpleNode(this, JJTATOMIC_FORMULA); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + predicate(); + if (type == LexerTreeConstants.JJTCONSTANT) { + label_12: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SYMBOL: + ; + break; + default: + jj_la1[20] = jj_gen; + break label_12; + } + constant(); + } + jjtn000.setTypeId(LexerTreeConstants.JJTCONSTANT); + } else if (type == LexerTreeConstants.JJTTERM) { + label_13: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SYMBOL: + case 104: + ; + break; + default: + jj_la1[21] = jj_gen; + break label_13; + } + term(); + } + jjtn000.setTypeId(LexerTreeConstants.JJTTERM); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token term() throws ParseException { + /* @bgen(jjtree) TERM */ + SimpleNode jjtn000 = new SimpleNode(this, JJTTERM); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SYMBOL: + t = constant(); + break; + case 104: + t = variable(); + break; + default: + jj_la1[22] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token literal(int type) throws ParseException { + /* @bgen(jjtree) LITERAL */ + SimpleNode jjtn000 = new SimpleNode(this, JJTLITERAL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_29(2)) { + t = atomic_formula(type); + } else if (jj_2_30(2)) { + t = not_atomic_formula(type); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token not_atomic_formula(int type) throws ParseException { + /* @bgen(jjtree) NOT_ATOMIC_FORMULA */ + SimpleNode jjtn000 = new SimpleNode(this, JJTNOT_ATOMIC_FORMULA); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(NOT); + atomic_formula(type); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token f_comp() throws ParseException { + /* @bgen(jjtree) F_COMP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTF_COMP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = binary_comp(); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token binary_comp() throws ParseException { + /* @bgen(jjtree) BINARY_COMP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTBINARY_COMP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_31(2)) { + t = greater_comp(); + } else if (jj_2_32(2)) { + t = less_comp(); + } else if (jj_2_33(2)) { + t = greater_equal_comp(); + } else if (jj_2_34(2)) { + t = less_equal_comp(); + } else if (jj_2_35(2)) { + t = equal_comp(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token greater_comp() throws ParseException { + /* @bgen(jjtree) GREATER_COMP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTGREATER_COMP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(GREATER); + f_exp(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token greater_equal_comp() throws ParseException { + /* @bgen(jjtree) GREATER_EQUAL_COMP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTGREATER_EQUAL_COMP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(GEQUAL); + f_exp(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token less_equal_comp() throws ParseException { + /* @bgen(jjtree) LESS_EQUAL_COMP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTLESS_EQUAL_COMP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(LEQUAL); + f_exp(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token less_comp() throws ParseException { + /* @bgen(jjtree) LESS_COMP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTLESS_COMP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(LESS); + f_exp(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token equal_comp() throws ParseException { + /* @bgen(jjtree) EQUAL_COMP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTEQUAL_COMP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(EQUAL); + f_exp(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token f_exp() throws ParseException { + /* @bgen(jjtree) F_EXP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTF_EXP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case NUMBER: + t = number(); + break; + default: + jj_la1[23] = jj_gen; + if (jj_2_36(2)) { + t = op(); + } else if (jj_2_37(2)) { + t = f_head(); + } else if (jj_2_38(2)) { + t = variable(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token number() throws ParseException { + /* @bgen(jjtree) NUMBER */ + SimpleNode jjtn000 = new SimpleNode(this, JJTNUMBER); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(NUMBER); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setImage(t.image); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token op() throws ParseException { + /* @bgen(jjtree) OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTOP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_39(2)) { + t = binary_operation(); + } else if (jj_2_40(2)) { + t = unary_op(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token binary_operation() throws ParseException { + /* @bgen(jjtree) BINARY_OPERATION */ + SimpleNode jjtn000 = new SimpleNode(this, JJTBINARY_OPERATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_41(2)) { + t = add_op(); + } else if (jj_2_42(2)) { + t = substract_op(); + } else if (jj_2_43(2)) { + t = multiply_op(); + } else if (jj_2_44(2)) { + t = divide_op(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token add_op() throws ParseException { + /* @bgen(jjtree) ADD_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTADD_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(ADD); + f_exp(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token substract_op() throws ParseException { + /* @bgen(jjtree) SUBSTRACT_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTSUBSTRACT_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(SUB); + f_exp(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token multiply_op() throws ParseException { + /* @bgen(jjtree) MULTIPLY_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTMULTIPLY_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(MUL); + f_exp(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token divide_op() throws ParseException { + /* @bgen(jjtree) DIVIDE_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDIVIDE_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(DIV); + f_exp(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token unary_op() throws ParseException { + /* @bgen(jjtree) UNARY_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTUNARY_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(SUB); + f_exp_da(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token f_head() throws ParseException { + /* @bgen(jjtree) F_HEAD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTF_HEAD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + functor(); + label_14: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SYMBOL: + case 104: + ; + break; + default: + jj_la1[24] = jj_gen; + break label_14; + } + term(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token structure_def() throws ParseException { + /* @bgen(jjtree) STRUCTURE_DEF */ + SimpleNode jjtn000 = new SimpleNode(this, JJTSTRUCTURE_DEF); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_45(2)) { + t = action_def(); + } else if (jj_2_46(2)) { + t = durative_action_def(); + } else if (jj_2_47(2)) { + t = derived_def(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token action_def() throws ParseException { + /* @bgen(jjtree) ACTION_DEF */ + SimpleNode jjtn000 = new SimpleNode(this, JJTACTION_DEF); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(ACTION); + action_name(); + jj_consume_token(PARAMETERS); + jj_consume_token(LPAREN); + typed_list(LexerTreeConstants.JJTVARIABLE); + jj_consume_token(RPAREN); + action_def_body(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token action_name() throws ParseException { + /* @bgen(jjtree) ACTION_NAME */ + SimpleNode jjtn000 = new SimpleNode(this, JJTACTION_NAME); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(SYMBOL); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setImage(t.image); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token action_def_body() throws ParseException { + /* @bgen(jjtree) ACTION_DEF_BODY */ + SimpleNode jjtn000 = new SimpleNode(this, JJTACTION_DEF_BODY); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(PRECONDITION); + pre_gd(); + jj_consume_token(EFFECT); + effect(); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token pre_gd() throws ParseException { + /* @bgen(jjtree) PRE_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTPRE_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_48(2)) { + t = empty_or(); + } else if (jj_2_49(2)) { + t = pref_gd(); + } else if (jj_2_50(2)) { + t = and_pre_gd(); + } else if (jj_2_51(2)) { + t = forall_pre_gd(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token empty_or() throws ParseException { + /* @bgen(jjtree) EMPTY_OR */ + SimpleNode jjtn000 = new SimpleNode(this, JJTEMPTY_OR); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token and_pre_gd() throws ParseException { + /* @bgen(jjtree) AND_PRE_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAND_PRE_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AND); + label_15: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[25] = jj_gen; + break label_15; + } + pre_gd(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token forall_pre_gd() throws ParseException { + /* @bgen(jjtree) FORALL_PRE_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTFORALL_PRE_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(FORALL); + jj_consume_token(LPAREN); + typed_list(LexerTreeConstants.JJTVARIABLE); + jj_consume_token(RPAREN); + pre_gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token pref_gd() throws ParseException { + /* @bgen(jjtree) PREF_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTPREF_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_52(2)) { + t = named_pref_gd(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + t = gd(); + break; + default: + jj_la1[26] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token named_pref_gd() throws ParseException { + /* @bgen(jjtree) NAMED_PREF_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTNAMED_PREF_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(PREFERENCE); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SYMBOL: + pref_name(); + break; + default: + jj_la1[27] = jj_gen; + ; + } + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token pref_name() throws ParseException { + /* @bgen(jjtree) PREF_NAME */ + SimpleNode jjtn000 = new SimpleNode(this, JJTPREF_NAME); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(SYMBOL); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token effect() throws ParseException { + /* @bgen(jjtree) EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTEFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_53(2)) { + t = and_c_effect(); + } else if (jj_2_54(2)) { + t = c_effect(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token and_c_effect() throws ParseException { + /* @bgen(jjtree) AND_C_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAND_C_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AND); + label_16: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[28] = jj_gen; + break label_16; + } + c_effect(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token prob_effect() throws ParseException { + /* @bgen(jjtree) PROB_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTPROB_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(PROB); + label_17: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case NUMBER: + ; + break; + default: + jj_la1[29] = jj_gen; + break label_17; + } + prob_term(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token prob_term() throws ParseException { + /* @bgen(jjtree) PROB_TERM */ + SimpleNode jjtn000 = new SimpleNode(this, JJTPROB_TERM); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_55(3)) { + t = number(); + c_effect(); + } else if (jj_2_56(3)) { + t = number(); + and_c_effect(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token c_effect() throws ParseException { + /* @bgen(jjtree) C_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTC_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_57(2)) { + t = forall_effect(); + } else if (jj_2_58(2)) { + t = when_con_effect(); + } else if (jj_2_59(2)) { + t = p_effect(); + } else if (jj_2_60(2)) { + t = prob_effect(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token forall_effect() throws ParseException { + /* @bgen(jjtree) FORALL_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTFORALL_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(FORALL); + jj_consume_token(LPAREN); + typed_list(LexerTreeConstants.JJTVARIABLE); + jj_consume_token(RPAREN); + effect(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token when_con_effect() throws ParseException { + /* @bgen(jjtree) WHEN_CON_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTWHEN_CON_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(WHEN); + gd(); + cond_effect(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token cond_effect() throws ParseException { + /* @bgen(jjtree) COND_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTCOND_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_61(2)) { + t = and_c_effect(); + } else if (jj_2_62(2)) { + t = c_effect(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token and_p_effect() throws ParseException { + /* @bgen(jjtree) AND_P_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAND_P_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AND); + label_18: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[30] = jj_gen; + break label_18; + } + p_effect(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token p_effect() throws ParseException { + /* @bgen(jjtree) P_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTP_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_63(2)) { + t = assign_op(); + } else if (jj_2_64(2)) { + t = literal(LexerTreeConstants.JJTTERM); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token assign_op() throws ParseException { + /* @bgen(jjtree) ASSIGN_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTASSIGN_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_65(2)) { + t = assign(); + } else if (jj_2_66(2)) { + t = scale_up(); + } else if (jj_2_67(2)) { + t = scale_down(); + } else if (jj_2_68(2)) { + t = increase(); + } else if (jj_2_69(2)) { + t = decrease(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token assign() throws ParseException { + /* @bgen(jjtree) ASSIGN */ + SimpleNode jjtn000 = new SimpleNode(this, JJTASSIGN); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(ASSIGN); + f_head(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token scale_up() throws ParseException { + /* @bgen(jjtree) SCALE_UP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTSCALE_UP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(SCALE_UP); + f_head(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token scale_down() throws ParseException { + /* @bgen(jjtree) SCALE_DOWN */ + SimpleNode jjtn000 = new SimpleNode(this, JJTSCALE_DOWN); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(SCALE_DOWN); + f_head(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token increase() throws ParseException { + /* @bgen(jjtree) INCREASE */ + SimpleNode jjtn000 = new SimpleNode(this, JJTINCREASE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(INCREASE); + f_head(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token decrease() throws ParseException { + /* @bgen(jjtree) DECREASE */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDECREASE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(DECREASE); + f_head(); + f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token durative_action_def() throws ParseException { + /* @bgen(jjtree) DURATION_ACTION_DEF */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDURATION_ACTION_DEF); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(DURATIVE_ACTION); + da_symbol(); + jj_consume_token(PARAMETERS); + jj_consume_token(LPAREN); + typed_list(LexerTreeConstants.JJTVARIABLE); + jj_consume_token(RPAREN); + da_def_body(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_symbol() throws ParseException { + /* @bgen(jjtree) DA_SYMBOL */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_SYMBOL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(SYMBOL); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setImage(t.image); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_def_body() throws ParseException { + /* @bgen(jjtree) DA_DEF_BODY */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_DEF_BODY); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(DURATION); + duration_constraint(); + jj_consume_token(CONDITION); + da_gd(); + jj_consume_token(EFFECT); + da_effect(); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token duration_constraint() throws ParseException { + /* @bgen(jjtree) DURATION_CONSTRAINT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDURATION_CONSTRAINT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_70(2)) { + t = empty_or(); + } else if (jj_2_71(2)) { + t = and_simple_duration_constraint(); + } else if (jj_2_72(2)) { + t = simple_duration_constraint(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token and_simple_duration_constraint() throws ParseException { + /* @bgen(jjtree) AND_SIMPLE_DURATION_CONSTRAINT */ + SimpleNode jjtn000 = new SimpleNode(this, + JJTAND_SIMPLE_DURATION_CONSTRAINT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AND); + label_19: while (true) { + simple_duration_constraint(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[31] = jj_gen; + break label_19; + } + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token simple_duration_constraint() throws ParseException { + /* @bgen(jjtree) SIMPLE_DURATION_CONSTRAINT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTSIMPLE_DURATION_CONSTRAINT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_73(2)) { + t = d_op(); + } else if (jj_2_74(2)) { + t = at_simple_duration_constraint(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_simple_duration_constraint() throws ParseException { + /* @bgen(jjtree) AT_SIMPLE_DURATION_CONSTRAINT */ + SimpleNode jjtn000 = new SimpleNode(this, + JJTAT_SIMPLE_DURATION_CONSTRAINT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_75(3)) { + t = at_start_simple_duration_constraint(); + } else if (jj_2_76(3)) { + t = at_end_simple_duration_constraint(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_start_simple_duration_constraint() + throws ParseException { + /* @bgen(jjtree) AT_START_SIMPLE_DURATION_CONSTRAINT */ + SimpleNode jjtn000 = new SimpleNode(this, + JJTAT_START_SIMPLE_DURATION_CONSTRAINT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AT); + jj_consume_token(START); + simple_duration_constraint(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_end_simple_duration_constraint() + throws ParseException { + /* @bgen(jjtree) AT_END_SIMPLE_DURATION_CONSTRAINT */ + SimpleNode jjtn000 = new SimpleNode(this, + JJTAT_END_SIMPLE_DURATION_CONSTRAINT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AT); + jj_consume_token(END); + simple_duration_constraint(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token d_op() throws ParseException { + /* @bgen(jjtree) D_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTD_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_77(2)) { + t = equal_d_op(); + } else if (jj_2_78(2)) { + t = gequal_d_op(); + } else if (jj_2_79(2)) { + t = lequal_d_op(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token equal_d_op() throws ParseException { + /* @bgen(jjtree) EQUAL_D_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTEQUAL_D_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(EQUAL); + var_duration(); + d_value(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token gequal_d_op() throws ParseException { + /* @bgen(jjtree) GEQUAL_D_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTGEQUAL_D_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(GEQUAL); + var_duration(); + d_value(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token lequal_d_op() throws ParseException { + /* @bgen(jjtree) LEQUAL_D_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTLEQUAL_D_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(LEQUAL); + var_duration(); + d_value(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token var_duration() throws ParseException { + /* @bgen(jjtree) VAR_DURATION */ + SimpleNode jjtn000 = new SimpleNode(this, JJTVAR_DURATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(VAR_DURATION); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token d_value() throws ParseException { + /* @bgen(jjtree) D_VALUE */ + SimpleNode jjtn000 = new SimpleNode(this, JJTD_VALUE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_80(2)) { + t = number(); + } else if (jj_2_81(2)) { + t = f_exp(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_gd() throws ParseException { + /* @bgen(jjtree) DA_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_82(2)) { + t = pref_timed_gd(); + } else if (jj_2_83(2)) { + t = and_da_gd(); + } else if (jj_2_84(2)) { + t = forall_da_gd(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token forall_da_gd() throws ParseException { + /* @bgen(jjtree) FORALL_DA_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTFORALL_DA_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(FORALL); + jj_consume_token(LPAREN); + typed_list(LexerTreeConstants.JJTVARIABLE); + jj_consume_token(RPAREN); + da_gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token and_da_gd() throws ParseException { + /* @bgen(jjtree) AND_DA_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAND_DA_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AND); + label_20: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[32] = jj_gen; + break label_20; + } + da_gd(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token pref_timed_gd() throws ParseException { + /* @bgen(jjtree) PREF_TIMED_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTPREF_TIMED_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_85(2)) { + t = timed_gd(); + } else if (jj_2_86(2)) { + t = named_pref_timed_gd(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token named_pref_timed_gd() throws ParseException { + /* @bgen(jjtree) NAMED_PREF_TIMED_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTNAMED_PREF_TIMED_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(PREFERENCE); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SYMBOL: + pref_name(); + break; + default: + jj_la1[33] = jj_gen; + ; + } + timed_gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token timed_gd() throws ParseException { + /* @bgen(jjtree) TIMED_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTTIMED_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_87(2)) { + t = at_timed_gd(); + } else if (jj_2_88(2)) { + t = over_timed_gd(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token over_timed_gd() throws ParseException { + /* @bgen(jjtree) OVER_TIMED_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTOVER_TIMED_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = over_all_timed_gd(); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token over_all_timed_gd() throws ParseException { + /* @bgen(jjtree) OVER_ALL_TIMED_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTOVER_ALL_TIMED_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(OVER); + jj_consume_token(ALL); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_timed_gd() throws ParseException { + /* @bgen(jjtree) AT_TIMED_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAT_TIMED_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_89(3)) { + t = at_start_timed_gd(); + } else if (jj_2_90(2)) { + t = at_end_timed_gd(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_start_timed_gd() throws ParseException { + /* @bgen(jjtree) AT_START_TIMED_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAT_START_TIMED_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AT); + jj_consume_token(START); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_end_timed_gd() throws ParseException { + /* @bgen(jjtree) AT_END_TIMED_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAT_END_TIMED_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AT); + jj_consume_token(END); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token interval() throws ParseException { + /* @bgen(jjtree) INTERVAL */ + SimpleNode jjtn000 = new SimpleNode(this, JJTINTERVAL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(ALL); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_effect() throws ParseException { + /* @bgen(jjtree) DA_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_91(2)) { + t = timed_effect(); + } else if (jj_2_92(2)) { + t = and_da_effect(); + } else if (jj_2_93(2)) { + t = forall_da_effect(); + } else if (jj_2_94(2)) { + t = when_da_effect(); + } else if (jj_2_95(2)) { + t = da_assign_op(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_assign_op() throws ParseException { + /* @bgen(jjtree) DA_ASSIGN_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_ASSIGN_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_96(2)) { + t = da_assign(); + } else if (jj_2_97(2)) { + t = da_scale_up(); + } else if (jj_2_98(2)) { + t = da_scale_down(); + } else if (jj_2_99(2)) { + t = da_increase(); + } else if (jj_2_100(2)) { + t = da_decrease(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_assign() throws ParseException { + /* @bgen(jjtree) DA_ASSIGN */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_ASSIGN); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(ASSIGN); + f_head(); + f_exp_da(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_scale_up() throws ParseException { + /* @bgen(jjtree) DA_SCALE_UP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_SCALE_UP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(SCALE_UP); + f_head(); + f_exp_da(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_scale_down() throws ParseException { + /* @bgen(jjtree) DA_SCALE_DOWN */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_SCALE_DOWN); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(SCALE_DOWN); + f_head(); + f_exp_da(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_increase() throws ParseException { + /* @bgen(jjtree) DA_INCREASE */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_INCREASE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(INCREASE); + f_head(); + f_exp_da(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_decrease() throws ParseException { + /* @bgen(jjtree) DA_DECREASE */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_DECREASE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(DECREASE); + f_head(); + f_exp_da(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token when_da_effect() throws ParseException { + /* @bgen(jjtree) WHEN_DA_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTWHEN_DA_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(WHEN); + da_gd(); + timed_effect(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token forall_da_effect() throws ParseException { + /* @bgen(jjtree) FORALL_DA_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTFORALL_DA_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(FORALL); + jj_consume_token(LPAREN); + typed_list(LexerTreeConstants.JJTVARIABLE); + jj_consume_token(RPAREN); + da_effect(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token and_da_effect() throws ParseException { + /* @bgen(jjtree) AND_DA_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAND_DA_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AND); + label_21: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[34] = jj_gen; + break label_21; + } + da_effect(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token timed_effect() throws ParseException { + /* @bgen(jjtree) TIMED_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTTIMED_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_101(2)) { + t = at_da_effect(); + } else if (jj_2_102(2)) { + t = at_f_assign_da_effect(); + } else if (jj_2_103(2)) { + t = assign_op_t(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_f_assign_da_effect() throws ParseException { + /* @bgen(jjtree) AT_F_ASSIGN_DA_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAT_F_ASSIGN_DA_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_104(3)) { + t = at_start_f_assign_da_effect(); + } else if (jj_2_105(3)) { + t = at_end_f_assign_da_effect(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_start_f_assign_da_effect() throws ParseException { + /* @bgen(jjtree) AT_START_F_ASSIGN_DA_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, + JJTAT_START_F_ASSIGN_DA_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AT); + jj_consume_token(START); + f_assign_da(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_end_f_assign_da_effect() throws ParseException { + /* @bgen(jjtree) AT_END_F_ASSIGN_DA_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAT_END_F_ASSIGN_DA_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AT); + jj_consume_token(END); + f_assign_da(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_da_effect() throws ParseException { + /* @bgen(jjtree) AT_DA_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAT_DA_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_106(4)) { + t = at_start_da_effect(); + } else if (jj_2_107(4)) { + t = at_end_da_effect(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_start_da_effect() throws ParseException { + /* @bgen(jjtree) AT_START_DA_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAT_START_DA_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AT); + jj_consume_token(START); + literal(LexerTreeConstants.JJTTERM); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token at_end_da_effect() throws ParseException { + /* @bgen(jjtree) AT_END_DA_EFFECT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAT_END_DA_EFFECT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AT); + jj_consume_token(END); + literal(LexerTreeConstants.JJTTERM); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token assign_op_t() throws ParseException { + /* @bgen(jjtree) ASSIGN_OP_T */ + SimpleNode jjtn000 = new SimpleNode(this, JJTASSIGN_OP_T); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_108(2)) { + t = increase_assign_op_t(); + } else if (jj_2_109(2)) { + t = decrease_assign_op_t(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token increase_assign_op_t() throws ParseException { + /* @bgen(jjtree) INCREASE_ASSIGN_OP_T */ + SimpleNode jjtn000 = new SimpleNode(this, JJTINCREASE_ASSIGN_OP_T); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(INCREASE); + f_head(); + f_exp_t(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token decrease_assign_op_t() throws ParseException { + /* @bgen(jjtree) DECREASE_ASSIGN_OP_T */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDECREASE_ASSIGN_OP_T); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(DECREASE); + f_head(); + f_exp_t(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token f_exp_t() throws ParseException { + /* @bgen(jjtree) F_EXP_T */ + SimpleNode jjtn000 = new SimpleNode(this, JJTF_EXP_T); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_110(2)) { + t = jj_consume_token(LPAREN); + jj_consume_token(MUL); + continous_variable(); + f_exp(); + jj_consume_token(RPAREN); + } else if (jj_2_111(2)) { + t = jj_consume_token(LPAREN); + jj_consume_token(MUL); + f_exp(); + continous_variable(); + jj_consume_token(RPAREN); + } else if (jj_2_112(2)) { + t = continous_variable(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token continous_variable() throws ParseException { + /* @bgen(jjtree) CONTINOUS_VARIABLE */ + SimpleNode jjtn000 = new SimpleNode(this, JJTCONTINOUS_VARIABLE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(CONTINOUS_VARIABLE); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setImage(t.image); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token f_assign_da() throws ParseException { + /* @bgen(jjtree) F_ASSIGN_DA */ + SimpleNode jjtn000 = new SimpleNode(this, JJTF_ASSIGN_DA); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_113(2)) { + t = da_assign(); + } else if (jj_2_114(2)) { + t = da_scale_up(); + } else if (jj_2_115(2)) { + t = da_scale_down(); + } else if (jj_2_116(2)) { + t = da_increase(); + } else if (jj_2_117(2)) { + t = da_decrease(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token f_exp_da() throws ParseException { + /* @bgen(jjtree) F_EXP_DA */ + SimpleNode jjtn000 = new SimpleNode(this, JJTF_EXP_DA); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_118(3)) { + t = f_exp(); + } else if (jj_2_119(3)) { + t = da_binary_op(); + } else if (jj_2_120(3)) { + t = da_unary_op(); + } else if (jj_2_121(3)) { + t = var_duration(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_binary_op() throws ParseException { + /* @bgen(jjtree) DA_BINARY_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_BINARY_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_122(2)) { + t = da_add_op(); + } else if (jj_2_123(2)) { + t = da_substract_op(); + } else if (jj_2_124(2)) { + t = da_multiply_op(); + } else if (jj_2_125(2)) { + t = da_divide_op(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_add_op() throws ParseException { + /* @bgen(jjtree) DA_ADD_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_ADD_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(ADD); + f_head(); + f_exp_da(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_substract_op() throws ParseException { + /* @bgen(jjtree) DA_SUBSTRACT_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_SUBSTRACT_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(SUB); + f_head(); + f_exp_da(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_multiply_op() throws ParseException { + /* @bgen(jjtree) DA_MULTIPLY_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_MULTIPLY_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(MUL); + f_head(); + f_exp_da(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_divide_op() throws ParseException { + /* @bgen(jjtree) DA_DIVIDE_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_DIVIDE_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(DIV); + f_head(); + f_exp_da(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token da_unary_op() throws ParseException { + /* @bgen(jjtree) DA_UNARY_OP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDA_UNARY_OP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(SUB); + f_exp_da(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token derived_def() throws ParseException { + /* @bgen(jjtree) DERIVED_DEF */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDERIVED_DEF); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(DERIVED); + atomic_formula(LexerTreeConstants.JJTVARIABLE); + gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token problem() throws ParseException { + /* @bgen(jjtree) PROBLEM */ + SimpleNode jjtn000 = new SimpleNode(this, JJTPROBLEM); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(DEFINE); + jj_consume_token(LPAREN); + jj_consume_token(PROBLEM); + problem_name(); + jj_consume_token(RPAREN); + jj_consume_token(LPAREN); + jj_consume_token(P_DOMAIN); + domain_name(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + if (jj_2_126(2)) { + require_def(); + } else { + ; + } + if (jj_2_127(2)) { + object_declaration(); + } else { + ; + } + init(); + goal(); + if (jj_2_128(2)) { + constraints(); + } else { + ; + } + if (jj_2_129(2)) { + metric_spec(); + } else { + ; + } + jj_consume_token(RPAREN); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token problem_name() throws ParseException { + /* @bgen(jjtree) PROBLEM_NAME */ + SimpleNode jjtn000 = new SimpleNode(this, JJTPROBLEM_NAME); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(SYMBOL); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setImage(t.image); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token domain_name() throws ParseException { + /* @bgen(jjtree) DOMAIN_NAME */ + SimpleNode jjtn000 = new SimpleNode(this, JJTDOMAIN_NAME); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(SYMBOL); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + jjtn000.setImage(t.image); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token object_declaration() throws ParseException { + /* @bgen(jjtree) OBJECT_DECLARATION */ + SimpleNode jjtn000 = new SimpleNode(this, JJTOBJECT_DECLARATION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(OBJECTS); + typed_list(LexerTreeConstants.JJTCONSTANT); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token init() throws ParseException { + /* @bgen(jjtree) INIT */ + SimpleNode jjtn000 = new SimpleNode(this, JJTINIT); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(INIT); + label_22: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[35] = jj_gen; + break label_22; + } + init_el(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token init_el() throws ParseException { + /* @bgen(jjtree) INIT_EL */ + SimpleNode jjtn000 = new SimpleNode(this, JJTINIT_EL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_130(2)) { + t = literal(LexerTreeConstants.JJTCONSTANT); + } else if (jj_2_131(2)) { + t = equal_init_el(); + } else if (jj_2_132(3)) { + t = timed_literal(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token equal_init_el() throws ParseException { + /* @bgen(jjtree) EQUAL_INIT_EL */ + SimpleNode jjtn000 = new SimpleNode(this, JJTEQUAL_INIT_EL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(EQUALITY); + f_head(); + number(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token timed_literal() throws ParseException { + /* @bgen(jjtree) TIMED_LITERAL */ + SimpleNode jjtn000 = new SimpleNode(this, JJTTIMED_LITERAL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AT); + number(); + literal(LexerTreeConstants.JJTCONSTANT); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token goal() throws ParseException { + /* @bgen(jjtree) GOAL */ + SimpleNode jjtn000 = new SimpleNode(this, JJTGOAL); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(GOAL); + pre_gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token constraints() throws ParseException { + /* @bgen(jjtree) CONSTRAINTS */ + SimpleNode jjtn000 = new SimpleNode(this, JJTCONSTRAINTS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(CONSTRAINTS); + pref_con_gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token pref_con_gd() throws ParseException { + /* @bgen(jjtree) PREF_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTPREF_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_133(2)) { + t = and_pref_con_gd(); + } else if (jj_2_134(2)) { + t = forall_pref_con_gd(); + } else if (jj_2_135(2)) { + t = named_pref_con_gd(); + } else if (jj_2_136(2)) { + t = con_gd(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token and_pref_con_gd() throws ParseException { + /* @bgen(jjtree) AND_PREF_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTAND_PREF_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(AND); + label_23: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + ; + break; + default: + jj_la1[36] = jj_gen; + break label_23; + } + pref_con_gd(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token named_pref_con_gd() throws ParseException { + /* @bgen(jjtree) NAMED_PREF_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTNAMED_PREF_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(PREFERENCE); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SYMBOL: + pref_name(); + break; + default: + jj_la1[37] = jj_gen; + ; + } + con_gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token forall_pref_con_gd() throws ParseException { + /* @bgen(jjtree) FORALL_PREF_CON_GD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTFORALL_PREF_CON_GD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(FORALL); + jj_consume_token(LPAREN); + typed_list(LexerTreeConstants.JJTVARIABLE); + jj_consume_token(RPAREN); + pref_con_gd(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token metric_spec() throws ParseException { + /* @bgen(jjtree) METRIC_SPEC */ + SimpleNode jjtn000 = new SimpleNode(this, JJTMETRIC_SPEC); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_137(3)) { + t = maximize(); + } else if (jj_2_138(3)) { + t = minimize(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token maximize() throws ParseException { + /* @bgen(jjtree) MAXIMIZE */ + SimpleNode jjtn000 = new SimpleNode(this, JJTMAXIMIZE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(METRIC); + jj_consume_token(MAXIMIZE); + metric_f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token minimize() throws ParseException { + /* @bgen(jjtree) MINIMIZE */ + SimpleNode jjtn000 = new SimpleNode(this, JJTMINIMIZE); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(METRIC); + jj_consume_token(MINIMIZE); + metric_f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token metric_f_exp() throws ParseException { + /* @bgen(jjtree) METRIC_F_EXP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTMETRIC_F_EXP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_139(2)) { + t = unary_op_metric_f_exp(); + } else if (jj_2_140(2)) { + t = binary_op_metric_f_exp(); + } else if (jj_2_141(2)) { + t = multi_op_metric_f_exp(); + } else if (jj_2_142(2)) { + t = number(); + } else if (jj_2_143(2)) { + t = constant_f_head(); + } else if (jj_2_144(2)) { + t = total_time(); + } else if (jj_2_145(2)) { + t = violated_pref_exp(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token violated_pref_exp() throws ParseException { + /* @bgen(jjtree) VIOLATED_PREF_EXP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTVIOLATED_PREF_EXP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(IS_VIOLATED); + pref_name(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token constant_f_head() throws ParseException { + /* @bgen(jjtree) CONSTANT_F_HEAD */ + SimpleNode jjtn000 = new SimpleNode(this, JJTCONSTANT_F_HEAD); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + functor(); + label_24: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SYMBOL: + ; + break; + default: + jj_la1[38] = jj_gen; + break label_24; + } + constant(); + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token total_time() throws ParseException { + /* @bgen(jjtree) TOTAL_TIME */ + SimpleNode jjtn000 = new SimpleNode(this, JJTTOTAL_TIME); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(TOTAL_TIME); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token binary_op_metric_f_exp() throws ParseException { + /* @bgen(jjtree) BINARY_OP_METRIC_F_EXP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTBINARY_OP_METRIC_F_EXP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_146(2)) { + t = add_op_metric_f_exp(); + } else if (jj_2_147(2)) { + t = substract_op_metric_f_exp(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token add_op_metric_f_exp() throws ParseException { + /* @bgen(jjtree) ADD_OP_METRIC_F_EXP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTADD_OP_METRIC_F_EXP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(ADD); + metric_f_exp(); + metric_f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token substract_op_metric_f_exp() throws ParseException { + /* @bgen(jjtree) SUBSTRACT_OP_METRIC_F_EXP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTSUBSTRACT_OP_METRIC_F_EXP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(SUB); + metric_f_exp(); + metric_f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token multi_op_metric_f_exp() throws ParseException { + /* @bgen(jjtree) MULTI_OP_METRIC_F_EXP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTMULTI_OP_METRIC_F_EXP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + if (jj_2_148(2)) { + t = multiply_narity_op_metric_f_exp(); + } else if (jj_2_149(2)) { + t = add_narity_op_metric_f_exp(); + } else { + jj_consume_token(-1); + throw new ParseException(); + } + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token multiply_narity_op_metric_f_exp() throws ParseException { + /* @bgen(jjtree) MULTIPLY_NARITY_OP_METRIC_F_EXP */ + SimpleNode jjtn000 = new SimpleNode(this, + JJTMULTIPLY_NARITY_OP_METRIC_F_EXP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(MUL); + metric_f_exp(); + label_25: while (true) { + metric_f_exp(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + case TOTAL_TIME: + case NUMBER: + ; + break; + default: + jj_la1[39] = jj_gen; + break label_25; + } + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token add_narity_op_metric_f_exp() throws ParseException { + /* @bgen(jjtree) ADD_NARITY_OP_METRIC_F_EXP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTADD_NARITY_OP_METRIC_F_EXP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(ADD); + metric_f_exp(); + label_26: while (true) { + metric_f_exp(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LPAREN: + case TOTAL_TIME: + case NUMBER: + ; + break; + default: + jj_la1[40] = jj_gen; + break label_26; + } + } + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + final public Token unary_op_metric_f_exp() throws ParseException { + /* @bgen(jjtree) UNARY_OP_METRIC_F_EXP */ + SimpleNode jjtn000 = new SimpleNode(this, JJTUNARY_OP_METRIC_F_EXP); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + Token t = token; + try { + try { + t = jj_consume_token(LPAREN); + jj_consume_token(SUB); + metric_f_exp(); + jj_consume_token(RPAREN); + } catch (Throwable e) { + this.error(e, t.beginLine, t.beginColumn); + ; + } + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.setLine(t.beginLine); + jjtn000.setColumn(t.beginColumn); + { + if (true) + return t; + } + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) + throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) + throw (ParseException) jjte000; + } + } + { + if (true) + throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + } + } + throw new Error("Missing return statement in function"); + } + + private boolean jj_2_1(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_1(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(0, xla); + } + } + + private boolean jj_2_2(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_2(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(1, xla); + } + } + + private boolean jj_2_3(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_3(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(2, xla); + } + } + + private boolean jj_2_4(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_4(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(3, xla); + } + } + + private boolean jj_2_5(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_5(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(4, xla); + } + } + + private boolean jj_2_6(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_6(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(5, xla); + } + } + + private boolean jj_2_7(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_7(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(6, xla); + } + } + + private boolean jj_2_8(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_8(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(7, xla); + } + } + + private boolean jj_2_9(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_9(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(8, xla); + } + } + + private boolean jj_2_10(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_10(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(9, xla); + } + } + + private boolean jj_2_11(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_11(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(10, xla); + } + } + + private boolean jj_2_12(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_12(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(11, xla); + } + } + + private boolean jj_2_13(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_13(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(12, xla); + } + } + + private boolean jj_2_14(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_14(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(13, xla); + } + } + + private boolean jj_2_15(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_15(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(14, xla); + } + } + + private boolean jj_2_16(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_16(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(15, xla); + } + } + + private boolean jj_2_17(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_17(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(16, xla); + } + } + + private boolean jj_2_18(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_18(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(17, xla); + } + } + + private boolean jj_2_19(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_19(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(18, xla); + } + } + + private boolean jj_2_20(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_20(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(19, xla); + } + } + + private boolean jj_2_21(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_21(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(20, xla); + } + } + + private boolean jj_2_22(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_22(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(21, xla); + } + } + + private boolean jj_2_23(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_23(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(22, xla); + } + } + + private boolean jj_2_24(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_24(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(23, xla); + } + } + + private boolean jj_2_25(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_25(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(24, xla); + } + } + + private boolean jj_2_26(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_26(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(25, xla); + } + } + + private boolean jj_2_27(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_27(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(26, xla); + } + } + + private boolean jj_2_28(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_28(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(27, xla); + } + } + + private boolean jj_2_29(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_29(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(28, xla); + } + } + + private boolean jj_2_30(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_30(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(29, xla); + } + } + + private boolean jj_2_31(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_31(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(30, xla); + } + } + + private boolean jj_2_32(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_32(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(31, xla); + } + } + + private boolean jj_2_33(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_33(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(32, xla); + } + } + + private boolean jj_2_34(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_34(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(33, xla); + } + } + + private boolean jj_2_35(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_35(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(34, xla); + } + } + + private boolean jj_2_36(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_36(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(35, xla); + } + } + + private boolean jj_2_37(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_37(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(36, xla); + } + } + + private boolean jj_2_38(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_38(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(37, xla); + } + } + + private boolean jj_2_39(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_39(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(38, xla); + } + } + + private boolean jj_2_40(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_40(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(39, xla); + } + } + + private boolean jj_2_41(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_41(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(40, xla); + } + } + + private boolean jj_2_42(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_42(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(41, xla); + } + } + + private boolean jj_2_43(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_43(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(42, xla); + } + } + + private boolean jj_2_44(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_44(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(43, xla); + } + } + + private boolean jj_2_45(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_45(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(44, xla); + } + } + + private boolean jj_2_46(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_46(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(45, xla); + } + } + + private boolean jj_2_47(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_47(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(46, xla); + } + } + + private boolean jj_2_48(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_48(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(47, xla); + } + } + + private boolean jj_2_49(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_49(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(48, xla); + } + } + + private boolean jj_2_50(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_50(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(49, xla); + } + } + + private boolean jj_2_51(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_51(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(50, xla); + } + } + + private boolean jj_2_52(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_52(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(51, xla); + } + } + + private boolean jj_2_53(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_53(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(52, xla); + } + } + + private boolean jj_2_54(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_54(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(53, xla); + } + } + + private boolean jj_2_55(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_55(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(54, xla); + } + } + + private boolean jj_2_56(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_56(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(55, xla); + } + } + + private boolean jj_2_57(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_57(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(56, xla); + } + } + + private boolean jj_2_58(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_58(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(57, xla); + } + } + + private boolean jj_2_59(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_59(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(58, xla); + } + } + + private boolean jj_2_60(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_60(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(59, xla); + } + } + + private boolean jj_2_61(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_61(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(60, xla); + } + } + + private boolean jj_2_62(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_62(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(61, xla); + } + } + + private boolean jj_2_63(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_63(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(62, xla); + } + } + + private boolean jj_2_64(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_64(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(63, xla); + } + } + + private boolean jj_2_65(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_65(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(64, xla); + } + } + + private boolean jj_2_66(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_66(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(65, xla); + } + } + + private boolean jj_2_67(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_67(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(66, xla); + } + } + + private boolean jj_2_68(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_68(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(67, xla); + } + } + + private boolean jj_2_69(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_69(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(68, xla); + } + } + + private boolean jj_2_70(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_70(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(69, xla); + } + } + + private boolean jj_2_71(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_71(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(70, xla); + } + } + + private boolean jj_2_72(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_72(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(71, xla); + } + } + + private boolean jj_2_73(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_73(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(72, xla); + } + } + + private boolean jj_2_74(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_74(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(73, xla); + } + } + + private boolean jj_2_75(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_75(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(74, xla); + } + } + + private boolean jj_2_76(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_76(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(75, xla); + } + } + + private boolean jj_2_77(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_77(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(76, xla); + } + } + + private boolean jj_2_78(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_78(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(77, xla); + } + } + + private boolean jj_2_79(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_79(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(78, xla); + } + } + + private boolean jj_2_80(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_80(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(79, xla); + } + } + + private boolean jj_2_81(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_81(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(80, xla); + } + } + + private boolean jj_2_82(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_82(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(81, xla); + } + } + + private boolean jj_2_83(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_83(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(82, xla); + } + } + + private boolean jj_2_84(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_84(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(83, xla); + } + } + + private boolean jj_2_85(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_85(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(84, xla); + } + } + + private boolean jj_2_86(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_86(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(85, xla); + } + } + + private boolean jj_2_87(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_87(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(86, xla); + } + } + + private boolean jj_2_88(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_88(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(87, xla); + } + } + + private boolean jj_2_89(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_89(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(88, xla); + } + } + + private boolean jj_2_90(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_90(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(89, xla); + } + } + + private boolean jj_2_91(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_91(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(90, xla); + } + } + + private boolean jj_2_92(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_92(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(91, xla); + } + } + + private boolean jj_2_93(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_93(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(92, xla); + } + } + + private boolean jj_2_94(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_94(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(93, xla); + } + } + + private boolean jj_2_95(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_95(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(94, xla); + } + } + + private boolean jj_2_96(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_96(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(95, xla); + } + } + + private boolean jj_2_97(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_97(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(96, xla); + } + } + + private boolean jj_2_98(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_98(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(97, xla); + } + } + + private boolean jj_2_99(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_99(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(98, xla); + } + } + + private boolean jj_2_100(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_100(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(99, xla); + } + } + + private boolean jj_2_101(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_101(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(100, xla); + } + } + + private boolean jj_2_102(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_102(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(101, xla); + } + } + + private boolean jj_2_103(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_103(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(102, xla); + } + } + + private boolean jj_2_104(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_104(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(103, xla); + } + } + + private boolean jj_2_105(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_105(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(104, xla); + } + } + + private boolean jj_2_106(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_106(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(105, xla); + } + } + + private boolean jj_2_107(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_107(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(106, xla); + } + } + + private boolean jj_2_108(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_108(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(107, xla); + } + } + + private boolean jj_2_109(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_109(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(108, xla); + } + } + + private boolean jj_2_110(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_110(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(109, xla); + } + } + + private boolean jj_2_111(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_111(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(110, xla); + } + } + + private boolean jj_2_112(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_112(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(111, xla); + } + } + + private boolean jj_2_113(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_113(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(112, xla); + } + } + + private boolean jj_2_114(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_114(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(113, xla); + } + } + + private boolean jj_2_115(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_115(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(114, xla); + } + } + + private boolean jj_2_116(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_116(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(115, xla); + } + } + + private boolean jj_2_117(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_117(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(116, xla); + } + } + + private boolean jj_2_118(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_118(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(117, xla); + } + } + + private boolean jj_2_119(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_119(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(118, xla); + } + } + + private boolean jj_2_120(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_120(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(119, xla); + } + } + + private boolean jj_2_121(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_121(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(120, xla); + } + } + + private boolean jj_2_122(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_122(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(121, xla); + } + } + + private boolean jj_2_123(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_123(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(122, xla); + } + } + + private boolean jj_2_124(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_124(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(123, xla); + } + } + + private boolean jj_2_125(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_125(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(124, xla); + } + } + + private boolean jj_2_126(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_126(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(125, xla); + } + } + + private boolean jj_2_127(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_127(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(126, xla); + } + } + + private boolean jj_2_128(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_128(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(127, xla); + } + } + + private boolean jj_2_129(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_129(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(128, xla); + } + } + + private boolean jj_2_130(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_130(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(129, xla); + } + } + + private boolean jj_2_131(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_131(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(130, xla); + } + } + + private boolean jj_2_132(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_132(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(131, xla); + } + } + + private boolean jj_2_133(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_133(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(132, xla); + } + } + + private boolean jj_2_134(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_134(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(133, xla); + } + } + + private boolean jj_2_135(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_135(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(134, xla); + } + } + + private boolean jj_2_136(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_136(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(135, xla); + } + } + + private boolean jj_2_137(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_137(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(136, xla); + } + } + + private boolean jj_2_138(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_138(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(137, xla); + } + } + + private boolean jj_2_139(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_139(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(138, xla); + } + } + + private boolean jj_2_140(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_140(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(139, xla); + } + } + + private boolean jj_2_141(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_141(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(140, xla); + } + } + + private boolean jj_2_142(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_142(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(141, xla); + } + } + + private boolean jj_2_143(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_143(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(142, xla); + } + } + + private boolean jj_2_144(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_144(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(143, xla); + } + } + + private boolean jj_2_145(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_145(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(144, xla); + } + } + + private boolean jj_2_146(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_146(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(145, xla); + } + } + + private boolean jj_2_147(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_147(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(146, xla); + } + } + + private boolean jj_2_148(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_148(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(147, xla); + } + } + + private boolean jj_2_149(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_149(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(148, xla); + } + } + + private boolean jj_3R_105() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_87()) { + jj_scanpos = xsp; + if (jj_3_88()) + return true; + } + return false; + } + + private boolean jj_3R_36() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(FORALL)) + return true; + return false; + } + + private boolean jj_3R_106() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(PREFERENCE)) + return true; + return false; + } + + private boolean jj_3R_35() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AND)) + return true; + return false; + } + + private boolean jj_3_86() { + if (jj_3R_106()) + return true; + return false; + } + + private boolean jj_3_85() { + if (jj_3R_105()) + return true; + return false; + } + + private boolean jj_3R_138() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(OBJECTS)) + return true; + return false; + } + + private boolean jj_3_20() { + if (jj_3R_46()) + return true; + return false; + } + + private boolean jj_3_19() { + if (jj_3R_45()) + return true; + return false; + } + + private boolean jj_3_18() { + if (jj_3R_44()) + return true; + return false; + } + + private boolean jj_3_17() { + if (jj_3R_43()) + return true; + return false; + } + + private boolean jj_3R_102() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_85()) { + jj_scanpos = xsp; + if (jj_3_86()) + return true; + } + return false; + } + + private boolean jj_3_16() { + if (jj_3R_42()) + return true; + return false; + } + + private boolean jj_3_15() { + if (jj_3R_41()) + return true; + return false; + } + + private boolean jj_3_14() { + if (jj_3R_40()) + return true; + return false; + } + + private boolean jj_3_13() { + if (jj_3R_39()) + return true; + return false; + } + + private boolean jj_3_12() { + if (jj_3R_38()) + return true; + return false; + } + + private boolean jj_3_11() { + if (jj_3R_37()) + return true; + return false; + } + + private boolean jj_3_10() { + if (jj_3R_36()) + return true; + return false; + } + + private boolean jj_3_9() { + if (jj_3R_35()) + return true; + return false; + } + + private boolean jj_3R_145() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_9()) { + jj_scanpos = xsp; + if (jj_3_10()) { + jj_scanpos = xsp; + if (jj_3_11()) { + jj_scanpos = xsp; + if (jj_3_12()) { + jj_scanpos = xsp; + if (jj_3_13()) { + jj_scanpos = xsp; + if (jj_3_14()) { + jj_scanpos = xsp; + if (jj_3_15()) { + jj_scanpos = xsp; + if (jj_3_16()) { + jj_scanpos = xsp; + if (jj_3_17()) { + jj_scanpos = xsp; + if (jj_3_18()) { + jj_scanpos = xsp; + if (jj_3_19()) { + jj_scanpos = xsp; + if (jj_3_20()) + return true; + } + } + } + } + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_103() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AND)) + return true; + return false; + } + + private boolean jj_3R_70() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(ACTION)) + return true; + return false; + } + + private boolean jj_3R_166() { + if (jj_3R_167()) + return true; + return false; + } + + private boolean jj_3_47() { + if (jj_3R_72()) + return true; + return false; + } + + private boolean jj_3_46() { + if (jj_3R_71()) + return true; + return false; + } + + private boolean jj_3_45() { + if (jj_3R_70()) + return true; + return false; + } + + private boolean jj_3R_104() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(FORALL)) + return true; + return false; + } + + private boolean jj_3_129() { + if (jj_3R_139()) + return true; + return false; + } + + private boolean jj_3_128() { + if (jj_3R_34()) + return true; + return false; + } + + private boolean jj_3_84() { + if (jj_3R_104()) + return true; + return false; + } + + private boolean jj_3_83() { + if (jj_3R_103()) + return true; + return false; + } + + private boolean jj_3_127() { + if (jj_3R_138()) + return true; + return false; + } + + private boolean jj_3_82() { + if (jj_3R_102()) + return true; + return false; + } + + private boolean jj_3_126() { + if (jj_3R_29()) + return true; + return false; + } + + private boolean jj_3R_28() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(DEFINE)) + return true; + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(PROBLEM)) + return true; + return false; + } + + private boolean jj_3R_160() { + if (jj_scan_token(SYMBOL)) + return true; + return false; + } + + private boolean jj_3R_62() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_3R_160()) + return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_166()) { + jj_scanpos = xsp; + break; + } + } + if (jj_scan_token(RPAREN)) + return true; + return false; + } + + private boolean jj_3_81() { + if (jj_3R_101()) + return true; + return false; + } + + private boolean jj_3_80() { + if (jj_3R_80()) + return true; + return false; + } + + private boolean jj_3R_72() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(DERIVED)) + return true; + return false; + } + + private boolean jj_3R_65() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(SUB)) + return true; + if (jj_3R_164()) + return true; + return false; + } + + private boolean jj_3R_132() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(SUB)) + return true; + if (jj_3R_164()) + return true; + return false; + } + + private boolean jj_3R_133() { + if (jj_scan_token(VAR_DURATION)) + return true; + return false; + } + + private boolean jj_3R_33() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(FUNCTIONS)) + return true; + return false; + } + + private boolean jj_3R_69() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(DIV)) + return true; + if (jj_3R_101()) + return true; + return false; + } + + private boolean jj_3R_137() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(DIV)) + return true; + if (jj_3R_62()) + return true; + return false; + } + + private boolean jj_3R_63() { + if (jj_scan_token(104)) + return true; + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(100)) { + jj_scanpos = xsp; + if (jj_scan_token(99)) { + jj_scanpos = xsp; + if (jj_scan_token(98)) + return true; + } + } + return false; + } + + private boolean jj_3R_100() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(LEQUAL)) + return true; + return false; + } + + private boolean jj_3R_68() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(MUL)) + return true; + if (jj_3R_101()) + return true; + return false; + } + + private boolean jj_3R_158() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(100)) { + jj_scanpos = xsp; + if (jj_scan_token(87)) + return true; + } + return false; + } + + private boolean jj_3R_136() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(MUL)) + return true; + if (jj_3R_62()) + return true; + return false; + } + + private boolean jj_3R_99() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(GEQUAL)) + return true; + return false; + } + + private boolean jj_3R_67() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(SUB)) + return true; + if (jj_3R_101()) + return true; + return false; + } + + private boolean jj_3R_135() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(SUB)) + return true; + if (jj_3R_62()) + return true; + return false; + } + + private boolean jj_3R_98() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(EQUAL)) + return true; + return false; + } + + private boolean jj_3R_66() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(ADD)) + return true; + if (jj_3R_101()) + return true; + return false; + } + + private boolean jj_3R_32() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(PREDICATES)) + return true; + return false; + } + + private boolean jj_3_79() { + if (jj_3R_100()) + return true; + return false; + } + + private boolean jj_3_78() { + if (jj_3R_99()) + return true; + return false; + } + + private boolean jj_3_77() { + if (jj_3R_98()) + return true; + return false; + } + + private boolean jj_3_44() { + if (jj_3R_69()) + return true; + return false; + } + + private boolean jj_3R_134() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(ADD)) + return true; + if (jj_3R_62()) + return true; + return false; + } + + private boolean jj_3_43() { + if (jj_3R_68()) + return true; + return false; + } + + private boolean jj_3_42() { + if (jj_3R_67()) + return true; + return false; + } + + private boolean jj_3_41() { + if (jj_3R_66()) + return true; + return false; + } + + private boolean jj_3R_94() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_77()) { + jj_scanpos = xsp; + if (jj_3_78()) { + jj_scanpos = xsp; + if (jj_3_79()) + return true; + } + } + return false; + } + + private boolean jj_3R_170() { + if (jj_scan_token(SYMBOL)) + return true; + return false; + } + + private boolean jj_3_125() { + if (jj_3R_137()) + return true; + return false; + } + + private boolean jj_3_124() { + if (jj_3R_136()) + return true; + return false; + } + + private boolean jj_3_123() { + if (jj_3R_135()) + return true; + return false; + } + + private boolean jj_3_122() { + if (jj_3R_134()) + return true; + return false; + } + + private boolean jj_3R_64() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_41()) { + jj_scanpos = xsp; + if (jj_3_42()) { + jj_scanpos = xsp; + if (jj_3_43()) { + jj_scanpos = xsp; + if (jj_3_44()) + return true; + } + } + } + return false; + } + + private boolean jj_3_40() { + if (jj_3R_65()) + return true; + return false; + } + + private boolean jj_3R_131() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_122()) { + jj_scanpos = xsp; + if (jj_3_123()) { + jj_scanpos = xsp; + if (jj_3_124()) { + jj_scanpos = xsp; + if (jj_3_125()) + return true; + } + } + } + return false; + } + + private boolean jj_3_39() { + if (jj_3R_64()) + return true; + return false; + } + + private boolean jj_3R_97() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AT)) + return true; + if (jj_scan_token(END)) + return true; + return false; + } + + private boolean jj_3R_31() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(CONSTANTS)) + return true; + return false; + } + + private boolean jj_3_121() { + if (jj_3R_133()) + return true; + return false; + } + + private boolean jj_3R_61() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_39()) { + jj_scanpos = xsp; + if (jj_3_40()) + return true; + } + return false; + } + + private boolean jj_3_120() { + if (jj_3R_132()) + return true; + return false; + } + + private boolean jj_3_119() { + if (jj_3R_131()) + return true; + return false; + } + + private boolean jj_3_118() { + if (jj_3R_101()) + return true; + return false; + } + + private boolean jj_3R_96() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AT)) + return true; + if (jj_scan_token(START)) + return true; + return false; + } + + private boolean jj_3R_164() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_118()) { + jj_scanpos = xsp; + if (jj_3_119()) { + jj_scanpos = xsp; + if (jj_3_120()) { + jj_scanpos = xsp; + if (jj_3_121()) + return true; + } + } + } + return false; + } + + private boolean jj_3_76() { + if (jj_3R_97()) + return true; + return false; + } + + private boolean jj_3_75() { + if (jj_3R_96()) + return true; + return false; + } + + private boolean jj_3_117() { + if (jj_3R_120()) + return true; + return false; + } + + private boolean jj_3R_80() { + if (jj_scan_token(NUMBER)) + return true; + return false; + } + + private boolean jj_3_116() { + if (jj_3R_119()) + return true; + return false; + } + + private boolean jj_3_115() { + if (jj_3R_118()) + return true; + return false; + } + + private boolean jj_3_114() { + if (jj_3R_117()) + return true; + return false; + } + + private boolean jj_3_113() { + if (jj_3R_116()) + return true; + return false; + } + + private boolean jj_3R_95() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_75()) { + jj_scanpos = xsp; + if (jj_3_76()) + return true; + } + return false; + } + + private boolean jj_3_38() { + if (jj_3R_63()) + return true; + return false; + } + + private boolean jj_3_37() { + if (jj_3R_62()) + return true; + return false; + } + + private boolean jj_3_36() { + if (jj_3R_61()) + return true; + return false; + } + + private boolean jj_3R_162() { + if (jj_3R_80()) + return true; + return false; + } + + private boolean jj_3_74() { + if (jj_3R_95()) + return true; + return false; + } + + private boolean jj_3_73() { + if (jj_3R_94()) + return true; + return false; + } + + private boolean jj_3R_101() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_162()) { + jj_scanpos = xsp; + if (jj_3_36()) { + jj_scanpos = xsp; + if (jj_3_37()) { + jj_scanpos = xsp; + if (jj_3_38()) + return true; + } + } + } + return false; + } + + private boolean jj_3R_93() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_73()) { + jj_scanpos = xsp; + if (jj_3_74()) + return true; + } + return false; + } + + private boolean jj_3R_130() { + if (jj_scan_token(CONTINOUS_VARIABLE)) + return true; + return false; + } + + private boolean jj_3R_60() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(EQUAL)) + return true; + return false; + } + + private boolean jj_3_112() { + if (jj_3R_130()) + return true; + return false; + } + + private boolean jj_3_111() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(MUL)) + return true; + return false; + } + + private boolean jj_3_110() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(MUL)) + return true; + return false; + } + + private boolean jj_3R_92() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AND)) + return true; + return false; + } + + private boolean jj_3_72() { + if (jj_3R_93()) + return true; + return false; + } + + private boolean jj_3R_30() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(TYPES)) + return true; + return false; + } + + private boolean jj_3_71() { + if (jj_3R_92()) + return true; + return false; + } + + private boolean jj_3_70() { + if (jj_3R_73()) + return true; + return false; + } + + private boolean jj_3R_57() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(LESS)) + return true; + return false; + } + + private boolean jj_3R_129() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(DECREASE)) + return true; + return false; + } + + private boolean jj_3R_59() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(LEQUAL)) + return true; + return false; + } + + private boolean jj_3R_128() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(INCREASE)) + return true; + return false; + } + + private boolean jj_3R_58() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(GEQUAL)) + return true; + return false; + } + + private boolean jj_3_109() { + if (jj_3R_129()) + return true; + return false; + } + + private boolean jj_3_108() { + if (jj_3R_128()) + return true; + return false; + } + + private boolean jj_3R_123() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_108()) { + jj_scanpos = xsp; + if (jj_3_109()) + return true; + } + return false; + } + + private boolean jj_3R_29() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(REQUIREMENTS)) + return true; + return false; + } + + private boolean jj_3R_56() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(GREATER)) + return true; + return false; + } + + private boolean jj_3_35() { + if (jj_3R_60()) + return true; + return false; + } + + private boolean jj_3_34() { + if (jj_3R_59()) + return true; + return false; + } + + private boolean jj_3_33() { + if (jj_3R_58()) + return true; + return false; + } + + private boolean jj_3_32() { + if (jj_3R_57()) + return true; + return false; + } + + private boolean jj_3_31() { + if (jj_3R_56()) + return true; + return false; + } + + private boolean jj_3R_71() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(DURATIVE_ACTION)) + return true; + return false; + } + + private boolean jj_3R_127() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AT)) + return true; + if (jj_scan_token(END)) + return true; + if (jj_3R_86()) + return true; + return false; + } + + private boolean jj_3_8() { + if (jj_3R_34()) + return true; + return false; + } + + private boolean jj_3_7() { + if (jj_3R_33()) + return true; + return false; + } + + private boolean jj_3R_159() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_31()) { + jj_scanpos = xsp; + if (jj_3_32()) { + jj_scanpos = xsp; + if (jj_3_33()) { + jj_scanpos = xsp; + if (jj_3_34()) { + jj_scanpos = xsp; + if (jj_3_35()) + return true; + } + } + } + } + return false; + } + + private boolean jj_3_6() { + if (jj_3R_32()) + return true; + return false; + } + + private boolean jj_3R_148() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(SUB)) + return true; + return false; + } + + private boolean jj_3R_91() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(DECREASE)) + return true; + return false; + } + + private boolean jj_3_5() { + if (jj_3R_31()) + return true; + return false; + } + + private boolean jj_3R_126() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AT)) + return true; + if (jj_scan_token(START)) + return true; + if (jj_3R_86()) + return true; + return false; + } + + private boolean jj_3_4() { + if (jj_3R_30()) + return true; + return false; + } + + private boolean jj_3R_54() { + if (jj_3R_159()) + return true; + return false; + } + + private boolean jj_3_107() { + if (jj_3R_127()) + return true; + return false; + } + + private boolean jj_3_3() { + if (jj_3R_29()) + return true; + return false; + } + + private boolean jj_3_106() { + if (jj_3R_126()) + return true; + return false; + } + + private boolean jj_3R_157() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(ADD)) + return true; + return false; + } + + private boolean jj_3R_90() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(INCREASE)) + return true; + return false; + } + + private boolean jj_3R_121() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_106()) { + jj_scanpos = xsp; + if (jj_3_107()) + return true; + } + return false; + } + + private boolean jj_3R_55() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(NOT)) + return true; + return false; + } + + private boolean jj_3R_27() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(DEFINE)) + return true; + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(DOMAIN)) + return true; + return false; + } + + private boolean jj_3R_156() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(MUL)) + return true; + return false; + } + + private boolean jj_3_30() { + if (jj_3R_55()) + return true; + return false; + } + + private boolean jj_3_29() { + if (jj_3R_47()) + return true; + return false; + } + + private boolean jj_3R_89() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(SCALE_DOWN)) + return true; + return false; + } + + private boolean jj_3_2() { + if (jj_3R_28()) + return true; + return false; + } + + private boolean jj_3_1() { + if (jj_3R_27()) + return true; + return false; + } + + private boolean jj_3R_125() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AT)) + return true; + if (jj_scan_token(END)) + return true; + return false; + } + + private boolean jj_3_149() { + if (jj_3R_157()) + return true; + return false; + } + + private boolean jj_3_148() { + if (jj_3R_156()) + return true; + return false; + } + + private boolean jj_3R_86() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_29()) { + jj_scanpos = xsp; + if (jj_3_30()) + return true; + } + return false; + } + + private boolean jj_3R_150() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_148()) { + jj_scanpos = xsp; + if (jj_3_149()) + return true; + } + return false; + } + + private boolean jj_3R_88() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(SCALE_UP)) + return true; + return false; + } + + private boolean jj_3R_169() { + if (jj_3R_63()) + return true; + return false; + } + + private boolean jj_3R_168() { + if (jj_3R_170()) + return true; + return false; + } + + private boolean jj_3R_124() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AT)) + return true; + if (jj_scan_token(START)) + return true; + return false; + } + + private boolean jj_3R_167() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_168()) { + jj_scanpos = xsp; + if (jj_3R_169()) + return true; + } + return false; + } + + private boolean jj_3_105() { + if (jj_3R_125()) + return true; + return false; + } + + private boolean jj_3_104() { + if (jj_3R_124()) + return true; + return false; + } + + private boolean jj_3R_155() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(SUB)) + return true; + return false; + } + + private boolean jj_3R_87() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(ASSIGN)) + return true; + return false; + } + + private boolean jj_3R_122() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_104()) { + jj_scanpos = xsp; + if (jj_3_105()) + return true; + } + return false; + } + + private boolean jj_3_69() { + if (jj_3R_91()) + return true; + return false; + } + + private boolean jj_3_68() { + if (jj_3R_90()) + return true; + return false; + } + + private boolean jj_3_67() { + if (jj_3R_89()) + return true; + return false; + } + + private boolean jj_3_66() { + if (jj_3R_88()) + return true; + return false; + } + + private boolean jj_3_65() { + if (jj_3R_87()) + return true; + return false; + } + + private boolean jj_3_103() { + if (jj_3R_123()) + return true; + return false; + } + + private boolean jj_3_102() { + if (jj_3R_122()) + return true; + return false; + } + + private boolean jj_3R_154() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(ADD)) + return true; + return false; + } + + private boolean jj_3_101() { + if (jj_3R_121()) + return true; + return false; + } + + private boolean jj_3R_47() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_3R_158()) + return true; + return false; + } + + private boolean jj_3R_85() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_65()) { + jj_scanpos = xsp; + if (jj_3_66()) { + jj_scanpos = xsp; + if (jj_3_67()) { + jj_scanpos = xsp; + if (jj_3_68()) { + jj_scanpos = xsp; + if (jj_3_69()) + return true; + } + } + } + } + return false; + } + + private boolean jj_3_147() { + if (jj_3R_155()) + return true; + return false; + } + + private boolean jj_3_146() { + if (jj_3R_154()) + return true; + return false; + } + + private boolean jj_3R_111() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_101()) { + jj_scanpos = xsp; + if (jj_3_102()) { + jj_scanpos = xsp; + if (jj_3_103()) + return true; + } + } + return false; + } + + private boolean jj_3_64() { + if (jj_3R_86()) + return true; + return false; + } + + private boolean jj_3_63() { + if (jj_3R_85()) + return true; + return false; + } + + private boolean jj_3R_149() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_146()) { + jj_scanpos = xsp; + if (jj_3_147()) + return true; + } + return false; + } + + private boolean jj_3R_53() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(FORALL)) + return true; + return false; + } + + private boolean jj_3R_83() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_63()) { + jj_scanpos = xsp; + if (jj_3_64()) + return true; + } + return false; + } + + private boolean jj_3R_112() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AND)) + return true; + return false; + } + + private boolean jj_3R_152() { + if (jj_scan_token(TOTAL_TIME)) + return true; + return false; + } + + private boolean jj_3R_52() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(EXISTS)) + return true; + return false; + } + + private boolean jj_3R_113() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(FORALL)) + return true; + return false; + } + + private boolean jj_3_62() { + if (jj_3R_79()) + return true; + return false; + } + + private boolean jj_3_61() { + if (jj_3R_78()) + return true; + return false; + } + + private boolean jj_3R_151() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_3R_160()) + return true; + return false; + } + + private boolean jj_3R_51() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(IMPLY)) + return true; + return false; + } + + private boolean jj_3R_114() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(WHEN)) + return true; + return false; + } + + private boolean jj_3R_153() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(IS_VIOLATED)) + return true; + return false; + } + + private boolean jj_3R_50() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(NOT)) + return true; + return false; + } + + private boolean jj_3R_82() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(WHEN)) + return true; + return false; + } + + private boolean jj_3_145() { + if (jj_3R_153()) + return true; + return false; + } + + private boolean jj_3R_120() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(DECREASE)) + return true; + return false; + } + + private boolean jj_3_144() { + if (jj_3R_152()) + return true; + return false; + } + + private boolean jj_3_143() { + if (jj_3R_151()) + return true; + return false; + } + + private boolean jj_3_142() { + if (jj_3R_80()) + return true; + return false; + } + + private boolean jj_3_141() { + if (jj_3R_150()) + return true; + return false; + } + + private boolean jj_3_140() { + if (jj_3R_149()) + return true; + return false; + } + + private boolean jj_3_139() { + if (jj_3R_148()) + return true; + return false; + } + + private boolean jj_3R_49() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(OR)) + return true; + return false; + } + + private boolean jj_3R_81() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(FORALL)) + return true; + return false; + } + + private boolean jj_3R_119() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(INCREASE)) + return true; + return false; + } + + private boolean jj_3_60() { + if (jj_3R_84()) + return true; + return false; + } + + private boolean jj_3R_48() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AND)) + return true; + return false; + } + + private boolean jj_3_59() { + if (jj_3R_83()) + return true; + return false; + } + + private boolean jj_3_58() { + if (jj_3R_82()) + return true; + return false; + } + + private boolean jj_3_57() { + if (jj_3R_81()) + return true; + return false; + } + + private boolean jj_3R_147() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(METRIC)) + return true; + if (jj_scan_token(MINIMIZE)) + return true; + return false; + } + + private boolean jj_3_28() { + if (jj_3R_54()) + return true; + return false; + } + + private boolean jj_3R_118() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(SCALE_DOWN)) + return true; + return false; + } + + private boolean jj_3_27() { + if (jj_3R_53()) + return true; + return false; + } + + private boolean jj_3_26() { + if (jj_3R_52()) + return true; + return false; + } + + private boolean jj_3_25() { + if (jj_3R_51()) + return true; + return false; + } + + private boolean jj_3R_79() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_57()) { + jj_scanpos = xsp; + if (jj_3_58()) { + jj_scanpos = xsp; + if (jj_3_59()) { + jj_scanpos = xsp; + if (jj_3_60()) + return true; + } + } + } + return false; + } + + private boolean jj_3_24() { + if (jj_3R_50()) + return true; + return false; + } + + private boolean jj_3_23() { + if (jj_3R_49()) + return true; + return false; + } + + private boolean jj_3_22() { + if (jj_3R_48()) + return true; + return false; + } + + private boolean jj_3_21() { + if (jj_3R_47()) + return true; + return false; + } + + private boolean jj_3R_146() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(METRIC)) + return true; + if (jj_scan_token(MAXIMIZE)) + return true; + return false; + } + + private boolean jj_3R_165() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_21()) { + jj_scanpos = xsp; + if (jj_3_22()) { + jj_scanpos = xsp; + if (jj_3_23()) { + jj_scanpos = xsp; + if (jj_3_24()) { + jj_scanpos = xsp; + if (jj_3_25()) { + jj_scanpos = xsp; + if (jj_3_26()) { + jj_scanpos = xsp; + if (jj_3_27()) { + jj_scanpos = xsp; + if (jj_3_28()) + return true; + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_117() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(SCALE_UP)) + return true; + return false; + } + + private boolean jj_3_56() { + if (jj_3R_80()) + return true; + if (jj_3R_78()) + return true; + return false; + } + + private boolean jj_3_55() { + if (jj_3R_80()) + return true; + if (jj_3R_79()) + return true; + return false; + } + + private boolean jj_3_138() { + if (jj_3R_147()) + return true; + return false; + } + + private boolean jj_3_137() { + if (jj_3R_146()) + return true; + return false; + } + + private boolean jj_3R_139() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_137()) { + jj_scanpos = xsp; + if (jj_3_138()) + return true; + } + return false; + } + + private boolean jj_3R_46() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(HOLD_AFTER)) + return true; + return false; + } + + private boolean jj_3R_116() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(ASSIGN)) + return true; + return false; + } + + private boolean jj_3R_84() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(PROB)) + return true; + return false; + } + + private boolean jj_3_100() { + if (jj_3R_120()) + return true; + return false; + } + + private boolean jj_3_99() { + if (jj_3R_119()) + return true; + return false; + } + + private boolean jj_3_98() { + if (jj_3R_118()) + return true; + return false; + } + + private boolean jj_3_97() { + if (jj_3R_117()) + return true; + return false; + } + + private boolean jj_3_96() { + if (jj_3R_116()) + return true; + return false; + } + + private boolean jj_3R_143() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(FORALL)) + return true; + return false; + } + + private boolean jj_3R_45() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(HOLD_DURING)) + return true; + return false; + } + + private boolean jj_3R_115() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_96()) { + jj_scanpos = xsp; + if (jj_3_97()) { + jj_scanpos = xsp; + if (jj_3_98()) { + jj_scanpos = xsp; + if (jj_3_99()) { + jj_scanpos = xsp; + if (jj_3_100()) + return true; + } + } + } + } + return false; + } + + private boolean jj_3R_78() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AND)) + return true; + return false; + } + + private boolean jj_3_95() { + if (jj_3R_115()) + return true; + return false; + } + + private boolean jj_3_94() { + if (jj_3R_114()) + return true; + return false; + } + + private boolean jj_3_93() { + if (jj_3R_113()) + return true; + return false; + } + + private boolean jj_3R_144() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(PREFERENCE)) + return true; + return false; + } + + private boolean jj_3_92() { + if (jj_3R_112()) + return true; + return false; + } + + private boolean jj_3_54() { + if (jj_3R_79()) + return true; + return false; + } + + private boolean jj_3_91() { + if (jj_3R_111()) + return true; + return false; + } + + private boolean jj_3R_44() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(ALWAYS_WITHIN)) + return true; + return false; + } + + private boolean jj_3_53() { + if (jj_3R_78()) + return true; + return false; + } + + private boolean jj_3R_142() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AND)) + return true; + return false; + } + + private boolean jj_3R_43() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(SOMETIME_BEFORE)) + return true; + return false; + } + + private boolean jj_3_136() { + if (jj_3R_145()) + return true; + return false; + } + + private boolean jj_3_135() { + if (jj_3R_144()) + return true; + return false; + } + + private boolean jj_3_134() { + if (jj_3R_143()) + return true; + return false; + } + + private boolean jj_3_133() { + if (jj_3R_142()) + return true; + return false; + } + + private boolean jj_3R_42() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(SOMETIME_AFTER)) + return true; + return false; + } + + private boolean jj_3R_110() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AT)) + return true; + return false; + } + + private boolean jj_3R_77() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(PREFERENCE)) + return true; + return false; + } + + private boolean jj_3R_41() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AT_MOST_ONCE)) + return true; + return false; + } + + private boolean jj_3R_34() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(CONSTRAINTS)) + return true; + return false; + } + + private boolean jj_3R_161() { + if (jj_3R_165()) + return true; + return false; + } + + private boolean jj_3_52() { + if (jj_3R_77()) + return true; + return false; + } + + private boolean jj_3R_109() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AT)) + return true; + if (jj_scan_token(START)) + return true; + return false; + } + + private boolean jj_3R_74() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_52()) { + jj_scanpos = xsp; + if (jj_3R_161()) + return true; + } + return false; + } + + private boolean jj_3_90() { + if (jj_3R_110()) + return true; + return false; + } + + private boolean jj_3R_40() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(WITHIN)) + return true; + return false; + } + + private boolean jj_3_89() { + if (jj_3R_109()) + return true; + return false; + } + + private boolean jj_3R_107() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_89()) { + jj_scanpos = xsp; + if (jj_3_90()) + return true; + } + return false; + } + + private boolean jj_3R_76() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(FORALL)) + return true; + return false; + } + + private boolean jj_3R_39() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(SOMETIME)) + return true; + return false; + } + + private boolean jj_3R_141() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AT)) + return true; + if (jj_3R_80()) + return true; + return false; + } + + private boolean jj_3R_163() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(OVER)) + return true; + return false; + } + + private boolean jj_3R_75() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AND)) + return true; + return false; + } + + private boolean jj_3R_38() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(ALWAYS)) + return true; + return false; + } + + private boolean jj_3R_140() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(EQUALITY)) + return true; + return false; + } + + private boolean jj_3_132() { + if (jj_3R_141()) + return true; + return false; + } + + private boolean jj_3R_108() { + if (jj_3R_163()) + return true; + return false; + } + + private boolean jj_3_131() { + if (jj_3R_140()) + return true; + return false; + } + + private boolean jj_3_130() { + if (jj_3R_86()) + return true; + return false; + } + + private boolean jj_3R_73() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(RPAREN)) + return true; + return false; + } + + private boolean jj_3R_37() { + if (jj_scan_token(LPAREN)) + return true; + if (jj_scan_token(AT)) + return true; + return false; + } + + private boolean jj_3_88() { + if (jj_3R_108()) + return true; + return false; + } + + private boolean jj_3_87() { + if (jj_3R_107()) + return true; + return false; + } + + private boolean jj_3_51() { + if (jj_3R_76()) + return true; + return false; + } + + private boolean jj_3_50() { + if (jj_3R_75()) + return true; + return false; + } + + private boolean jj_3_49() { + if (jj_3R_74()) + return true; + return false; + } + + private boolean jj_3_48() { + if (jj_3R_73()) + return true; + return false; + } + + /** Generated Token Manager. */ + public LexerTokenManager token_source; + SimpleCharStream jj_input_stream; + /** Current token. */ + public Token token; + /** Next token. */ + public Token jj_nt; + private int jj_ntk; + private Token jj_scanpos, jj_lastpos; + private int jj_la; + private int jj_gen; + final private int[] jj_la1 = new int[41]; + static private int[] jj_la1_0; + static private int[] jj_la1_1; + static private int[] jj_la1_2; + static private int[] jj_la1_3; + static { + jj_la1_init_0(); + jj_la1_init_1(); + jj_la1_init_2(); + jj_la1_init_3(); + } + + private static void jj_la1_init_0() { + jj_la1_0 = new int[] { 0x2000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x2000, 0x0, 0x2000, 0x0, 0x0, 0x2000, 0x0, 0x2000, + 0x2000, 0x2000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2000, 0x2000, 0x0, + 0x2000, 0x0, 0x2000, 0x2000, 0x2000, 0x0, 0x2000, 0x2000, + 0x2000, 0x0, 0x0, 0x2000, 0x2000, }; + } + + private static void jj_la1_init_1() { + jj_la1_1 = new int[] { 0x0, 0x3ffff00, 0x3ffff00, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, }; + } + + private static void jj_la1_init_2() { + jj_la1_2 = new int[] { 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x4, 0x0, 0x4, + 0x0, 0x0, 0x0, 0x0, 0x800000, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10000000, 0x10000000, }; + } + + private static void jj_la1_init_3() { + jj_la1_3 = new int[] { 0x0, 0x0, 0x0, 0x1c, 0x0, 0x10, 0x0, 0x100, 0x0, + 0x1c, 0x1c, 0x1c, 0x0, 0x10, 0x1c, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x10, 0x110, 0x110, 0x20, 0x110, 0x0, 0x0, 0x10, 0x0, 0x20, + 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x10, 0x20, 0x20, }; + } + + final private JJCalls[] jj_2_rtns = new JJCalls[149]; + private boolean jj_rescan = false; + private int jj_gc = 0; + + /** Constructor with InputStream. */ + public Lexer(java.io.InputStream stream) { + this(stream, null); + } + + /** Constructor with InputStream and supplied encoding */ + public Lexer(java.io.InputStream stream, String encoding) { + try { + jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); + } catch (java.io.UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + token_source = new LexerTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 41; i++) + jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) + jj_2_rtns[i] = new JJCalls(); + } + + /** Reinitialise. */ + public void ReInit(java.io.InputStream stream) { + ReInit(stream, null); + } + + /** Reinitialise. */ + public void ReInit(java.io.InputStream stream, String encoding) { + try { + jj_input_stream.ReInit(stream, encoding, 1, 1); + } catch (java.io.UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jjtree.reset(); + jj_gen = 0; + for (int i = 0; i < 41; i++) + jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) + jj_2_rtns[i] = new JJCalls(); + } + + /** Constructor. */ + public Lexer(java.io.Reader stream) { + jj_input_stream = new SimpleCharStream(stream, 1, 1); + token_source = new LexerTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 41; i++) + jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) + jj_2_rtns[i] = new JJCalls(); + } + + /** Reinitialise. */ + public void ReInit(java.io.Reader stream) { + jj_input_stream.ReInit(stream, 1, 1); + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jjtree.reset(); + jj_gen = 0; + for (int i = 0; i < 41; i++) + jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) + jj_2_rtns[i] = new JJCalls(); + } + + /** Constructor with generated Token Manager. */ + public Lexer(LexerTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 41; i++) + jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) + jj_2_rtns[i] = new JJCalls(); + } + + /** Reinitialise. */ + public void ReInit(LexerTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jjtree.reset(); + jj_gen = 0; + for (int i = 0; i < 41; i++) + jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) + jj_2_rtns[i] = new JJCalls(); + } + + private Token jj_consume_token(int kind) throws ParseException { + Token oldToken; + if ((oldToken = token).next != null) + token = token.next; + else + token = token.next = token_source.getNextToken(); + jj_ntk = -1; + if (token.kind == kind) { + jj_gen++; + if (++jj_gc > 100) { + jj_gc = 0; + for (int i = 0; i < jj_2_rtns.length; i++) { + JJCalls c = jj_2_rtns[i]; + while (c != null) { + if (c.gen < jj_gen) + c.first = null; + c = c.next; + } + } + } + return token; + } + token = oldToken; + jj_kind = kind; + throw generateParseException(); + } + + static private final class LookaheadSuccess extends java.lang.Error { + } + + final private LookaheadSuccess jj_ls = new LookaheadSuccess(); + + private boolean jj_scan_token(int kind) { + if (jj_scanpos == jj_lastpos) { + jj_la--; + if (jj_scanpos.next == null) { + jj_lastpos = jj_scanpos = jj_scanpos.next = token_source + .getNextToken(); + } else { + jj_lastpos = jj_scanpos = jj_scanpos.next; + } + } else { + jj_scanpos = jj_scanpos.next; + } + if (jj_rescan) { + int i = 0; + Token tok = token; + while (tok != null && tok != jj_scanpos) { + i++; + tok = tok.next; + } + if (tok != null) + jj_add_error_token(kind, i); + } + if (jj_scanpos.kind != kind) + return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) + throw jj_ls; + return false; + } + + /** Get the next Token. */ + final public Token getNextToken() { + if (token.next != null) + token = token.next; + else + token = token.next = token_source.getNextToken(); + jj_ntk = -1; + jj_gen++; + return token; + } + + /** Get the specific Token. */ + final public Token getToken(int index) { + Token t = token; + for (int i = 0; i < index; i++) { + if (t.next != null) + t = t.next; + else + t = t.next = token_source.getNextToken(); + } + return t; + } + + private int jj_ntk() { + if ((jj_nt = token.next) == null) + return (jj_ntk = (token.next = token_source.getNextToken()).kind); + else + return (jj_ntk = jj_nt.kind); + } + + private java.util.List jj_expentries = new java.util.ArrayList(); + private int[] jj_expentry; + private int jj_kind = -1; + private int[] jj_lasttokens = new int[100]; + private int jj_endpos; + + private void jj_add_error_token(int kind, int pos) { + if (pos >= 100) + return; + if (pos == jj_endpos + 1) { + jj_lasttokens[jj_endpos++] = kind; + } else if (jj_endpos != 0) { + jj_expentry = new int[jj_endpos]; + for (int i = 0; i < jj_endpos; i++) { + jj_expentry[i] = jj_lasttokens[i]; + } + jj_entries_loop: for (java.util.Iterator it = jj_expentries + .iterator(); it.hasNext();) { + int[] oldentry = (int[]) (it.next()); + if (oldentry.length == jj_expentry.length) { + for (int i = 0; i < jj_expentry.length; i++) { + if (oldentry[i] != jj_expentry[i]) { + continue jj_entries_loop; + } + } + jj_expentries.add(jj_expentry); + break jj_entries_loop; + } + } + if (pos != 0) + jj_lasttokens[(jj_endpos = pos) - 1] = kind; + } + } + + /** Generate ParseException. */ + public ParseException generateParseException() { + jj_expentries.clear(); + boolean[] la1tokens = new boolean[105]; + if (jj_kind >= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 41; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1 << j)) != 0) { + la1tokens[j] = true; + } + if ((jj_la1_1[i] & (1 << j)) != 0) { + la1tokens[32 + j] = true; + } + if ((jj_la1_2[i] & (1 << j)) != 0) { + la1tokens[64 + j] = true; + } + if ((jj_la1_3[i] & (1 << j)) != 0) { + la1tokens[96 + j] = true; + } + } + } + } + for (int i = 0; i < 105; i++) { + if (la1tokens[i]) { + jj_expentry = new int[1]; + jj_expentry[0] = i; + jj_expentries.add(jj_expentry); + } + } + jj_endpos = 0; + jj_rescan_token(); + jj_add_error_token(0, 0); + int[][] exptokseq = new int[jj_expentries.size()][]; + for (int i = 0; i < jj_expentries.size(); i++) { + exptokseq[i] = (int[]) jj_expentries.get(i); + } + return new ParseException(token, exptokseq, tokenImage); + } + + /** Enable tracing. */ + final public void enable_tracing() { + } + + /** Disable tracing. */ + final public void disable_tracing() { + } + + private void jj_rescan_token() { + jj_rescan = true; + for (int i = 0; i < 149; i++) { + try { + JJCalls p = jj_2_rtns[i]; + do { + if (p.gen > jj_gen) { + jj_la = p.arg; + jj_lastpos = jj_scanpos = p.first; + switch (i) { + case 0: + jj_3_1(); + break; + case 1: + jj_3_2(); + break; + case 2: + jj_3_3(); + break; + case 3: + jj_3_4(); + break; + case 4: + jj_3_5(); + break; + case 5: + jj_3_6(); + break; + case 6: + jj_3_7(); + break; + case 7: + jj_3_8(); + break; + case 8: + jj_3_9(); + break; + case 9: + jj_3_10(); + break; + case 10: + jj_3_11(); + break; + case 11: + jj_3_12(); + break; + case 12: + jj_3_13(); + break; + case 13: + jj_3_14(); + break; + case 14: + jj_3_15(); + break; + case 15: + jj_3_16(); + break; + case 16: + jj_3_17(); + break; + case 17: + jj_3_18(); + break; + case 18: + jj_3_19(); + break; + case 19: + jj_3_20(); + break; + case 20: + jj_3_21(); + break; + case 21: + jj_3_22(); + break; + case 22: + jj_3_23(); + break; + case 23: + jj_3_24(); + break; + case 24: + jj_3_25(); + break; + case 25: + jj_3_26(); + break; + case 26: + jj_3_27(); + break; + case 27: + jj_3_28(); + break; + case 28: + jj_3_29(); + break; + case 29: + jj_3_30(); + break; + case 30: + jj_3_31(); + break; + case 31: + jj_3_32(); + break; + case 32: + jj_3_33(); + break; + case 33: + jj_3_34(); + break; + case 34: + jj_3_35(); + break; + case 35: + jj_3_36(); + break; + case 36: + jj_3_37(); + break; + case 37: + jj_3_38(); + break; + case 38: + jj_3_39(); + break; + case 39: + jj_3_40(); + break; + case 40: + jj_3_41(); + break; + case 41: + jj_3_42(); + break; + case 42: + jj_3_43(); + break; + case 43: + jj_3_44(); + break; + case 44: + jj_3_45(); + break; + case 45: + jj_3_46(); + break; + case 46: + jj_3_47(); + break; + case 47: + jj_3_48(); + break; + case 48: + jj_3_49(); + break; + case 49: + jj_3_50(); + break; + case 50: + jj_3_51(); + break; + case 51: + jj_3_52(); + break; + case 52: + jj_3_53(); + break; + case 53: + jj_3_54(); + break; + case 54: + jj_3_55(); + break; + case 55: + jj_3_56(); + break; + case 56: + jj_3_57(); + break; + case 57: + jj_3_58(); + break; + case 58: + jj_3_59(); + break; + case 59: + jj_3_60(); + break; + case 60: + jj_3_61(); + break; + case 61: + jj_3_62(); + break; + case 62: + jj_3_63(); + break; + case 63: + jj_3_64(); + break; + case 64: + jj_3_65(); + break; + case 65: + jj_3_66(); + break; + case 66: + jj_3_67(); + break; + case 67: + jj_3_68(); + break; + case 68: + jj_3_69(); + break; + case 69: + jj_3_70(); + break; + case 70: + jj_3_71(); + break; + case 71: + jj_3_72(); + break; + case 72: + jj_3_73(); + break; + case 73: + jj_3_74(); + break; + case 74: + jj_3_75(); + break; + case 75: + jj_3_76(); + break; + case 76: + jj_3_77(); + break; + case 77: + jj_3_78(); + break; + case 78: + jj_3_79(); + break; + case 79: + jj_3_80(); + break; + case 80: + jj_3_81(); + break; + case 81: + jj_3_82(); + break; + case 82: + jj_3_83(); + break; + case 83: + jj_3_84(); + break; + case 84: + jj_3_85(); + break; + case 85: + jj_3_86(); + break; + case 86: + jj_3_87(); + break; + case 87: + jj_3_88(); + break; + case 88: + jj_3_89(); + break; + case 89: + jj_3_90(); + break; + case 90: + jj_3_91(); + break; + case 91: + jj_3_92(); + break; + case 92: + jj_3_93(); + break; + case 93: + jj_3_94(); + break; + case 94: + jj_3_95(); + break; + case 95: + jj_3_96(); + break; + case 96: + jj_3_97(); + break; + case 97: + jj_3_98(); + break; + case 98: + jj_3_99(); + break; + case 99: + jj_3_100(); + break; + case 100: + jj_3_101(); + break; + case 101: + jj_3_102(); + break; + case 102: + jj_3_103(); + break; + case 103: + jj_3_104(); + break; + case 104: + jj_3_105(); + break; + case 105: + jj_3_106(); + break; + case 106: + jj_3_107(); + break; + case 107: + jj_3_108(); + break; + case 108: + jj_3_109(); + break; + case 109: + jj_3_110(); + break; + case 110: + jj_3_111(); + break; + case 111: + jj_3_112(); + break; + case 112: + jj_3_113(); + break; + case 113: + jj_3_114(); + break; + case 114: + jj_3_115(); + break; + case 115: + jj_3_116(); + break; + case 116: + jj_3_117(); + break; + case 117: + jj_3_118(); + break; + case 118: + jj_3_119(); + break; + case 119: + jj_3_120(); + break; + case 120: + jj_3_121(); + break; + case 121: + jj_3_122(); + break; + case 122: + jj_3_123(); + break; + case 123: + jj_3_124(); + break; + case 124: + jj_3_125(); + break; + case 125: + jj_3_126(); + break; + case 126: + jj_3_127(); + break; + case 127: + jj_3_128(); + break; + case 128: + jj_3_129(); + break; + case 129: + jj_3_130(); + break; + case 130: + jj_3_131(); + break; + case 131: + jj_3_132(); + break; + case 132: + jj_3_133(); + break; + case 133: + jj_3_134(); + break; + case 134: + jj_3_135(); + break; + case 135: + jj_3_136(); + break; + case 136: + jj_3_137(); + break; + case 137: + jj_3_138(); + break; + case 138: + jj_3_139(); + break; + case 139: + jj_3_140(); + break; + case 140: + jj_3_141(); + break; + case 141: + jj_3_142(); + break; + case 142: + jj_3_143(); + break; + case 143: + jj_3_144(); + break; + case 144: + jj_3_145(); + break; + case 145: + jj_3_146(); + break; + case 146: + jj_3_147(); + break; + case 147: + jj_3_148(); + break; + case 148: + jj_3_149(); + break; + } + } + p = p.next; + } while (p != null); + } catch (LookaheadSuccess ls) { + } + } + jj_rescan = false; + } + + private void jj_save(int index, int xla) { + JJCalls p = jj_2_rtns[index]; + while (p.gen > jj_gen) { + if (p.next == null) { + p = p.next = new JJCalls(); + break; + } + p = p.next; + } + p.gen = jj_gen + xla - jj_la; + p.first = token; + p.arg = xla; + } + + static final class JJCalls { + int gen; + Token first; + int arg; + JJCalls next; + } + +}
\ No newline at end of file diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/LexerConstants.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/LexerConstants.java new file mode 100644 index 00000000000..426c9fdf05e --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/LexerConstants.java @@ -0,0 +1,320 @@ +/* Generated By:JJTree&JavaCC: Do not edit this line. LexerConstants.java */ +package pddl4j.lexer; + + +/** + * Token literal values and constants. + * Generated by org.javacc.parser.OtherFilesGen#start() + */ +public interface LexerConstants { + + /** End of File. */ + int EOF = 0; + /** RegularExpression Id. */ + int SINGLE_LINE_COMMENT = 9; + /** RegularExpression Id. */ + int FORMAL_COMMENT = 10; + /** RegularExpression Id. */ + int MULTI_LINE_COMMENT = 11; + /** RegularExpression Id. */ + int LPAREN = 13; + /** RegularExpression Id. */ + int RPAREN = 14; + /** RegularExpression Id. */ + int DEFINE = 15; + /** RegularExpression Id. */ + int DOMAIN = 16; + /** RegularExpression Id. */ + int REQUIREMENTS = 17; + /** RegularExpression Id. */ + int TYPES = 18; + /** RegularExpression Id. */ + int EITHER = 19; + /** RegularExpression Id. */ + int CONSTANTS = 20; + /** RegularExpression Id. */ + int PREDICATES = 21; + /** RegularExpression Id. */ + int FUNCTIONS = 22; + /** RegularExpression Id. */ + int ACTION = 23; + /** RegularExpression Id. */ + int PARAMETERS = 24; + /** RegularExpression Id. */ + int PRECONDITION = 25; + /** RegularExpression Id. */ + int EFFECT = 26; + /** RegularExpression Id. */ + int PREFERENCE = 27; + /** RegularExpression Id. */ + int WHEN = 28; + /** RegularExpression Id. */ + int PROB = 29; + /** RegularExpression Id. */ + int DURATIVE_ACTION = 30; + /** RegularExpression Id. */ + int DURATION = 31; + /** RegularExpression Id. */ + int CONDITION = 32; + /** RegularExpression Id. */ + int DERIVED = 33; + /** RegularExpression Id. */ + int PROBLEM = 34; + /** RegularExpression Id. */ + int P_DOMAIN = 35; + /** RegularExpression Id. */ + int OBJECTS = 36; + /** RegularExpression Id. */ + int INIT = 37; + /** RegularExpression Id. */ + int GOAL = 38; + /** RegularExpression Id. */ + int METRIC = 39; + /** RegularExpression Id. */ + int STRIPS = 40; + /** RegularExpression Id. */ + int TYPING = 41; + /** RegularExpression Id. */ + int NEGATIVE_PRECONDITIONS = 42; + /** RegularExpression Id. */ + int DISJUNCTIVE_PRECONDITIONS = 43; + /** RegularExpression Id. */ + int EQUALITY = 44; + /** RegularExpression Id. */ + int EXISTENTIAL_PRECONDITIONS = 45; + /** RegularExpression Id. */ + int UNIVERSAL_PRECONDITIONS = 46; + /** RegularExpression Id. */ + int QUANTIFIED_PRECONDITIONS = 47; + /** RegularExpression Id. */ + int CONDITIONAL_EFFECTS = 48; + /** RegularExpression Id. */ + int FLUENTS = 49; + /** RegularExpression Id. */ + int ADL = 50; + /** RegularExpression Id. */ + int DURATIVE_ACTIONS = 51; + /** RegularExpression Id. */ + int DERIVED_PREDICATES = 52; + /** RegularExpression Id. */ + int TIMED_INITIAL_LITERALS = 53; + /** RegularExpression Id. */ + int PREFERENCES = 54; + /** RegularExpression Id. */ + int CONSTRAINTS = 55; + /** RegularExpression Id. */ + int CONTINUS_EFFECTS = 56; + /** RegularExpression Id. */ + int DURATION_INEQUALITIES = 57; + /** RegularExpression Id. */ + int GREATER = 58; + /** RegularExpression Id. */ + int LESS = 59; + /** RegularExpression Id. */ + int GEQUAL = 60; + /** RegularExpression Id. */ + int LEQUAL = 61; + /** RegularExpression Id. */ + int EQUAL = 62; + /** RegularExpression Id. */ + int MUL = 63; + /** RegularExpression Id. */ + int DIV = 64; + /** RegularExpression Id. */ + int ADD = 65; + /** RegularExpression Id. */ + int SUB = 66; + /** RegularExpression Id. */ + int ASSIGN = 67; + /** RegularExpression Id. */ + int SCALE_UP = 68; + /** RegularExpression Id. */ + int SCALE_DOWN = 69; + /** RegularExpression Id. */ + int INCREASE = 70; + /** RegularExpression Id. */ + int DECREASE = 71; + /** RegularExpression Id. */ + int OR = 72; + /** RegularExpression Id. */ + int AND = 73; + /** RegularExpression Id. */ + int IMPLY = 74; + /** RegularExpression Id. */ + int NOT = 75; + /** RegularExpression Id. */ + int FORALL = 76; + /** RegularExpression Id. */ + int EXISTS = 77; + /** RegularExpression Id. */ + int ALWAYS = 78; + /** RegularExpression Id. */ + int SOMETIME = 79; + /** RegularExpression Id. */ + int WITHIN = 80; + /** RegularExpression Id. */ + int AT_MOST_ONCE = 81; + /** RegularExpression Id. */ + int SOMETIME_AFTER = 82; + /** RegularExpression Id. */ + int SOMETIME_BEFORE = 83; + /** RegularExpression Id. */ + int ALWAYS_WITHIN = 84; + /** RegularExpression Id. */ + int HOLD_DURING = 85; + /** RegularExpression Id. */ + int HOLD_AFTER = 86; + /** RegularExpression Id. */ + int AT = 87; + /** RegularExpression Id. */ + int START = 88; + /** RegularExpression Id. */ + int END = 89; + /** RegularExpression Id. */ + int OVER = 90; + /** RegularExpression Id. */ + int ALL = 91; + /** RegularExpression Id. */ + int TOTAL_TIME = 92; + /** RegularExpression Id. */ + int MAXIMIZE = 93; + /** RegularExpression Id. */ + int MINIMIZE = 94; + /** RegularExpression Id. */ + int IS_VIOLATED = 95; + /** RegularExpression Id. */ + int VAR_DURATION = 96; + /** RegularExpression Id. */ + int CONTINOUS_VARIABLE = 97; + /** RegularExpression Id. */ + int NUMBER_TYPE = 98; + /** RegularExpression Id. */ + int OBJECT_TYPE = 99; + /** RegularExpression Id. */ + int SYMBOL = 100; + /** RegularExpression Id. */ + int NUMBER = 101; + /** RegularExpression Id. */ + int DIGIT = 102; + /** RegularExpression Id. */ + int LETTER = 103; + + /** Lexical state. */ + int DEFAULT = 0; + /** Lexical state. */ + int IN_SINGLE_LINE_COMMENT = 1; + /** Lexical state. */ + int IN_FORMAL_COMMENT = 2; + /** Lexical state. */ + int IN_MULTI_LINE_COMMENT = 3; + + /** Literal token values. */ + String[] tokenImage = { + "<EOF>", + "\" \"", + "\"\\t\"", + "\"\\n\"", + "\"\\r\"", + "\"//\"", + "\";\"", + "<token of kind 7>", + "\"/*\"", + "<SINGLE_LINE_COMMENT>", + "\"*/\"", + "\"*/\"", + "<token of kind 12>", + "\"(\"", + "\")\"", + "\"define\"", + "\"domain\"", + "\":requirements\"", + "\":types\"", + "\"either\"", + "\":constants\"", + "\":predicates\"", + "\":functions\"", + "\":action\"", + "\":parameters\"", + "\":precondition\"", + "\":effect\"", + "\"preference\"", + "\"when\"", + "\"probabilistic\"", + "\":durative-action\"", + "\":duration\"", + "\":condition\"", + "\":derived\"", + "\"problem\"", + "\":domain\"", + "\":objects\"", + "\":init\"", + "\":goal\"", + "\":metric\"", + "\":strips\"", + "\":typing\"", + "\":negative-preconditions\"", + "\":disjunctive-preconditions\"", + "\":equality\"", + "\":existential-preconditions\"", + "\":universal-preconditions\"", + "\":quantified-preconditions\"", + "\":conditional-effects\"", + "\":fluents\"", + "\":adl\"", + "\":durative-actions\"", + "\":derived-predicates\"", + "\":timed-initial-literals\"", + "\":preferences\"", + "\":constraints\"", + "\":continus_effects\"", + "\":duration-inequalities\"", + "\">\"", + "\"<\"", + "\">=\"", + "\"<=\"", + "\"=\"", + "\"*\"", + "\"/\"", + "\"+\"", + "\"-\"", + "\"assign\"", + "\"scale-up\"", + "\"scale-down\"", + "\"increase\"", + "\"decrease\"", + "\"or\"", + "\"and\"", + "\"imply\"", + "\"not\"", + "\"forall\"", + "\"exists\"", + "\"always\"", + "\"sometime\"", + "\"within\"", + "\"at-most-once\"", + "\"sometime-after\"", + "\"sometime-before\"", + "\"always-within\"", + "\"hold-during\"", + "\"hold-after\"", + "\"at\"", + "\"start\"", + "\"end\"", + "\"over\"", + "\"all\"", + "\"total_time\"", + "\"maximize\"", + "\"minimize\"", + "\"is-violated\"", + "\"?duration\"", + "\"#t\"", + "\"number\"", + "\"object\"", + "<SYMBOL>", + "<NUMBER>", + "<DIGIT>", + "<LETTER>", + "\"?\"", + }; + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/LexerTokenManager.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/LexerTokenManager.java new file mode 100644 index 00000000000..8c6b22538bd --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/LexerTokenManager.java @@ -0,0 +1,2226 @@ +/* Generated By:JJTree&JavaCC: Do not edit this line. LexerTokenManager.java */ +package pddl4j.lexer; +import java.io.InputStream; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import pddl4j.ErrorManager; +import pddl4j.ErrorManager.Message; + +/** Token Manager. */ +public class LexerTokenManager implements LexerConstants +{ + + /** Debug output. */ + public java.io.PrintStream debugStream = System.out; + /** Set debug output. */ + public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } +private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) +{ + switch (pos) + { + case 0: + if ((active0 & 0x120L) != 0L || (active1 & 0x1L) != 0L) + return 2; + if ((active0 & 0x438098000L) != 0L || (active1 & 0xefffffff8L) != 0L) + { + jjmatchedKind = 100; + return 5; + } + if ((active1 & 0x4L) != 0L) + return 5; + return -1; + case 1: + if ((active0 & 0x100L) != 0L) + return 0; + if ((active0 & 0x438098000L) != 0L || (active1 & 0xcff7dfef8L) != 0L) + { + if (jjmatchedPos != 1) + { + jjmatchedKind = 100; + jjmatchedPos = 1; + } + return 5; + } + if ((active1 & 0x200820100L) != 0L) + return 5; + return -1; + case 2: + if ((active0 & 0x438098000L) != 0L || (active1 & 0xcf57ff4f8L) != 0L) + { + jjmatchedKind = 100; + jjmatchedPos = 2; + return 5; + } + if ((active1 & 0xa000a00L) != 0L) + return 5; + return -1; + case 3: + if ((active0 & 0x428098000L) != 0L || (active1 & 0xcf17ff4f8L) != 0L) + { + jjmatchedKind = 100; + jjmatchedPos = 3; + return 5; + } + if ((active0 & 0x10000000L) != 0L || (active1 & 0x4000000L) != 0L) + return 5; + return -1; + case 4: + if ((active0 & 0x428098000L) != 0L || (active1 & 0xcf07ff0f8L) != 0L) + { + jjmatchedKind = 100; + jjmatchedPos = 4; + return 5; + } + if ((active1 & 0x1000400L) != 0L) + return 5; + return -1; + case 5: + if ((active0 & 0x428000000L) != 0L || (active1 & 0xf06e80f0L) != 0L) + { + if (jjmatchedPos != 5) + { + jjmatchedKind = 100; + jjmatchedPos = 5; + } + return 5; + } + if ((active0 & 0x98000L) != 0L || (active1 & 0xc00117008L) != 0L) + return 5; + return -1; + case 6: + if ((active0 & 0x400000000L) != 0L) + return 5; + if ((active0 & 0x28000000L) != 0L || (active1 & 0xf07e80f0L) != 0L) + { + jjmatchedKind = 100; + jjmatchedPos = 6; + return 5; + } + return -1; + case 7: + if ((active1 & 0x600c80d0L) != 0L) + return 5; + if ((active0 & 0x28000000L) != 0L || (active1 & 0x90720020L) != 0L) + { + if (jjmatchedPos != 7) + { + jjmatchedKind = 100; + jjmatchedPos = 7; + } + return 5; + } + return -1; + case 8: + if ((active0 & 0x28000000L) != 0L || (active1 & 0x907e0020L) != 0L) + { + if (jjmatchedPos != 8) + { + jjmatchedKind = 100; + jjmatchedPos = 8; + } + return 5; + } + return -1; + case 9: + if ((active0 & 0x20000000L) != 0L || (active1 & 0x803e0000L) != 0L) + { + if (jjmatchedPos != 9) + { + jjmatchedKind = 100; + jjmatchedPos = 9; + } + return 5; + } + if ((active0 & 0x8000000L) != 0L || (active1 & 0x10400020L) != 0L) + return 5; + return -1; + case 10: + if ((active0 & 0x20000000L) != 0L || (active1 & 0x1e0000L) != 0L) + { + jjmatchedKind = 100; + jjmatchedPos = 10; + return 5; + } + if ((active1 & 0x80200000L) != 0L) + return 5; + return -1; + case 11: + if ((active0 & 0x20000000L) != 0L || (active1 & 0x1c0000L) != 0L) + { + jjmatchedKind = 100; + jjmatchedPos = 11; + return 5; + } + if ((active1 & 0x20000L) != 0L) + return 5; + return -1; + case 12: + if ((active1 & 0xc0000L) != 0L) + { + jjmatchedKind = 100; + jjmatchedPos = 12; + return 5; + } + if ((active0 & 0x20000000L) != 0L || (active1 & 0x100000L) != 0L) + return 5; + return -1; + case 13: + if ((active1 & 0x80000L) != 0L) + { + jjmatchedKind = 100; + jjmatchedPos = 13; + return 5; + } + if ((active1 & 0x40000L) != 0L) + return 5; + return -1; + case 14: + if ((active1 & 0x80000L) != 0L) + return 5; + return -1; + default : + return -1; + } +} +private final int jjStartNfa_0(int pos, long active0, long active1) +{ + return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1); +} +private int jjStopAtPos(int pos, int kind) +{ + jjmatchedKind = kind; + jjmatchedPos = pos; + return pos + 1; +} +private int jjMoveStringLiteralDfa0_0() +{ + switch(curChar) + { + case 35: + return jjMoveStringLiteralDfa1_0(0x0L, 0x200000000L); + case 40: + return jjStopAtPos(0, 13); + case 41: + return jjStopAtPos(0, 14); + case 42: + return jjStopAtPos(0, 63); + case 43: + return jjStopAtPos(0, 65); + case 45: + return jjStartNfaWithStates_0(0, 66, 5); + case 47: + jjmatchedKind = 64; + return jjMoveStringLiteralDfa1_0(0x120L, 0x0L); + case 58: + return jjMoveStringLiteralDfa1_0(0x3fffffbc7f60000L, 0x0L); + case 59: + return jjStopAtPos(0, 6); + case 60: + jjmatchedKind = 59; + return jjMoveStringLiteralDfa1_0(0x2000000000000000L, 0x0L); + case 61: + return jjStopAtPos(0, 62); + case 62: + jjmatchedKind = 58; + return jjMoveStringLiteralDfa1_0(0x1000000000000000L, 0x0L); + case 63: + jjmatchedKind = 104; + return jjMoveStringLiteralDfa1_0(0x0L, 0x100000000L); + case 65: + case 97: + return jjMoveStringLiteralDfa1_0(0x0L, 0x8924208L); + case 68: + case 100: + return jjMoveStringLiteralDfa1_0(0x18000L, 0x80L); + case 69: + case 101: + return jjMoveStringLiteralDfa1_0(0x80000L, 0x2002000L); + case 70: + case 102: + return jjMoveStringLiteralDfa1_0(0x0L, 0x1000L); + case 72: + case 104: + return jjMoveStringLiteralDfa1_0(0x0L, 0x600000L); + case 73: + case 105: + return jjMoveStringLiteralDfa1_0(0x0L, 0x80000440L); + case 77: + case 109: + return jjMoveStringLiteralDfa1_0(0x0L, 0x60000000L); + case 78: + case 110: + return jjMoveStringLiteralDfa1_0(0x0L, 0x400000800L); + case 79: + case 111: + return jjMoveStringLiteralDfa1_0(0x0L, 0x804000100L); + case 80: + case 112: + return jjMoveStringLiteralDfa1_0(0x428000000L, 0x0L); + case 83: + case 115: + return jjMoveStringLiteralDfa1_0(0x0L, 0x10c8030L); + case 84: + case 116: + return jjMoveStringLiteralDfa1_0(0x0L, 0x10000000L); + case 87: + case 119: + return jjMoveStringLiteralDfa1_0(0x10000000L, 0x10000L); + default : + return jjMoveNfa_0(3, 0); + } +} +private int jjMoveStringLiteralDfa1_0(long active0, long active1) +{ + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(0, active0, active1); + return 1; + } + switch(curChar) + { + case 42: + if ((active0 & 0x100L) != 0L) + return jjStartNfaWithStates_0(1, 8, 0); + break; + case 47: + if ((active0 & 0x20L) != 0L) + return jjStopAtPos(1, 5); + break; + case 61: + if ((active0 & 0x1000000000000000L) != 0L) + return jjStopAtPos(1, 60); + else if ((active0 & 0x2000000000000000L) != 0L) + return jjStopAtPos(1, 61); + break; + case 65: + case 97: + return jjMoveStringLiteralDfa2_0(active0, 0x4000000800000L, active1, 0x20000000L); + case 66: + case 98: + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x800000000L); + case 67: + case 99: + return jjMoveStringLiteralDfa2_0(active0, 0x181000100100000L, active1, 0x30L); + case 68: + case 100: + return jjMoveStringLiteralDfa2_0(active0, 0x218080ac0000000L, active1, 0x100000000L); + case 69: + case 101: + return jjMoveStringLiteralDfa2_0(active0, 0x300004008000L, active1, 0x80L); + case 70: + case 102: + return jjMoveStringLiteralDfa2_0(active0, 0x2000000400000L, active1, 0L); + case 71: + case 103: + return jjMoveStringLiteralDfa2_0(active0, 0x4000000000L, active1, 0L); + case 72: + case 104: + return jjMoveStringLiteralDfa2_0(active0, 0x10000000L, active1, 0L); + case 73: + case 105: + return jjMoveStringLiteralDfa2_0(active0, 0x2000080000L, active1, 0x40010000L); + case 76: + case 108: + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x8104000L); + case 77: + case 109: + return jjMoveStringLiteralDfa2_0(active0, 0x8000000000L, active1, 0x400L); + case 78: + case 110: + return jjMoveStringLiteralDfa2_0(active0, 0x40000000000L, active1, 0x2000240L); + case 79: + case 111: + return jjMoveStringLiteralDfa2_0(active0, 0x1000010000L, active1, 0x106c9800L); + case 80: + case 112: + return jjMoveStringLiteralDfa2_0(active0, 0x40000003200000L, active1, 0L); + case 81: + case 113: + return jjMoveStringLiteralDfa2_0(active0, 0x800000000000L, active1, 0L); + case 82: + case 114: + if ((active1 & 0x100L) != 0L) + return jjStartNfaWithStates_0(1, 72, 5); + return jjMoveStringLiteralDfa2_0(active0, 0x428020000L, active1, 0L); + case 83: + case 115: + return jjMoveStringLiteralDfa2_0(active0, 0x10000000000L, active1, 0x80000008L); + case 84: + case 116: + if ((active1 & 0x800000L) != 0L) + { + jjmatchedKind = 87; + jjmatchedPos = 1; + } + else if ((active1 & 0x200000000L) != 0L) + return jjStartNfaWithStates_0(1, 97, 5); + return jjMoveStringLiteralDfa2_0(active0, 0x20020000040000L, active1, 0x1020000L); + case 85: + case 117: + return jjMoveStringLiteralDfa2_0(active0, 0x400000000000L, active1, 0x400000000L); + case 86: + case 118: + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x4000000L); + case 88: + case 120: + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x2000L); + default : + break; + } + return jjStartNfa_0(0, active0, active1); +} +private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(0, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(1, active0, active1); + return 2; + } + switch(curChar) + { + case 45: + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x80020000L); + case 65: + case 97: + return jjMoveStringLiteralDfa3_0(active0, 0x1000000L, active1, 0x1000030L); + case 66: + case 98: + return jjMoveStringLiteralDfa3_0(active0, 0x1000000000L, active1, 0L); + case 67: + case 99: + return jjMoveStringLiteralDfa3_0(active0, 0x800000L, active1, 0xc0L); + case 68: + case 100: + if ((active1 & 0x200L) != 0L) + return jjStartNfaWithStates_0(2, 73, 5); + else if ((active1 & 0x2000000L) != 0L) + return jjStartNfaWithStates_0(2, 89, 5); + return jjMoveStringLiteralDfa3_0(active0, 0x4000000000000L, active1, 0L); + case 69: + case 101: + return jjMoveStringLiteralDfa3_0(active0, 0x10048218020000L, active1, 0x4000000L); + case 70: + case 102: + return jjMoveStringLiteralDfa3_0(active0, 0x4008000L, active1, 0L); + case 73: + case 105: + return jjMoveStringLiteralDfa3_0(active0, 0x20080000000000L, active1, 0x2000L); + case 74: + case 106: + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x800000000L); + case 76: + case 108: + if ((active1 & 0x8000000L) != 0L) + return jjStartNfaWithStates_0(2, 91, 5); + return jjMoveStringLiteralDfa3_0(active0, 0x2000000000000L, active1, 0x600000L); + case 77: + case 109: + return jjMoveStringLiteralDfa3_0(active0, 0x10000L, active1, 0x4000c8000L); + case 78: + case 110: + return jjMoveStringLiteralDfa3_0(active0, 0x402000000000L, active1, 0x40000000L); + case 79: + case 111: + return jjMoveStringLiteralDfa3_0(active0, 0x181004d20100000L, active1, 0L); + case 80: + case 112: + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x400L); + case 81: + case 113: + return jjMoveStringLiteralDfa3_0(active0, 0x100000000000L, active1, 0L); + case 82: + case 114: + return jjMoveStringLiteralDfa3_0(active0, 0x40000002200000L, active1, 0x1000L); + case 83: + case 115: + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x8L); + case 84: + case 116: + if ((active1 & 0x800L) != 0L) + return jjStartNfaWithStates_0(2, 75, 5); + return jjMoveStringLiteralDfa3_0(active0, 0x10000080000L, active1, 0x10010000L); + case 85: + case 117: + return jjMoveStringLiteralDfa3_0(active0, 0x2088000c0400000L, active1, 0x100000000L); + case 87: + case 119: + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x104000L); + case 88: + case 120: + return jjMoveStringLiteralDfa3_0(active0, 0x200000000000L, active1, 0x20000000L); + case 89: + case 121: + return jjMoveStringLiteralDfa3_0(active0, 0x20000040000L, active1, 0L); + default : + break; + } + return jjStartNfa_0(1, active0, active1); +} +private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(1, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(2, active0, active1); + return 3; + } + switch(curChar) + { + case 65: + case 97: + return jjMoveStringLiteralDfa4_0(active0, 0x804000010000L, active1, 0x10105000L); + case 66: + case 98: + return jjMoveStringLiteralDfa4_0(active0, 0x420000000L, active1, 0x400000000L); + case 68: + case 100: + return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x600000L); + case 69: + case 101: + return jjMoveStringLiteralDfa4_0(active0, 0x40000002200000L, active1, 0x8000c8000L); + case 70: + case 102: + return jjMoveStringLiteralDfa4_0(active0, 0xc000000L, active1, 0L); + case 71: + case 103: + return jjMoveStringLiteralDfa4_0(active0, 0x40000000000L, active1, 0L); + case 72: + case 104: + return jjMoveStringLiteralDfa4_0(active0, 0x80000L, active1, 0x10000L); + case 73: + case 105: + return jjMoveStringLiteralDfa4_0(active0, 0x602000008000L, active1, 0x60000008L); + case 74: + case 106: + return jjMoveStringLiteralDfa4_0(active0, 0x1000000000L, active1, 0L); + case 76: + case 108: + if ((active0 & 0x4000000000000L) != 0L) + return jjStopAtPos(3, 50); + return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x430L); + case 77: + case 109: + return jjMoveStringLiteralDfa4_0(active0, 0x20000800000000L, active1, 0x20000L); + case 78: + case 110: + if ((active0 & 0x10000000L) != 0L) + return jjStartNfaWithStates_0(3, 28, 5); + return jjMoveStringLiteralDfa4_0(active0, 0x181000100500000L, active1, 0L); + case 80: + case 112: + return jjMoveStringLiteralDfa4_0(active0, 0x20000040000L, active1, 0L); + case 81: + case 113: + return jjMoveStringLiteralDfa4_0(active0, 0x20000L, active1, 0L); + case 82: + case 114: + if ((active1 & 0x4000000L) != 0L) + return jjStartNfaWithStates_0(3, 90, 5); + return jjMoveStringLiteralDfa4_0(active0, 0x2180102c1000000L, active1, 0x1010000c0L); + case 83: + case 115: + return jjMoveStringLiteralDfa4_0(active0, 0x80000000000L, active1, 0x2000L); + case 84: + case 116: + return jjMoveStringLiteralDfa4_0(active0, 0x8000800000L, active1, 0L); + case 85: + case 117: + return jjMoveStringLiteralDfa4_0(active0, 0x2100000000000L, active1, 0L); + case 86: + case 118: + return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x80000000L); + default : + break; + } + return jjStartNfa_0(2, active0, active1); +} +private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(2, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(3, active0, active1); + return 4; + } + switch(curChar) + { + case 45: + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x600000L); + case 65: + case 97: + return jjMoveStringLiteralDfa5_0(active0, 0x2081408e1000000L, active1, 0x100000000L); + case 67: + case 99: + return jjMoveStringLiteralDfa5_0(active0, 0x2400000L, active1, 0x800000000L); + case 68: + case 100: + return jjMoveStringLiteralDfa5_0(active0, 0x1000100200000L, active1, 0L); + case 69: + case 101: + return jjMoveStringLiteralDfa5_0(active0, 0x2200100c0c0000L, active1, 0x4000000f0L); + case 70: + case 102: + return jjMoveStringLiteralDfa5_0(active0, 0x40000000000000L, active1, 0L); + case 71: + case 103: + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x8L); + case 73: + case 105: + return jjMoveStringLiteralDfa5_0(active0, 0x10030200810000L, active1, 0x80010000L); + case 74: + case 106: + return jjMoveStringLiteralDfa5_0(active0, 0x80000000000L, active1, 0L); + case 76: + case 108: + if ((active0 & 0x4000000000L) != 0L) + return jjStopAtPos(4, 38); + return jjMoveStringLiteralDfa5_0(active0, 0x400000000L, active1, 0x10001000L); + case 77: + case 109: + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x60000000L); + case 78: + case 110: + return jjMoveStringLiteralDfa5_0(active0, 0x800000008000L, active1, 0L); + case 79: + case 111: + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x20000L); + case 82: + case 114: + return jjMoveStringLiteralDfa5_0(active0, 0x8000000000L, active1, 0L); + case 83: + case 115: + return jjMoveStringLiteralDfa5_0(active0, 0x80200000100000L, active1, 0L); + case 84: + case 116: + if ((active0 & 0x2000000000L) != 0L) + return jjStopAtPos(4, 37); + else if ((active1 & 0x1000000L) != 0L) + return jjStartNfaWithStates_0(4, 88, 5); + return jjMoveStringLiteralDfa5_0(active0, 0x100000000000000L, active1, 0xca000L); + case 85: + case 117: + return jjMoveStringLiteralDfa5_0(active0, 0x20000L, active1, 0L); + case 86: + case 118: + return jjMoveStringLiteralDfa5_0(active0, 0x400000000000L, active1, 0L); + case 89: + case 121: + if ((active1 & 0x400L) != 0L) + return jjStartNfaWithStates_0(4, 74, 5); + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x104000L); + default : + break; + } + return jjStartNfa_0(3, active0, active1); +} +private int jjMoveStringLiteralDfa5_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(3, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(4, active0, active1); + return 5; + } + switch(curChar) + { + case 45: + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x30L); + case 95: + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x10000000L); + case 65: + case 97: + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x4000c0L); + case 66: + case 98: + return jjMoveStringLiteralDfa6_0(active0, 0x20000000L, active1, 0L); + case 67: + case 99: + return jjMoveStringLiteralDfa6_0(active0, 0x1004000000L, active1, 0L); + case 68: + case 100: + return jjMoveStringLiteralDfa6_0(active0, 0x20000000000000L, active1, 0x200000L); + case 69: + case 101: + if ((active0 & 0x8000L) != 0L) + return jjStartNfaWithStates_0(5, 15, 5); + return jjMoveStringLiteralDfa6_0(active0, 0x40400400000000L, active1, 0L); + case 73: + case 105: + return jjMoveStringLiteralDfa6_0(active0, 0x101008900220000L, active1, 0x600c8000L); + case 76: + case 108: + if ((active1 & 0x1000L) != 0L) + return jjStartNfaWithStates_0(5, 76, 5); + return jjMoveStringLiteralDfa6_0(active0, 0x100000000000L, active1, 0L); + case 77: + case 109: + return jjMoveStringLiteralDfa6_0(active0, 0x1000000L, active1, 0L); + case 78: + case 110: + if ((active0 & 0x10000L) != 0L) + return jjStartNfaWithStates_0(5, 16, 5); + else if ((active1 & 0x8L) != 0L) + return jjStartNfaWithStates_0(5, 67, 5); + else if ((active1 & 0x10000L) != 0L) + return jjStartNfaWithStates_0(5, 80, 5); + return jjMoveStringLiteralDfa6_0(active0, 0x2020000000000L, active1, 0L); + case 79: + case 111: + return jjMoveStringLiteralDfa6_0(active0, 0x2800000L, active1, 0x80000000L); + case 80: + case 112: + return jjMoveStringLiteralDfa6_0(active0, 0x10000000000L, active1, 0L); + case 82: + case 114: + if ((active0 & 0x80000L) != 0L) + return jjStartNfaWithStates_0(5, 19, 5); + else if ((active1 & 0x400000000L) != 0L) + return jjStartNfaWithStates_0(5, 98, 5); + return jjMoveStringLiteralDfa6_0(active0, 0x8000000L, active1, 0L); + case 83: + case 115: + if ((active0 & 0x40000L) != 0L) + return jjStopAtPos(5, 18); + else if ((active1 & 0x2000L) != 0L) + return jjStartNfaWithStates_0(5, 77, 5); + else if ((active1 & 0x4000L) != 0L) + { + jjmatchedKind = 78; + jjmatchedPos = 5; + } + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x120000L); + case 84: + case 116: + if ((active1 & 0x800000000L) != 0L) + return jjStartNfaWithStates_0(5, 99, 5); + return jjMoveStringLiteralDfa6_0(active0, 0x288a400c0500000L, active1, 0x100000000L); + case 85: + case 117: + return jjMoveStringLiteralDfa6_0(active0, 0x80000000000L, active1, 0L); + case 86: + case 118: + return jjMoveStringLiteralDfa6_0(active0, 0x10000200000000L, active1, 0L); + default : + break; + } + return jjStartNfa_0(4, active0, active1); +} +private int jjMoveStringLiteralDfa6_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(4, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(5, active0, active1); + return 6; + } + switch(curChar) + { + case 45: + return jjMoveStringLiteralDfa7_0(active0, 0x20000000000000L, active1, 0x100000L); + case 65: + case 97: + return jjMoveStringLiteralDfa7_0(active0, 0x100000L, active1, 0L); + case 67: + case 99: + if ((active0 & 0x8000000000L) != 0L) + return jjStopAtPos(6, 39); + return jjMoveStringLiteralDfa7_0(active0, 0x200000L, active1, 0L); + case 68: + case 100: + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x20L); + case 69: + case 101: + return jjMoveStringLiteralDfa7_0(active0, 0x10200209000000L, active1, 0L); + case 70: + case 102: + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x400000L); + case 71: + case 103: + if ((active0 & 0x20000000000L) != 0L) + return jjStopAtPos(6, 41); + break; + case 73: + case 105: + return jjMoveStringLiteralDfa7_0(active0, 0x2089400e0400000L, active1, 0x100000000L); + case 76: + case 108: + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x80000000L); + case 77: + case 109: + if ((active0 & 0x400000000L) != 0L) + return jjStartNfaWithStates_0(6, 34, 5); + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0xc8000L); + case 78: + case 110: + if ((active0 & 0x800000L) != 0L) + return jjStopAtPos(6, 23); + else if ((active0 & 0x800000000L) != 0L) + return jjStopAtPos(6, 35); + return jjMoveStringLiteralDfa7_0(active0, 0x100080002000000L, active1, 0L); + case 82: + case 114: + return jjMoveStringLiteralDfa7_0(active0, 0xc0400000020000L, active1, 0L); + case 83: + case 115: + if ((active0 & 0x10000000000L) != 0L) + return jjStopAtPos(6, 40); + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0xc0L); + case 84: + case 116: + if ((active0 & 0x4000000L) != 0L) + return jjStopAtPos(6, 26); + return jjMoveStringLiteralDfa7_0(active0, 0x3001100000000L, active1, 0x10020000L); + case 85: + case 117: + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x200010L); + case 90: + case 122: + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x60000000L); + default : + break; + } + return jjStartNfa_0(5, active0, active1); +} +private int jjMoveStringLiteralDfa7_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(5, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(6, active0, active1); + return 7; + } + switch(curChar) + { + case 45: + return jjMoveStringLiteralDfa8_0(active0, 0L, active1, 0x20000L); + case 65: + case 97: + return jjMoveStringLiteralDfa8_0(active0, 0x80000000200000L, active1, 0x80000000L); + case 67: + case 99: + return jjMoveStringLiteralDfa8_0(active0, 0x80000000000L, active1, 0L); + case 68: + case 100: + if ((active0 & 0x200000000L) != 0L) + { + jjmatchedKind = 33; + jjmatchedPos = 7; + } + return jjMoveStringLiteralDfa8_0(active0, 0x10000002000000L, active1, 0L); + case 69: + case 101: + if ((active1 & 0x40L) != 0L) + return jjStartNfaWithStates_0(7, 70, 5); + else if ((active1 & 0x80L) != 0L) + return jjStartNfaWithStates_0(7, 71, 5); + else if ((active1 & 0x8000L) != 0L) + { + jjmatchedKind = 79; + jjmatchedPos = 7; + } + else if ((active1 & 0x20000000L) != 0L) + return jjStartNfaWithStates_0(7, 93, 5); + else if ((active1 & 0x40000000L) != 0L) + return jjStartNfaWithStates_0(7, 94, 5); + return jjMoveStringLiteralDfa8_0(active0, 0x40000000020000L, active1, 0xc0000L); + case 70: + case 102: + return jjMoveStringLiteralDfa8_0(active0, 0x800000000000L, active1, 0L); + case 73: + case 105: + return jjMoveStringLiteralDfa8_0(active0, 0x21000100000000L, active1, 0x10000000L); + case 76: + case 108: + return jjMoveStringLiteralDfa8_0(active0, 0x20000000L, active1, 0L); + case 78: + case 110: + return jjMoveStringLiteralDfa8_0(active0, 0x200008100000L, active1, 0L); + case 79: + case 111: + return jjMoveStringLiteralDfa8_0(active0, 0x200000080400000L, active1, 0x100000020L); + case 80: + case 112: + if ((active1 & 0x10L) != 0L) + return jjStartNfaWithStates_0(7, 68, 5); + break; + case 82: + case 114: + return jjMoveStringLiteralDfa8_0(active0, 0L, active1, 0x200000L); + case 83: + case 115: + if ((active0 & 0x1000000000L) != 0L) + return jjStopAtPos(7, 36); + else if ((active0 & 0x2000000000000L) != 0L) + return jjStopAtPos(7, 49); + return jjMoveStringLiteralDfa8_0(active0, 0x400000000000L, active1, 0L); + case 84: + case 116: + return jjMoveStringLiteralDfa8_0(active0, 0x100001000000L, active1, 0x400000L); + case 85: + case 117: + return jjMoveStringLiteralDfa8_0(active0, 0x100000000000000L, active1, 0L); + case 86: + case 118: + return jjMoveStringLiteralDfa8_0(active0, 0x8040040000000L, active1, 0L); + case 87: + case 119: + return jjMoveStringLiteralDfa8_0(active0, 0L, active1, 0x100000L); + default : + break; + } + return jjStartNfa_0(6, active0, active1); +} +private int jjMoveStringLiteralDfa8_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(6, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(7, active0, active1); + return 8; + } + switch(curChar) + { + case 45: + return jjMoveStringLiteralDfa9_0(active0, 0x10000000000000L, active1, 0xc0000L); + case 65: + case 97: + return jjMoveStringLiteralDfa9_0(active0, 0x400000000000L, active1, 0L); + case 67: + case 99: + return jjMoveStringLiteralDfa9_0(active0, 0x8000000L, active1, 0L); + case 69: + case 101: + return jjMoveStringLiteralDfa9_0(active0, 0x8040041000000L, active1, 0x400000L); + case 73: + case 105: + return jjMoveStringLiteralDfa9_0(active0, 0x80800022000000L, active1, 0x300000L); + case 77: + case 109: + return jjMoveStringLiteralDfa9_0(active0, 0x20000L, active1, 0x10000000L); + case 78: + case 110: + if ((active0 & 0x80000000L) != 0L) + { + jjmatchedKind = 31; + jjmatchedPos = 8; + } + else if ((active1 & 0x100000000L) != 0L) + return jjStopAtPos(8, 96); + return jjMoveStringLiteralDfa9_0(active0, 0x260000000400000L, active1, 0L); + case 79: + case 111: + return jjMoveStringLiteralDfa9_0(active0, 0x1000100000000L, active1, 0x20000L); + case 83: + case 115: + return jjMoveStringLiteralDfa9_0(active0, 0x100000000000000L, active1, 0L); + case 84: + case 116: + return jjMoveStringLiteralDfa9_0(active0, 0x280000300000L, active1, 0x80000000L); + case 87: + case 119: + return jjMoveStringLiteralDfa9_0(active0, 0L, active1, 0x20L); + case 89: + case 121: + if ((active0 & 0x100000000000L) != 0L) + return jjStopAtPos(8, 44); + break; + default : + break; + } + return jjStartNfa_0(7, active0, active1); +} +private int jjMoveStringLiteralDfa9_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(7, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(8, active0, active1); + return 9; + } + switch(curChar) + { + case 45: + return jjMoveStringLiteralDfa10_0(active0, 0x208040040000000L, active1, 0L); + case 95: + return jjMoveStringLiteralDfa10_0(active0, 0x100000000000000L, active1, 0L); + case 65: + case 97: + return jjMoveStringLiteralDfa10_0(active0, 0L, active1, 0x40000L); + case 66: + case 98: + return jjMoveStringLiteralDfa10_0(active0, 0L, active1, 0x80000L); + case 67: + case 99: + return jjMoveStringLiteralDfa10_0(active0, 0x40000000000000L, active1, 0L); + case 69: + case 101: + if ((active0 & 0x8000000L) != 0L) + return jjStartNfaWithStates_0(9, 27, 5); + else if ((active1 & 0x10000000L) != 0L) + return jjStartNfaWithStates_0(9, 92, 5); + return jjMoveStringLiteralDfa10_0(active0, 0x800000220000L, active1, 0x80000000L); + case 73: + case 105: + return jjMoveStringLiteralDfa10_0(active0, 0x20280000000000L, active1, 0L); + case 76: + case 108: + return jjMoveStringLiteralDfa10_0(active0, 0x400000000000L, active1, 0L); + case 78: + case 110: + if ((active0 & 0x100000000L) != 0L) + { + jjmatchedKind = 32; + jjmatchedPos = 9; + } + else if ((active1 & 0x20L) != 0L) + return jjStartNfaWithStates_0(9, 69, 5); + return jjMoveStringLiteralDfa10_0(active0, 0x81000000000000L, active1, 0x220000L); + case 80: + case 112: + return jjMoveStringLiteralDfa10_0(active0, 0x10000000000000L, active1, 0L); + case 82: + case 114: + if ((active1 & 0x400000L) != 0L) + return jjStartNfaWithStates_0(9, 86, 5); + return jjMoveStringLiteralDfa10_0(active0, 0x1000000L, active1, 0L); + case 83: + case 115: + if ((active0 & 0x100000L) != 0L) + return jjStopAtPos(9, 20); + else if ((active0 & 0x400000L) != 0L) + return jjStopAtPos(9, 22); + return jjMoveStringLiteralDfa10_0(active0, 0x20000000L, active1, 0L); + case 84: + case 116: + return jjMoveStringLiteralDfa10_0(active0, 0x2000000L, active1, 0x100000L); + default : + break; + } + return jjStartNfa_0(8, active0, active1); +} +private int jjMoveStringLiteralDfa10_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(8, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(9, active0, active1); + return 10; + } + switch(curChar) + { + case 45: + return jjMoveStringLiteralDfa11_0(active0, 0x400000000000L, active1, 0L); + case 65: + case 97: + return jjMoveStringLiteralDfa11_0(active0, 0x9200040000000L, active1, 0L); + case 67: + case 99: + return jjMoveStringLiteralDfa11_0(active0, 0L, active1, 0x20000L); + case 68: + case 100: + if ((active1 & 0x80000000L) != 0L) + return jjStartNfaWithStates_0(10, 95, 5); + return jjMoveStringLiteralDfa11_0(active0, 0x800000000000L, active1, 0L); + case 69: + case 101: + return jjMoveStringLiteralDfa11_0(active0, 0x140000000000000L, active1, 0x80000L); + case 70: + case 102: + return jjMoveStringLiteralDfa11_0(active0, 0L, active1, 0x40000L); + case 71: + case 103: + if ((active1 & 0x200000L) != 0L) + return jjStartNfaWithStates_0(10, 85, 5); + break; + case 72: + case 104: + return jjMoveStringLiteralDfa11_0(active0, 0L, active1, 0x100000L); + case 73: + case 105: + return jjMoveStringLiteralDfa11_0(active0, 0x200000002000000L, active1, 0L); + case 78: + case 110: + return jjMoveStringLiteralDfa11_0(active0, 0x20000L, active1, 0L); + case 80: + case 112: + return jjMoveStringLiteralDfa11_0(active0, 0x40000000000L, active1, 0L); + case 82: + case 114: + return jjMoveStringLiteralDfa11_0(active0, 0x10000000000000L, active1, 0L); + case 83: + case 115: + if ((active0 & 0x200000L) != 0L) + return jjStopAtPos(10, 21); + else if ((active0 & 0x1000000L) != 0L) + return jjStopAtPos(10, 24); + break; + case 84: + case 116: + return jjMoveStringLiteralDfa11_0(active0, 0xa0000020000000L, active1, 0L); + case 86: + case 118: + return jjMoveStringLiteralDfa11_0(active0, 0x80000000000L, active1, 0L); + default : + break; + } + return jjStartNfa_0(9, active0, active1); +} +private int jjMoveStringLiteralDfa11_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(9, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(10, active0, active1); + return 11; + } + switch(curChar) + { + case 45: + return jjMoveStringLiteralDfa12_0(active0, 0x800000000000L, active1, 0L); + case 67: + case 99: + return jjMoveStringLiteralDfa12_0(active0, 0x8000040000000L, active1, 0L); + case 69: + case 101: + if ((active1 & 0x20000L) != 0L) + return jjStartNfaWithStates_0(11, 81, 5); + return jjMoveStringLiteralDfa12_0(active0, 0x10080000000000L, active1, 0L); + case 70: + case 102: + return jjMoveStringLiteralDfa12_0(active0, 0x100000000000000L, active1, 0x80000L); + case 73: + case 105: + return jjMoveStringLiteralDfa12_0(active0, 0x20000020000000L, active1, 0x100000L); + case 76: + case 108: + return jjMoveStringLiteralDfa12_0(active0, 0x1200000000000L, active1, 0L); + case 78: + case 110: + return jjMoveStringLiteralDfa12_0(active0, 0x200000000000000L, active1, 0L); + case 79: + case 111: + return jjMoveStringLiteralDfa12_0(active0, 0x2000000L, active1, 0L); + case 80: + case 112: + return jjMoveStringLiteralDfa12_0(active0, 0x400000000000L, active1, 0L); + case 82: + case 114: + return jjMoveStringLiteralDfa12_0(active0, 0x40000000000L, active1, 0L); + case 83: + case 115: + if ((active0 & 0x40000000000000L) != 0L) + return jjStopAtPos(11, 54); + else if ((active0 & 0x80000000000000L) != 0L) + return jjStopAtPos(11, 55); + break; + case 84: + case 116: + return jjMoveStringLiteralDfa12_0(active0, 0x20000L, active1, 0x40000L); + default : + break; + } + return jjStartNfa_0(10, active0, active1); +} +private int jjMoveStringLiteralDfa12_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(10, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(11, active0, active1); + return 12; + } + switch(curChar) + { + case 45: + return jjMoveStringLiteralDfa13_0(active0, 0x1280000000000L, active1, 0L); + case 65: + case 97: + return jjMoveStringLiteralDfa13_0(active0, 0x20000000000000L, active1, 0L); + case 67: + case 99: + if ((active0 & 0x20000000L) != 0L) + return jjStartNfaWithStates_0(12, 29, 5); + break; + case 68: + case 100: + return jjMoveStringLiteralDfa13_0(active0, 0x10000000000000L, active1, 0L); + case 69: + case 101: + return jjMoveStringLiteralDfa13_0(active0, 0x200040000000000L, active1, 0x40000L); + case 70: + case 102: + return jjMoveStringLiteralDfa13_0(active0, 0x100000000000000L, active1, 0L); + case 78: + case 110: + if ((active0 & 0x2000000L) != 0L) + return jjStopAtPos(12, 25); + else if ((active1 & 0x100000L) != 0L) + return jjStartNfaWithStates_0(12, 84, 5); + break; + case 79: + case 111: + return jjMoveStringLiteralDfa13_0(active0, 0L, active1, 0x80000L); + case 80: + case 112: + return jjMoveStringLiteralDfa13_0(active0, 0x800000000000L, active1, 0L); + case 82: + case 114: + return jjMoveStringLiteralDfa13_0(active0, 0x400000000000L, active1, 0L); + case 83: + case 115: + if ((active0 & 0x20000L) != 0L) + return jjStopAtPos(12, 17); + break; + case 84: + case 116: + return jjMoveStringLiteralDfa13_0(active0, 0x8000040000000L, active1, 0L); + default : + break; + } + return jjStartNfa_0(11, active0, active1); +} +private int jjMoveStringLiteralDfa13_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(11, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(12, active0, active1); + return 13; + } + switch(curChar) + { + case 67: + case 99: + return jjMoveStringLiteralDfa14_0(active0, 0x40000000000L, active1, 0L); + case 69: + case 101: + return jjMoveStringLiteralDfa14_0(active0, 0x101400000000000L, active1, 0L); + case 73: + case 105: + return jjMoveStringLiteralDfa14_0(active0, 0x18000040000000L, active1, 0L); + case 76: + case 108: + return jjMoveStringLiteralDfa14_0(active0, 0x20000000000000L, active1, 0L); + case 80: + case 112: + return jjMoveStringLiteralDfa14_0(active0, 0x280000000000L, active1, 0L); + case 81: + case 113: + return jjMoveStringLiteralDfa14_0(active0, 0x200000000000000L, active1, 0L); + case 82: + case 114: + if ((active1 & 0x40000L) != 0L) + return jjStartNfaWithStates_0(13, 82, 5); + return jjMoveStringLiteralDfa14_0(active0, 0x800000000000L, active1, 0x80000L); + default : + break; + } + return jjStartNfa_0(12, active0, active1); +} +private int jjMoveStringLiteralDfa14_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(12, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(13, active0, active1); + return 14; + } + switch(curChar) + { + case 45: + return jjMoveStringLiteralDfa15_0(active0, 0x20000000000000L, active1, 0L); + case 67: + case 99: + return jjMoveStringLiteralDfa15_0(active0, 0x110400000000000L, active1, 0L); + case 69: + case 101: + if ((active1 & 0x80000L) != 0L) + return jjStartNfaWithStates_0(14, 83, 5); + return jjMoveStringLiteralDfa15_0(active0, 0x800000000000L, active1, 0L); + case 70: + case 102: + return jjMoveStringLiteralDfa15_0(active0, 0x1000000000000L, active1, 0L); + case 79: + case 111: + return jjMoveStringLiteralDfa15_0(active0, 0x8040040000000L, active1, 0L); + case 82: + case 114: + return jjMoveStringLiteralDfa15_0(active0, 0x280000000000L, active1, 0L); + case 85: + case 117: + return jjMoveStringLiteralDfa15_0(active0, 0x200000000000000L, active1, 0L); + default : + break; + } + return jjStartNfa_0(13, active0, active1); +} +private int jjMoveStringLiteralDfa15_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(13, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(14, active0, 0L); + return 15; + } + switch(curChar) + { + case 65: + case 97: + return jjMoveStringLiteralDfa16_0(active0, 0x210000000000000L); + case 67: + case 99: + return jjMoveStringLiteralDfa16_0(active0, 0x800000000000L); + case 69: + case 101: + return jjMoveStringLiteralDfa16_0(active0, 0x280000000000L); + case 70: + case 102: + return jjMoveStringLiteralDfa16_0(active0, 0x1000000000000L); + case 76: + case 108: + return jjMoveStringLiteralDfa16_0(active0, 0x20000000000000L); + case 78: + case 110: + if ((active0 & 0x40000000L) != 0L) + { + jjmatchedKind = 30; + jjmatchedPos = 15; + } + return jjMoveStringLiteralDfa16_0(active0, 0x8040000000000L); + case 79: + case 111: + return jjMoveStringLiteralDfa16_0(active0, 0x400000000000L); + case 84: + case 116: + return jjMoveStringLiteralDfa16_0(active0, 0x100000000000000L); + default : + break; + } + return jjStartNfa_0(14, active0, 0L); +} +private int jjMoveStringLiteralDfa16_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(14, old0, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(15, active0, 0L); + return 16; + } + switch(curChar) + { + case 67: + case 99: + return jjMoveStringLiteralDfa17_0(active0, 0x280000000000L); + case 68: + case 100: + return jjMoveStringLiteralDfa17_0(active0, 0x40000000000L); + case 69: + case 101: + return jjMoveStringLiteralDfa17_0(active0, 0x1000000000000L); + case 73: + case 105: + return jjMoveStringLiteralDfa17_0(active0, 0x20000000000000L); + case 76: + case 108: + return jjMoveStringLiteralDfa17_0(active0, 0x200000000000000L); + case 78: + case 110: + return jjMoveStringLiteralDfa17_0(active0, 0x400000000000L); + case 79: + case 111: + return jjMoveStringLiteralDfa17_0(active0, 0x800000000000L); + case 83: + case 115: + if ((active0 & 0x8000000000000L) != 0L) + return jjStopAtPos(16, 51); + else if ((active0 & 0x100000000000000L) != 0L) + return jjStopAtPos(16, 56); + break; + case 84: + case 116: + return jjMoveStringLiteralDfa17_0(active0, 0x10000000000000L); + default : + break; + } + return jjStartNfa_0(15, active0, 0L); +} +private int jjMoveStringLiteralDfa17_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(15, old0, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(16, active0, 0L); + return 17; + } + switch(curChar) + { + case 67: + case 99: + return jjMoveStringLiteralDfa18_0(active0, 0x1000000000000L); + case 68: + case 100: + return jjMoveStringLiteralDfa18_0(active0, 0x400000000000L); + case 69: + case 101: + return jjMoveStringLiteralDfa18_0(active0, 0x10000000000000L); + case 73: + case 105: + return jjMoveStringLiteralDfa18_0(active0, 0x200040000000000L); + case 78: + case 110: + return jjMoveStringLiteralDfa18_0(active0, 0x800000000000L); + case 79: + case 111: + return jjMoveStringLiteralDfa18_0(active0, 0x280000000000L); + case 84: + case 116: + return jjMoveStringLiteralDfa18_0(active0, 0x20000000000000L); + default : + break; + } + return jjStartNfa_0(16, active0, 0L); +} +private int jjMoveStringLiteralDfa18_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(16, old0, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(17, active0, 0L); + return 18; + } + switch(curChar) + { + case 68: + case 100: + return jjMoveStringLiteralDfa19_0(active0, 0x800000000000L); + case 69: + case 101: + return jjMoveStringLiteralDfa19_0(active0, 0x20000000000000L); + case 73: + case 105: + return jjMoveStringLiteralDfa19_0(active0, 0x400000000000L); + case 78: + case 110: + return jjMoveStringLiteralDfa19_0(active0, 0x280000000000L); + case 83: + case 115: + if ((active0 & 0x10000000000000L) != 0L) + return jjStopAtPos(18, 52); + break; + case 84: + case 116: + return jjMoveStringLiteralDfa19_0(active0, 0x201040000000000L); + default : + break; + } + return jjStartNfa_0(17, active0, 0L); +} +private int jjMoveStringLiteralDfa19_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(17, old0, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(18, active0, 0L); + return 19; + } + switch(curChar) + { + case 68: + case 100: + return jjMoveStringLiteralDfa20_0(active0, 0x280000000000L); + case 73: + case 105: + return jjMoveStringLiteralDfa20_0(active0, 0x200840000000000L); + case 82: + case 114: + return jjMoveStringLiteralDfa20_0(active0, 0x20000000000000L); + case 83: + case 115: + if ((active0 & 0x1000000000000L) != 0L) + return jjStopAtPos(19, 48); + break; + case 84: + case 116: + return jjMoveStringLiteralDfa20_0(active0, 0x400000000000L); + default : + break; + } + return jjStartNfa_0(18, active0, 0L); +} +private int jjMoveStringLiteralDfa20_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(18, old0, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(19, active0, 0L); + return 20; + } + switch(curChar) + { + case 65: + case 97: + return jjMoveStringLiteralDfa21_0(active0, 0x20000000000000L); + case 69: + case 101: + return jjMoveStringLiteralDfa21_0(active0, 0x200000000000000L); + case 73: + case 105: + return jjMoveStringLiteralDfa21_0(active0, 0x680000000000L); + case 79: + case 111: + return jjMoveStringLiteralDfa21_0(active0, 0x40000000000L); + case 84: + case 116: + return jjMoveStringLiteralDfa21_0(active0, 0x800000000000L); + default : + break; + } + return jjStartNfa_0(19, active0, 0L); +} +private int jjMoveStringLiteralDfa21_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(19, old0, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(20, active0, 0L); + return 21; + } + switch(curChar) + { + case 73: + case 105: + return jjMoveStringLiteralDfa22_0(active0, 0x800000000000L); + case 76: + case 108: + return jjMoveStringLiteralDfa22_0(active0, 0x20000000000000L); + case 78: + case 110: + return jjMoveStringLiteralDfa22_0(active0, 0x40000000000L); + case 79: + case 111: + return jjMoveStringLiteralDfa22_0(active0, 0x400000000000L); + case 83: + case 115: + if ((active0 & 0x200000000000000L) != 0L) + return jjStopAtPos(21, 57); + break; + case 84: + case 116: + return jjMoveStringLiteralDfa22_0(active0, 0x280000000000L); + default : + break; + } + return jjStartNfa_0(20, active0, 0L); +} +private int jjMoveStringLiteralDfa22_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(20, old0, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(21, active0, 0L); + return 22; + } + switch(curChar) + { + case 73: + case 105: + return jjMoveStringLiteralDfa23_0(active0, 0x280000000000L); + case 78: + case 110: + return jjMoveStringLiteralDfa23_0(active0, 0x400000000000L); + case 79: + case 111: + return jjMoveStringLiteralDfa23_0(active0, 0x800000000000L); + case 83: + case 115: + if ((active0 & 0x40000000000L) != 0L) + return jjStopAtPos(22, 42); + else if ((active0 & 0x20000000000000L) != 0L) + return jjStopAtPos(22, 53); + break; + default : + break; + } + return jjStartNfa_0(21, active0, 0L); +} +private int jjMoveStringLiteralDfa23_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(21, old0, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(22, active0, 0L); + return 23; + } + switch(curChar) + { + case 78: + case 110: + return jjMoveStringLiteralDfa24_0(active0, 0x800000000000L); + case 79: + case 111: + return jjMoveStringLiteralDfa24_0(active0, 0x280000000000L); + case 83: + case 115: + if ((active0 & 0x400000000000L) != 0L) + return jjStopAtPos(23, 46); + break; + default : + break; + } + return jjStartNfa_0(22, active0, 0L); +} +private int jjMoveStringLiteralDfa24_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(22, old0, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(23, active0, 0L); + return 24; + } + switch(curChar) + { + case 78: + case 110: + return jjMoveStringLiteralDfa25_0(active0, 0x280000000000L); + case 83: + case 115: + if ((active0 & 0x800000000000L) != 0L) + return jjStopAtPos(24, 47); + break; + default : + break; + } + return jjStartNfa_0(23, active0, 0L); +} +private int jjMoveStringLiteralDfa25_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(23, old0, 0L); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(24, active0, 0L); + return 25; + } + switch(curChar) + { + case 83: + case 115: + if ((active0 & 0x80000000000L) != 0L) + return jjStopAtPos(25, 43); + else if ((active0 & 0x200000000000L) != 0L) + return jjStopAtPos(25, 45); + break; + default : + break; + } + return jjStartNfa_0(24, active0, 0L); +} +private int jjStartNfaWithStates_0(int pos, int kind, int state) +{ + jjmatchedKind = kind; + jjmatchedPos = pos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return pos + 1; } + return jjMoveNfa_0(state, pos + 1); +} +static final long[] jjbitVec0 = { + 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL +}; +private int jjMoveNfa_0(int startState, int curPos) +{ + int startsAt = 0; + jjnewStateCnt = 9; + int i = 1; + jjstateSet[0] = startState; + int kind = 0x7fffffff; + for (;;) + { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) + { + long l = 1L << curChar; + do + { + switch(jjstateSet[--i]) + { + case 3: + if ((0x3ff000000000000L & l) != 0L) + { + if (kind > 101) + kind = 101; + jjCheckNAddTwoStates(6, 7); + } + else if ((0x200800000000L & l) != 0L) + { + if (kind > 100) + kind = 100; + jjCheckNAdd(5); + } + else if (curChar == 47) + jjstateSet[jjnewStateCnt++] = 2; + break; + case 0: + if (curChar == 42) + jjstateSet[jjnewStateCnt++] = 1; + break; + case 1: + if ((0xffff7fffffffffffL & l) != 0L && kind > 7) + kind = 7; + break; + case 2: + if (curChar == 42) + jjstateSet[jjnewStateCnt++] = 0; + break; + case 4: + if ((0x200800000000L & l) == 0L) + break; + if (kind > 100) + kind = 100; + jjCheckNAdd(5); + break; + case 5: + if ((0x3ff200800000000L & l) == 0L) + break; + if (kind > 100) + kind = 100; + jjCheckNAdd(5); + break; + case 6: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 101) + kind = 101; + jjCheckNAddTwoStates(6, 7); + break; + case 7: + if (curChar != 46) + break; + if (kind > 101) + kind = 101; + jjCheckNAdd(8); + break; + case 8: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 101) + kind = 101; + jjCheckNAdd(8); + break; + default : break; + } + } while(i != startsAt); + } + else if (curChar < 128) + { + long l = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 3: + case 5: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 100) + kind = 100; + jjCheckNAdd(5); + break; + case 1: + if (kind > 7) + kind = 7; + break; + default : break; + } + } while(i != startsAt); + } + else + { + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 1: + if ((jjbitVec0[i2] & l2) != 0L && kind > 7) + kind = 7; + break; + default : break; + } + } while(i != startsAt); + } + if (kind != 0x7fffffff) + { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 9 - (jjnewStateCnt = startsAt))) + return curPos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return curPos; } + } +} +private int jjMoveStringLiteralDfa0_3() +{ + switch(curChar) + { + case 42: + return jjMoveStringLiteralDfa1_3(0x800L); + default : + return 1; + } +} +private int jjMoveStringLiteralDfa1_3(long active0) +{ + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + return 1; + } + switch(curChar) + { + case 47: + if ((active0 & 0x800L) != 0L) + return jjStopAtPos(1, 11); + break; + default : + return 2; + } + return 2; +} +private int jjMoveStringLiteralDfa0_1() +{ + return jjMoveNfa_1(0, 0); +} +private int jjMoveNfa_1(int startState, int curPos) +{ + int startsAt = 0; + jjnewStateCnt = 3; + int i = 1; + jjstateSet[0] = startState; + int kind = 0x7fffffff; + for (;;) + { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) + { + long l = 1L << curChar; + do + { + switch(jjstateSet[--i]) + { + case 0: + if ((0x2400L & l) != 0L) + { + if (kind > 9) + kind = 9; + } + if (curChar == 13) + jjstateSet[jjnewStateCnt++] = 1; + break; + case 1: + if (curChar == 10 && kind > 9) + kind = 9; + break; + case 2: + if (curChar == 13) + jjstateSet[jjnewStateCnt++] = 1; + break; + default : break; + } + } while(i != startsAt); + } + else if (curChar < 128) + { + long l = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + default : break; + } + } while(i != startsAt); + } + else + { + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + default : break; + } + } while(i != startsAt); + } + if (kind != 0x7fffffff) + { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt))) + return curPos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return curPos; } + } +} +private int jjMoveStringLiteralDfa0_2() +{ + switch(curChar) + { + case 42: + return jjMoveStringLiteralDfa1_2(0x400L); + default : + return 1; + } +} +private int jjMoveStringLiteralDfa1_2(long active0) +{ + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + return 1; + } + switch(curChar) + { + case 47: + if ((active0 & 0x400L) != 0L) + return jjStopAtPos(1, 10); + break; + default : + return 2; + } + return 2; +} +static final int[] jjnextStates = { +}; + +/** Token literal values. */ +public static final String[] jjstrLiteralImages = { +"", null, null, null, null, null, null, null, null, null, null, null, null, +"\50", "\51", null, null, null, null, null, null, null, null, null, null, null, null, +null, null, null, null, null, null, null, null, null, null, null, null, null, null, +null, null, null, null, null, null, null, null, null, null, null, null, null, null, +null, null, null, "\76", "\74", "\76\75", "\74\75", "\75", "\52", "\57", "\53", +"\55", null, null, null, null, null, null, null, null, null, null, null, null, null, +null, null, null, null, null, null, null, null, null, null, null, null, null, null, +null, null, null, null, null, null, null, null, null, null, "\77", }; + +/** Lexer state names. */ +public static final String[] lexStateNames = { + "DEFAULT", + "IN_SINGLE_LINE_COMMENT", + "IN_FORMAL_COMMENT", + "IN_MULTI_LINE_COMMENT", +}; + +/** Lex State array. */ +public static final int[] jjnewLexState = { + -1, -1, -1, -1, -1, 1, 1, 2, 3, 0, 0, 0, -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, -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, -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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, +}; +static final long[] jjtoToken = { + 0xffffffffffffe001L, 0x13fffffffffL, +}; +static final long[] jjtoSkip = { + 0xe1eL, 0x0L, +}; +static final long[] jjtoSpecial = { + 0xe00L, 0x0L, +}; +static final long[] jjtoMore = { + 0x11e0L, 0x0L, +}; +protected SimpleCharStream input_stream; +private final int[] jjrounds = new int[9]; +private final int[] jjstateSet = new int[18]; +private final StringBuffer jjimage = new StringBuffer(); +private StringBuffer image = jjimage; +private int jjimageLen; +private int lengthOfMatch; +protected char curChar; +/** Constructor. */ +public LexerTokenManager(SimpleCharStream stream){ + if (SimpleCharStream.staticFlag) + throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); + input_stream = stream; +} + +/** Constructor. */ +public LexerTokenManager(SimpleCharStream stream, int lexState){ + this(stream); + SwitchTo(lexState); +} + +/** Reinitialise parser. */ +public void ReInit(SimpleCharStream stream) +{ + jjmatchedPos = jjnewStateCnt = 0; + curLexState = defaultLexState; + input_stream = stream; + ReInitRounds(); +} +private void ReInitRounds() +{ + int i; + jjround = 0x80000001; + for (i = 9; i-- > 0;) + jjrounds[i] = 0x80000000; +} + +/** Reinitialise parser. */ +public void ReInit(SimpleCharStream stream, int lexState) +{ + ReInit(stream); + SwitchTo(lexState); +} + +/** Switch to specified lex state. */ +public void SwitchTo(int lexState) +{ + if (lexState >= 4 || lexState < 0) + throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); + else + curLexState = lexState; +} + +protected Token jjFillToken() +{ + final Token t; + final String curTokenImage; + final int beginLine; + final int endLine; + final int beginColumn; + final int endColumn; + String im = jjstrLiteralImages[jjmatchedKind]; + curTokenImage = (im == null) ? input_stream.GetImage() : im; + beginLine = input_stream.getBeginLine(); + beginColumn = input_stream.getBeginColumn(); + endLine = input_stream.getEndLine(); + endColumn = input_stream.getEndColumn(); + t = Token.newToken(jjmatchedKind, curTokenImage); + + t.beginLine = beginLine; + t.endLine = endLine; + t.beginColumn = beginColumn; + t.endColumn = endColumn; + + return t; +} + +int curLexState = 0; +int defaultLexState = 0; +int jjnewStateCnt; +int jjround; +int jjmatchedPos; +int jjmatchedKind; + +/** Get the next Token. */ +public Token getNextToken() +{ + Token specialToken = null; + Token matchedToken; + int curPos = 0; + + EOFLoop : + for (;;) + { + try + { + curChar = input_stream.BeginToken(); + } + catch(java.io.IOException e) + { + jjmatchedKind = 0; + matchedToken = jjFillToken(); + matchedToken.specialToken = specialToken; + return matchedToken; + } + image = jjimage; + image.setLength(0); + jjimageLen = 0; + + for (;;) + { + switch(curLexState) + { + case 0: + try { input_stream.backup(0); + while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L) + curChar = input_stream.BeginToken(); + } + catch (java.io.IOException e1) { continue EOFLoop; } + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_0(); + break; + case 1: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_1(); + if (jjmatchedPos == 0 && jjmatchedKind > 12) + { + jjmatchedKind = 12; + } + break; + case 2: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_2(); + if (jjmatchedPos == 0 && jjmatchedKind > 12) + { + jjmatchedKind = 12; + } + break; + case 3: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_3(); + if (jjmatchedPos == 0 && jjmatchedKind > 12) + { + jjmatchedKind = 12; + } + break; + } + if (jjmatchedKind != 0x7fffffff) + { + if (jjmatchedPos + 1 < curPos) + input_stream.backup(curPos - jjmatchedPos - 1); + if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) + { + matchedToken = jjFillToken(); + matchedToken.specialToken = specialToken; + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + return matchedToken; + } + else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) + { + if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) + { + matchedToken = jjFillToken(); + if (specialToken == null) + specialToken = matchedToken; + else + { + matchedToken.specialToken = specialToken; + specialToken = (specialToken.next = matchedToken); + } + SkipLexicalActions(matchedToken); + } + else + SkipLexicalActions(null); + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + continue EOFLoop; + } + MoreLexicalActions(); + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + curPos = 0; + jjmatchedKind = 0x7fffffff; + try { + curChar = input_stream.readChar(); + continue; + } + catch (java.io.IOException e1) { } + } + int error_line = input_stream.getEndLine(); + int error_column = input_stream.getEndColumn(); + String error_after = null; + boolean EOFSeen = false; + try { input_stream.readChar(); input_stream.backup(1); } + catch (java.io.IOException e1) { + EOFSeen = true; + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + if (curChar == '\n' || curChar == '\r') { + error_line++; + error_column = 0; + } + else + error_column++; + } + if (!EOFSeen) { + input_stream.backup(1); + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + } + throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); + } + } +} + +void SkipLexicalActions(Token matchedToken) +{ + switch(jjmatchedKind) + { + default : + break; + } +} +void MoreLexicalActions() +{ + jjimageLen += (lengthOfMatch = jjmatchedPos + 1); + switch(jjmatchedKind) + { + case 7 : + image.append(input_stream.GetSuffix(jjimageLen)); + jjimageLen = 0; + input_stream.backup(1); + break; + default : + break; + } +} +private void jjCheckNAdd(int state) +{ + if (jjrounds[state] != jjround) + { + jjstateSet[jjnewStateCnt++] = state; + jjrounds[state] = jjround; + } +} +private void jjAddStates(int start, int end) +{ + do { + jjstateSet[jjnewStateCnt++] = jjnextStates[start]; + } while (start++ != end); +} +private void jjCheckNAddTwoStates(int state1, int state2) +{ + jjCheckNAdd(state1); + jjCheckNAdd(state2); +} + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/LexerTreeConstants.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/LexerTreeConstants.java new file mode 100644 index 00000000000..ccd0adb3aed --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/LexerTreeConstants.java @@ -0,0 +1,357 @@ +/* Generated By:JavaCC: Do not edit this line. LexerTreeConstants.java Version 4.1d1 */ +package pddl4j.lexer; + +public interface LexerTreeConstants +{ + public int JJTROOT = 0; + public int JJTDOMAIN = 1; + public int JJTREQUIRE_DEF = 2; + public int JJTREQUIRE_KEY = 3; + public int JJTTYPE_DEF = 4; + public int JJTTYPED_LIST = 5; + public int JJTTYPE = 6; + public int JJTPRIMITIVE_TYPE = 7; + public int JJTCONSTANT_DEF = 8; + public int JJTCONSTANT = 9; + public int JJTPREDICATE_DEF = 10; + public int JJTATOMIC_FORMULA_SKELETON = 11; + public int JJTPREDICATE = 12; + public int JJTVARIABLE = 13; + public int JJTFUNCTION_DEF = 14; + public int JJTATOMIC_FUNCTION_SKELETON = 15; + public int JJTFUNCTOR = 16; + public int JJTFUNCTION_TYPED_LIST = 17; + public int JJTFUNCTION_TYPE = 18; + public int JJTCON_GD = 19; + public int JJTAND_CON_GD = 20; + public int JJTFORALL_CON_GD = 21; + public int JJTAT_END_CON_GD = 22; + public int JJTALWAYS_CON_GD = 23; + public int JJTSOMETIME_CON_GD = 24; + public int JJTWITHIN_CON_GD = 25; + public int JJTAT_MOST_ONCE_CON_GD = 26; + public int JJTSOMETIME_AFTER_CON_GD = 27; + public int JJTSOMETIME_BEFORE_CON_GD = 28; + public int JJTALWAYS_WITHIN_CON_GD = 29; + public int JJTHOLD_DURING_CON_GD = 30; + public int JJTHOLD_AFTER_CON_GD = 31; + public int JJTGD = 32; + public int JJTAND_GD = 33; + public int JJTOR_GD = 34; + public int JJTNOT_GD = 35; + public int JJTIMPLY_GD = 36; + public int JJTEXISTS_GD = 37; + public int JJTFORALL_GD = 38; + public int JJTATOMIC_FORMULA = 39; + public int JJTTERM = 40; + public int JJTLITERAL = 41; + public int JJTNOT_ATOMIC_FORMULA = 42; + public int JJTF_COMP = 43; + public int JJTBINARY_COMP = 44; + public int JJTGREATER_COMP = 45; + public int JJTGREATER_EQUAL_COMP = 46; + public int JJTLESS_EQUAL_COMP = 47; + public int JJTLESS_COMP = 48; + public int JJTEQUAL_COMP = 49; + public int JJTF_EXP = 50; + public int JJTNUMBER = 51; + public int JJTOP = 52; + public int JJTBINARY_OPERATION = 53; + public int JJTADD_OP = 54; + public int JJTSUBSTRACT_OP = 55; + public int JJTMULTIPLY_OP = 56; + public int JJTDIVIDE_OP = 57; + public int JJTUNARY_OP = 58; + public int JJTF_HEAD = 59; + public int JJTSTRUCTURE_DEF = 60; + public int JJTACTION_DEF = 61; + public int JJTACTION_NAME = 62; + public int JJTACTION_DEF_BODY = 63; + public int JJTPRE_GD = 64; + public int JJTEMPTY_OR = 65; + public int JJTAND_PRE_GD = 66; + public int JJTFORALL_PRE_GD = 67; + public int JJTPREF_GD = 68; + public int JJTNAMED_PREF_GD = 69; + public int JJTPREF_NAME = 70; + public int JJTEFFECT = 71; + public int JJTAND_C_EFFECT = 72; + public int JJTPROB_EFFECT = 73; + public int JJTPROB_TERM = 74; + public int JJTC_EFFECT = 75; + public int JJTFORALL_EFFECT = 76; + public int JJTWHEN_CON_EFFECT = 77; + public int JJTCOND_EFFECT = 78; + public int JJTAND_P_EFFECT = 79; + public int JJTP_EFFECT = 80; + public int JJTASSIGN_OP = 81; + public int JJTASSIGN = 82; + public int JJTSCALE_UP = 83; + public int JJTSCALE_DOWN = 84; + public int JJTINCREASE = 85; + public int JJTDECREASE = 86; + public int JJTDURATION_ACTION_DEF = 87; + public int JJTDA_SYMBOL = 88; + public int JJTDA_DEF_BODY = 89; + public int JJTDURATION_CONSTRAINT = 90; + public int JJTAND_SIMPLE_DURATION_CONSTRAINT = 91; + public int JJTSIMPLE_DURATION_CONSTRAINT = 92; + public int JJTAT_SIMPLE_DURATION_CONSTRAINT = 93; + public int JJTAT_START_SIMPLE_DURATION_CONSTRAINT = 94; + public int JJTAT_END_SIMPLE_DURATION_CONSTRAINT = 95; + public int JJTD_OP = 96; + public int JJTEQUAL_D_OP = 97; + public int JJTGEQUAL_D_OP = 98; + public int JJTLEQUAL_D_OP = 99; + public int JJTVAR_DURATION = 100; + public int JJTD_VALUE = 101; + public int JJTDA_GD = 102; + public int JJTFORALL_DA_GD = 103; + public int JJTAND_DA_GD = 104; + public int JJTPREF_TIMED_GD = 105; + public int JJTNAMED_PREF_TIMED_GD = 106; + public int JJTTIMED_GD = 107; + public int JJTOVER_TIMED_GD = 108; + public int JJTOVER_ALL_TIMED_GD = 109; + public int JJTAT_TIMED_GD = 110; + public int JJTAT_START_TIMED_GD = 111; + public int JJTAT_END_TIMED_GD = 112; + public int JJTINTERVAL = 113; + public int JJTDA_EFFECT = 114; + public int JJTDA_ASSIGN_OP = 115; + public int JJTDA_ASSIGN = 116; + public int JJTDA_SCALE_UP = 117; + public int JJTDA_SCALE_DOWN = 118; + public int JJTDA_INCREASE = 119; + public int JJTDA_DECREASE = 120; + public int JJTWHEN_DA_EFFECT = 121; + public int JJTFORALL_DA_EFFECT = 122; + public int JJTAND_DA_EFFECT = 123; + public int JJTTIMED_EFFECT = 124; + public int JJTAT_F_ASSIGN_DA_EFFECT = 125; + public int JJTAT_START_F_ASSIGN_DA_EFFECT = 126; + public int JJTAT_END_F_ASSIGN_DA_EFFECT = 127; + public int JJTAT_DA_EFFECT = 128; + public int JJTAT_START_DA_EFFECT = 129; + public int JJTAT_END_DA_EFFECT = 130; + public int JJTASSIGN_OP_T = 131; + public int JJTINCREASE_ASSIGN_OP_T = 132; + public int JJTDECREASE_ASSIGN_OP_T = 133; + public int JJTF_EXP_T = 134; + public int JJTCONTINOUS_VARIABLE = 135; + public int JJTF_ASSIGN_DA = 136; + public int JJTF_EXP_DA = 137; + public int JJTDA_BINARY_OP = 138; + public int JJTDA_ADD_OP = 139; + public int JJTDA_SUBSTRACT_OP = 140; + public int JJTDA_MULTIPLY_OP = 141; + public int JJTDA_DIVIDE_OP = 142; + public int JJTDA_UNARY_OP = 143; + public int JJTDERIVED_DEF = 144; + public int JJTPROBLEM = 145; + public int JJTPROBLEM_NAME = 146; + public int JJTDOMAIN_NAME = 147; + public int JJTOBJECT_DECLARATION = 148; + public int JJTINIT = 149; + public int JJTINIT_EL = 150; + public int JJTEQUAL_INIT_EL = 151; + public int JJTTIMED_LITERAL = 152; + public int JJTGOAL = 153; + public int JJTCONSTRAINTS = 154; + public int JJTPREF_CON_GD = 155; + public int JJTAND_PREF_CON_GD = 156; + public int JJTNAMED_PREF_CON_GD = 157; + public int JJTFORALL_PREF_CON_GD = 158; + public int JJTMETRIC_SPEC = 159; + public int JJTMAXIMIZE = 160; + public int JJTMINIMIZE = 161; + public int JJTMETRIC_F_EXP = 162; + public int JJTVIOLATED_PREF_EXP = 163; + public int JJTCONSTANT_F_HEAD = 164; + public int JJTTOTAL_TIME = 165; + public int JJTBINARY_OP_METRIC_F_EXP = 166; + public int JJTADD_OP_METRIC_F_EXP = 167; + public int JJTSUBSTRACT_OP_METRIC_F_EXP = 168; + public int JJTMULTI_OP_METRIC_F_EXP = 169; + public int JJTMULTIPLY_NARITY_OP_METRIC_F_EXP = 170; + public int JJTADD_NARITY_OP_METRIC_F_EXP = 171; + public int JJTUNARY_OP_METRIC_F_EXP = 172; + + + public String[] jjtNodeName = { + "ROOT", + "DOMAIN", + "REQUIRE_DEF", + "REQUIRE_KEY", + "TYPE_DEF", + "TYPED_LIST", + "TYPE", + "PRIMITIVE_TYPE", + "CONSTANT_DEF", + "CONSTANT", + "PREDICATE_DEF", + "ATOMIC_FORMULA_SKELETON", + "PREDICATE", + "VARIABLE", + "FUNCTION_DEF", + "ATOMIC_FUNCTION_SKELETON", + "FUNCTOR", + "FUNCTION_TYPED_LIST", + "FUNCTION_TYPE", + "CON_GD", + "AND_CON_GD", + "FORALL_CON_GD", + "AT_END_CON_GD", + "ALWAYS_CON_GD", + "SOMETIME_CON_GD", + "WITHIN_CON_GD", + "AT_MOST_ONCE_CON_GD", + "SOMETIME_AFTER_CON_GD", + "SOMETIME_BEFORE_CON_GD", + "ALWAYS_WITHIN_CON_GD", + "HOLD_DURING_CON_GD", + "HOLD_AFTER_CON_GD", + "GD", + "AND_GD", + "OR_GD", + "NOT_GD", + "IMPLY_GD", + "EXISTS_GD", + "FORALL_GD", + "ATOMIC_FORMULA", + "TERM", + "LITERAL", + "NOT_ATOMIC_FORMULA", + "F_COMP", + "BINARY_COMP", + "GREATER_COMP", + "GREATER_EQUAL_COMP", + "LESS_EQUAL_COMP", + "LESS_COMP", + "EQUAL_COMP", + "F_EXP", + "NUMBER", + "OP", + "BINARY_OPERATION", + "ADD_OP", + "SUBSTRACT_OP", + "MULTIPLY_OP", + "DIVIDE_OP", + "UNARY_OP", + "F_HEAD", + "STRUCTURE_DEF", + "ACTION_DEF", + "ACTION_NAME", + "ACTION_DEF_BODY", + "PRE_GD", + "EMPTY_OR", + "AND_PRE_GD", + "FORALL_PRE_GD", + "PREF_GD", + "NAMED_PREF_GD", + "PREF_NAME", + "EFFECT", + "AND_C_EFFECT", + "PROB_EFFECT", + "PROB_TERM", + "C_EFFECT", + "FORALL_EFFECT", + "WHEN_CON_EFFECT", + "COND_EFFECT", + "AND_P_EFFECT", + "P_EFFECT", + "ASSIGN_OP", + "ASSIGN", + "SCALE_UP", + "SCALE_DOWN", + "INCREASE", + "DECREASE", + "DURATION_ACTION_DEF", + "DA_SYMBOL", + "DA_DEF_BODY", + "DURATION_CONSTRAINT", + "AND_SIMPLE_DURATION_CONSTRAINT", + "SIMPLE_DURATION_CONSTRAINT", + "AT_SIMPLE_DURATION_CONSTRAINT", + "AT_START_SIMPLE_DURATION_CONSTRAINT", + "AT_END_SIMPLE_DURATION_CONSTRAINT", + "D_OP", + "EQUAL_D_OP", + "GEQUAL_D_OP", + "LEQUAL_D_OP", + "VAR_DURATION", + "D_VALUE", + "DA_GD", + "FORALL_DA_GD", + "AND_DA_GD", + "PREF_TIMED_GD", + "NAMED_PREF_TIMED_GD", + "TIMED_GD", + "OVER_TIMED_GD", + "OVER_ALL_TIMED_GD", + "AT_TIMED_GD", + "AT_START_TIMED_GD", + "AT_END_TIMED_GD", + "INTERVAL", + "DA_EFFECT", + "DA_ASSIGN_OP", + "DA_ASSIGN", + "DA_SCALE_UP", + "DA_SCALE_DOWN", + "DA_INCREASE", + "DA_DECREASE", + "WHEN_DA_EFFECT", + "FORALL_DA_EFFECT", + "AND_DA_EFFECT", + "TIMED_EFFECT", + "AT_F_ASSIGN_DA_EFFECT", + "AT_START_F_ASSIGN_DA_EFFECT", + "AT_END_F_ASSIGN_DA_EFFECT", + "AT_DA_EFFECT", + "AT_START_DA_EFFECT", + "AT_END_DA_EFFECT", + "ASSIGN_OP_T", + "INCREASE_ASSIGN_OP_T", + "DECREASE_ASSIGN_OP_T", + "F_EXP_T", + "CONTINOUS_VARIABLE", + "F_ASSIGN_DA", + "F_EXP_DA", + "DA_BINARY_OP", + "DA_ADD_OP", + "DA_SUBSTRACT_OP", + "DA_MULTIPLY_OP", + "DA_DIVIDE_OP", + "DA_UNARY_OP", + "DERIVED_DEF", + "PROBLEM", + "PROBLEM_NAME", + "DOMAIN_NAME", + "OBJECT_DECLARATION", + "INIT", + "INIT_EL", + "EQUAL_INIT_EL", + "TIMED_LITERAL", + "GOAL", + "CONSTRAINTS", + "PREF_CON_GD", + "AND_PREF_CON_GD", + "NAMED_PREF_CON_GD", + "FORALL_PREF_CON_GD", + "METRIC_SPEC", + "MAXIMIZE", + "MINIMIZE", + "METRIC_F_EXP", + "VIOLATED_PREF_EXP", + "CONSTANT_F_HEAD", + "TOTAL_TIME", + "BINARY_OP_METRIC_F_EXP", + "ADD_OP_METRIC_F_EXP", + "SUBSTRACT_OP_METRIC_F_EXP", + "MULTI_OP_METRIC_F_EXP", + "MULTIPLY_NARITY_OP_METRIC_F_EXP", + "ADD_NARITY_OP_METRIC_F_EXP", + "UNARY_OP_METRIC_F_EXP", + }; +} +/* JavaCC - OriginalChecksum=63543501f658814e66383e38e8200929 (do not edit this line) */ diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/Node.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/Node.java new file mode 100644 index 00000000000..9413085ed9d --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/Node.java @@ -0,0 +1,34 @@ +/* Generated By:JJTree: Do not edit this line. Node.java */ + +package pddl4j.lexer; + +/* All AST nodes must implement this interface. It provides basic + machinery for constructing the parent and child relationships + between nodes. */ + +public interface Node { + + /** This method is called after the node has been made the current + node. It indicates that child nodes can now be added to it. */ + public void jjtOpen(); + + /** This method is called after all the child nodes have been + added. */ + public void jjtClose(); + + /** This pair of methods are used to inform the node of its + parent. */ + public void jjtSetParent(Node n); + public Node jjtGetParent(); + + /** This method tells the node to add its argument to the node's + list of children. */ + public void jjtAddChild(Node n, int i); + + /** This method returns a child node. The children are numbered + from zero, left to right. */ + public Node jjtGetChild(int i); + + /** Return the number of children the node has. */ + public int jjtGetNumChildren(); +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/ParseException.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/ParseException.java new file mode 100644 index 00000000000..0221597c168 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/ParseException.java @@ -0,0 +1,198 @@ +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 4.1 */ +/* JavaCCOptions:KEEP_LINE_COL=null */ +package pddl4j.lexer; + +/** + * This exception is thrown when parse errors are encountered. + * You can explicitly create objects of this exception type by + * calling the method generateParseException in the generated + * parser. + * + * You can modify this class to customize your error reporting + * mechanisms so long as you retain the public fields. + */ +public class ParseException extends Exception { + + /** + * This constructor is used by the method "generateParseException" + * in the generated parser. Calling this constructor generates + * a new object of this type with the fields "currentToken", + * "expectedTokenSequences", and "tokenImage" set. The boolean + * flag "specialConstructor" is also set to true to indicate that + * this constructor was used to create this object. + * This constructor calls its super class with the empty string + * to force the "toString" method of parent class "Throwable" to + * print the error message in the form: + * ParseException: <result of getMessage> + */ + public ParseException(Token currentTokenVal, + int[][] expectedTokenSequencesVal, + String[] tokenImageVal + ) + { + super(""); + specialConstructor = true; + currentToken = currentTokenVal; + expectedTokenSequences = expectedTokenSequencesVal; + tokenImage = tokenImageVal; + } + + /** + * The following constructors are for use by you for whatever + * purpose you can think of. Constructing the exception in this + * manner makes the exception behave in the normal way - i.e., as + * documented in the class "Throwable". The fields "errorToken", + * "expectedTokenSequences", and "tokenImage" do not contain + * relevant information. The JavaCC generated code does not use + * these constructors. + */ + + public ParseException() { + super(); + specialConstructor = false; + } + + /** Constructor with message. */ + public ParseException(String message) { + super(message); + specialConstructor = false; + } + + /** + * This variable determines which constructor was used to create + * this object and thereby affects the semantics of the + * "getMessage" method (see below). + */ + protected boolean specialConstructor; + + /** + * This is the last token that has been consumed successfully. If + * this object has been created due to a parse error, the token + * followng this token will (therefore) be the first error token. + */ + public Token currentToken; + + /** + * Each entry in this array is an array of integers. Each array + * of integers represents a sequence of tokens (by their ordinal + * values) that is expected at this point of the parse. + */ + public int[][] expectedTokenSequences; + + /** + * This is a reference to the "tokenImage" array of the generated + * parser within which the parse error occurred. This array is + * defined in the generated ...Constants interface. + */ + public String[] tokenImage; + + /** + * This method has the standard behavior when this object has been + * created using the standard constructors. Otherwise, it uses + * "currentToken" and "expectedTokenSequences" to generate a parse + * error message and returns it. If this object has been created + * due to a parse error, and you do not catch it (it gets thrown + * from the parser), then this method is called during the printing + * of the final stack trace, and hence the correct error message + * gets displayed. + */ + public String getMessage() { + if (!specialConstructor) { + return super.getMessage(); + } + StringBuffer expected = new StringBuffer(); + int maxSize = 0; + for (int i = 0; i < expectedTokenSequences.length; i++) { + if (maxSize < expectedTokenSequences[i].length) { + maxSize = expectedTokenSequences[i].length; + } + for (int j = 0; j < expectedTokenSequences[i].length; j++) { + expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); + } + if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { + expected.append("..."); + } + expected.append(eol).append(" "); + } + String retval = "Encountered \""; + Token tok = currentToken.next; + for (int i = 0; i < maxSize; i++) { + if (i != 0) retval += " "; + if (tok.kind == 0) { + retval += tokenImage[0]; + break; + } + retval += " " + tokenImage[tok.kind]; + retval += " \""; + retval += add_escapes(tok.image); + retval += " \""; + tok = tok.next; + } + retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; + retval += "." + eol; + if (expectedTokenSequences.length == 1) { + retval += "Was expecting:" + eol + " "; + } else { + retval += "Was expecting one of:" + eol + " "; + } + retval += expected.toString(); + return retval; + } + + /** + * The end of line string for this machine. + */ + protected String eol = System.getProperty("line.separator", "\n"); + + /** + * Used to convert raw characters to their escaped version + * when these raw version cannot be used as part of an ASCII + * string literal. + */ + protected String add_escapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) + { + case 0 : + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + +} +/* JavaCC - OriginalChecksum=315808adef26ee1a95c3bd49bc0c7494 (do not edit this line) */ diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/SimpleCharStream.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/SimpleCharStream.java new file mode 100644 index 00000000000..da4cbaafdff --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/SimpleCharStream.java @@ -0,0 +1,472 @@ +/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.1 */ +/* JavaCCOptions:STATIC=false */ +package pddl4j.lexer; + +/** + * An implementation of interface CharStream, where the stream is assumed to + * contain only ASCII characters (without unicode processing). + */ + +public class SimpleCharStream +{ +/** Whether parser is static. */ + public static final boolean staticFlag = false; + int bufsize; + int available; + int tokenBegin; +/** Position in buffer. */ + public int bufpos = -1; + protected int bufline[]; + protected int bufcolumn[]; + + protected int column = 0; + protected int line = 1; + + protected boolean prevCharIsCR = false; + protected boolean prevCharIsLF = false; + + protected java.io.Reader inputStream; + + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int inBuf = 0; + protected int tabSize = 8; + + protected void setTabSize(int i) { tabSize = i; } + protected int getTabSize(int i) { return tabSize; } + + + protected void ExpandBuff(boolean wrapAround) + { + char[] newbuffer = new char[bufsize + 2048]; + int newbufline[] = new int[bufsize + 2048]; + int newbufcolumn[] = new int[bufsize + 2048]; + + try + { + if (wrapAround) + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, + bufsize - tokenBegin, bufpos); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos += (bufsize - tokenBegin)); + } + else + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos -= tokenBegin); + } + } + catch (Throwable t) + { + throw new Error(t.getMessage()); + } + + + bufsize += 2048; + available = bufsize; + tokenBegin = 0; + } + + protected void FillBuff() throws java.io.IOException + { + if (maxNextCharInd == available) + { + if (available == bufsize) + { + if (tokenBegin > 2048) + { + bufpos = maxNextCharInd = 0; + available = tokenBegin; + } + else if (tokenBegin < 0) + bufpos = maxNextCharInd = 0; + else + ExpandBuff(false); + } + else if (available > tokenBegin) + available = bufsize; + else if ((tokenBegin - available) < 2048) + ExpandBuff(true); + else + available = tokenBegin; + } + + int i; + try { + if ((i = inputStream.read(buffer, maxNextCharInd, + available - maxNextCharInd)) == -1) + { + inputStream.close(); + throw new java.io.IOException(); + } + else + maxNextCharInd += i; + return; + } + catch(java.io.IOException e) { + --bufpos; + backup(0); + if (tokenBegin == -1) + tokenBegin = bufpos; + throw e; + } + } + +/** Start. */ + public char BeginToken() throws java.io.IOException + { + tokenBegin = -1; + char c = readChar(); + tokenBegin = bufpos; + + return c; + } + + protected void UpdateLineColumn(char c) + { + column++; + + if (prevCharIsLF) + { + prevCharIsLF = false; + line += (column = 1); + } + else if (prevCharIsCR) + { + prevCharIsCR = false; + if (c == '\n') + { + prevCharIsLF = true; + } + else + line += (column = 1); + } + + switch (c) + { + case '\r' : + prevCharIsCR = true; + break; + case '\n' : + prevCharIsLF = true; + break; + case '\t' : + column--; + column += (tabSize - (column % tabSize)); + break; + default : + break; + } + + bufline[bufpos] = line; + bufcolumn[bufpos] = column; + } + +/** Read a character. */ + public char readChar() throws java.io.IOException + { + if (inBuf > 0) + { + --inBuf; + + if (++bufpos == bufsize) + bufpos = 0; + + return buffer[bufpos]; + } + + if (++bufpos >= maxNextCharInd) + FillBuff(); + + char c = buffer[bufpos]; + + UpdateLineColumn(c); + return c; + } + + /** + * @deprecated + * @see #getEndColumn + */ + + public int getColumn() { + return bufcolumn[bufpos]; + } + + /** + * @deprecated + * @see #getEndLine + */ + + public int getLine() { + return bufline[bufpos]; + } + + /** Get token end column number. */ + public int getEndColumn() { + return bufcolumn[bufpos]; + } + + /** Get token end line number. */ + public int getEndLine() { + return bufline[bufpos]; + } + + /** Get token beginning column number. */ + public int getBeginColumn() { + return bufcolumn[tokenBegin]; + } + + /** Get token beginning line number. */ + public int getBeginLine() { + return bufline[tokenBegin]; + } + +/** Backup a number of characters. */ + public void backup(int amount) { + + inBuf += amount; + if ((bufpos -= amount) < 0) + bufpos += bufsize; + } + + /** Constructor. */ + public SimpleCharStream(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) + { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + } + + /** Constructor. */ + public SimpleCharStream(java.io.Reader dstream, int startline, + int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + + /** Constructor. */ + public SimpleCharStream(java.io.Reader dstream) + { + this(dstream, 1, 1, 4096); + } + + /** Reinitialise. */ + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) + { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + if (buffer == null || buffersize != buffer.length) + { + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + } + prevCharIsLF = prevCharIsCR = false; + tokenBegin = inBuf = maxNextCharInd = 0; + bufpos = -1; + } + + /** Reinitialise. */ + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn) + { + ReInit(dstream, startline, startcolumn, 4096); + } + + /** Reinitialise. */ + public void ReInit(java.io.Reader dstream) + { + ReInit(dstream, 1, 1, 4096); + } + /** Constructor. */ + public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException + { + this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + + /** Constructor. */ + public SimpleCharStream(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) + { + this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + } + + /** Constructor. */ + public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException + { + this(dstream, encoding, startline, startcolumn, 4096); + } + + /** Constructor. */ + public SimpleCharStream(java.io.InputStream dstream, int startline, + int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + + /** Constructor. */ + public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException + { + this(dstream, encoding, 1, 1, 4096); + } + + /** Constructor. */ + public SimpleCharStream(java.io.InputStream dstream) + { + this(dstream, 1, 1, 4096); + } + + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException + { + ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) + { + ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + } + + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException + { + ReInit(dstream, encoding, 1, 1, 4096); + } + + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream) + { + ReInit(dstream, 1, 1, 4096); + } + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException + { + ReInit(dstream, encoding, startline, startcolumn, 4096); + } + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn) + { + ReInit(dstream, startline, startcolumn, 4096); + } + /** Get token literal value. */ + public String GetImage() + { + if (bufpos >= tokenBegin) + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); + else + return new String(buffer, tokenBegin, bufsize - tokenBegin) + + new String(buffer, 0, bufpos + 1); + } + + /** Get the suffix. */ + public char[] GetSuffix(int len) + { + char[] ret = new char[len]; + + if ((bufpos + 1) >= len) + System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); + else + { + System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, + len - bufpos - 1); + System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); + } + + return ret; + } + + /** Reset buffer when finished. */ + public void Done() + { + buffer = null; + bufline = null; + bufcolumn = null; + } + + /** + * Method to adjust line and column numbers for the start of a token. + */ + public void adjustBeginLineColumn(int newLine, int newCol) + { + int start = tokenBegin; + int len; + + if (bufpos >= tokenBegin) + { + len = bufpos - tokenBegin + inBuf + 1; + } + else + { + len = bufsize - tokenBegin + bufpos + 1 + inBuf; + } + + int i = 0, j = 0, k = 0; + int nextColDiff = 0, columnDiff = 0; + + while (i < len && + bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) + { + bufline[j] = newLine; + nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; + bufcolumn[j] = newCol + columnDiff; + columnDiff = nextColDiff; + i++; + } + + if (i < len) + { + bufline[j] = newLine++; + bufcolumn[j] = newCol + columnDiff; + + while (i++ < len) + { + if (bufline[j = start % bufsize] != bufline[++start % bufsize]) + bufline[j] = newLine++; + else + bufline[j] = newLine; + } + } + + line = bufline[j]; + column = bufcolumn[j]; + } + +} +/* JavaCC - OriginalChecksum=6b2a2131d1c8281ea047dbdf2703150c (do not edit this line) */ diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/SimpleNode.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/SimpleNode.java new file mode 100644 index 00000000000..937c938f26c --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/SimpleNode.java @@ -0,0 +1,211 @@ +/* Generated By:JJTree: Do not edit this line. SimpleNode.java */ + +package pddl4j.lexer; + +import java.util.Iterator; +import java.util.LinkedList; + +public class SimpleNode implements Node, Iterable<SimpleNode> { + protected Node parent; + + protected Node[] children; + + protected int id; + + protected Lexer parser; + + protected Token token; + + protected int line; + + protected int column; + + protected String image; + + protected int typeId; + + + + public SimpleNode(int id) { + this.id = id; + this.line = -1; + this.column = -1; + this.image = ""; + this.typeId = -1; + } + + public SimpleNode(Lexer p, int id) { + this(id); + parser = p; + } + + public void jjtOpen() { + } + + public void jjtClose() { + } + + public void jjtSetParent(Node n) { + parent = n; + } + + public Node jjtGetParent() { + return parent; + } + + public void jjtAddChild(Node n, int i) { + if (children == null) { + children = new Node[i + 1]; + } else if (i >= children.length) { + Node c[] = new Node[i + 1]; + System.arraycopy(children, 0, c, 0, children.length); + children = c; + } + children[i] = n; + } + + public Node jjtGetChild(int i) { + return children[i]; + } + + public int jjtGetNumChildren() { + return (children == null) ? 0 : children.length; + } + + /* + * You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the + * tree is dumped. If your output uses more than one line you should override toString(String), otherwise overriding + * toString() is probably all you need to do. + */ + + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("["); + str.append(this.getLabel()); + + if (!this.image.equals("")) { + str.append(", image=\"" + this.image + "\""); + } + str.append(", line=" + this.line); + str.append(", column=" + this.column); + if (this.typeId != -1) { + str.append(", type=" + LexerTreeConstants.jjtNodeName[this.typeId]); + } + str.append("]"); + return str.toString(); + + } + + public String toString(String prefix) { + return prefix + toString(); + } + + public int getDepth() { + int depth = 0; + SimpleNode pred = (SimpleNode) this.parent; + while (pred != null) { + depth++; + pred = (SimpleNode) pred.parent; + } + return depth; + } + /* + * Override this method if you want to customize how the node dumps out its children. + */ + + public void dump(String prefix) { + System.out.println(toString(prefix)); + if (children != null) { + for (int i = 0; i < children.length; ++i) { + SimpleNode n = (SimpleNode) children[i]; + if (n != null) { + n.dump(prefix + " "); + } + } + } + } + + public void setToken(Token token) { + this.token = token; + } + + public final String getLabel() { + return LexerTreeConstants.jjtNodeName[id]; + } + + public final void setLine(int line) { + this.line = line; + } + + public final int getLine() { + return this.line; + } + + public final void setColumn(int column) { + this.column = column; + } + + public final int getColumn() { + return this.column; + } + + public void setTypeId(int typeId) { + this.typeId = typeId; + } + + public int getTypeId() { + return this.typeId; + } + + /** + * @return Returns the image. + */ + public final String getImage() { + return image; + } + + public int getId() { + return this.id; + } + + /** + * @param image The image to set. + */ + public final void setImage(String image) { + this.image = image.toLowerCase(); + } + + private class TreeIterator implements Iterator<SimpleNode> { + + private LinkedList<SimpleNode> nodes; + + public TreeIterator() { + this.nodes = new LinkedList<SimpleNode>(); + this.nodes.add(SimpleNode.this); + } + public boolean hasNext() { + return !this.nodes.isEmpty(); + } + + public SimpleNode next() { + SimpleNode node = null; + if (this.hasNext()) { + node = nodes.poll(); + for (int i = 0; i < node.jjtGetNumChildren(); i++) { + nodes.add(i, (SimpleNode) node.jjtGetChild(i)); + } + } + return node; + } + + public void remove() { + return; + } + + } + + public Iterator<SimpleNode> iterator() { + return new TreeIterator(); + } + +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/Token.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/Token.java new file mode 100644 index 00000000000..33d86b68a58 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/Token.java @@ -0,0 +1,124 @@ +/* Generated By:JavaCC: Do not edit this line. Token.java Version 4.1 */ +/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null */ +package pddl4j.lexer; + +/** + * Describes the input token stream. + */ + +public class Token { + + /** + * An integer that describes the kind of this token. This numbering + * system is determined by JavaCCParser, and a table of these numbers is + * stored in the file ...Constants.java. + */ + public int kind; + + /** The line number of the first character of this Token. */ + public int beginLine; + /** The column number of the first character of this Token. */ + public int beginColumn; + /** The line number of the last character of this Token. */ + public int endLine; + /** The column number of the last character of this Token. */ + public int endColumn; + + /** + * The string image of the token. + */ + public String image; + + /** + * A reference to the next regular (non-special) token from the input + * stream. If this is the last token from the input stream, or if the + * token manager has not read tokens beyond this one, this field is + * set to null. This is true only if this token is also a regular + * token. Otherwise, see below for a description of the contents of + * this field. + */ + public Token next; + + /** + * This field is used to access special tokens that occur prior to this + * token, but after the immediately preceding regular (non-special) token. + * If there are no such special tokens, this field is set to null. + * When there are more than one such special token, this field refers + * to the last of these special tokens, which in turn refers to the next + * previous special token through its specialToken field, and so on + * until the first special token (whose specialToken field is null). + * The next fields of special tokens refer to other special tokens that + * immediately follow it (without an intervening regular token). If there + * is no such token, this field is null. + */ + public Token specialToken; + + /** + * An optional attribute value of the Token. + * Tokens which are not used as syntactic sugar will often contain + * meaningful values that will be used later on by the compiler or + * interpreter. This attribute value is often different from the image. + * Any subclass of Token that actually wants to return a non-null value can + * override this method as appropriate. + */ + public Object getValue() { + return null; + } + + /** + * No-argument constructor + */ + public Token() {} + + /** + * Constructs a new token for the specified Image. + */ + public Token(int kind) + { + this(kind, null); + } + + /** + * Constructs a new token for the specified Image and Kind. + */ + public Token(int kind, String image) + { + this.kind = kind; + this.image = image; + } + + /** + * Returns the image. + */ + public String toString() + { + return image; + } + + /** + * Returns a new Token object, by default. However, if you want, you + * can create and return subclass objects based on the value of ofKind. + * Simply add the cases to the switch for all those special cases. + * For example, if you have a subclass of Token called IDToken that + * you want to create if ofKind is ID, simply add something like : + * + * case MyParserConstants.ID : return new IDToken(ofKind, image); + * + * to the following switch statement. Then you can cast matchedToken + * variable to the appropriate type and use sit in your lexical actions. + */ + public static Token newToken(int ofKind, String image) + { + switch(ofKind) + { + default : return new Token(ofKind, image); + } + } + + public static Token newToken(int ofKind) + { + return newToken(ofKind, null); + } + +} +/* JavaCC - OriginalChecksum=25f564df9e313b43b960343a8a0a31e9 (do not edit this line) */ diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/TokenMgrError.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/TokenMgrError.java new file mode 100644 index 00000000000..e7aacfdac90 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/TokenMgrError.java @@ -0,0 +1,140 @@ +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 4.1 */ +/* JavaCCOptions: */ +package pddl4j.lexer; + +/** Token Manager Error. */ +public class TokenMgrError extends Error +{ + + /* + * Ordinals for various reasons why an Error of this type can be thrown. + */ + + /** + * Lexical error occurred. + */ + static final int LEXICAL_ERROR = 0; + + /** + * An attempt was made to create a second instance of a static token manager. + */ + static final int STATIC_LEXER_ERROR = 1; + + /** + * Tried to change to an invalid lexical state. + */ + static final int INVALID_LEXICAL_STATE = 2; + + /** + * Detected (and bailed out of) an infinite loop in the token manager. + */ + static final int LOOP_DETECTED = 3; + + /** + * Indicates the reason why the exception is thrown. It will have + * one of the above 4 values. + */ + int errorCode; + + /** + * Replaces unprintable characters by their escaped (or unicode escaped) + * equivalents in the given string + */ + protected static final String addEscapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) + { + case 0 : + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + + /** + * Returns a detailed message for the Error when it is thrown by the + * token manager to indicate a lexical error. + * Parameters : + * EOFSeen : indicates if EOF caused the lexical error + * curLexState : lexical state in which this error occurred + * errorLine : line number when the error occurred + * errorColumn : column number when the error occurred + * errorAfter : prefix that was seen before this error occurred + * curchar : the offending character + * Note: You can customize the lexical error message by modifying this method. + */ + protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { + return("Lexical error at line " + + errorLine + ", column " + + errorColumn + ". Encountered: " + + (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + + "after : \"" + addEscapes(errorAfter) + "\""); + } + + /** + * You can also modify the body of this method to customize your error messages. + * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not + * of end-users concern, so you can return something like : + * + * "Internal Error : Please file a bug report .... " + * + * from this method for such cases in the release version of your parser. + */ + public String getMessage() { + return super.getMessage(); + } + + /* + * Constructors of various flavors follow. + */ + + /** No arg constructor. */ + public TokenMgrError() { + } + + /** Constructor with message and reason. */ + public TokenMgrError(String message, int reason) { + super(message); + errorCode = reason; + } + + /** Full Constructor. */ + public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { + this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); + } +} +/* JavaCC - OriginalChecksum=4ee9b485172dfaa0038728998591a931 (do not edit this line) */ diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/package.html b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/package.html new file mode 100644 index 00000000000..311e1e26bb9 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/lexer/package.html @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title></title> + <meta name="Generator" content="Cocoa HTML Writer"> + <meta name="CocoaVersion" content="824.42"> + <style type="text/css"> + p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times} + </style> +</head> +<body> +<p>This package contains the classes of the pddl lexer. This code is automatically generated with javacc 4.0 from the grammar description file Lexer.jjt.</p> +</body> +</html> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/overview.html b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/overview.html new file mode 100644 index 00000000000..6d2b9a8f51c --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/overview.html @@ -0,0 +1,70 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <meta name="Generator" content="Cocoa HTML Writer"> + <meta name="CocoaVersion" content="824.42"> + <style type="text/css"> + p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times} + </style> +</head> +<body> +<h1>PDDL4J beta API Specification.</h1> +<p>PDDL4J is an open source library under licence CECILL (<a href= +"http://www.cecill.info/licences/Licence_CeCILL_V2-en.html">http://www.cecill.info/</a>). +The purpose of the PDDL4J is to facilitate the java implementation of planners +based on the PDDL (Planning Description Language). The library contains a +parser on the last version of PDDL 3.0 and all the classes need to manipulate its +concepts. The parser can be configured to accept only specified requirements of +PDDL langage. The list of requirements accepted are as follow: + +<ul> +<li>:strips - Basic STRIPS-style.</li> +<li>:typing - Allows type names in declaration of variables</li> +<li>:negative-preconditions - Allows not in goal and preconditions descriptions.</li> +<li>:disjunctive-preconditions - Allows or in goal and preconditions descriptions.</li> +<li>:equality - Supports = as built-in predicate.</li> +<li>:existential-preconditions - Allows exists in goal and preconditions descriptions.</li> +<li>:universal-preconditions - Allows forall in goal and preconditions descriptions.</li> +<li>:quantified-preconditions - Is equivalent to :existential-preconditions + + :universal-preconditions.</li> +<li>:conditional-effects - Allows when clause in actionCtx effects. +<li>:fluents - Allows function definitions and use of effects using assignement + operators and numeric preconditions.</li> +<li>:adl - Is equivalent to :strips + :typing + :negative-preconditions + + :disjunctive-preconditions + :equality + :quantified-preconditions + + :conditional-effects.</li> +<li>:durative-actions - Allows durative actions. Note that this does note imply + :fluents.</li> +<li>:derived-predicate - Allows predicates whose truth value is defined by a formula. +<li>:time-initial-literals - Allows the initial state to specify literals that will + become true at a specified time point implies durative-actions.</li> +<li>:preferences - Allows use of preferences in actionCtx preconditions and goals. +<li>:constraints - Allows use of constraints fields in domain and problem description. + These may contain modal operator supporting trajectory constraints.</li> +</ul> +</p> + +<p>PDDL was originally developed by Drew McDermott and the 1998 planning competition +committee. It was inspired by the need to encourage the empirical comparison of +planning systems and the exchange of planning benchmarks within the community. +Its development improved the communication of research results and triggered an + explosion in performance, expressivity and robustness of planning systems.</p> + +<p>PDDL has now been used in all 3 planning competitions, undergoing various +revisions for each. In the most recent competition PDDL was extended by Maria Fox, +Derek Long and the 2002 committee to handle time and duration (PDDL2.1). Further +enrichments to the modelling of hybrid and real-time systems (PDDL+) were proposed, + while another committee is currently investigating extensions to probabilistic +planning.</p> + +<p>PDDL has become a de facto standard language for describing planning domains, +not only for the competition but more widely, as it offers an opportunity to carry +out empirical evaluation of planning systems on a growing collection of generally +adopted standard benchmark domains. The emergence of a language standard will have + an impact on the entire field, influencing what is seen as central and what +peripheral in the development of planning systems. </p> + +</body> +</html> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/package.html b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/package.html new file mode 100644 index 00000000000..d677043e4de --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/package.html @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title></title> + <meta name="Generator" content="Cocoa HTML Writer"> + <meta name="CocoaVersion" content="824.42"> + <style type="text/css"> + p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times} + </style> +</head> +<body> +<p>This package contains the classes relative to the pddl4j librairy.</p> +</body> +</html> diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/tests/Test.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/tests/Test.java new file mode 100644 index 00000000000..89773dca704 --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/tests/Test.java @@ -0,0 +1,136 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is a computer program whose purpose is to propose an + * environment for multi-agent planning. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.tests; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Iterator; +import java.util.Properties; + +import pddl4j.ErrorManager; +import pddl4j.PDDLObject; +import pddl4j.Parser; +import pddl4j.ParserException; +import pddl4j.RequireKey; +import pddl4j.Source; +import pddl4j.ErrorManager.Message; +import pddl4j.exp.action.ActionDef; + +public class Test { + + public static void main(String[] args) { + try { + // Creates an instance of the java pddl parser + Parser parser = new Parser(getParserOptions()); + // Gets the error manager of the pddl parser + ErrorManager mgr = parser.getErrorManager(); + + boolean success; + PDDLObject domain = parser.parse(new File(args[0])); + + if (mgr.contains(Message.ERROR)) { + mgr.print(Message.ALL); + } // else we print the warning and start the planning process + else { + mgr.print(Message.WARNING); + System.out.println("\nParsing domain \"" + domain.getDomainName() + + "\" done successfully ..."); + //System.out.println(domain); + + + PDDLObject problem = parser.parse(new File(args[1])); + if (mgr.contains(Message.ERROR)) { + mgr.print(Message.ALL); + } // else we print the warning and start the planning process + else { + mgr.print(Message.WARNING); + System.out.println("\nParsing problem \"" + problem.getProblemName() + + "\" done successfully ..."); + //System.out.println(problem); + + + PDDLObject obj = parser.link(domain, problem); + + if (mgr.contains(Message.LINKER_ERROR)) { + mgr.print(Message.LINKER_ERROR); + } // else we print the warning and start the planning process + else { + mgr.print(Message.LINKER_WARNING); + System.out.println("Linking \"" + domain.getDomainName() + "\" with \"" + problem.getProblemName() + + "\" done successfully ..."); + System.out.println(obj); + + /*Iterator<ActionDef> i = obj.actionsIterator(); + while (i.hasNext()) { + ActionDef action = i.next(); + System.out.println(action.toTypedString()); + System.out.println(action.normalize().toTypedString()); + + }*/ + + + } + } + } + + // If the parser produces errors we print it and stop + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /** + * Returns the default options of the compiler. + * + * @return the default options. + */ + private static Properties getParserOptions() { + Properties options = new Properties(); + options.put("source", Source.V3_0); + options.put(RequireKey.STRIPS, true); + options.put(RequireKey.TYPING, true); + options.put(RequireKey.EQUALITY, true); + options.put(RequireKey.FLUENTS, false); + options.put(RequireKey.NEGATIVE_PRECONDITIONS, true); + options.put(RequireKey.DISJUNCTIVE_PRECONDITIONS, true); + options.put(RequireKey.EXISTENTIAL_PRECONDITIONS, true); + options.put(RequireKey.UNIVERSAL_PRECONDITIONS, true); + options.put(RequireKey.QUANTIFIED_PRECONDITIONS, true); + options.put(RequireKey.CONDITIONAL_EFFECTS, true); + options.put(RequireKey.DURATIVE_ACTIONS, true); + options.put(RequireKey.ADL, true); + return options; + } +} diff --git a/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/tests/TestCNF.java b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/tests/TestCNF.java new file mode 100644 index 00000000000..ebf3c0dec1b --- /dev/null +++ b/utils/PDDLtoSANetTranslator/PDDLParser/src/pddl4j/tests/TestCNF.java @@ -0,0 +1,285 @@ +/* + * Copyright Dept. of Mathematics & Computer Science Univ. Paris-Descartes + * + * This software is a computer program whose purpose is to propose an + * environment for multi-agent planning. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package pddl4j.tests; + +import pddl4j.exp.AndExp; +import pddl4j.exp.AtomicFormula; +import pddl4j.exp.ExistsExp; +import pddl4j.exp.Exp; +import pddl4j.exp.ForallExp; +import pddl4j.exp.ImplyExp; +import pddl4j.exp.NotAtomicFormula; +import pddl4j.exp.NotExp; +import pddl4j.exp.OrExp; +import pddl4j.exp.term.Constant; +import pddl4j.exp.term.Variable; +import pddl4j.exp.type.Type; + +public class TestCNF { + + /** + * @param args + */ + public static void main(String[] args) { + + // (and (forall (?x) (p1 ?x ?y)) (p2 ?x ?y)) + + Variable x = new Variable("?x"); + Variable y = new Variable("?y"); + + AtomicFormula p1 = new AtomicFormula("p1"); + p1.add(x); + p1.add(y); + + AtomicFormula p2 = new AtomicFormula("p2"); + p2.add(x); + p2.add(y); + + ForallExp forall = new ForallExp(); + forall.add(x); + forall.setExp(p1); + + AndExp and = new AndExp(); + and.add(forall); + and.add(p2); + + System.out.println(and); + System.out.println(and.standardize()); + //System.out.println(and.getFreeVariables()); + + AndExp a2 = new AndExp(); + a2.add(p1); + a2.add(p2); + + //System.out.println(a2); + //System.out.println(a2.standardize()); + + + ExistsExp e1 = new ExistsExp(); + e1.add(y); + e1.setExp(p1); + + ForallExp f1 = new ForallExp(); + f1.add(x); + f1.setExp(e1); + + ExistsExp e2 = new ExistsExp(); + e2.add(x); + e2.add(y); + e2.setExp(p2); + + AndExp a1 = new AndExp(); + a1.add(f1); + a1.add(e2); + + //System.out.println(a1); + //System.out.println(a1.standardize()); + + + + //System.out.println(a1.getFreeVariables()); + + + + /*Variable x = new Variable("?x"); + Variable y = new Variable("?y"); + Variable z = new Variable("?z"); + + AtomicFormula animal = new AtomicFormula("animal"); + animal.add(y); + + AtomicFormula loves1 = new AtomicFormula("loves"); + loves1.add(x); + loves1.add(y); + + System.out.println(loves1); + System.out.println(loves1.normalize()); + + + /*AtomicFormula loves2 = new AtomicFormula("loves"); + loves2.add(y); + loves2.add(x); + + ExistsExp e1 = new ExistsExp(); + e1.add(y); + e1.setExp(loves2); + + ImplyExp e3 = new ImplyExp(animal, loves1); + + ForallExp e2 = new ForallExp(); + e2.add(y); + e2.setExp(e3); + + ImplyExp e4 = new ImplyExp(e2, e1); + + ForallExp e5 = new ForallExp(); + e5.add(x); + e5.setExp(e4); + + ForallExp e7 = new ForallExp(); + e7.add(x); + e7.setExp(loves2); + + + AndExp e6 = new AndExp(); + e6.add(e7); + e6.add(loves1); + e6.add(e1); + + //System.out.println(e6); + //Exp e8 = e6.toPNF(); + //System.out.println(e8); + //System.out.println(e8.toPNF()); + + + + + + System.out.println("INIT: \n" + e5); + System.out.println(e5.standardize()); + System.out.println(e5.standardize().moveQuantifierOutward()); + //System.out.println(e5.standardize().moveQuantifierOutward().toNNF()); + //System.out.println(e5.toNNF()); + Exp e9 = e5.toPrenexNormaForm(); + System.out.println("PNF:\n" + e9); + //System.out.println(e9.toNNF()); + System.out.println("CNF:\n" + e9.toConjunctiveNormalForm()); + + + /*Variable v1 = new Variable("v1"); + Variable v2 = new Variable("v2"); + + Constant c1 = new Constant("c1"); + Constant c2 = new Constant("c2"); + + AtomicFormula a1 = new AtomicFormula("a1"); + a1.add(v1); + a1.add(v2); + + AtomicFormula a2 = new AtomicFormula("a2"); + a2.add(c1); + a2.add(c2); + + NotAtomicFormula nota2 = new NotAtomicFormula(a2); + + AndExp and = new AndExp(); + and.add(a1); + and.add(nota2); + + OrExp or = new OrExp(); + or.add(a1); + or.add(nota2); + + + + ForallExp forall = new ForallExp(or); + forall.add(v1); + forall.add(v2); + + NotExp not = new NotExp(forall); + + System.out.println(not); + System.out.println(not.standardize());*/ + + /*AtomicFormula A = new AtomicFormula("A"); + AtomicFormula B = new AtomicFormula("B"); + AtomicFormula C = new AtomicFormula("C"); + AtomicFormula D = new AtomicFormula("D"); + AtomicFormula E = new AtomicFormula("E"); + AtomicFormula F = new AtomicFormula("F"); + + + AndExp AetB = new AndExp(); + AetB.add(A); + AetB.add(B); + + AndExp CetD = new AndExp(); + CetD.add(C); + CetD.add(D); + + OrExp CouD = new OrExp(); + CouD.add(C); + CouD.add(D); + + OrExp AouB = new OrExp(); + AouB.add(A); + AouB.add(B); + + + AndExp AouBetCouD = new AndExp(); + AouBetCouD.add(AouB); + AouBetCouD.add(CouD); + + OrExp AetBouCetD = new OrExp(); + AetBouCetD.add(AetB); + AetBouCetD.add(CetD); + + OrExp AetBouCouD = new OrExp(); + AetBouCouD.add(AetB); + AetBouCouD.add(CouD); + + AndExp and1 = new AndExp(); + and1.add(F); + and1.add(AetBouCetD); + //and1.add(F); + + ImplyExp AimplyAnd1 = new ImplyExp(A, and1); + + NotExp notE = new NotExp(E); + + + //and2.add(F); + + AndExp and3 = new AndExp(); + and3.add(A); + and3.add(CouD); + + AndExp and2 = new AndExp(); + and2.add(F); + and2.add(and3); + + + System.out.println("IN: "+ AimplyAnd1); + System.out.println("IN: "+ AimplyAnd1.standardize()); + System.out.println("DNF: "+ AimplyAnd1.toDNF()); + + /*System.out.println("IN: "+ and1); + Exp nnf = and1.toNNF(); + System.out.println("NNF: " + nnf); + Exp cnf = nnf.toDNF(); + System.out.println("CNF: " + cnf);*/ + + } + +} |