[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
g++ assembler problem
From: |
Allyson |
Subject: |
g++ assembler problem |
Date: |
27 Jul 2004 18:36:43 -0700 |
Hi, All:
I compiled my program which has many .cc code. I only got the
following error from only source file:
Assembler: data.types.cc
aline 24491: symbol already has a type
aline 24492: nultiple defined label
aline 24533: symbol already has a size
aline 34927: symbol already has a type
aline 34928: multiply defined label
aline 34956: symbol already has a size
Any idea where the problem is?
My header file is as follows:
// ------------------------------------------------------
#ifndef DATA_TYPES_H
#define DATA_TYPES_H
#include <string>
#include <map>
using namespace std;
class LispEntity;
class ActionDescription;
class Domain;
typedef pair<string, vector<int> > SymFactDescription;
/** implementation for proper type handling; generates and
maintains type hierarchy object, predicate, function, action
and constant types as STL mapping sfrom strings to strings.
*/
class TypeEngine {
typedef map<string, string> TypeMap;
TypeMap inherits;
TypeMap objectTypes;
TypeMap predicateTypes;
TypeMap functionTypes;
TypeMap actionTypes;
TypeMap constTypes;
map<string, TypeMap> allActionTypes;
bool typing;
Domain& domain;
void add(TypeMap &t, string newType, string baseType);
public:
vector<string> readTypedList(vector <LispEntity> &l, TypeMap &m);
// core routine to parse a list of objects with
// intermediate "- type" information
// interface for other parsing engines, mainly to avoid duplicates
TypeMap& getObjectTypes() { return objectTypes; }
TypeMap& getPredicatateTypes() {return predicateTypes; }
TypeMap& getInherits() { return inherits; }
TypeEngine(Domain &d); // constructor called by domain
// unrolling eliminates forall and exist quantification
vector<LispEntity> unrollList(vector<LispEntity> in);
vector<LispEntity> unroll(LispEntity& in);
vector<LispEntity> unrollNumeric(LispEntity& in);
void requireTyping() {typing = true;}
// sets type information
vector<string> readTypesDef(LispEntity &le);
// read type definition and build type hierarchy
void readObjectDef(LispEntity &le);
// read object definition and associate type information
vector<string> readConstantDef(LispEntity &le);
// read constant definition and associate type information
string Inherits(string base);
// returns base type of parameter
vector<ActionDescription *> readActionDef(vector<LispEntity> in);
ActionDescription * readNormal(vector<LispEntity> in, string name);
// reads action description as lisp entity and extracts
// all type information from it
ActionDescription * readDurative(vector<LispEntity> in, string
name);
// reads durative action description as lisp entity and extracts
// all type information from it
vector<map<string, string> >
readPredicateDef(vector<LispEntity> &l, vector<string>& names);
// read predicate definition and strip type information
vector<map<string, string> >
readFunctionDef(vector<LispEntity> &l, vector<string>& names);
// read function definition and strip type information
string toString();
};
#endif
My c file is as follows:
// --------------------------------------------
#include <string>
#include <map>
using namespace std;
#include <util.options.h>
#include <util.tools.h>
#include <lisp.entity.h>
#include <data.actionDescription.h>
#include <data.types.h>
TypeEngine::TypeEngine(Domain& d): domain(d) {
typing = false;
// add(inherits, "number", "");
add(inherits, "object", "");
}
vector<string> TypeEngine::readTypedList(vector<LispEntity> &l,
TypeMap &m) {
vector<string> result;
int i = 0;
while(i < l.size()) {
vector<string> names;
vector<string> types;
while( i < l.size() && l[i].getString() != "-") {
names.push_back(l[i++].getString());
}
if(i != l.size()) {
if(++i == l.size())
::error("type missing");
if(l[i].isList()) { // (either ...) type
vector<LispEntity> tl = l[i].getList();
if(tl.size() == 0 || tl[0].getString() != "either")
::error("empty either clause");
for(int j = 1; j < tl.size(); j++)
types.push_back(tl[j].getString());
} else {
types.push_back(l[i].getString());
}
i++;
} else {
types.push_back("object");
}
for(int j = 0; j < names.size(); j++) {
result.push_back(names[j]);
for(int k = 0; k < types.size(); k++) {
// cout << names[j] << " " << types[k] << endl;
add(m,names[j], types[k]);
}
}
}
return result;
}
void TypeEngine::readObjectDef(LispEntity &le) {
if(le.getList().size() == 0 || (
le.getList().front().getString() != ":objects" ))
::error(":objects clause expected");
vector<LispEntity> l(le.getList().begin() + 1, le.getList().end());
readTypedList(l, objectTypes);
}
vector<string> TypeEngine::readConstantDef(LispEntity &le) {
if(le.getList().size() == 0 || (
le.getList().front().getString() != ":constants"))
::error(":constant clause expected");
vector<LispEntity> l(le.getList().begin() + 1, le.getList().end());
return readTypedList(l, objectTypes);
}
vector<map<string, string> >
TypeEngine::readPredicateDef(vector<LispEntity> &le, vector<string>&
names) {
string name;
int i = 0;
vector<map<string, string> > returnVal;
while(i < le.size()) {
if(le[i].getList().size() == 0)
::error("invalid predicate: no name given");
name = le[i].getList().front().getString();
vector<LispEntity> vl(le[i].getList().begin() + 1,
le[i].getList().end());
vector<string> partial = readTypedList(vl, predicateTypes);
// second step: determine types and check syntax
for(int j = 0; j < partial.size(); j++)
if(partial[j][0] != '?')
::error("invalid predicate: illegal parameter" + partial[j]);
names.push_back(name);
returnVal.push_back(predicateTypes);
i++;
predicateTypes.clear();
}
return returnVal;
}
vector<map<string, string> >
TypeEngine::readFunctionDef(vector<LispEntity> &le, vector<string>&
names) {
string name;
int i = 0;
vector<map<string, string> > returnVal;
while(i < le.size()) {
if(le[i].getList().size() == 0)
::error("invalid function: no name given");
name = le[i].getList().front().getString();
vector<LispEntity> vl(le[i].getList().begin() + 1,
le[i].getList().end());
vector<string> partial = readTypedList(vl, functionTypes);
// second step: determine types and check syntax
for(int j = 0; j < partial.size(); j++)
if(partial[j][0] != '?')
::error("invalid function: illegal parameter" + partial[j]);
names.push_back(name);
returnVal.push_back(functionTypes);
i++;
functionTypes.clear();
}
return returnVal;
}
vector<string>
TypeEngine::readTypesDef(LispEntity &le) {
if(le.getList().size() == 0 || le.getList().front().getString() !=
":types")
::error(":types clause expected");
vector<LispEntity> l(le.getList().begin() + 1, le.getList().end());
return readTypedList(l, inherits);
}
void TypeEngine::add(TypeMap &t, string newType, string baseType) {
// if(baseType != "" && !t.count(baseType))
// ::error("unknown base type: " + baseType);
t.insert(make_pair(newType, baseType));
}
vector<LispEntity> TypeEngine::unrollNumeric(LispEntity& in) {
vector<LispEntity> back;
assert (in.getList()[0].getString() == "forall" ||
in.getList()[0].getString() == "exists");
// cout << " forall/exists detected " << endl;
vector<LispEntity> l(in.getList().begin()+1, in.getList().end());
// cout << " quantifier " << l[0].toString() << endl;
// cout << " body " << l[1].toString() << endl;
string name = l[1].getList().front().getString();
vector<LispEntity> vq(l[0].getList().begin(), l[0].getList().end());
vector<LispEntity> vl(l[1].getList().begin() + 1,
l[1].getList().end());
map <string,string> quantTypes;
vector<string> quantifier = readTypedList(vq,quantTypes);
for(int j = 0; j < quantifier.size(); j++) {
// cout << " eliminating "
// << quantifier[j] << " " << quantTypes[quantifier[j]] <<
endl;
vector<string> partial;
// cout << vl[0].toString() << endl;
LispEntity op = vl[0].getList()[0];
LispEntity val = vl[0].getList()[2];
LispEntity fun = vl[0].getList()[1];
vector<LispEntity> nl(fun.getList().begin() + 1,
fun.getList().end());
partial = readTypedList(nl, functionTypes);
for(int p = 0; p < partial.size(); p++) {
if(partial[p][0] != '?')
::error("invalid spec: illegal parameter" + partial[p]);
if (partial[p] == quantifier[j]) {
// cout << " match of " << partial[p]
//<< " in " << l[1].toString() << endl;
// LispEntity and(l[1].getList()[0].getString());
LispEntity func(fun.getList()[0].getString());
// cout << " substituted by " ;
for(map<string,string>::iterator pos =
objectTypes.begin(); pos != objectTypes.end(); ++pos) {
string obj = (string &) pos->first;
if (objectTypes[obj] == quantTypes[quantifier[j]]) {
vector<LispEntity> comb;
comb.push_back(func);
for(int q = 0; q < partial.size(); q++) {
if (partial[q] == quantifier[j]) {
// cout << " " << obj;
LispEntity ob(obj);
comb.push_back(ob);
}
else {
LispEntity ob(partial[q]);
comb.push_back(ob);
}
}
LispEntity instance(comb);
vector<LispEntity> together;
together.push_back(op);
together.push_back(instance);
together.push_back(val);
LispEntity almost(together);
//vector<LispEntity> merge;
//merge.push_back(and);
//merge.push_back(almost);
LispEntity all(together);
back.push_back(all);
// cout << " for instance " << all.toString() << endl;
}
}
}
}
}
return back;
}
vector<LispEntity> TypeEngine::unroll(LispEntity& in) {
vector<LispEntity> back;
assert (in.getList()[0].getString() == "forall" ||
in.getList()[0].getString() == "exists");
// cout << " forall/exists detected " << endl;
vector<LispEntity> l(in.getList().begin()+1, in.getList().end());
// cout << " quantifier " << l[0].toString() << endl;
// cout << " body " << l[1].toString() << endl;
string name = l[1].getList().front().getString();
vector<LispEntity> vq(l[0].getList().begin(), l[0].getList().end());
vector<LispEntity> vl(l[1].getList().begin() + 1,
l[1].getList().end());
map <string,string> quantTypes;
vector<string> quantifier = readTypedList(vq,quantTypes);
for(int j = 0; j < quantifier.size(); j++) {
// cout << " eliminating "
// << quantifier[j] << " " << quantTypes[quantifier[j]] <<
endl;
vector<string> partial;
//cout << vl[0].toString() << endl;
partial = readTypedList(vl, predicateTypes);
for(int p = 0; p < partial.size(); p++) {
if(partial[p][0] != '?')
::error("invalid spec: illegal parameter" + partial[p]);
if (partial[p] == quantifier[j]) {
// cout << " match of " << partial[p]
// << " in " << l[1].toString() << endl;
LispEntity pred(l[1].getList()[0].getString());
// cout << " substituted by " ;
for(map<string,string>::iterator pos =
objectTypes.begin(); pos != objectTypes.end(); ++pos) {
string obj = (string &) pos->first;
if (objectTypes[obj] == quantTypes[quantifier[j]]) {
vector<LispEntity> comb;
comb.push_back(pred);
for(int q = 0; q < partial.size(); q++) {
if (partial[q] == quantifier[j]) {
// cout << " " << obj;
LispEntity ob(obj);
comb.push_back(ob);
}
else {
LispEntity ob(partial[q]);
comb.push_back(ob);
}
}
LispEntity instance(comb);
back.push_back(instance);
// cout << " for instance " << instance.toString() << endl;
}
}
}
}
}
return back;
}
vector<LispEntity> TypeEngine::unrollList(vector<LispEntity> in) {
vector<LispEntity> back;
for(int i = 0; i < in.size(); i++) {
if (in[i].getList()[0].getString() == "forall") {
vector<LispEntity> u = unroll(in[i]);
for (int j=0;j<u.size();j++)
back.push_back(u[j]);
}
else {
back.push_back(in[i]);
}
}
return back;
}
ActionDescription *
TypeEngine::readDurative(vector<LispEntity> in, string name) {
map<string,int> parameters;
// cout << "durative action to be checked" << endl;
int j = 2;
int count = 1;
if(j + 1 < in.size() && in[j].getString() == ":parameters") {
vector<LispEntity> le = in[j + 1].getList();
vector<string> actions = readTypedList(le,actionTypes);
// second step: check structure
for(int k = 0; k < actions.size(); k++)
if(actions[k][0] != '?')
::error("illegal parameter" + actions[j]);
for(int k = 0; k < actions.size(); k++) {
if(parameters.count(actions[k]))
::error("doubly defined parameter: " + actions[k]);
parameters[actions[k]] = k;
}
j += 2;
}
if(in[j].getString() != ":duration")
::error("duration missing: " + name);
else
j += 2;
if(in[j].getString() != ":condition")
::error("condition missing: " + name);
else
j += 2;
if(in[j].getString() != ":effect")
::error("effect missing: " + name);
else
j += 2;
if(j < in.size())
::error("invalid durative action specification: " + name);
// cout << "durative action checked" << endl;
return new
ActionDescription(name,in[j-5],in[j-3],in[j-1],*this,
parameters,actionTypes,domain);
}
ActionDescription *
TypeEngine::readNormal(vector<LispEntity> in, string name) {
map<string,int> parameters;
// cout << "usual action to be checked" << endl;
int j = 2;
int count = 1;
if(j + 1 < in.size() && in[j].getString() == ":parameters") {
vector<LispEntity> le = in[j + 1].getList();
vector<string> actions = readTypedList(le,actionTypes);
// second step: check structure
for(int k = 0; k < actions.size(); k++)
if(actions[k][0] != '?')
::error("illegal parameter" + actions[j]);
for(int k = 0; k < actions.size(); k++) {
if(parameters.count(actions[k]))
::error("doubly defined parameter: " + actions[k]);
parameters[actions[k]] = k;
}
j += 2;
}
if(in[j].getString() != ":precondition")
; // ::error("preconditions missing: " + name);
else
j += 2;
if(in[j].getString() != ":effect")
::error("effect missing: " + name);
else
j += 2;
if(j < in.size())
::error("invalid action specification: " + name);
// cout << "usual action checked" << endl;
return new
ActionDescription(name,in[j-3],in[j-1],*this,
parameters,actionTypes,domain);
}
vector<ActionDescription *>
TypeEngine::readActionDef(vector<LispEntity> in) {
vector<ActionDescription *> result;
for(int i = 0; i < in.size(); i++) {
LispEntity le = in[i];
// cout << "action " << i << ". " << le.toString() << endl;
if(le.isString()
|| le.getList().size() == 0
|| le.getList()[0].isList()
|| (le.getList()[0].getString() != ":action"
&& le.getList()[0].getString() != ":durative-action"))
::error("action specification expected");
vector<LispEntity> &vec = le.getList();
if(vec.size() == 1 || vec[1].isList())
::error("invalid action: no name given");
string name = vec[1].getString();
if(options.debug(Options::PARSING))
cout << " action " << i << ". " << name << endl;
if (vec[0].getString() == ":durative-action")
result.push_back(readDurative(vec,name));
else
result.push_back(readNormal(vec,name));
allActionTypes.insert(make_pair(name,actionTypes));
actionTypes.clear();
}
return result;
}
// string TypeEngine::Inherits(string name) {
// return inherits[name];
// }
string TypeEngine::toString() {
if(!typing)
return "no typing";
string back = " Type hierarchy:\n";
for(TypeMap::iterator pos = inherits.begin(); pos != inherits.end();
++pos) {
back += " " + pos->first;
for(string base = pos->second; base != ""; base = inherits[base])
back += " <- " + base;
back += '\n';
}
back += " Object mapping:\n";
for(TypeMap::iterator pos = objectTypes.begin(); pos !=
objectTypes.end(); ++pos) {
back += " " + pos->first;
for(string base = pos->second; base != ""; base = inherits[base])
back += " <- " + base;
back += '\n';
}
return back;
}
- g++ assembler problem,
Allyson <=