-
Notifications
You must be signed in to change notification settings - Fork 6
/
TypeGround.cpp
42 lines (38 loc) · 1.33 KB
/
TypeGround.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 TypeGround::PDDLPrint( std::ostream & s, unsigned indent, const TokenStruct< std::string > & ts, Domain & d ) {
tabindent( s, indent );
s << "( " << name;
for ( unsigned i = 0; i < params.size(); ++i )
s << " " << d.types[lifted->params[i]]->object( params[i] ).first;
s << " )";
}
void TypeGround::insert( Domain & d, const StringVec & v ) {
params.resize( lifted->params.size() );
for ( unsigned i = 0; i < lifted->params.size(); ++i ) {
std::pair< bool, unsigned > p = d.types[lifted->params[i]]->parseObject( v[i] );
if ( p.first ) params[i] = p.second;
else {
std::pair< bool, int > q = d.types[lifted->params[i]]->parseConstant( v[i] );
if ( q.first ) params[i] = q.second;
else {
std::cerr << "Unknown object " << v[i] << "\n";
std::exit( 1 );
}
}
}
}
void TypeGround::parse( Filereader & f, TokenStruct< std::string > & ts, Domain & d ) {
f.next();
params.resize( lifted->params.size() );
for ( unsigned i = 0; i < lifted->params.size(); ++i, f.next() ) {
std::string s = f.getToken();
std::pair< bool, unsigned > p = d.types[lifted->params[i]]->parseObject( s );
if ( p.first ) params[i] = p.second;
else {
std::pair< bool, int > q = d.types[lifted->params[i]]->parseConstant( s );
if ( q.first ) params[i] = q.second;
else f.tokenExit( s );
}
}
f.assert( ")" );
}