-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathWhen.cpp
42 lines (37 loc) · 842 Bytes
/
When.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "Domain.h"
void When::PDDLPrint( std::ostream & s, unsigned indent, const TokenStruct< std::string > & ts, Domain & d ) {
tabindent( s, indent );
s << "( WHEN\n";
if ( pars ) pars->PDDLPrint( s, indent + 1, ts, d );
else {
tabindent( s, indent + 1 );
s << "()";
}
s << "\n";
if ( cond ) cond->PDDLPrint( s, indent + 1, ts, d );
else {
tabindent( s, indent + 1 );
s << "()";
}
s << "\n";
tabindent( s, indent );
s << ")";
}
void When::parse( Filereader & f, TokenStruct< std::string > & ts, Domain & d ) {
f.next();
f.assert( "(" );
if ( f.getChar() != ')' ) {
pars = createCondition( f, d );
pars->parse( f, ts, d );
}
else ++f.c;
f.next();
f.assert( "(" );
if ( f.getChar() != ')' ) {
cond = createCondition( f, d );
cond->parse( f, ts, d );
}
else ++f.c;
f.next();
f.assert( ")" );
}