Add parser support for VHDL's procedure call
Parse procedure calls and put them into abstract syntax tree. Elaboration and emission still has to be done.
This commit is contained in:
parent
721f9d5d9b
commit
ad31eaaea8
|
|
@ -21,6 +21,7 @@
|
|||
# include "entity.h"
|
||||
# include "architec.h"
|
||||
# include "expression.h"
|
||||
# include "parse_types.h"
|
||||
# include "vsignal.h"
|
||||
# include "vtype.h"
|
||||
# include <fstream>
|
||||
|
|
@ -339,3 +340,9 @@ void ExpUNot::dump(ostream&out, int indent) const
|
|||
out << setw(indent) << "" << "not() at " << get_fileline() << endl;
|
||||
dump_operand1(out, indent+4);
|
||||
}
|
||||
|
||||
void named_expr_t::dump(ostream&out, int indent) const
|
||||
{
|
||||
out << setw(indent) << "" << name_ << "=>";
|
||||
expr_->dump(out, indent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ const VType*parse_type_by_name(perm_string name)
|
|||
|
||||
%type <sequ_list> sequence_of_statements if_statement_else
|
||||
%type <sequ> sequential_statement if_statement signal_assignment_statement
|
||||
%type <sequ> case_statement
|
||||
%type <sequ> case_statement procedure_call procedure_call_statement
|
||||
|
||||
%type <case_alt> case_statement_alternative
|
||||
%type <case_alt_list> case_statement_alternative_list
|
||||
|
|
@ -1194,6 +1194,32 @@ primary_unit
|
|||
| package_declaration
|
||||
;
|
||||
|
||||
procedure_call
|
||||
: IDENTIFIER
|
||||
{
|
||||
ProcedureCall* tmp = new ProcedureCall(lex_strings.make($1));
|
||||
sorrymsg(@1, "Procedure calls are not supported.\n");
|
||||
$$ = tmp;
|
||||
}
|
||||
| IDENTIFIER '(' association_list ')'
|
||||
{
|
||||
ProcedureCall* tmp = new ProcedureCall(lex_strings.make($1), $3);
|
||||
sorrymsg(@1, "Procedure calls are not supported.\n");
|
||||
$$ = tmp;
|
||||
}
|
||||
| IDENTIFIER '(' error ')'
|
||||
{
|
||||
errormsg(@1, "Errors in procedure call.\n");
|
||||
yyerrok;
|
||||
delete[]$1;
|
||||
$$ = 0;
|
||||
};
|
||||
|
||||
procedure_call_statement
|
||||
: IDENTIFIER ':' procedure_call { $$ = $3; }
|
||||
| procedure_call { $$ = $1; }
|
||||
;
|
||||
|
||||
process_statement
|
||||
: IDENTIFIER ':' K_postponed_opt K_process
|
||||
process_sensitivity_list_opt K_is_opt
|
||||
|
|
@ -1363,6 +1389,7 @@ sequential_statement
|
|||
: if_statement { $$ = $1; }
|
||||
| signal_assignment_statement { $$ = $1; }
|
||||
| case_statement { $$ = $1; }
|
||||
| procedure_call_statement { $$ = $1; }
|
||||
;
|
||||
|
||||
shift_expression : simple_expression { $$ = $1; } ;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
|
||||
# include "StringHeap.h"
|
||||
class Expression;
|
||||
# include "expression.h"
|
||||
|
||||
class named_expr_t {
|
||||
|
||||
|
|
@ -29,6 +29,7 @@ class named_expr_t {
|
|||
|
||||
perm_string name() const { return name_; }
|
||||
Expression* expr() const { return expr_; }
|
||||
void dump(ostream&out, int indent) const;
|
||||
private:
|
||||
perm_string name_;
|
||||
Expression* expr_;
|
||||
|
|
|
|||
|
|
@ -133,3 +133,22 @@ CaseSeqStmt::CaseStmtAlternative::CaseStmtAlternative(Expression* exp, list<Sequ
|
|||
{
|
||||
if (stmts) stmts_.splice(stmts_.end(), *stmts);
|
||||
}
|
||||
|
||||
ProcedureCall::ProcedureCall(perm_string name)
|
||||
: name_(name), param_list_(0)
|
||||
{
|
||||
}
|
||||
|
||||
ProcedureCall::ProcedureCall(perm_string name, std::list<named_expr_t*>* param_list)
|
||||
: name_(name), param_list_(param_list)
|
||||
{
|
||||
}
|
||||
|
||||
ProcedureCall::~ProcedureCall()
|
||||
{
|
||||
while(param_list_->size() > 0) {
|
||||
named_expr_t* cur = param_list_->front();
|
||||
param_list_->pop_front();
|
||||
delete cur;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
# include "LineInfo.h"
|
||||
# include "parse_types.h"
|
||||
# include <list>
|
||||
|
||||
class Architecture;
|
||||
|
|
@ -134,4 +135,18 @@ class CaseSeqStmt : public SequentialStmt {
|
|||
Expression* cond_;
|
||||
std::list<CaseStmtAlternative*> alt_;
|
||||
};
|
||||
|
||||
class ProcedureCall : public SequentialStmt {
|
||||
public:
|
||||
ProcedureCall(perm_string name);
|
||||
ProcedureCall(perm_string name, std::list<named_expr_t*>* param_list);
|
||||
~ProcedureCall();
|
||||
|
||||
int elaborate(Entity*ent, Architecture*arc);
|
||||
int emit(ostream&out, Entity*entity, Architecture*arc);
|
||||
void dump(ostream&out, int indent) const;
|
||||
private:
|
||||
perm_string name_;
|
||||
std::list<named_expr_t*>* param_list_;
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -99,3 +99,13 @@ void CaseSeqStmt::CaseStmtAlternative::dump(ostream& out, int indent) const
|
|||
; cur != stmts_.end(); ++cur)
|
||||
(*cur)->dump(out, indent+1);
|
||||
}
|
||||
|
||||
void ProcedureCall::dump(ostream& out, int indent) const
|
||||
{
|
||||
out << setw(indent) << "" << "ProcedureCall at file=" << get_fileline() << endl;
|
||||
out << setw(indent+2) << "" << name_ << "(";
|
||||
for(list<named_expr_t*>::const_iterator it = param_list_->begin();
|
||||
it != param_list_->end(); ++it)
|
||||
(*it)->dump(out, indent);
|
||||
out << ")" << endl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,3 +88,8 @@ int SignalSeqAssignment::elaborate(Entity*ent, Architecture*arc)
|
|||
|
||||
return errors;
|
||||
}
|
||||
|
||||
int ProcedureCall::elaborate(Entity*, Architecture*)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,3 +98,11 @@ int SignalSeqAssignment::emit(ostream&out, Entity*ent, Architecture*arc)
|
|||
|
||||
return errors;
|
||||
}
|
||||
|
||||
int ProcedureCall::emit(ostream&out, Entity*, Architecture*)
|
||||
{
|
||||
out << " // " << get_fileline() << ": internal error: "
|
||||
<< "I don't know how to emit this sequential statement! "
|
||||
<< "type=" << typeid(*this).name() << endl;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue