/****************************************************************************** * * Copyright (C) 2014 by M. Kreis * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * */ options { JAVA_UNICODE_ESCAPE = true; OUTPUT_LANGUAGE = "c++"; NAMESPACE = "vhdl::parser"; STATIC=false; PARSER_INCLUDE="vhdljjparser.h"; TOKEN_MANAGER_INCLUDE="vhdlstring.h"; // TOKEN_MANAGER_USES_PARSER = true; TOKEN_MANAGER_SUPER_CLASS = "TokenParser"; // DEBUG_PARSER = true; //OUTPUT_DIRECTORY = "."; //DEBUG_PARSER=true; //DEBUG_LOOKAHEAD=true; } PARSER_BEGIN(VhdlParser) struct SharedState { std::shared_ptr current_root; std::shared_ptr tempEntry; std::shared_ptr lastEntity; std::shared_ptr lastCompound; std::shared_ptr current; QCString compSpec; QCString currName; int levelCounter = 0; QCString confName; QCString genLabels; QCString lab; int param_sec = 0; int parse_sec = 0; int currP = 0; }; VHDLOutlineParser *m_outlineParser; SharedState *m_sharedState; void setOutlineParser(VHDLOutlineParser* p) { m_outlineParser=p; } VHDLOutlineParser *outlineParser() const { return m_outlineParser; } void setSharedState(SharedState *s) { m_sharedState=s; } void clearError() { hasError = false; } //typedef unsigned long long uint64; //---------------------------------------- //void setLineParsed(int tok); //int getLine(int tok); //int getLine(); //void lineCount(const char*); //void lineCount(); //void outlineParser()->addProto(const char *s1,const char *s2,const char *s3,const char *s4,const char *s5,const char *s6); //void addConfigureNode(const char* a,const char*b, bool,bool isLeaf,bool inlineConf); //void createFunction(const char *impure,uint64 spec,const char *fname); //void outlineParser()->addVhdlType(const char *n,int startLine,int section, uint64 spec,const char* args,const char* type,Protection prot); //void outlineParser()->addCompInst(const char *n, const char* instName, const char* comp,int iLine); //void handleCommentBlock(const char* doc,bool brief); //void handleFlowComment(const char*); //void initEntry(Entry *e); //void outlineParser()->newEntry(); //bool isFuncProcProced(); //void pushLabel(QCString &,QCString&); //QCString popLabel(QCString & q); //bool addLibUseClause(const QCString &type); //void mapLibPackage( Entry* root); //void createFlow(); //void outlineParser()->error_skipto(int kind); //void oneLineComment(QCString qcs); //void setMultCommentLine(); PARSER_END(VhdlParser) SKIP : { " " | "\t" | "\n" {parser->outlineParser()->lineCount();} | "\r" } SKIP: { // VHDL comment -- ...... // VHDL doxygen line comment --! .... <#DOXYGEN_VHDL_COMMENT: (" "|"\t")*"--!"(~["\n", "\r"])* ("\n" | "\r" | "\r\n")?> | )+ > { { QCString doc(image.data()); int count=doc.contains("--!"); parser->outlineParser()->setMultCommentLine(); parser->outlineParser()->lineCount(image.data()); if (count == 1) parser->outlineParser()->oneLineComment(doc); else parser->outlineParser()->handleCommentBlock(QCString(image),FALSE); ; } } | { parser->outlineParser()->handleFlowComment(image.data());} | { parser->outlineParser()->lineCount(image.data());} } // VHDL 2008 comment /* .... */ // VHDL 2008 doxygen comment /*! .... */ SKIP : { { { QCString q = filter2008VhdlComment(image.data()); parser->outlineParser()->lineCount(image.data()); parser->outlineParser()->handleCommentBlock(QCString(q),TRUE);image.clear(); } } | { parser->outlineParser()->lineCount(image.data());image.clear();} } /* KEYWORDS */ TOKEN [IGNORE_CASE] : { | | | {parser->outlineParser()->setLineParsed(ALIAS_T);} | | | {parser->outlineParser()->setLineParsed(ARCHITECTURE_T);} | {parser->outlineParser()->setLineParsed(ARRAY_T);} | | | | {parser->outlineParser()->setLineParsed(ATTRIBUTE_T);} | | | {parser->outlineParser()->setLineParsed(BODY_T);} | | | {parser->outlineParser()->setLineParsed(COMPONENT_T);} | | {parser->outlineParser()->setLineParsed(CONFIGURATION_T);} | {parser->outlineParser()->setLineParsed(CONSTANT_T);} | {parser->outlineParser()->setLineParsed(CONTEXT_T);} | | | | | | | {parser->outlineParser()->setLineParsed(END_T);} | {parser->outlineParser()->setLineParsed(ENTITY_T);} | | | {parser->outlineParser()->setLineParsed(FILE_T);} | | | {parser->outlineParser()->setLineParsed(FUNCTION_T);} | | | {parser->outlineParser()->setLineParsed(GROUP_T);} | | | | | | | | | {parser->outlineParser()->setLineParsed(LIBRARY_T);} | | | | | | | | | | | | | | | | | | {parser->outlineParser()->setLineParsed(PACKAGE_T);} | | {parser->outlineParser()->setLineParsed(PORT_T);} | | {parser->outlineParser()->setLineParsed(PROCEDURE_T);} | {parser->outlineParser()->setLineParsed(PROCESS_T);} | | | | | {parser->outlineParser()->setLineParsed(RECORD_T);} | | | | | | | | | | | | | | {parser->outlineParser()->setLineParsed(SIGNAL_T);} | | | | | | | {parser->outlineParser()->setLineParsed(SUBTYPE_T);} | | | | {parser->outlineParser()->setLineParsed(TYPE_T);} | | {parser->outlineParser()->setLineParsed(UNITS_T);} | | | | | | | | | | | | } /* OPERATORS */ TOKEN : { < AMPERSAND_T: "&" > | < APOSTROPHE_T: "'" > | < LPAREN_T: "(" > | < RPAREN_T: ")" > | < DOUBLEMULT_T: "**" > | < MULT_T: "*" > | < PLUS_T: "+" > | < MINUS_T: "-" > | < COMMA_T: "," > | < VARASSIGN_T: ":=" > | < COLON_T: ":" > | < SEMI_T: ";" >{parser->outlineParser()->setLineParsed(SEMI_T);} | < LESSTHAN_T: "<=" > | < GREATERTHAN_T: ">=" > | < LT_T: "<" > | < GT_T: ">" > | < EQU_T: "=" > | < NOTEQU_T: "/=" > | < ARROW_T: "=>" > | < BOX_T: "<>" > | < SLSL_T: "<<" > | < RSRS_T: ">>" > | < QQ_T: "??" > | < QGT_T: "?>=" > | < QLT_T: "?<=" > | < QG_T: "?>" > | < QL_T: "?<" > | < QEQU_T: "?=" > | < QNEQU_T: "?/=" > | < Q_T: "?" > | < BAR_T: "|" > | | < SLASH_T: "/" > | < AT_T: "@" > | < NEG_T: "^" > | < LBRACKET_T: "[" > | < RBRACKET_T: "]" > | < LBRACE: "{" > | < RBRACE: "}" > } TOKEN: { ((["_"])? ())* > | )*) "\"")+ > | ( (["_"])* )*) > | )*["\\"] ) > | |)["'"]) > | (["."])? ()? ) > | ( )* > | ["#"](["."] )? ["#"] ()? > | <#EXPONENT: (["e","E"] (["+","-"])? ()+) > | < #BASIC_GRAPHIC_CHARACTER: (|||) > | < #GRAPHIC_CHARACTER: ( || ) > | < #LETTER_OR_DIGIT: ( | ) > | < #LETTER_OR_DIGIT_OR_STD: ( | ) > | < #LETTER: (|) > | < #UPPER_CASE_LETTER: ["A"-"Z"] > | )*["\""](((["_"])*)*)["\""] > | <#BASE_SPECIFIER: ()*(["S","U"])*["B","O","X","b","o","x","d","D"] > | <#STD_LOGIC:["0","1","L","H","X","Z","W","-","l","h","x","z","w"]> | < #DIGIT: ["0"-"9"] > | < #SPECIAL_CHARACTER: ["#","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","_","|"] > | < #OTHER_SPECIAL_CHARACTER: ["%","!","$","@","?","[","\\","]","^","`","{","}","~","\u00A0"-"\u00FF"]> | < #SPACE_CHARACTER: [" ","\t"] > | < #LOWER_CASE_LETTER: ["a"-"z"] > | < #QUOTE: ["\""] > | |)+ > | )["'"]) > } QCString abstract_literal() : {Token *tok;} { tok= { return QCString(tok->image); } | tok= { return QCString(tok->image); } | tok= { return QCString(tok->image); } } QCString access_type_definition() : {Token *tok=0;QCString str,str1;} { tok= str1=subtype_indication() { str=tok->image; return str+str1; } } QCString actual_designator() : {QCString str;Token *t=0;} { t= { return QCString(t->image); } | LOOKAHEAD(expression()) str=expression() { return str; } | str=identifier(){return str;} } QCString actual_parameter_part() : {QCString s;} { s=association_list() { return s;} } QCString actual_part() : {QCString s,s1;} { LOOKAHEAD(actual_designator()) s=actual_designator() { return s;} | { return "<>";} | LOOKAHEAD(name() ) s=name() s1=actual_designator() {s+="(";s+=s1+")";return s;} } QCString adding_operator () : {} { { return "+";} | { return "-";} | { return "&";} } QCString aggregate() : {QCString s,s1,s2;} { s=element_association() ( s1=element_association(){s+=","+s1;})* { return QCString("("+s+")");} } QCString alias_declaration() : {QCString s,s1,s2;} { s2=alias_designator() [ { s+=":"; } s1=subtype_indication() { s+=s1; }] { s+=" is "; } s1=name() {s+=s1;} [s1=signature() {s+=s1;}] { outlineParser()->addVhdlType(s2.data(),outlineParser()->getLine(ALIAS_T),Entry::VARIABLE_SEC,VhdlDocGen::ALIAS,0,s.data(),Public); return s2+" "+s+";"; } } QCString alias_designator() : {Token *tok=0;QCString s;} { s=identifier() { return s;} | tok= { return QCString(tok->image); } | s=operator_symbol() { return s; } } void allocator() :{} { LOOKAHEAD(3) qualified_expression() | subtype_indication() } void architecture_body() : {QCString s,s1;} { s=identifier() s1=name() { QCString t=s1+"::"+s; m_sharedState->genLabels.resize(0); outlineParser()->pushLabel(m_sharedState->genLabels,s1); m_sharedState->lastCompound=m_sharedState->current; outlineParser()->addVhdlType(t.data(),outlineParser()->getLine(ARCHITECTURE_T),Entry::CLASS_SEC,VhdlDocGen::ARCHITECTURE,0,0,Private); } try { architecture_declarative_part() } catch(...) { outlineParser()->error_skipto(BEGIN_T); } architecture_statement_part() [] [name()] { m_sharedState->lastEntity=0;m_sharedState->lastCompound=0; m_sharedState->genLabels.resize(0); } } void architecture_declarative_part() : {} { (block_declarative_item() )* // | () } void architecture_statement_part() : {} { (concurrent_statement())* // | () } QCString array_type_definition (): { QCString s;} { LOOKAHEAD( index_constraint() ) s=constraint_array_definition() {return s;} | s=unconstraint_array_definition() {return s;} } QCString assertion() : {QCString s,s1,s2;Token *t=0;Token *t1=0;} { s=condition() [ t= s1=expression() ] [t1= s2=expression()] { s.prepend("assert "); if(t) s1.prepend(" report "); if(t1) s2.prepend(" report "); return s+s1+s2; } } QCString assertion_statement() : {QCString s,s1,s2;Token *t=0;} { [ s=label() t= ] s1=assertion() { if(t) s+=":"; return s+s1+";"; } } QCString association_element() : {QCString s,s1;} { [LOOKAHEAD(formal_part() ) s=formal_part() ] s1=actual_part() { return s+" => "+s1;} } QCString association_list (): {QCString s,s1;} { s=association_element() ( s1=association_element() { s+=","+s1; })* { return s; } } QCString attribute_declaration() : {QCString s,s1;} { s=identifier() s1=type_mark() { outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(ATTRIBUTE_T),Entry::VARIABLE_SEC,VhdlDocGen::ATTRIBUTE,0,s1.data(),Public); return " attribute "+s+":"+s1+";"; } } QCString attribute_designator (): {QCString s;Token *tok=0;} { s=identifier() { return s;} | tok= { return QCString(tok->image); } } QCString attribute_name (): {QCString s,s1;} { s=identifier() ( | s1=name()) { s+=s1; }[LOOKAHEAD(1)s1=expression() {s+=s1;}] { return s; } } QCString attribute_specification(): {QCString s,s1,s2;} { s=attribute_designator() s1=entity_specification() s2=expression() { QCString t= s1+" is "+s2; outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(ATTRIBUTE_T),Entry::VARIABLE_SEC,VhdlDocGen::ATTRIBUTE,0,t.data(),Public); return " attribute "+s+" of "+s1+ " is "+s2+";"; } } QCString base() : {Token *tok=0;} { tok= { return QCString(tok->image);} } QCString base_specifier (): {Token *tok=0;} { tok= { return QCString(tok->image);} } QCString base_unit_declaration() : {QCString s;} { s=identifier() { return s; } } QCString based_integer() : {Token *tok=0;} { tok= { return QCString(tok->image);} } QCString based_literal(): {Token *tok=0;} { tok= { return QCString(tok->image);} } QCString basic_identifier() : {Token *tok=0;} { tok= { return QCString(tok->image);} } void binding_indication() : {} { [ entity_aspect() ] [ generic_map_aspect() ] [ port_map_aspect() ] } QCString bit_string_literal (): {Token *tok=0;} { tok= { return QCString(tok->image);} } QCString bit_value() : {Token *tok=0;} { tok= { return QCString(tok->image);} } void block_configuration() : {} { block_specification() ( use_clause() )* ( configuration_item())* } void block_declarative_item (): {} { subprogram_declaration() | type_declaration() | subtype_declaration() | constant_declaration() | signal_declaration() | variable_declaration() | file_declaration() | alias_declaration() | component_declaration() | LOOKAHEAD(attribute_declaration()) attribute_declaration() | attribute_specification() | configuration_specification() | disconnection_specification () | use_clause() | LOOKAHEAD(3) group_template_declaration() | group_declaration() //| } void block_declarative_part() : {} { (block_declarative_item() )* } void block_header() : {} { [LOOKAHEAD(generic_clause()) generic_clause()[ generic_map_aspect() ] ] [ port_clause() [ port_map_aspect() ] ] } void block_specification() : {} { name() [ index_specification() ] } void block_statement() : {QCString s;} { s=identifier() { outlineParser()->pushLabel(m_sharedState->genLabels,s); }[ expression() ] [ ] block_header() block_declarative_part() block_statement_part() [ identifier() ] { m_sharedState->genLabels=outlineParser()->popLabel(m_sharedState->genLabels); } } void block_statement_part() : {} { ( concurrent_statement() )* } void case_statement() : {QCString s;} { [ identifier() [] ] s=expression() { QCString ca="case "+s; FlowChart::addFlowChart(FlowChart::CASE_NO,QCString(),ca); } case_statement_alternative() ( case_statement_alternative ())* [ identifier() ] { FlowChart::moveToPrevLevel(); FlowChart::addFlowChart(FlowChart::END_CASE,"end case",QCString()); } } void case_statement_alternative() : {QCString s;} { s=choices() { QCString t("when "); t+=s+"=> "; FlowChart::addFlowChart(FlowChart::WHEN_NO,s,t); } sequence_of_statement(){FlowChart::moveToPrevLevel(); } } QCString character_literal() : {Token *tok=0;} { tok={ return QCString(tok->image);} } QCString choice() : {QCString s;} { LOOKAHEAD(simple_expression() direction ()) s=range() { return s;} | LOOKAHEAD(simple_expression()) s=simple_expression(){ return s; } | LOOKAHEAD(discrete_range()) s=discrete_range(){ return s; } | s=identifier(){ return s; } | { return " others "; } } QCString choices() : {QCString s,s1;} { s=choice() ( s1=choice(){s+="|";s+=s1;})* { return s; } } void component_configuration () :{} { component_specification() [ binding_indication() ] [ block_configuration() ] } void component_declaration() : {QCString s;} { s=identifier() [ ] { m_sharedState->currP=VhdlDocGen::COMPONENT; } [ generic_clause() ] [ port_clause() ] { outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(COMPONENT_T),Entry::VARIABLE_SEC,VhdlDocGen::COMPONENT,0,0,Public); m_sharedState->currP=0; } [ identifier() ] } void component_instantiation_statement() : {QCString s,s1;} { s=identifier() s1=instantiation_unit() { QCString s3; if (s1.contains("|")) { s3=VhdlDocGen::getIndexWord(s1,0); s1=VhdlDocGen::getIndexWord(s1,1); } outlineParser()->addCompInst(s.lower().data(),s1.lower().data(),s3.data(),outlineParser()->getLine()); } [ LOOKAHEAD(generic_map_aspect()) generic_map_aspect() ] [ port_map_aspect() ] } void component_specification() : {} { instantiation_list() name() } QCString composite_type_definition() : { QCString s,s1;} { s=array_type_definition(){ return s; } | record_type_definition(){ return s+"#"; } } void concurrent_assertion_statement() : {} { [ LOOKAHEAD(2) identifier() ] [ ] assertion() } void concurrent_procedure_call_statement() : {} { [ LOOKAHEAD(2) identifier() ] [ ] procedure_call() } void concurrent_signal_assignment_statement() : {} { [ LOOKAHEAD(2) identifier() ] [ ] ( LOOKAHEAD(conditional_signal_assignment() ) conditional_signal_assignment() | selected_signal_assignment() ) } void concurrent_statement() : {} { // try { LOOKAHEAD([identifier() ":"] ) block_statement() | LOOKAHEAD([identifier() ":"] [] ) process_statement() | LOOKAHEAD(3) generate_statement() | case_scheme() | LOOKAHEAD([identifier() ":"] [] ) concurrent_assertion_statement() | LOOKAHEAD(concurrent_signal_assignment_statement()) concurrent_signal_assignment_statement() | LOOKAHEAD(component_instantiation_statement() ) component_instantiation_statement() | LOOKAHEAD(concurrent_procedure_call_statement()) concurrent_procedure_call_statement() | } QCString condition() : {QCString s;} { s=expression() { return s; } } QCString condition_clause() : {QCString s;} { s=condition() { return " until "+s; } } void conditional_signal_assignment() : {} { // LOOKAHEAD( target() "<=" options_() conditional_waveforms() ";") target() options() conditional_waveforms() } void conditional_waveforms() : {} { waveform() ( LOOKAHEAD( condition() ) condition() waveform() )* [ condition() ] } void configuration_declaration() : {QCString s,s1;} { s=identifier() s1=name() { m_sharedState->confName=s+"::"+s1; outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(CONFIGURATION_T),Entry::VARIABLE_SEC,VhdlDocGen::CONFIG,"configuration",s1.data(),Public); } configuration_declarative_part() block_configuration() [ ] [ name() ] { m_sharedState->genLabels.resize(0); m_sharedState->confName="";} } void configuration_declarative_item() : {} { use_clause() | attribute_specification() | group_declaration() } void configuration_declarative_part() : {} { (configuration_declarative_item())* } void configuration_item (): {} { LOOKAHEAD(component_configuration()) component_configuration() | block_configuration() } void configuration_specification() : {} { component_specification() binding_indication() } QCString constant_declaration() : {QCString s,s1,s2;Token *t=0;} { s=identifier_list() s1= subtype_indication() [ t= s2=expression() ] { if(t) s2.prepend(":="); QCString it=s1+s2; outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(CONSTANT_T),Entry::VARIABLE_SEC,VhdlDocGen::CONSTANT,0,it.data(),Public); it.prepend("constant "); return it; } } QCString constraint_array_definition (): {QCString s,s1;} { s=index_constraint() s1=subtype_indication(){ return s+" "+s1;} } void context_clause (): {} { (LOOKAHEAD(3) context_item())* } QCString constraint () :{QCString s;} { LOOKAHEAD(range_constraint()) s=range_constraint(){ return s;} | LOOKAHEAD(index_constraint()) s=index_constraint(){ return s;} } void context_item() : {} { library_clause() | use_clause() | LOOKAHEAD(context_declaration()) context_declaration() | context_ref() } QCString decimal_literal() : {Token *tok=0;} { tok= { return QCString(tok->image); } } QCString delay_mechanism (): {QCString s;} { { return " transport ";} | [ s=expression() {s.prepend(" reject ");}] { return s+" inertial "; } } void design_file() : {} { (design_unit() )+ {} | } void design_unit() : {} { context_clause()library_unit() } QCString designator() : {QCString s;} { s=identifier() {return s;} | s=operator_symbol(){return s;} } QCString direction (): {Token *tok=0;} { tok= { return QCString(tok->image);} | tok= { return QCString(tok->image);} } void disconnection_specification() : {} { guarded_signal_specificatio() expression() } void guarded_signal_specificatio() : {} { signal_list() name() } QCString discrete_range() : {QCString s;} { LOOKAHEAD(range()) s=range() { return s;} | LOOKAHEAD(subtype_indication()) s=subtype_indication() { return s;} } QCString element_association() : {QCString s,s1;} { [LOOKAHEAD(choices() ) s=choices() ] s1=expression() { if(!s.isEmpty()) return s+"=>"+s1; return s1; } } QCString element_declaration() : {QCString rec_name,s1,s2;} { rec_name=identifier_list() s1=subtype_indication() { auto ql = split(rec_name.str(),","); for (const auto &n : ql) { std::string name=n+"~"; name+=outlineParser()->getNameID().data(); outlineParser()->addVhdlType( name.c_str(),outlineParser()->getLine(), Entry::VARIABLE_SEC, VhdlDocGen::RECORD,0, s1.data(), Public); } s2=rec_name+":"+s1; return s2; } } QCString entity_aspect() : {Token *tok=0;QCString s,s1;} { tok= s=name() [ LOOKAHEAD(1) s1=identifier() {s+="("+s1+")";} ] { return s;} | tok= s=name() { return QCString(tok->image)+s;} | tok= { return QCString(tok->image); } } QCString entity_class() : {} { { return "entity";} | {return "architecture";} | {return "configuration";} | {return "procedure";} | {return "function";} | {return "package";} | {return "type";} | {return "subtype";} | {return "constant";} | {return "signal";} | {return "variable";} | {return "component";} | {return "label";} | {return "literal";} | {return "units";} | {return "group";} | {return "file";} } QCString entity_class_entry() : {QCString s;} { s=entity_class() [ {s+="<>";} ] { return s;} } QCString entity_class_entry_list() : {QCString s,s1,s2;} { ( s1=entity_class_entry() {s+=s1;} )( s=entity_class_entry(){s2+=",";s2+=s;} )* { return s1+s2;} } void entity_declaration() : {QCString s;} { // try{ s=identifier() { m_sharedState->lastEntity=m_sharedState->current; m_sharedState->lastCompound=0; outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(ENTITY_T),Entry::CLASS_SEC,VhdlDocGen::ENTITY,0,0,Public); } entity_header() entity_declarative_part () [ entity_statement_part() ] [ ] [ name() ] // }catch(...){outlineParser()->error_skipto(SEMI_T);} { m_sharedState->lastEntity=0;m_sharedState->lastCompound=0; m_sharedState->genLabels.resize(0); } } void entity_declarative_item() : {} { subprogram_declaration() //| subprogram_body() | type_declaration() | subtype_declaration() | constant_declaration() | signal_declaration() | variable_declaration() | file_declaration() | alias_declaration() | LOOKAHEAD(attribute_declaration()) attribute_declaration() | attribute_specification() | disconnection_specification() | use_clause() | LOOKAHEAD(3) group_template_declaration() | group_declaration() | LOOKAHEAD(5) package_instantiation_declaration() |package_declaration() | } void entity_declarative_part() : {} { (entity_declarative_item() )* } QCString entity_designator() : {QCString s,s1;} { s=entity_tag() [ s1=signature() ] { return s+s1;} } void entity_header() : {} { [ { m_sharedState->currP=VhdlDocGen::GENERIC;m_sharedState->parse_sec=GEN_SEC; } generic_clause()] [ { m_sharedState->currP=VhdlDocGen::PORT; } port_clause()] } QCString entity_name_list() : {QCString s,s1,s2;} { (s1=entity_designator() ) ( s=entity_designator() { s2+=s; } )* { return s2;} | { return "other";} | {return "all";} } QCString entity_specification() : {QCString s,s1;} { s=entity_name_list() s1=entity_class(){ return s+":"+s1;} } void entity_statement() : {} { LOOKAHEAD(concurrent_assertion_statement()) concurrent_assertion_statement() | LOOKAHEAD(process_statement()) process_statement() | concurrent_procedure_call_statement() } void entity_statement_part() : {} { (entity_statement())* } QCString entity_tag (): {QCString s;} { s=name() { return s;} | s=character_literal() { return s;} } QCString enumeration_literal() : {QCString s;} { s=identifier() { return s;} | s=character_literal() { return s;} } QCString enumeration_type_definition() : {QCString s,s1;} { s=enumeration_literal() (LOOKAHEAD(1) s1=enumeration_literal() {s+=",";s+=s1;} )* { return "("+s+")";} } QCString exit_statement() : {QCString s,s1,s2;Token *t=0;Token *t1=0;} { [ s=identifier() t= ] [ s1=identifier() ] [ t1= s2=condition() ] { m_sharedState->lab.resize(0); if(t) s+=":"; if(t1) s2.prepend(" when "); FlowChart::addFlowChart(FlowChart::EXIT_NO,"exit",s2,s1); return s+s1+s2+";"; } } QCString expression (): {QCString s,s1,s2;} { s=relation() ( s1=logop() s2=relation() {s+=s1;s+=s2;} )* { return s; } } QCString logop() : {} { { return "and" ;} | { return "nand" ;} | { return "nor" ;} | { return "xnor" ;} | { return "xor" ;} | { return "or" ;} } QCString extended_identifier (): {Token *t;} { t= { return QCString(t->image); } } QCString factor(): {QCString s,s1;} { s=primary() [LOOKAHEAD(1) s1=primary(){ s+="**";s+=s1;} ] { return s;} | s=primary(){ s1 = "abs "; return s1+s; } | s=primary(){s1="not ";return s1+s;} | s=primary(){s1="?? ";return s1;} | s=logop() s1=primary() { return s;} } QCString file_declaration() : {QCString s,s1,s2,s3;} { s=identifier_list() s2=subtype_indication() [ s3=file_open_information() ] { QCString t1=s2+" "+s3; outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(),Entry::VARIABLE_SEC,VhdlDocGen::VFILE,0,t1.data(),Public); return " file "+s+":"+s2+" "+s3+";"; } } QCString file_logical_name(): {QCString s;} { s=expression() { return s; } } QCString file_open_information() : {QCString s,s1,s2;} { [ s=expression() ] [inout_stat()] s1=file_logical_name() {s2="open "+s+" is "+s1; return s2; } } QCString file_type_definition() : {QCString s,s1;} { s=type_mark() { s1=" file of "+s; return s1;} } QCString floating_type_definition() : {QCString s;} { s=range_constraint(){ return s;} } QCString formal_designator() : {QCString s;Token *tok=0;} { s=name() { return s; } |tok= { return QCString(tok->image);} } QCString formal_parameter_list() : {QCString s;} { s=interface_list(){ return s; } } QCString formal_part() : {QCString s,s1;} { s=name() [ formal_designator() {s+"("+s1+")";}] {return s;} } QCString full_type_declaration() : { std::shared_ptr tmpEntry;QCString s,s1,s2; } { s=identifier() { tmpEntry=m_sharedState->current; outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(),Entry::VARIABLE_SEC,VhdlDocGen::RECORD,0,0,Public); } s2=type_definition() { if (s2.contains("#")) { VhdlDocGen::deleteAllChars(s2,'#'); tmpEntry->spec=VhdlDocGen::RECORD; tmpEntry->type=s2.data(); } else if (s2.contains("%")) { VhdlDocGen::deleteAllChars(s2,'%'); tmpEntry->spec=VhdlDocGen::UNITS; tmpEntry->type=s2.data(); } else { tmpEntry->spec=VhdlDocGen::TYPE; tmpEntry->type=s2.data(); } tmpEntry.reset(); return "type "+s+" is "+s2+";"; } } QCString function_call() : {QCString s,s1;} { s=name() s1=actual_parameter_part() { return s+"("+s1+")";} } void generate_statement() : {QCString s;} { s=identifier() try{ generate_scheme() { outlineParser()->pushLabel(m_sharedState->genLabels,s); } generate_statement_body1() }catch(...){outlineParser()->error_skipto(GENERATE_T);} [ identifier() ] {m_sharedState->genLabels=outlineParser()->popLabel(m_sharedState->genLabels); } } void generate_scheme() : {} { parameter_specification() | [LOOKAHEAD(2) identifier() ] condition() } void generic_clause() : {QCString s;} { { m_sharedState->parse_sec=GEN_SEC; } s=generic_list() { m_sharedState->parse_sec=0; } } QCString generic_list() : {QCString s;} { s=interface_list() { return s; } } void generic_map_aspect() : {} { association_list() } QCString group_constituent() : {QCString s;} { s=name() { return s; } | s=character_literal() { return s;} } QCString group_constituent_list() : {QCString s,s1,s2;} { (s1=group_constituent())( s=group_constituent(){s2+=",";s2+=s1;})* { return s+s2;} } QCString group_declaration() : {QCString s,s1,s2;} { s=identifier() s1=identifier() s2=group_constituent_list() { return "group "+s+":"+s1+"("+s2+");"; } } QCString group_template_declaration() : {QCString s,s1;} { s=identifier() s1=entity_class_entry_list() { return "group "+s+ "is ("+s1+");"; } } void guarded_signal_specification() : {} { signal_list() type_mark() } QCString identifier() : {Token *tok=0;} { tok={ return QCString(tok->image); } |tok= { return QCString(tok->image); } } QCString identifier_list() : {QCString str,str1;} { str=name() ( str1=name() {str+=",";str+=str1;})* { return str; } } void if_statement() : {QCString s,s1;} { [LOOKAHEAD(1) identifier() ] s=condition() { s.prepend("if "); FlowChart::addFlowChart(FlowChart::IF_NO,QCString(),s); } sequence_of_statement() ( s1=condition() { s1.prepend("elsif "); FlowChart::addFlowChart(FlowChart::ELSIF_NO,QCString(),s1); } sequence_of_statement() )* [LOOKAHEAD(1) { FlowChart::addFlowChart(FlowChart::ELSE_NO,QCString(),QCString()); } sequence_of_statement() ] [ identifier() ] { FlowChart::moveToPrevLevel(); FlowChart::addFlowChart(FlowChart::ENDIF_NO,QCString(),QCString()); } } QCString incomplete_type_declaration() : {QCString s;} { s=identifier() { return "type "+s+";"; } } QCString index_constraint() : {QCString s("("); QCString s1,s2;} { s2=discrete_range(){s+=s2;}(LOOKAHEAD(1) s1=discrete_range(){s+=",";s+=s1;})* {return s+")";} } QCString index_specification() : {QCString s;} { LOOKAHEAD( discrete_range()) s=discrete_range() { return s;} | s=expression(){ return s;} } QCString index_subtype_definition() : {QCString s;} { s=type_mark() { return s+" range <> ";} } QCString instantiation_unit() : {QCString s,s1,s2;} { [ ] s=identifier() {s1="component "; return s; } | [LOOKAHEAD(2) ] s2=name() {s="entity|"+s2;} [ s1=identifier() {s+="(";s+=s1;s+=")" ;}] { return s;} | s=name() {s1="configuration ";return s;} } QCString instantiation_list() : {QCString s;Token *tok=0;} { s=identifier_list() { return s;} | tok= {return QCString(tok->image);} | tok= {return QCString(tok->image);} } QCString integer() : {Token *t;} { t= {return QCString(t->image);} } QCString integer_type_definition() : {QCString s;} { s=range_constraint(){ return s;} } QCString interface_declaration() : {QCString s,s1;} { LOOKAHEAD(5) s=interface_subprogram_declaration() { return s;} | LOOKAHEAD(5) interface_package_declaration() { return s;} | LOOKAHEAD(5) s=interface_variable_declaration() { return s;} | LOOKAHEAD(5) interface_file_declaration() { return s;} | LOOKAHEAD(subprogram_declaration()) subprogram_declaration() { return s;} | s=object_class() s1=identifier() { if (m_sharedState->parse_sec==GEN_SEC) outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(),Entry::VARIABLE_SEC,m_sharedState->currP,s1.data(),0,Public); return s; } } QCString interface_element() : {QCString s;} { s=interface_declaration(){ return s;} } QCString interface_file_declaration() : {QCString s,s1;} { s=identifier_list() s1=subtype_indication() { outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(),Entry::VARIABLE_SEC,VhdlDocGen::VFILE,0,s1.data(),Public); return QCString(" file "+s+":"+s1); } } QCString interface_list() : {QCString s,s1,s2;} { s=interface_element() (LOOKAHEAD(1) s1=interface_element(){s2+=";";s2+=s1;})* { return s+s2;} } QCString interface_variable_declaration() : {Token *tok=0;Token *tok1=0;Token *tok2=0;QCString s,s1,s2,s3,s4,s5;} { [ ( tok= | tok= | tok=|tok=) ] s=identifier_list() [ s1=mode() ] s2=subtype_indication() [ tok1= ] [ tok2= s4=expression() ] { if(tok) s5=QCString(tok->image); if(tok1) s3=tok1->image.data(); if(tok2) s3+=":="; QCString it=s+":"+s1+" "+s2+" "+s3+" "+s4; if (m_sharedState->currP!=VhdlDocGen::COMPONENT) { if (m_sharedState->currP==VhdlDocGen::FUNCTION || m_sharedState->currP==VhdlDocGen::PROCEDURE) { outlineParser()->addProto(s5.data(),s.data(),s1.data(),s2.data(),s3.data(),s4.data()); } else { QCString i=s2+s3+s4; if (m_sharedState->currP==VhdlDocGen::GENERIC && m_sharedState->param_sec==0) outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(),Entry::VARIABLE_SEC,m_sharedState->currP,i.data(),s1.data(),Public); else if(m_sharedState->parse_sec != GEN_SEC) outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(),Entry::VARIABLE_SEC,m_sharedState->currP,i.data(),s1.data(),Public); } // fprintf(stderr,"\n\n <>\n",$$.data()); } // if component return it; } } QCString iteration_scheme() : {QCString s;} { s=condition() { s.prepend("while "); FlowChart::addFlowChart(FlowChart::WHILE_NO,QCString(),s,m_sharedState->lab); m_sharedState->lab=""; return s; } | s=parameter_specification() { QCString q=m_sharedState->lab+" for "+s; FlowChart::addFlowChart(FlowChart::FOR_NO,QCString(),q,m_sharedState->lab); m_sharedState->lab=""; return q; } } QCString label() : {QCString s;} { s=identifier() { return s;} } QCString library_clause() : {QCString s;} { ( s=identifier_list() ) { if ( m_sharedState->parse_sec==0 && Config_getBool(SHOW_INCLUDE_FILES) ) { outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(),Entry::VARIABLE_SEC,VhdlDocGen::LIBRARY,s.data(),"_library_",Public); } QCString s1="library "+s; return s1; } } QCString library_unit() : {QCString s;} { LOOKAHEAD(2) primary_unit() { return s; } | secondary_unit() { return s; } } QCString literal() : {QCString s;} { LOOKAHEAD(bit_string_literal()) s=bit_string_literal() { return s;} | LOOKAHEAD(numeric_literal()) s=numeric_literal() { return s;} | LOOKAHEAD(enumeration_literal()) s=enumeration_literal() { return s;} | s=string_literal() { return s;} | {return "null";} } QCString logical_operator() : {QCString s;} { s=logop() { return s;} } QCString loop_statement() : {QCString s,s1,s2,s3;} { [ s=identifier() {s+=":";} ] [ s1=iteration_scheme() ] { if(s1.isEmpty()) FlowChart::addFlowChart(FlowChart::LOOP_NO,QCString(),"infinite"); } s2=sequence_of_statement() [ s3=identifier() ] { QCString q = s+" loop "+s2+" end loop" +s3; QCString endLoop="end loop" + s3; FlowChart::moveToPrevLevel(); FlowChart::addFlowChart(FlowChart::END_LOOP,endLoop,QCString()); return q; } } QCString miscellaneous_operator():{Token *t=0;} { { return "**"; } | { return "abs"; } | { return "not"; } } QCString mode() : {Token *tok=0;} { tok= { return "in"; } | tok= { return "out"; } | tok= { return "inout"; } | tok= { return "buffer"; } | tok= { return "linkage"; } } QCString multiplying_operation() : {Token *tok=0;} { tok= { return QCString(tok->image); } | tok= { return QCString(tok->image); } | tok= { return QCString(tok->image); } | tok= { return QCString(tok->image); } } QCString name() : {QCString s,s1;} { ( s=operator_symbol() [LOOKAHEAD(name_ext1()) s1=name_ext1(){ s+=s1;}] { return s; } |s=external_name() [LOOKAHEAD(name_ext1()) s1=name_ext1(){ s+=s1;}] { return s; } | s=identifier() [LOOKAHEAD(name_ext1()) s1=name_ext1(){ s+=s1;}] { return s; } ) } QCString name_ext1() : {QCString s,s1,s2;} { s=name_ext() (LOOKAHEAD(name_ext()) s1=name_ext(){s+=s1;})* { return s;} } QCString name_ext() : {QCString s,s1,s2;} { ( LOOKAHEAD() {s+="'subtype"; return s;} | LOOKAHEAD( suffix()) s1=suffix(){s+=".";s+=s1; return s;} | LOOKAHEAD(test_att_name()) s1=test_att_name() { s+=s1;return s;} | LOOKAHEAD( discrete_range() ) s1=discrete_range() {s+="(";s+=s1;s+=")";return s;} | LOOKAHEAD( "(" expression() ("," expression() )* ")" ) s1=expression() {s+="(";s+=s1;} (LOOKAHEAD(1) s1=expression(){s+=",";s+=s1;})* { s+=")";return s;} ) } QCString test_att_name() : {QCString s,s1;} { [ LOOKAHEAD() s1=signature() {s=s1;}] s1=attribute_designator() {s+="'";s+=s1;} [LOOKAHEAD(1) s1=expression() {s+="(";s+=s1;s+=")";}] { return s;} } QCString indexed_name() : {QCString s,s1,s2;} { s2=identifier() s1=expression(){s=s2+"("+s1;} ( s1=expression(){s+=",";s+=s1;})* {return s+")";} } QCString next_statement() : {QCString s,s1,s2;Token *t=0;Token *t1=0;} { [ s=identifier() t= ] [ s1=identifier() ] [ t1= s2=condition() ] { if(t) s+=":"; FlowChart::addFlowChart(FlowChart::NEXT_NO,"next ",s2,s1); m_sharedState->lab.resize(0); if(t1) s2.prepend("when "); return s+s1+s2+";"; } } QCString null_statement() : {QCString s;} { [ s=identifier() {s+=":";}] {return s+="null";} } QCString numeric_literal() : {QCString s;} { LOOKAHEAD(physical_literal()) s=physical_literal(){ return s;} | s=abstract_literal() { return s;} } QCString object_class() : {} { { return "constant"; } | { return "signal"; } | { return "variable"; } | { return "shared variable"; } | { return "file"; } | { return "type"; } } QCString operator_symbol() : {Token *tok=0;} { tok= {return QCString(tok->image);} } void options() : {} { [ ] [ delay_mechanism() ] } void package_body() : {QCString s;} { s=name() { m_sharedState->lastCompound=m_sharedState->current; s.prepend("_"); outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(),Entry::CLASS_SEC,VhdlDocGen::PACKAGE_BODY,0,0,Protected); } package_body_declarative_part() [ ] [ name() ] { m_sharedState->lastCompound=0; m_sharedState->genLabels.resize(0); } } void package_body_declarative_item() : {} { subprogram_declaration() | type_declaration() | subtype_declaration() | constant_declaration() | variable_declaration() | file_declaration() | alias_declaration() | use_clause() | LOOKAHEAD(3) group_template_declaration() | group_declaration() } void package_body_declarative_part() : {} { (package_body_declarative_item() )* } void package_header(): {QCString s;} { [ generic_clause() [ generic_map_aspect() ] ] } void package_declaration(): {QCString s;} { s=identifier() { m_sharedState->lastCompound=m_sharedState->current; std::shared_ptr clone=std::make_shared(*m_sharedState->current); clone->section=Entry::NAMESPACE_SEC; clone->spec=VhdlDocGen::PACKAGE; clone->name=s; clone->startLine=outlineParser()->getLine(PACKAGE_T); clone->bodyLine=outlineParser()->getLine(PACKAGE_T); clone->protection=Package; m_sharedState->current_root->moveToSubEntryAndKeep(clone); outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(PACKAGE_T),Entry::CLASS_SEC,VhdlDocGen::PACKAGE,0,0,Package); } package_header() package_declarative_part() [ ] [ name() ] { m_sharedState->lastEntity=0;m_sharedState->lastCompound=0; m_sharedState->genLabels.resize(0); } } void geninter():{} { [gen_interface_list() [gen_assoc_list() ]] } void package_declarative_item() : {} { subprogram_declaration() | type_declaration() | subtype_declaration() | constant_declaration() | signal_declaration() | variable_declaration() | file_declaration() | alias_declaration() | component_declaration() | LOOKAHEAD(attribute_declaration()) attribute_declaration() | attribute_specification() | disconnection_specification() | use_clause() | LOOKAHEAD(3) group_template_declaration() | group_declaration() | LOOKAHEAD(5) package_instantiation_declaration() |package_declaration() } void package_declarative_part() : {} { (package_declarative_item())* } QCString parameter_specification() : {QCString s,s1;} { s=identifier() s1=discrete_range(){ return s+" in "+s1;} } QCString physical_literal() : {QCString s,s1;} { [LOOKAHEAD(abstract_literal()) s=abstract_literal()] s1=name(){s+=" ";s+=s1;s.prepend(" "); return s;} } QCString physical_type_definition() : {QCString s,s1,s2;Token *t=0;} { t= s=identifier() { outlineParser()->addVhdlType(s.data(),t->beginLine,Entry::VARIABLE_SEC,VhdlDocGen::UNITS,0,0,Public);} ( s1=secondary_unit_declaration() )* [name()] { return s;} } void port_clause() : {} { port_list() { m_sharedState->currP=0; } } QCString port_list() : {QCString s;} { s=interface_list(){return s;} } void port_map_aspect() : {} { association_list() } QCString primary() : {QCString s,s1;} { LOOKAHEAD(function_call()) s=function_call() { return s;} | LOOKAHEAD( expression() ) s1=expression() { s="("+s1+")"; return s;} | LOOKAHEAD(qualified_expression()) s=qualified_expression() { return s;} | LOOKAHEAD(type_conversion()) s=type_conversion() { return s;} | LOOKAHEAD(literal()) s=literal() { s.prepend(" ");return s;} | LOOKAHEAD(name()) s=name() { return s;} | LOOKAHEAD(allocator()) allocator() { return QCString();} | s=aggregate() { return s; } } void primary_unit() : {} { entity_declaration() | configuration_declaration() | LOOKAHEAD(package_instantiation_declaration()) package_instantiation_declaration() | LOOKAHEAD(4) interface_package_declaration() | package_declaration() | context_declaration() } QCString procedure_call() : {QCString s,s1;} { s=name() [ s1=actual_parameter_part() { s1.prepend("("); s1.append(")");}] { return s+s1;} } QCString procedure_call_statement() : {QCString s,s1;} { [LOOKAHEAD(2) s=identifier() { s+=":"; }] s1=procedure_call() { return s+s1+";"; } } QCString process_declarative_item() : {QCString s;} { subprogram_declaration() { return QCString();} //| subprogram_body() | s=type_declaration() { return s;} | s=subtype_declaration() { return s;} | s=constant_declaration() { return s;} | s=variable_declaration() { return s;} | s=file_declaration() { return s;} | s=alias_declaration() { return s;} | LOOKAHEAD(3) s=attribute_declaration() { return s;} | s=attribute_specification() { return s;} | s=use_clause() { return s;} | LOOKAHEAD(3) s=group_template_declaration() { return s;} | s=group_declaration() { return s;} } QCString process_declarative_part() :{QCString s,s1;} { ( s1=process_declarative_item(){s+=s1;} )* { return s;} } void process_statement() : {QCString s,s1,s2;Token *tok=0;Token *tok1=0;} { [ s=identifier() ] [ ] tok1= { m_sharedState->currP=VhdlDocGen::PROCESS; m_sharedState->current->startLine=tok1->beginLine; m_sharedState->current->bodyLine=tok1->beginLine; } [ (s1=sensitivity_list() ) ] [ ] s2=process_declarative_part() { if (s2.data()) FlowChart::addFlowChart(FlowChart::VARIABLE_NO,s2,QCString()); FlowChart::addFlowChart(FlowChart::BEGIN_NO,"BEGIN",QCString()); } process_statement_part() [ ] [ identifier() ] { if(s.isEmpty()) m_sharedState->currName=VhdlDocGen::getProcessNumber(); else m_sharedState->currName=s; m_sharedState->current->name=m_sharedState->currName; m_sharedState->tempEntry=m_sharedState->current; m_sharedState->tempEntry->type=""; m_sharedState->current->endBodyLine=outlineParser()->getLine(); m_sharedState->currP=0; if(tok) s1=tok->image; outlineParser()->createFunction(m_sharedState->currName.data(),VhdlDocGen::PROCESS,s1.data()); outlineParser()->createFlow(); m_sharedState->currName=""; outlineParser()->newEntry(); } } void process_statement_part() : {} { (sequential_statement())* } QCString qualified_expression() : {QCString s,s1;} { s1=identifier() {s=s1+"'";} ( LOOKAHEAD(aggregate()) s1=aggregate(){s+=s1;} | s1=expression() {s+="(";s+=s1;s+=")";} ) {return s;} } QCString range() : {QCString s,s1,s2;} { LOOKAHEAD( simple_expression() direction() simple_expression()) s=simple_expression() s1=direction() s2=simple_expression(){return s+" "+s1+" "+s2;} | LOOKAHEAD(attribute_name()) s=attribute_name(){ return s;} } QCString range_constraint() : {QCString s,s1;} { s=range(){return " range "+s;} } void record_type_definition() : {} { // try{ (element_declaration())+ // }catch(...){outlineParser()->error_skipto(END_T);} [ name()] } QCString relation() : {QCString s,s1,s2;} { s=shift_expression() [LOOKAHEAD(1) s1=relation_operator() s2=shift_expression() ] {return s+s1+s2;} } QCString relation_operator() : {} { {return "<";} | {return ">";} | {return "=";} | {return ">=";} | {return "<=";} | {return "/=";} | { return "?>=";} | { return "?<=";} | { return "?>";} | { return "?<";} | { return "?=";} | {return "?/="; } } QCString report_statement() : {Token *t=0;Token *t1=0;QCString s,s1,s2;} { [ s=identifier() t= ] s1=expression() [ t1= s2=expression() ] { if(t) s.append(":"); s1.prepend(" report "); if(t1) s2.prepend(" severity "); return s+s1+s2+";"; } } QCString return_statement() : {QCString s,s1;} { [ s=identifier() { s+=":";}] [ s1=expression() ] { return s+" return "+s1+";";} } QCString scalar_type_definition() : {QCString s,s1;} { LOOKAHEAD(enumeration_type_definition()) s=enumeration_type_definition(){ return s;} | s=range_constraint() [ s1=physical_type_definition()] { return s+" "+s1;} } void secondary_unit() : {} { architecture_body() | package_body() } QCString secondary_unit_declaration() : {QCString s,s1;Token *t1=0;} { s=identifier() t1= s1=physical_literal() { outlineParser()->addVhdlType(s.data(),t1->beginLine,Entry::VARIABLE_SEC,VhdlDocGen::UNITS,0,s1.data(),Public); return s+"="+s1; } } QCString selected_name() : {QCString s,s1;} { s=identifier() s1=suffix(){ return s+"."+s1;} } void selected_signal_assignment() : {} { expression() target() < LESSTHAN_T> options() selected_waveforms() } void selected_waveforms() : {} { waveform() choices()( waveform() choices())* } QCString sensitivity_clause() : {QCString s;} { s=sensitivity_list() { s.prepend(" on "); return s; } } QCString sensitivity_list() : {QCString s,s1;Token* tok=0;} { tok= { if(tok) return "all" ;} | s=name() ( s1=name(){s+=",";s+=s1;} )* { return s;} } QCString sequence_of_statement() : {QCString s,s1;} { ( LOOKAHEAD(3) s1=sequential_statement() {s+=s1;} )* { return s;} } QCString sequential_statement() :{QCString s;} { LOOKAHEAD( [ identifier() ":" ] target() "<=") s=signal_assignment_statement(){FlowChart::addFlowChart(FlowChart::TEXT_NO,s,QCString());return s;} | LOOKAHEAD(3) s=assertion_statement(){FlowChart::addFlowChart(FlowChart::TEXT_NO,s,QCString());return s;} | LOOKAHEAD(3) s=report_statement(){FlowChart::addFlowChart(FlowChart::TEXT_NO,s,QCString());return s;} | LOOKAHEAD(3) s=wait_statement(){FlowChart::addFlowChart(FlowChart::TEXT_NO,s,QCString());return s;} | LOOKAHEAD( [ identifier() ":" ] target() ":=" ) s=variable_assignment_statement(){FlowChart::addFlowChart(FlowChart::TEXT_NO,s,QCString());return s;} | LOOKAHEAD(3) s=procedure_call_statement(){ FlowChart::addFlowChart(FlowChart::TEXT_NO,s,QCString());return s; } | LOOKAHEAD(3) if_statement(){return s;} | LOOKAHEAD(3) case_statement(){return s;} | LOOKAHEAD(3) loop_statement(){return s;} | LOOKAHEAD(3) s=next_statement() {return s;} | LOOKAHEAD(3) s=exit_statement(){return s;} | LOOKAHEAD(3) s=return_statement(){FlowChart::addFlowChart(FlowChart::RETURN_NO,s,QCString());return s;} | s=null_statement(){FlowChart::addFlowChart(FlowChart::TEXT_NO,s,QCString());return s;} } QCString shift_expression() : {QCString s,s1,s2;} { s=simple_expression() [ s1=shift_operator() s2=simple_expression() ] { return s+s1+s2;} } QCString shift_operator() : {} { { return "sll";} | { return "srl";} | { return "sla";} | { return "sra";} | { return "rol";} | { return "ror";} } QCString sign() : {} { { return "+";} | { return "-";} } QCString signal_assignment_statement() : {QCString s,s1,s2,s3;} { LOOKAHEAD(conditional_signal_assignment_wave()) conditional_signal_assignment_wave(){ return QCString(); } | LOOKAHEAD(selected_signal_assignment_wave()) selected_signal_assignment_wave() { return QCString(); } | [LOOKAHEAD(2) s=identifier() {s+=":";} ] s1=target() [ s2=delay_mechanism() ] s3=waveform() { return s+s1+"<="+s2+s3+";"; } } void semi() : {} { } void signal_declaration() : { Token* tok=0;QCString s,s1,s2,s3,s4;} { s=identifier_list() s1=subtype_indication() [ s2=signal_kind() ] [ tok= s3=expression() ] { if(tok) s3.prepend(":="); s4=s1+s2+s3; outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(),Entry::VARIABLE_SEC,VhdlDocGen::SIGNAL,0,s4.data(),Public); } } QCString signal_kind() : {} { { return "register";} | { return "bus";} } QCString signal_list() : {QCString s,s1;} { s=name() ( s1=name() { s+=",";s+=s1;})* | { return "other";} | { return "all";} } QCString signature() : {QCString s,s1,s2;} { [ s=name() ( s1=name() {s+=",";s+=s1; })* ] [ s1=name() {s+="return ";s+=s1;}] { s1="["+s+"]";return s1;} } QCString simple_expression(): {QCString s,s1,s2;} { [ s=sign() ] s1=term() {s+=s1;} ( LOOKAHEAD(adding_operator() term()) s1=adding_operator() s2=term() {s+=s1;s+=s2;})* { return s;} } void simple_name() : {} { name() } QCString slice_name() : {QCString s,s1;} { s=identifier() s1=discrete_range() {return s+"("+s1+")";} } QCString string_literal() : {Token *tok=0;} { tok= {return QCString(tok->image);} } void subprogram_body() : {QCString s;} { //subprogram_specification() //try{ s=subprogram_declarative_part() { if (s.data()) { FlowChart::addFlowChart(FlowChart::VARIABLE_NO,s,QCString()); } FlowChart::addFlowChart(FlowChart::BEGIN_NO,"BEGIN",QCString()); } // }catch(...){outlineParser()->error_skipto(BEGIN_T);} subprogram_statement_part() [ subprogram_kind() ] [ designator() ] { m_sharedState->tempEntry->endBodyLine=outlineParser()->getLine(END_T); outlineParser()->createFlow(); m_sharedState->currP=0; } } void subprogram_declaration() : {} { LOOKAHEAD(subprogram_instantiation_declaration()) subprogram_instantiation_declaration() | subprogram_specification()subprogram_1(){m_sharedState->currP=0;} } void subprogram_1() : {} { subprogram_body() | } QCString subprogram_declarative_item() : {QCString s;} { subprogram_declaration(){ return QCString();} |s=type_declaration(){ return s;} | subprogram_body(){ return QCString();} | s=subtype_declaration(){ return s;} | s=constant_declaration(){ return s;} | s=variable_declaration(){ return s;} | s=file_declaration(){ return s;} | s=alias_declaration(){ return s;} | LOOKAHEAD(attribute_declaration()) s=attribute_declaration(){ return s;} | s=attribute_specification(){ return s;} | s=use_clause(){ return s;} | LOOKAHEAD(3) s=group_template_declaration(){ return s;} | s=group_declaration() { return s;} } QCString subprogram_declarative_part() : {QCString s,s1;} { (s1=subprogram_declarative_item(){s+=s1;})* { return s;} } void subprogram_kind() : {} { | } void subprogram_specification() : {QCString s;Token *tok=0;Token *t;} { s=designator() { m_sharedState->currP=VhdlDocGen::PROCEDURE; outlineParser()->createFunction(s.data(),m_sharedState->currP,0); m_sharedState->tempEntry=m_sharedState->current; m_sharedState->current->startLine=outlineParser()->getLine(PROCEDURE_T); m_sharedState->current->bodyLine=outlineParser()->getLine(PROCEDURE_T); } [LOOKAHEAD(1) { m_sharedState->param_sec=PARAM_SEC; } interface_list() { m_sharedState->param_sec=0; } ] [LOOKAHEAD(2) gen_interface_list()] [ LOOKAHEAD(2) gen_assoc_list()] param() { outlineParser()->newEntry(); } | [ (tok= | tok=) ] t= s=designator() { m_sharedState->currP=VhdlDocGen::FUNCTION; if(tok) outlineParser()->createFunction(tok->image.c_str(),m_sharedState->currP,s.data()); else outlineParser()->createFunction(0,m_sharedState->currP,s.data()); m_sharedState->tempEntry=m_sharedState->current; m_sharedState->current->startLine=outlineParser()->getLine(FUNCTION_T); m_sharedState->current->bodyLine=outlineParser()->getLine(FUNCTION_T); } [{ m_sharedState->param_sec=PARAM_SEC; } formal_parameter_list() { m_sharedState->param_sec=0; }] s=type_mark() { m_sharedState->tempEntry=m_sharedState->current; m_sharedState->current->type=s; outlineParser()->newEntry(); } } void subprogram_statement_part() : {} { (sequential_statement())* } QCString subtype_declaration() : {QCString s,s1;} { s=identifier() s1=subtype_indication() { outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(),Entry::VARIABLE_SEC,VhdlDocGen::SUBTYPE,0,s1.data(),Public); return " subtype "+s+" is "+s1+";"; } } QCString reslution_indication(): {QCString s;} { s=expression() { return "("+s+")"; } // |s=name() { return s;} } //[LOOKAHEAD (reslution_indication()) s=reslution_indication()] // [ resolution_indication ] type_mark [ constraint ] QCString subtype_indication() : {QCString s,s1,s2;} { [LOOKAHEAD(5) s=reslution_indication()] (s1=name())+ [LOOKAHEAD(constraint() ) s2=constraint()] {return s+" "+s1+" "+s2;} } QCString suffix() : { QCString s; } { LOOKAHEAD(name()) s=name() { return s;} | s=character_literal() { return s;} | s=operator_symbol(){ return s;} | {return " all ";} } QCString target() : { QCString s; } { s=name(){ return s;} | s=aggregate() { return s;} } QCString term() : { QCString s,s1,s2; } { s=factor() ( LOOKAHEAD(2) s1=multiplying_operation() s2=factor(){s+=s1;s+=s2;} )* { return s;} } QCString timeout_clause() : { QCString s; } { s=expression() { return " for "+s; } } QCString type_conversion() : {QCString s,s1;} { s=name() s1=expression() { return s+"("+s1+")";} } QCString type_declaration() : {QCString s;} { LOOKAHEAD(3) s=full_type_declaration(){ return s;} | s=incomplete_type_declaration(){ return s;} } QCString type_definition() : {QCString s;} { s=scalar_type_definition(){ return s;} | s=composite_type_definition(){ return s;} | s=access_type_definition(){ return s;} | s=file_type_definition(){ return s;} | LOOKAHEAD(2) protected_type_body() { return QCString(); } | protected_type_declaration() { return QCString(); } } QCString type_mark() : {QCString s; } { s=name() { return s;} } QCString unconstraint_array_definition() : {QCString s,s1,s2,s3;} { s=index_subtype_definition() ( s1=index_subtype_definition(){s3+=",";s3+=s1;})* s2=subtype_indication() {return "array("+s+s3+") of "+s2;} } QCString use_clause() : {QCString s,s1;} { s=selected_name()( s1=selected_name(){s+=",";s+=s1;})* { auto ql1=split(s.str(),","); for (const auto &name : ql1) { auto ql2=split(name,"."); if (ql2.size()>1) { std::string it=ql2[1]; if ( m_sharedState->parse_sec==0 && Config_getBool(SHOW_INCLUDE_FILES) ) { outlineParser()->addVhdlType(it.c_str(), outlineParser()->getLine(), Entry::VARIABLE_SEC, VhdlDocGen::USE, it.c_str(), "_use_",Public); } } } s1="use "+s; return s1; } } QCString variable_assignment_statement() : {QCString s,s1,s2;} { [LOOKAHEAD(2) s=identifier() {s+=":";}] s1=target() s2=expression() {return s+s1+":="+s2+";";} | selected_variable_assignment() { return QCString(); } } QCString variable_declaration() : {Token *tok=0;Token *t1=0;QCString s,s1,s2;} { [ tok= ] s=identifier_list() s1=subtype_indication() [ t1= s2=expression() ] { int spec; if(t1) s2.prepend(":="); QCString val=" variable "+s+":"+s1+s2+";"; QCString it=s1; if(tok != 0) { it.prepend(" shared "); val.prepend(" shared"); spec=VhdlDocGen::SHAREDVARIABLE; } else spec=VhdlDocGen::SHAREDVARIABLE; if(t1) { it+=":="; it+=s2; } outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(),Entry::VARIABLE_SEC,spec,0,it.data(),Public); return val; } } QCString wait_statement() : {QCString s,s1,s2,s3;Token *t=0;} { [ s=identifier() t= ] [ s1=sensitivity_clause() ] [ s2=condition_clause() ] [ s3=timeout_clause() ] { if(t) s.append(":"); return s+" wait "+s1+s2+s3+";"; } } QCString waveform() : {QCString s,s1;} { s=waveform_element() (LOOKAHEAD(1) s1=waveform_element(){s+=","; s+=s1;})* { return s;} | { return " unaffected ";} } QCString waveform_element() : {QCString s,s1;} { s=expression() [ s1=expression(){ s1.prepend(" after ");} ] { return s+s1;} // [ expression() ] } // ----------------------------------------------------------------- // VHDL 2002 // ----------------------------------------------------------------- QCString protected_type_body() :{ } { // try{ protected_type_body_declarative_part() //}catch(...){outlineParser()->error_skipto(END_T);} [identifier()] {return QCString();} } void protected_type_body_declarative_item() : { } { subprogram_declaration() | subprogram_body() | type_declaration() | subtype_declaration() | constant_declaration() | variable_declaration() | file_declaration() | alias_declaration() | LOOKAHEAD( attribute_declaration()) attribute_declaration() | attribute_specification() | use_clause() | LOOKAHEAD(3) group_template_declaration() | group_declaration() } void protected_type_body_declarative_part() :{ } { ( protected_type_body_declarative_item ())* } QCString protected_type_declaration() : { } { try{ protected_type_declarative_part() }catch(...){outlineParser()->error_skipto(END_T);} [ identifier() ] { return QCString();} } void protected_type_declarative_item(): { } { subprogram_specification() | attribute_specification() | use_clause() } void protected_type_declarative_part() : {} { (protected_type_declarative_item ())* } // ----------------------------------------------------------------- // VHDL 2008 // ----------------------------------------------------------------- QCString context_ref() : {QCString s, s1;} { s=identifier() ( s1=identifier() {s+=".";s+=s1;} )* { return "context "+s ; } } void context_declaration(): {QCString s,s1;} { s=identifier() { m_sharedState->parse_sec=CONTEXT_SEC; } (s1=libustcont_stats())* [ ][identifier()] { m_sharedState->parse_sec=0; outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(LIBRARY_T),Entry::VARIABLE_SEC,VhdlDocGen::LIBRARY,"context",s1.data(),Public); } } QCString libustcont_stats(): {QCString s;} { s=use_clause() { return s;} | s=library_clause() { return s;} | s=context_ref() { return s;} } void package_instantiation_declaration() : {QCString s,s1,s2;} { s=identifier() s1=name() s2=signature() [gen_assoc_list()] { QCString q=" is new "+s1+s2; outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(PACKAGE_T),Entry::VARIABLE_SEC,VhdlDocGen::INSTANTIATION,"package",q.data(),Public); } } QCString interface_package_declaration(): {QCString s,s1;} { s=identifier() s1=name() [gen_assoc_list()] { m_sharedState->current->name=s; return "package "+s+" is new "+s1; } } QCString subprogram_instantiation_declaration():{QCString s,s1,s2;} { s=identifier() s1=name() s2=signature() [gen_assoc_list()] { QCString q= " is new "+s1+s2; outlineParser()->addVhdlType(s.data(),outlineParser()->getLine(FUNCTION_T),Entry::VARIABLE_SEC,VhdlDocGen::INSTANTIATION,"function ",q.data(),Public); return q; } } void gen_assoc_list():{} { association_list() } void gen_interface_list() : {} { { //int u=s_str.iLine; m_sharedState->parse_sec=GEN_SEC; } interface_list() { // QCString vo=$3; m_sharedState->parse_sec=0; } } void case_scheme (): {} { expression() when_stats() [LOOKAHEAD(3) ttend()] generate_statement_body() } void when_stats() : {} { ( [LOOKAHEAD(2) label() ] choices() generate_statement_body() )+ } void ttend(): {} { [identifier()] } void generate_statement_body() : {} { [(LOOKAHEAD(block_declarative_item())block_declarative_item() )* ] (concurrent_statement())* } void generate_statement_body1() : {} { generate_statement_body() generate_scheme_1() [generate_scheme_2()] } void generate_scheme_1() : {} { ( generate_scheme_3())* } void generate_scheme_2() : {} { [LOOKAHEAD(2) identifier() ] generate_statement_body() } void generate_scheme_3() : {} { [LOOKAHEAD(2) identifier() ] expression() generate_statement_body() } QCString external_name(): {QCString s,s1,s2;} { s=sig_stat() s1=external_pathname() s2=subtype_indication() { QCString t="<<"+s; QCString t1=s1+":"+s2+">>"; return s+s1; } } QCString sig_stat(): {Token *t;} { t= { return QCString(t->image); } | t= { return QCString(t->image); } | t= { return QCString(t->image); } } QCString external_pathname(): {QCString s;} { s=absolute_pathname() { return s;} | s=relative_pathname() { return s;} | s=package_path_name() { return s;} } QCString absolute_pathname(): {QCString s,s1;} { LOOKAHEAD( pathname_element_list()) s=pathname_element_list() s1=identifier() { return "."+s+s1;} | s=identifier (){ return "."+s;} } QCString relative_pathname():{QCString s,s1,s2;} { s=neg_list() [LOOKAHEAD( pathname_element_list()) s1=pathname_element_list() ] s2=identifier() { return s+s1+s2;} } QCString neg_list(): {QCString s;} { ( {s+="^.";})+ {return s; } } QCString pathname_element ():{QCString s,s1;} { s=identifier() [ s1=expression() ] { if(!s1.isEmpty()) return s+"("+s1+")"; return s; } } QCString pathname_element_list():{QCString s,s1,s2;} { ( s=pathname_element() ) {s+=".";} (LOOKAHEAD(pathname_element() ) s1=pathname_element() {s2+=s1;s2+="."; })* { return s+s2; } } QCString package_path_name():{QCString s;} { s=name() { return "@"+s; } } void conditional_signal_assignment_wave(): {} { LOOKAHEAD(conditional_force_assignment()) conditional_force_assignment() | conditional_waveform_assignment() } void conditional_waveform_assignment():{} { target() [LOOKAHEAD(1) delay_mechanism() ] waveform_element() expression() [else_wave_list()] } void else_wave_list(): {} { expression() [ expression()] } void conditional_force_assignment(): {} { target() [inout_stat()] expression() [expression() else_stat()] } void selected_signal_assignment_wave() : {} { LOOKAHEAD(selected_force_assignment() ) selected_force_assignment() | selected_waveform_assignment() } void selected_variable_assignment():{} { expression() [] select_name() sel_var_list() // { $$=""; } } void select_name(): {} { LOOKAHEAD(aggregate()) aggregate() | name() } void selected_waveform_assignment():{} { expression() [] target() [delay_mechanism()] sel_wave_list() } void selected_force_assignment():{} { expression() [] target() [inout_stat()] sel_var_list() } void sel_var_list(): {} { (expression() choices() (|))(LOOKAHEAD(expression() ) expression() choices() (|))* } void sel_wave_list() : {} { waveform_element() choices() (LOOKAHEAD(1) sel_wave_list())* } void inout_stat(): {} { | } void else_stat(): {} { ( expression() [LOOKAHEAD(1) expression()])+ } QCString interface_subprogram_declaration(): {QCString s;} { s=iproc() { return s;} | s=ifunc() { return s; } } QCString iproc(): {QCString s,s1;} { s=identifier() s1=param() { m_sharedState->current->name=s; return "procedure "+s+s1; } } QCString ifunc():{QCString s,s1,s2,s3;Token *t=0;Token *t1=0;Token *t2=0;} { [t= | t= ] s=name() s1=param() s2=name() [t1= (s3=identifier() | t2=)] { QCString q; if(t) q=t->image.data(); if(t2) s3="<>"; if (!s3.isEmpty()) { s3.prepend(" is "); } m_sharedState->current->name=s; if (m_sharedState->parse_sec==GEN_SEC) { QCString ss=q+" function "+s1+" return "+s2+s3; int a=outlineParser()->getLine(FUNCTION_T); int b=outlineParser()->getLine(PROCEDURE_T); if (a>b) b=a; outlineParser()->addVhdlType(m_sharedState->current->name.data(),b,Entry::VARIABLE_SEC,VhdlDocGen::GENERIC,ss.data(),0,Public); } m_sharedState->currP=0;return QCString(); } } QCString param(): {QCString s,s1;Token *tok=0;} { [ tok= ] { m_sharedState->param_sec=PARAM_SEC; } [ s1=interface_list() ] { if(tok) { s = tok->image.data(); } m_sharedState->param_sec=0; return s+"("+s1+")"; } } // ----------------------------------------------------------------- // needed for inline (function/process/procedure) parsing void parseInline() : {} { process_statement() | subprogram_declaration() }