Add String Expression to the VHDL parser
This commit is contained in:
parent
88760b9982
commit
721f9d5d9b
|
|
@ -313,6 +313,16 @@ void ExpRelation::dump(ostream&out, int indent) const
|
|||
dump_operands(out, indent+4);
|
||||
}
|
||||
|
||||
void ExpString::dump(ostream&out, int indent) const
|
||||
{
|
||||
out << setw(indent) << "" << "String \"";
|
||||
for(vector<char>::const_iterator it = value_.begin();
|
||||
it != value_.end(); ++it)
|
||||
out << *it;
|
||||
out << "\""
|
||||
<< " at " << get_fileline() << endl;
|
||||
}
|
||||
|
||||
void ExpUAbs::dump(ostream&out, int indent) const
|
||||
{
|
||||
out << setw(indent) << "" << "abs() at " << get_fileline() << endl;
|
||||
|
|
|
|||
|
|
@ -291,6 +291,17 @@ ExpRelation::~ExpRelation()
|
|||
{
|
||||
}
|
||||
|
||||
ExpString::ExpString(const char* value)
|
||||
: value_(strlen(value))
|
||||
{
|
||||
for(unsigned i=0; i<strlen(value); ++i)
|
||||
value_.push_back(value[i]);
|
||||
}
|
||||
|
||||
ExpString::~ExpString()
|
||||
{
|
||||
}
|
||||
|
||||
ExpUAbs::ExpUAbs(Expression*op1)
|
||||
: ExpUnary(op1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -367,6 +367,20 @@ class ExpRelation : public ExpBinary {
|
|||
fun_t fun_;
|
||||
};
|
||||
|
||||
class ExpString : public Expression {
|
||||
|
||||
public:
|
||||
explicit ExpString(const char*);
|
||||
~ExpString();
|
||||
|
||||
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
|
||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||
void dump(ostream&out, int indent = 0) const;
|
||||
|
||||
private:
|
||||
std::vector<char> value_;
|
||||
};
|
||||
|
||||
class ExpUAbs : public ExpUnary {
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -268,3 +268,10 @@ int ExpRelation::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
|
|||
errors += elaborate_exprs(ent, arc, ltype);
|
||||
return errors;
|
||||
}
|
||||
|
||||
int ExpString::elaborate_expr(Entity*, Architecture*, const VType*ltype)
|
||||
{
|
||||
assert(ltype != 0);
|
||||
set_type(ltype);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -339,6 +339,16 @@ int ExpRelation::emit(ostream&out, Entity*ent, Architecture*arc)
|
|||
return errors;
|
||||
}
|
||||
|
||||
int ExpString::emit(ostream& out, Entity*ent, Architecture*arc)
|
||||
{
|
||||
out << "\"";
|
||||
for(vector<char>::const_iterator it = value_.begin();
|
||||
it != value_.end(); ++it)
|
||||
out << *it;
|
||||
out << "\"";
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ExpUAbs::emit(ostream&out, Entity*ent, Architecture*arc)
|
||||
{
|
||||
int errors = 0;
|
||||
|
|
|
|||
|
|
@ -1172,6 +1172,12 @@ primary
|
|||
FILE_NAME(tmp, @1);
|
||||
$$ = tmp;
|
||||
}
|
||||
| STRING_LITERAL
|
||||
{ ExpString*tmp = new ExpString($1);
|
||||
FILE_NAME(tmp,@1);
|
||||
delete[]$1;
|
||||
$$ = tmp;
|
||||
}
|
||||
| BITSTRING_LITERAL
|
||||
{ ExpBitstring*tmp = new ExpBitstring($1);
|
||||
FILE_NAME(tmp, @1);
|
||||
|
|
|
|||
Loading…
Reference in New Issue