/** RDDL Parser: Definitive Grammar (for use with JavaCUP)
*
* @author Scott Sanner (ssanner@gmail.com)
*/
package rddl.parser;
import rddl.RDDL;
import java_cup.runtime.*;
import java.io.*;
import java.util.*;
parser code {:
// Just a testing interface (loads formula from file)
public static void main(String args[]) throws Exception {
if (args.length == 0 || args.length > 2)
usageAndExit();
else if (args.length == 2 && args[1].equalsIgnoreCase(“-prefix-output”))
RDDL.USE_PREFIX = true; // Set prefix output
else if (args.length == 2) {
System.out.println(“Unrecognized option: ” + args[1]);
usageAndExit();
}
RDDL rddl = parse(new File(args[0]));
System.out.println(rddl);
}
public static void usageAndExit() {
System.out.println(“Usage: RDDL-filename [-prefix-output]”);
System.exit(1);
}
// The main runtime method to call
public static RDDL parse(String s)
throws ParseException {
Yylex lex = null;
Symbol rval = null;
parser p = null;
try {
lex = new Yylex(new StringReader(s));
p = new parser(lex);
rval = p.parse();
} catch (Exception e) {
int cur_line = (lex != null) ? lex.yyline() + 1 : -1;
String cur_token = “[NOT AVAILABLE]”;
try {
cur_token = “#” + p.cur_token.sym + “: ‘” + p.cur_token.value + “‘”;
} catch (Exception e2) { /* discard */ }
String next_token = “[NOT AVAILABLE]”;
try {
Symbol s2 = lex.next_token();
next_token = “#” + s2.sym + “: ‘” + s2.value + “‘”;
} catch (Exception e2) { /* discard */ }
System.out.println(“Error on line ” +
((lex != null) ? “”+ cur_line + “, cur token: ” + cur_token + “, next token: ” + next_token : “”)
+ “\nException: ” + e);
//e.printStackTrace();
}
return (RDDL)rval.value;
}
// The main runtime method to call
public static RDDL parse(File f)
throws Exception {
Yylex lex = null;
Symbol rval = null;
parser p = null;
try {
lex = new Yylex(new FileInputStream(f));
p = new parser(lex);
rval = p.parse();
} catch (FileNotFoundException fne) {
System.out.println(“ERROR: Could not find file: ‘” + f + “‘”);
} catch (Exception e) {
int cur_line = (lex != null) ? lex.yyline() + 1 : -1;
String cur_token = “[NOT AVAILABLE]”;
try {
cur_token = “#” + p.cur_token.sym + “: ‘” + p.cur_token.value + “‘”;
} catch (Exception e2) { /* discard */ }
String next_token = “[NOT AVAILABLE]”;
try {
Symbol s2 = lex.next_token();
next_token = “#” + s2.sym + “: ‘” + s2.value + “‘”;
} catch (Exception e2) { /* discard */ }
System.out.println(“Error on line ” +
((lex != null) ? “”+ cur_line + “, cur token: ” + cur_token + “, next token: ” + next_token : “?”)
+ “\nException: ” + e);
//e.printStackTrace();
}
return (RDDL)rval.value;
}
:}
/* Define Terminals (and Java types if relevant) */
terminal DOMAIN, INSTANCE, HORIZON, DISCOUNT, OBJECTS, INIT_STATE,
REQUIREMENTS, LCURLY, RCURLY, DERIVED_FLUENT, UNDERSCORE,
STATE_ACTION_CONSTRAINTS, ACTION_PRECONDITIONS, STATE_INVARIANTS,
TYPES, NEG_INF, POS_INF, MAX_NONDEF_ACTIONS,
PVARIABLES, STATE, NON_FLUENTS, CASE,
INTERMEDIATE, OBSERVATION, ACTION, LEVEL, DEFAULT,
AGG_OPER, REWARD, FORALL, DOLLAR_SIGN,
EXISTS, AND, AMPERSAND, OR, NOT, KRON_DELTA, DIRAC_DELTA, UNIFORM, BERNOULLI, DISCRETE,
NORMAL, POISSON, EXPONENTIAL, PLUS, TIMES, DIV, MINUS, IF, THEN, TERMINATE_WHEN,
ELSE, SWITCH, DOT, OTHERWISE, WEIBULL, GAMMA, MULTINOMIAL, DIRICHLET, TERMINAL;
terminal SEMI, LPAREN, RPAREN, COMMA, LBRACK, COLON, QUESTION,
RBRACK, LESS, LESSEQ, GREATER, GREATEREQ, IMPLY, EQUIV,
ASSIGN_EQUAL, COMP_EQUAL, TRUE, FALSE, NEQ, UMINUS;
terminal Integer INTEGER;
terminal Double DOUBLE;
terminal String IDENT, VAR, OBJECT, BOOL, INT, REAL, NON_FLUENT, CPFS, CDFS, ENUM_VAL;
/* Define Non-terminals (and Java types) */
non terminal RDDL RDDL_BLOCK;
non terminal RDDL.DOMAIN DOMAIN_BLOCK;
non terminal ArrayList DOMAIN_LIST;
non terminal RDDL.INSTANCE INSTANCE_BLOCK;
non terminal RDDL.NONFLUENTS NONFLUENT_BLOCK;
non terminal RDDL.DOMAIN REQ_SECTION;
non terminal ArrayList TYPE_SECTION;
non terminal ArrayList ENUM_LIST;
non terminal ArrayList TYPE_LIST;
non terminal RDDL.STRUCT_VAL STRUCT_RANGE_CONST;
non terminal RDDL.STRUCT_VAL STRUCT_RANGE_CONST2;
non terminal ArrayList PARAM_LIST;
non terminal ArrayList PARAM_LIST2;
non terminal ArrayList STRUCT_MEMBER_LIST;
non terminal String TYPE_SPEC;
non terminal RDDL.TYPE_DEF TYPE_DEF;
non terminal ArrayList PVAR_SECTION;
non terminal ArrayList PVAR_LIST;
non terminal RDDL.PVARIABLE_DEF PVAR_DEF;
non terminal ArrayList CPF_SECTION;
non terminal ArrayList CPF_LIST;
non terminal RDDL.STRUCT_EXPR STRUCT_EXPR_LIST;
non terminal RDDL.CPF_DEF CPF_DEF;
non terminal RDDL.REWARD_DEF REW_SECTION;
non terminal ArrayList STATE_CONS_SECTION;
non terminal ArrayList STATE_CONS_LIST;
non terminal RDDL.STATE_CONS_DEF STATE_CONS_DEF;
non terminal ArrayList ACTION_PRECOND_SECTION;
non terminal ArrayList ACTION_PRECOND_LIST;
non terminal RDDL.ACTION_PRECOND_DEF ACTION_PRECOND_DEF;
non terminal ArrayList STATE_INVARIANT_SECTION;
non terminal ArrayList STATE_INVARIANT_LIST;
non terminal RDDL.STATE_INVARIANT_DEF STATE_INVARIANT_DEF;
non terminal ArrayList OBJECT_CONST_LIST;
non terminal ArrayList OBJECTS_LIST;
non terminal ArrayList OBJECTS_SECTION;
non terminal ArrayList MEMBER_LIST;
non terminal RDDL.OBJECTS_DEF OBJECTS_DEF;
non terminal ArrayList STRING_LIST;
non terminal Object RANGE_CONST;
non terminal Boolean BOOL_TYPE;
non terminal Integer INT_TYPE;
non terminal Integer POS_INT_TYPE_OR_POS_INF;
non terminal Object HORIZON_SPEC;
non terminal Double DOUBLE_TYPE;
non terminal String CPF_HEADER;
non terminal RDDL.PVAR_EXPR PVAR_EXPR;
non terminal RDDL.EXPR EXPR;
non terminal ArrayList PVAR_INST_LIST;
non terminal RDDL.PVAR_INST_DEF PVAR_INST_DEF;
non terminal ArrayList LCONST_LIST;
non terminal RDDL.LCONST LCONST;
non terminal ArrayList TERM_LIST;
non terminal RDDL.LTERM TERM;
non terminal RDDL.LTERM PTERM;
non terminal ArrayList TYPED_VAR_LIST;
non terminal RDDL.LTYPED_VAR TYPED_VAR;
non terminal ArrayList LCONST_CASE_LIST;
non terminal ArrayList CASE_LIST;
non terminal RDDL.CASE CASE_DEF;
non terminal ArrayList EXPR_LIST;
/* Precedence Definitions – Highest at bottom */
precedence left IF;
precedence left ASSIGN_EQUAL;
precedence left EXISTS;
precedence left FORALL; /* COUNT */
precedence left AGG_OPER;
precedence left EQUIV;
precedence left IMPLY;
precedence left OR;
precedence left AND, AMPERSAND; /* At Thomas Keller’s insistence, we allow both ^ and & for AND */
precedence left NOT;
precedence left COMP_EQUAL, NEQ, LESS, LESSEQ, GREATER, GREATEREQ;
precedence left PLUS, MINUS;
precedence left TIMES, DIV; /* MOD; */
precedence left UMINUS;
/* precedence left HIGHEST; */
/* Productions */
start with RDDL_BLOCK;
RDDL_BLOCK ::= DOMAIN_BLOCK:d RDDL_BLOCK:rddl {: rddl.addDomain(d); RESULT = rddl; :}
| INSTANCE_BLOCK:i RDDL_BLOCK:rddl {: rddl.addInstance(i); RESULT = rddl; :}
| NONFLUENT_BLOCK:n RDDL_BLOCK:rddl {: rddl.addNonFluents(n); RESULT = rddl; :}
| DOMAIN_BLOCK:d {: RDDL rddl = new RDDL(); rddl.addDomain(d); RESULT = rddl; :}
| INSTANCE_BLOCK:i {: RDDL rddl = new RDDL(); rddl.addInstance(i); RESULT = rddl; :}
| NONFLUENT_BLOCK:n {: RDDL rddl = new RDDL(); rddl.addNonFluents(n); RESULT = rddl; :}
;
/* RDDL2: Requirements section now optional */
DOMAIN_BLOCK ::= DOMAIN IDENT:name LCURLY REQ_SECTION:domain DOMAIN_LIST:list RCURLY
{: domain.setName(name); domain.addDefs(list); RESULT = domain; :}
| DOMAIN IDENT:name LCURLY DOMAIN_LIST:list RCURLY
{: RDDL.DOMAIN domain = new RDDL.DOMAIN(new ArrayList()); domain.setName(name); domain.addDefs(list); RESULT = domain; :}
;
REQ_SECTION ::= REQUIREMENTS ASSIGN_EQUAL LCURLY STRING_LIST:list RCURLY SEMI {: RESULT = new RDDL.DOMAIN(list); :}
| REQUIREMENTS ASSIGN_EQUAL LCURLY RCURLY SEMI {: RESULT = new RDDL.DOMAIN(new ArrayList()); :}
/* RDDL2 allows definition of requirements section with equals sign (for consistency with the rest of the syntax) */
| REQUIREMENTS LCURLY STRING_LIST:list RCURLY SEMI {: RESULT = new RDDL.DOMAIN(list); :}
| REQUIREMENTS LCURLY RCURLY SEMI {: RESULT = new RDDL.DOMAIN(new ArrayList()); :}
;
/* RDDL2: Allow objects specification in domain */
DOMAIN_LIST ::= TYPE_SECTION:t DOMAIN_LIST:list {: list.addAll(t); RESULT = list; :}
| PVAR_SECTION:p DOMAIN_LIST:list {: list.addAll(p); RESULT = list; :}
| CPF_SECTION:c DOMAIN_LIST:list {: list.addAll(c); RESULT = list; :}
| REW_SECTION:r DOMAIN_LIST:list {: list.add(0,r); RESULT = list; :}
| STATE_CONS_SECTION:s DOMAIN_LIST:list {: list.addAll(s); RESULT = list; :}
| ACTION_PRECOND_SECTION:s DOMAIN_LIST:list {: list.addAll(s); RESULT = list; :}
| STATE_INVARIANT_SECTION:s DOMAIN_LIST:list {: list.addAll(s); RESULT = list; :}
| OBJECTS_SECTION:o DOMAIN_LIST:list {: list.addAll(o); RESULT = list; :}
| TYPE_SECTION:t {: RESULT = t; :}
| PVAR_SECTION:p {: RESULT = p; :}
| CPF_SECTION:c {: RESULT = c; :}
| REW_SECTION:r {: RESULT = new ArrayList(Arrays.asList(new Object[] {r})); :}
| STATE_CONS_SECTION:s {: RESULT = s; :}
| ACTION_PRECOND_SECTION:s {: RESULT = s; :}
| STATE_INVARIANT_SECTION:s {: RESULT = s; :}
| OBJECTS_SECTION:o {: RESULT = o; :}
;
OBJECTS_SECTION ::= OBJECTS LCURLY OBJECTS_LIST:objects RCURLY SEMI {: RESULT = objects; :}
;
TYPE_SECTION ::= TYPES LCURLY TYPE_LIST:list RCURLY SEMI {: RESULT = list; :}
;
TYPE_LIST ::= TYPE_DEF:def {: RESULT = new ArrayList(Arrays.asList(new Object[] {def})); :}
| TYPE_DEF:def TYPE_LIST:list {: list.add(0,def); RESULT = list; :}
;
TYPE_DEF ::= IDENT:i COLON OBJECT SEMI {: RESULT = new RDDL.OBJECT_TYPE_DEF(i); :}
| IDENT:i COLON IDENT:superclass SEMI {: RESULT = new RDDL.OBJECT_TYPE_DEF(i, superclass); :}
| IDENT:i COLON LCURLY ENUM_LIST:el RCURLY SEMI {: RESULT = new RDDL.ENUM_TYPE_DEF(i,el); :}
| IDENT:i COLON LCURLY ENUM_VAL:min DOT DOT ENUM_VAL:max RCURLY SEMI {: RESULT = new RDDL.ENUM_TYPE_DEF(i,new RDDL.ENUM_VAL(min),new RDDL.ENUM_VAL(max)); :}
| IDENT:i COLON LBRACK IDENT:type RBRACK LESS QUESTION COLON TYPE_SPEC:t GREATER SEMI {: RESULT = new RDDL.STRUCT_TYPE_DEF(type,i,t); :} /* labels match enum or object */
| IDENT:i COLON LESS STRUCT_MEMBER_LIST:members GREATER SEMI {: RESULT = new RDDL.STRUCT_TYPE_DEF(i,members); :} /* explicitly named entries — should not aggregate */
;
/* RDDL2: The format for action arguments */
STRUCT_MEMBER_LIST ::= LCONST:name COLON TYPE_SPEC:t {: RESULT = new ArrayList(Arrays.asList(new Object[] { new RDDL.STRUCT_TYPE_DEF_MEMBER(new RDDL.TYPE_NAME(t), name)})); :}
| LCONST:name COLON TYPE_SPEC:t COMMA STRUCT_MEMBER_LIST:list {: list.add(0, new RDDL.STRUCT_TYPE_DEF_MEMBER(new RDDL.TYPE_NAME(t), name)); RESULT = list; :}
;
STRING_LIST ::= IDENT:i {: RESULT = new ArrayList(Arrays.asList(new Object[] {i})); :}
| IDENT:i COMMA STRING_LIST:list {: list.add(0,i); RESULT = list; :}
;
ENUM_LIST ::= ENUM_VAL:i {: RESULT = new ArrayList(Arrays.asList(new Object[] {new RDDL.ENUM_VAL(i)})); :}
| ENUM_VAL:i COMMA ENUM_LIST:list {: list.add(0,new RDDL.ENUM_VAL(i)); RESULT = list; :}
;
RANGE_CONST ::= BOOL_TYPE:t {: RESULT = t; :}
| DOUBLE_TYPE:t {: RESULT = t; :}
| INT_TYPE:t {: RESULT = t; :}
| IDENT:i {: RESULT = new RDDL.OBJECT_VAL(i); :} /* Unambiguous… cannot have PVAR_EXPR here */
| DOLLAR_SIGN IDENT:i {: RESULT = new RDDL.OBJECT_VAL(i); :}
| ENUM_VAL:e {: RESULT = new RDDL.ENUM_VAL(e); :}
| LESS STRUCT_RANGE_CONST:s GREATER {: RESULT = s; :}
| LPAREN LESS STRUCT_RANGE_CONST:s GREATER RPAREN {: RESULT = s; :}
| LBRACK LESS STRUCT_RANGE_CONST:s GREATER RBRACK {: RESULT = s; :}
;
STRUCT_RANGE_CONST ::= QUESTION COLON RANGE_CONST:a {: RESULT = new RDDL.STRUCT_VAL(a); :}
| STRUCT_RANGE_CONST2:v {: RESULT = v; :}
;
STRUCT_RANGE_CONST2 ::= LCONST:label COLON RANGE_CONST:a {: RESULT = new RDDL.STRUCT_VAL(label, a); :}
| LCONST:label COLON RANGE_CONST:a COMMA STRUCT_RANGE_CONST2:s {: s.addMemberAsFirst(label, a); RESULT = s; :}
;
BOOL_TYPE ::= TRUE {: RESULT = new Boolean(true); :}
| FALSE {: RESULT = new Boolean(false); :}
;
DOUBLE_TYPE ::= DOUBLE:d {: RESULT = d; :}
| MINUS DOUBLE:d {: RESULT = new Double(-d.doubleValue()); :}
| POS_INF {: RESULT = new Double(Double.POSITIVE_INFINITY); :}
| NEG_INF {: RESULT = new Double(Double.NEGATIVE_INFINITY); :}
;
INT_TYPE ::= INTEGER:i {: RESULT = i; :}
| MINUS INTEGER:i {: RESULT = new Integer(-i.intValue()); :}
;
/* RDDL2: positive integers or infinity (mainly for horizon and max_nondef_actions spec — inf for unrestricted concurrency) */
POS_INT_TYPE_OR_POS_INF ::= INTEGER:i {: RESULT = i; :}
| POS_INF {: RESULT = new Integer(Integer.MAX_VALUE); :}
;
HORIZON_SPEC ::= HORIZON ASSIGN_EQUAL POS_INT_TYPE_OR_POS_INF:h {: RESULT = h; :}
| HORIZON ASSIGN_EQUAL TERMINATE_WHEN LPAREN EXPR:e RPAREN {: RESULT = e; :}
;
PARAM_LIST ::= COLON {: RESULT = new ArrayList(); :}
| LPAREN PARAM_LIST2:list RPAREN COLON {: RESULT = list; :}
;
PARAM_LIST2 ::= TYPE_SPEC:t {: RESULT = new ArrayList(Arrays.asList(new Object[] {t})); :}
| TYPE_SPEC:t COMMA PARAM_LIST2:list {: list.add(0,t); RESULT = list; :}
;
TYPE_SPEC ::= IDENT:i {: RESULT = i; :}
| INT:i {: RESULT = i; :}
| REAL:i {: RESULT = i; :}
| BOOL:i {: RESULT = i; :}
;
PVAR_SECTION ::= PVARIABLES LCURLY PVAR_LIST:list RCURLY SEMI {: RESULT = list; :}
;
PVAR_LIST ::= PVAR_DEF:d {: RESULT = new ArrayList(Arrays.asList(new Object[] {d})); :}
| PVAR_DEF:d PVAR_LIST:list {: list.add(0,d); RESULT = list; :}
;
/* RDDL2: Added derived-fluent as variant of intermediate fluent and made levels for derived/interm optional */
PVAR_DEF ::= IDENT:varname PARAM_LIST:list LCURLY STATE COMMA TYPE_SPEC:range COMMA DEFAULT ASSIGN_EQUAL RANGE_CONST:defvalue RCURLY SEMI {: RESULT = new RDDL.PVARIABLE_STATE_DEF(varname, false, range, list, defvalue); :}
| IDENT:varname PARAM_LIST:list LCURLY NON_FLUENT COMMA TYPE_SPEC:range COMMA DEFAULT ASSIGN_EQUAL RANGE_CONST:defvalue RCURLY SEMI {: RESULT = new RDDL.PVARIABLE_STATE_DEF(varname, true, range, list, defvalue); :}
| IDENT:varname PARAM_LIST:list LCURLY INTERMEDIATE COMMA TYPE_SPEC:range COMMA LEVEL ASSIGN_EQUAL INTEGER:level RCURLY SEMI {: RESULT = new RDDL.PVARIABLE_INTERM_DEF(varname, false /*not derived*/, range, list, level); :}
| IDENT:varname PARAM_LIST:list LCURLY DERIVED_FLUENT COMMA TYPE_SPEC:range COMMA LEVEL ASSIGN_EQUAL INTEGER:level RCURLY SEMI {: RESULT = new RDDL.PVARIABLE_INTERM_DEF(varname, true /*derived*/, range, list, level); :}
| IDENT:varname PARAM_LIST:list LCURLY INTERMEDIATE COMMA TYPE_SPEC:range RCURLY SEMI {: RESULT = new RDDL.PVARIABLE_INTERM_DEF(varname, false /*not derived*/, range, list, -1); :}
| IDENT:varname PARAM_LIST:list LCURLY DERIVED_FLUENT COMMA TYPE_SPEC:range RCURLY SEMI {: RESULT = new RDDL.PVARIABLE_INTERM_DEF(varname, true /*derived*/, range, list, -1); :}
| IDENT:varname PARAM_LIST:list LCURLY OBSERVATION COMMA TYPE_SPEC:range RCURLY SEMI {: RESULT = new RDDL.PVARIABLE_OBS_DEF(varname, range, list); :}
| IDENT:varname PARAM_LIST:list LCURLY ACTION COMMA TYPE_SPEC:range COMMA DEFAULT ASSIGN_EQUAL RANGE_CONST:defvalue RCURLY SEMI {: RESULT = new RDDL.PVARIABLE_ACTION_DEF(varname, range, list, defvalue); :}
;
CPF_SECTION ::= CPF_HEADER:ident LCURLY CPF_LIST:list RCURLY SEMI {: list.add(0,new RDDL.CPF_HEADER_NAME(ident)); RESULT = list; :}
;
CPF_HEADER ::= CPFS:ident {: RESULT = ident; :}
| CDFS:ident {: RESULT = ident; :}
;
CPF_LIST ::= CPF_DEF:d {: RESULT = new ArrayList(Arrays.asList(new Object[] {d})); :}
| CPF_DEF:d CPF_LIST:list {: list.add(0,d); RESULT = list; :}
;
CPF_DEF ::= PVAR_EXPR:pexpr ASSIGN_EQUAL EXPR:expr SEMI {: RESULT = new RDDL.CPF_DEF(pexpr, expr); :}
;
REW_SECTION ::= REWARD ASSIGN_EQUAL EXPR:expr SEMI {: RESULT = new RDDL.REWARD_DEF(expr); :}
;
STATE_CONS_SECTION ::= STATE_ACTION_CONSTRAINTS LCURLY STATE_CONS_LIST:list RCURLY SEMI {: RESULT = list; :}
| STATE_ACTION_CONSTRAINTS LCURLY RCURLY SEMI {: RESULT = new ArrayList(); :}
;
STATE_CONS_LIST ::= STATE_CONS_DEF:d {: RESULT = new ArrayList(Arrays.asList(new Object[] {d})); :}
| STATE_CONS_DEF:d STATE_CONS_LIST:list {: list.add(0,d); RESULT = list; :}
;
STATE_CONS_DEF ::= EXPR:expr SEMI {: RESULT = new RDDL.STATE_CONS_DEF(expr); :}
;
/* RDDL2 */
ACTION_PRECOND_SECTION ::= ACTION_PRECONDITIONS LCURLY ACTION_PRECOND_LIST:list RCURLY SEMI {: RESULT = list; :}
| ACTION_PRECONDITIONS LCURLY RCURLY SEMI {: RESULT = new ArrayList(); :}
;
/* RDDL2 */
ACTION_PRECOND_LIST ::= ACTION_PRECOND_DEF:d {: RESULT = new ArrayList(Arrays.asList(new Object[] {d})); :}
| ACTION_PRECOND_DEF:d ACTION_PRECOND_LIST:list {: list.add(0,d); RESULT = list; :}
;
/* RDDL2 */
ACTION_PRECOND_DEF ::= EXPR:expr SEMI {: RESULT = new RDDL.ACTION_PRECOND_DEF(expr); :}
;
/* RDDL2 */
STATE_INVARIANT_SECTION ::= STATE_INVARIANTS LCURLY STATE_INVARIANT_LIST:list RCURLY SEMI {: RESULT = list; :}
| STATE_INVARIANTS LCURLY RCURLY SEMI {: RESULT = new ArrayList(); :}
;
/* RDDL2 */
STATE_INVARIANT_LIST ::= STATE_INVARIANT_DEF:d {: RESULT = new ArrayList(Arrays.asList(new Object[] {d})); :}
| STATE_INVARIANT_DEF:d STATE_INVARIANT_LIST:list {: list.add(0,d); RESULT = list; :}
;
/* RDDL2 */
STATE_INVARIANT_DEF ::= EXPR:expr SEMI {: RESULT = new RDDL.STATE_INVARIANT_DEF(expr); :}
;
OBJECTS_LIST ::= OBJECTS_DEF:d {: RESULT = new ArrayList(Arrays.asList(new Object[] {d})); :}
| OBJECTS_DEF:d OBJECTS_LIST:list {: list.add(0,d); RESULT = list; :}
;
OBJECTS_DEF ::= IDENT:i COLON LCURLY OBJECT_CONST_LIST:l RCURLY SEMI {: RESULT = new RDDL.OBJECTS_DEF(i, l); :}
;
PVAR_INST_LIST ::= PVAR_INST_DEF:d {: RESULT = new ArrayList(Arrays.asList(new Object[] {d})); :}
| PVAR_INST_DEF:d PVAR_INST_LIST:list {: list.add(0,d); RESULT = list; :}
;
PVAR_INST_DEF ::= IDENT:i LPAREN LCONST_LIST:list RPAREN SEMI {: RESULT = new RDDL.PVAR_INST_DEF(i, new Boolean(true), list); :}
| IDENT:i SEMI {: RESULT = new RDDL.PVAR_INST_DEF(i, new Boolean(true), new ArrayList()); :}
| NOT IDENT:i LPAREN LCONST_LIST:list RPAREN SEMI {: RESULT = new RDDL.PVAR_INST_DEF(i, new Boolean(false), list); :}
| NOT IDENT:i SEMI {: RESULT = new RDDL.PVAR_INST_DEF(i, new Boolean(false), new ArrayList()); :}
| IDENT:i LPAREN LCONST_LIST:list RPAREN ASSIGN_EQUAL RANGE_CONST:val SEMI {: RESULT = new RDDL.PVAR_INST_DEF(i, val, list); :}
| IDENT:i ASSIGN_EQUAL RANGE_CONST:val SEMI {: RESULT = new RDDL.PVAR_INST_DEF(i, val, new ArrayList()); :}
;
OBJECT_CONST_LIST ::= IDENT:i {: RESULT = new ArrayList(Arrays.asList(new Object[] {new RDDL.OBJECT_VAL(i)})); :} /* Unambiguous… cannot have PVAR_EXPR here */
| IDENT:i COMMA OBJECT_CONST_LIST:list {: list.add(0,new RDDL.OBJECT_VAL(i)); RESULT = list; :} /* Unambiguous… cannot have PVAR_EXPR here */
| DOLLAR_SIGN IDENT:i {: RESULT = new ArrayList(Arrays.asList(new Object[] {new RDDL.OBJECT_VAL(i)})); :}
| DOLLAR_SIGN IDENT:i COMMA OBJECT_CONST_LIST:list {: list.add(0,new RDDL.OBJECT_VAL(i)); RESULT = list; :}
;
LCONST_LIST ::= LCONST:i {: RESULT = new ArrayList(Arrays.asList(new Object[] {i})); :}
| LCONST:i COMMA LCONST_LIST:list {: list.add(0,i); RESULT = list; :}
;
LCONST ::= IDENT:i {: RESULT = new RDDL.OBJECT_VAL(i); :}
| DOLLAR_SIGN IDENT:i {: RESULT = new RDDL.OBJECT_VAL(i); :}
| ENUM_VAL:e {: RESULT = new RDDL.ENUM_VAL(e); :}
;
TERM ::= VAR:v {: RESULT = new RDDL.LVAR(v); :}
| PVAR_EXPR:p {: RESULT = new RDDL.TVAR_EXPR(p); :}
| ENUM_VAL:e {: RESULT = new RDDL.ENUM_VAL(e); :}
| DOLLAR_SIGN IDENT:i {: RESULT = new RDDL.OBJECT_VAL(i); :} /* DOLLAR_SIGN required here to disambiguate from parameterless PVAR_EXPR */
;
PVAR_EXPR ::= IDENT:i LPAREN TERM_LIST:l RPAREN {: RESULT = new RDDL.PVAR_EXPR(i, l); :}
| IDENT:i LPAREN TERM_LIST:l RPAREN MEMBER_LIST:list {: RESULT = new RDDL.PVAR_EXPR(i, l, list); :}
| IDENT:i {: RESULT = new RDDL.PVAR_EXPR(i, new ArrayList()); :}
| IDENT:i MEMBER_LIST:list {: RESULT = new RDDL.PVAR_EXPR(i, new ArrayList(), list); :}
| IDENT:i DOT DEFAULT {: RESULT = new RDDL.PVAR_EXPR(i, new ArrayList(), new ArrayList(Arrays.asList(new Object[] {RDDL.PVAR_EXPR.DEFAULT}))); :}
;
/* Nested pvar_expr in . indices can have attachment ambiguity… must enclose in parens or brackets */
PTERM ::= VAR:v {: RESULT = new RDDL.LVAR(v); :}
| LPAREN PVAR_EXPR:p RPAREN {: RESULT = new RDDL.TVAR_EXPR(p); :}
| LBRACK PVAR_EXPR:p RBRACK {: RESULT = new RDDL.TVAR_EXPR(p); :}
| ENUM_VAL:e {: RESULT = new RDDL.ENUM_VAL(e); :}
| DOLLAR_SIGN IDENT:i {: RESULT = new RDDL.OBJECT_VAL(i); :} /* DOLLAR_SIGN required here to disambiguate from parameterless PVAR_EXPR */
;
MEMBER_LIST ::= DOT PTERM:member {: RESULT = new ArrayList(Arrays.asList(new Object[] {member})); :}
| DOT PTERM:member MEMBER_LIST:list {: list.add(0,member); RESULT = list; :}
;
TERM_LIST ::= TERM:t {: RESULT = new ArrayList(Arrays.asList(new Object[] {t})); :}
| TERM:t COMMA TERM_LIST:list {: list.add(0,t); RESULT = list; :}
;
STRUCT_EXPR_LIST ::= LCONST:label COLON EXPR:e GREATER {: RESULT = new RDDL.STRUCT_EXPR(label, e); :}
| LCONST:label COLON EXPR:e COMMA STRUCT_EXPR_LIST:s {: s.addMemberAsFirst(label, e); RESULT = s; :}
;
TYPED_VAR_LIST ::= TYPED_VAR:t {: RESULT = new ArrayList(Arrays.asList(new Object[] {t})); :}
| TYPED_VAR:t COMMA TYPED_VAR_LIST:list {: list.add(0,t); RESULT = list; :}
;
TYPED_VAR ::= VAR:var COLON IDENT:type {: RESULT = new RDDL.LTYPED_VAR(var, type); :}
;
LCONST_CASE_LIST ::= LCONST:label COLON EXPR:e {: RESULT = new ArrayList(Arrays.asList(new Object[] {label,e})); :}
| LCONST:label COLON OTHERWISE {: RESULT = new ArrayList(Arrays.asList(new Object[] {label, RDDL.Discrete.OTHERWISE_CASE})); :}
| LCONST:label COLON EXPR:e COMMA LCONST_CASE_LIST:list {: list.add(0,e); list.add(0,label); RESULT = list; :}
;
EXPR_LIST ::= EXPR:e {: RESULT = new ArrayList(Arrays.asList(new Object[] {e})); :}
| EXPR:e COMMA EXPR_LIST:list {: list.add(0,e); RESULT = list; :}
;
CASE_LIST ::= CASE_DEF:e {: RESULT = new ArrayList(Arrays.asList(new Object[] {e})); :}
| CASE_DEF:e COMMA CASE_LIST:list {: list.add(0,e); RESULT = list; :}
;
CASE_DEF ::= CASE TERM:v COLON EXPR:e {: RESULT = new RDDL.CASE(v,e); :}
| DEFAULT COLON EXPR:e {: RESULT = new RDDL.CASE(null,e); :}
;
EXPR ::= VAR:v {: RESULT = new RDDL.LVAR(v); :}
| PVAR_EXPR:p {: RESULT = p; :} /* Will be converted to TVAR_EXPR if nested in PVAR_EXPR */
| ENUM_VAL:e {: RESULT = new RDDL.ENUM_VAL(e); :}
| DOLLAR_SIGN IDENT:i {: RESULT = new RDDL.OBJECT_VAL(i); :} /* DOLLAR_SIGN required here to disambiguate from parameterless PVAR_EXPR */
/* — (NESTED) VECTOR EXPRESSION — */
| LESS STRUCT_EXPR_LIST:s {: RESULT = s; :} /* vector expressions */
/* — GROUPING EXPRESSIONS — */
| LBRACK EXPR:e RBRACK {: RESULT = e; :}
| LPAREN EXPR:e RPAREN {: RESULT = e; :}
/* — SPECIAL FUNCTIONS — */
| IDENT:i LBRACK EXPR_LIST:l RBRACK {: RESULT = new RDDL.FUN_EXPR(i, l); :}
/* — BOOLEAN EXPRESSIONS — */
/* Treat boolean expressions as true=1, false=0 when nested in arithmetic expressions */
| TRUE {: RESULT = new RDDL.BOOL_CONST_EXPR(true); :}
| FALSE {: RESULT = new RDDL.BOOL_CONST_EXPR(false); :}
| EXPR:e1 COMP_EQUAL EXPR:e2 {: RESULT = new RDDL.COMP_EXPR(e1, e2, “==”); :}
| EXPR:e1 NEQ EXPR:e2 {: RESULT = new RDDL.COMP_EXPR(e1, e2, “~=”); :}
| EXPR:e1 GREATER EXPR:e2 {: RESULT = new RDDL.COMP_EXPR(e1, e2, “>”); :}
| EXPR:e1 GREATEREQ EXPR:e2 {: RESULT = new RDDL.COMP_EXPR(e1, e2, “>=”); :}
| EXPR:e1 LESS EXPR:e2 {: RESULT = new RDDL.COMP_EXPR(e1, e2, “<"); :}
| EXPR:e1 LESSEQ EXPR:e2 {: RESULT = new RDDL.COMP_EXPR(e1, e2, "<="); :}
| NOT EXPR:b {: RESULT = new RDDL.NEG_EXPR(b); :} %prec UMINUS
| EXPR:b1 AND EXPR:b2 {: RESULT = new RDDL.CONN_EXPR(b1, b2, "^"); :}
| EXPR:b1 AMPERSAND EXPR:b2 {: RESULT = new RDDL.CONN_EXPR(b1, b2, "^"); :} /* At Thomas Keller's insistence, we allow both ^ and & for AND */
| EXPR:b1 OR EXPR:b2 {: RESULT = new RDDL.CONN_EXPR(b1, b2, "|"); :}
| EXPR:b1 IMPLY EXPR:b2 {: RESULT = new RDDL.CONN_EXPR(b1, b2, "=>“); :}
| EXPR:b1 EQUIV EXPR:b2 {: RESULT = new RDDL.CONN_EXPR(b1, b2, “<=>“); :}
| FORALL UNDERSCORE LCURLY TYPED_VAR_LIST:list RCURLY EXPR:b {: RESULT = new RDDL.QUANT_EXPR(“forall”, list, b); :} %prec FORALL
| EXISTS UNDERSCORE LCURLY TYPED_VAR_LIST:list RCURLY EXPR:b {: RESULT = new RDDL.QUANT_EXPR(“exists”, list, b); :} %prec EXISTS
/* — NUMERICAL EXPRESSIONS — */
/* Treat numerical expressions as (if val=0 then val=false else val=true) when nested in arithmetic expressions */
| INTEGER:i {: RESULT = new RDDL.INT_CONST_EXPR(i); :}
| DOUBLE:d {: RESULT = new RDDL.REAL_CONST_EXPR(d); :}
| PLUS EXPR:e {: RESULT = e; :} %prec UMINUS
| MINUS EXPR:e {: RESULT = new RDDL.OPER_EXPR(new RDDL.INT_CONST_EXPR(0), e, “-“); :} %prec UMINUS
| EXPR:e1 TIMES EXPR:e2 {: RESULT = new RDDL.OPER_EXPR(e1, e2, “*”); :}
| EXPR:e1 DIV EXPR:e2 {: RESULT = new RDDL.OPER_EXPR(e1, e2, “/”); :}
| EXPR:e1 PLUS EXPR:e2 {: RESULT = new RDDL.OPER_EXPR(e1, e2, “+”); :}
| EXPR:e1 MINUS EXPR:e2 {: RESULT = new RDDL.OPER_EXPR(e1, e2, “-“); :}
| IDENT:i UNDERSCORE LCURLY TYPED_VAR_LIST:list RCURLY EXPR:e {: RESULT = new RDDL.AGG_EXPR(i, list, e); :} %prec AGG_OPER
| IF LPAREN EXPR:b RPAREN THEN EXPR:e1 ELSE EXPR:e2 {: RESULT = new RDDL.IF_EXPR(b, e1, e2); :} %prec IF
| SWITCH LPAREN TERM:t RPAREN LCURLY CASE_LIST:list RCURLY {: RESULT = new RDDL.SWITCH_EXPR(t, list); :}
/* — RANDOM VARIABLES — */
| BERNOULLI LPAREN EXPR:prob RPAREN {: RESULT = new RDDL.Bernoulli(prob); :}
| DIRAC_DELTA LPAREN EXPR:d RPAREN {: RESULT = new RDDL.DiracDelta(d); :}
| KRON_DELTA LPAREN EXPR:k RPAREN {: RESULT = new RDDL.KronDelta(k); :}
| UNIFORM LPAREN EXPR:l COMMA EXPR:u RPAREN {: RESULT = new RDDL.Uniform(l,u); :}
| NORMAL LPAREN EXPR:mu COMMA EXPR:var RPAREN {: RESULT = new RDDL.Normal(mu, var); :}
| EXPONENTIAL LPAREN EXPR:lambda RPAREN {: RESULT = new RDDL.Exponential(lambda); :}
| DISCRETE LPAREN IDENT:type COMMA LCONST_CASE_LIST:list RPAREN {: RESULT = new RDDL.Discrete(type, list); :}
| MULTINOMIAL LPAREN IDENT:type COMMA EXPR:count COMMA LCONST_CASE_LIST:list RPAREN {: RESULT = new RDDL.Multinomial(type, count, list); :}
| DIRICHLET LPAREN IDENT:type COMMA EXPR:alpha RPAREN {: RESULT = new RDDL.Dirichlet(type, alpha); :} /* For now, just symmetric case */
| POISSON LPAREN EXPR:lambda RPAREN {: RESULT = new RDDL.Poisson(lambda); :}
| WEIBULL LPAREN EXPR:shape COMMA EXPR:scale RPAREN {: RESULT = new RDDL.Weibull(shape, scale); :}
| GAMMA LPAREN EXPR:shape COMMA EXPR:scale RPAREN {: RESULT = new RDDL.Gamma(shape, scale); :}
;
/* For simplicity in the NONFLUENT_BLOCK grammar, order matters. */
/* Also, OBJECTS is the only optional entry. */
NONFLUENT_BLOCK ::= NON_FLUENTS IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
OBJECTS LCURLY OBJECTS_LIST:objects RCURLY SEMI
NON_FLUENTS LCURLY PVAR_INST_LIST:nonfluents_list RCURLY SEMI
RCURLY
{: RESULT = new RDDL.NONFLUENTS(name,domain,objects,nonfluents_list); :}
| NON_FLUENTS IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
NON_FLUENTS PVAR_INST_LIST:nonfluents_list SEMI
RCURLY
{: RESULT = new RDDL.NONFLUENTS(name,domain,null,nonfluents_list); :}
;
/* For simplicity in the INSTANCE_BLOCK grammar, order matters. */
INSTANCE_BLOCK ::= INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
NON_FLUENTS ASSIGN_EQUAL IDENT:nonfluents SEMI
OBJECTS LCURLY OBJECTS_LIST:objects RCURLY SEMI
INIT_STATE LCURLY PVAR_INST_LIST:state_list RCURLY SEMI
MAX_NONDEF_ACTIONS ASSIGN_EQUAL POS_INT_TYPE_OR_POS_INF:a SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,nonfluents,null,objects,state_list,a,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
OBJECTS LCURLY OBJECTS_LIST:objects RCURLY SEMI
INIT_STATE LCURLY PVAR_INST_LIST:state_list RCURLY SEMI
MAX_NONDEF_ACTIONS ASSIGN_EQUAL POS_INT_TYPE_OR_POS_INF:a SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,null,null,objects,state_list,a,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
NON_FLUENTS ASSIGN_EQUAL IDENT:nonfluents SEMI
INIT_STATE LCURLY PVAR_INST_LIST:state_list RCURLY SEMI
MAX_NONDEF_ACTIONS ASSIGN_EQUAL POS_INT_TYPE_OR_POS_INF:a SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,nonfluents,null,null,state_list,a,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
INIT_STATE LCURLY PVAR_INST_LIST:state_list RCURLY SEMI
MAX_NONDEF_ACTIONS ASSIGN_EQUAL POS_INT_TYPE_OR_POS_INF:a SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,null,null,null,state_list,a,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
NON_FLUENTS ASSIGN_EQUAL IDENT:nonfluents SEMI
OBJECTS LCURLY OBJECTS_LIST:objects RCURLY SEMI
MAX_NONDEF_ACTIONS ASSIGN_EQUAL POS_INT_TYPE_OR_POS_INF:a SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,nonfluents,null,objects,new ArrayList(),a,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
OBJECTS LCURLY OBJECTS_LIST:objects RCURLY SEMI
MAX_NONDEF_ACTIONS ASSIGN_EQUAL POS_INT_TYPE_OR_POS_INF:a SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,null,null,objects,new ArrayList(),a,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
NON_FLUENTS ASSIGN_EQUAL IDENT:nonfluents SEMI
MAX_NONDEF_ACTIONS ASSIGN_EQUAL POS_INT_TYPE_OR_POS_INF:a SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,nonfluents,null,null,new ArrayList(),a,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
MAX_NONDEF_ACTIONS ASSIGN_EQUAL POS_INT_TYPE_OR_POS_INF:a SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,null,null,null,new ArrayList(),a,h,d); :}
/* New section omits MAX_NONDEF_ACTIONS */
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
NON_FLUENTS ASSIGN_EQUAL IDENT:nonfluents SEMI
OBJECTS LCURLY OBJECTS_LIST:objects RCURLY SEMI
INIT_STATE LCURLY PVAR_INST_LIST:state_list RCURLY SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,nonfluents,null,objects,state_list,null,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
OBJECTS LCURLY OBJECTS_LIST:objects RCURLY SEMI
INIT_STATE LCURLY PVAR_INST_LIST:state_list RCURLY SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,null,null,objects,state_list,null,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
NON_FLUENTS ASSIGN_EQUAL IDENT:nonfluents SEMI
INIT_STATE LCURLY PVAR_INST_LIST:state_list RCURLY SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,nonfluents,null,null,state_list,null,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
INIT_STATE LCURLY PVAR_INST_LIST:state_list RCURLY SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,null,null,null,state_list,null,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
NON_FLUENTS ASSIGN_EQUAL IDENT:nonfluents SEMI
OBJECTS LCURLY OBJECTS_LIST:objects RCURLY SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,nonfluents,null,objects,new ArrayList(),null,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
OBJECTS LCURLY OBJECTS_LIST:objects RCURLY SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,null,null,objects,new ArrayList(),null,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
NON_FLUENTS ASSIGN_EQUAL IDENT:nonfluents SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,nonfluents,null,null,new ArrayList(),null,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,null,null,null,new ArrayList(),null,h,d); :}
/* These are required for IPC 2018 and will be part of RDDL 2. We should list all possible legal combinations though */
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
OBJECTS LCURLY OBJECTS_LIST:objects RCURLY SEMI
NON_FLUENTS LCURLY PVAR_INST_LIST:nonfluents_list RCURLY SEMI
INIT_STATE LCURLY PVAR_INST_LIST:state_list RCURLY SEMI
HORIZON_SPEC:h SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,null,nonfluents_list,objects,state_list,null,h,d); :}
| INSTANCE IDENT:name LCURLY
DOMAIN ASSIGN_EQUAL IDENT:domain SEMI
OBJECTS LCURLY OBJECTS_LIST:objects RCURLY SEMI
NON_FLUENTS LCURLY PVAR_INST_LIST:nonfluents_list RCURLY SEMI
INIT_STATE LCURLY PVAR_INST_LIST:state_list RCURLY SEMI
TERMINAL ASSIGN_EQUAL EXPR:expr SEMI
DISCOUNT ASSIGN_EQUAL DOUBLE:d SEMI RCURLY
{: RESULT = new RDDL.INSTANCE(name,domain,null,nonfluents_list,objects,state_list,null,expr,d); :}
;