mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 11:42:30 +00:00 
			
		
		
		
	ast: ownership for string values
This commit is contained in:
		
							parent
							
								
									8a873a7724
								
							
						
					
					
						commit
						6cb789b2c2
					
				
					 2 changed files with 71 additions and 75 deletions
				
			
		|  | @ -74,12 +74,12 @@ YOSYS_NAMESPACE_END | ||||||
| 	log("Lexer warning: The SystemVerilog keyword `%s' (at %s:%d) is not "\ | 	log("Lexer warning: The SystemVerilog keyword `%s' (at %s:%d) is not "\ | ||||||
| 			"recognized unless read_verilog is called with -sv!\n", YYText(), \ | 			"recognized unless read_verilog is called with -sv!\n", YYText(), \ | ||||||
| 			AST::current_filename.c_str(), yylineno); \ | 			AST::current_filename.c_str(), yylineno); \ | ||||||
| 	string_t val = new std::string(std::string("\\") + YYText()); \ | 	string_t val = std::make_unique<std::string>(std::string("\\") + YYText()); \ | ||||||
| 	return parser::make_TOK_ID(val, out_loc); | 	return parser::make_TOK_ID(std::move(val), out_loc); | ||||||
| 
 | 
 | ||||||
| #define NON_KEYWORD() \ | #define NON_KEYWORD() \ | ||||||
| 	string_t val = new std::string(std::string("\\") + YYText()); \ | 	string_t val = std::make_unique<std::string>(std::string("\\") + YYText()); \ | ||||||
| 	return parser::make_TOK_ID(val, out_loc); | 	return parser::make_TOK_ID(std::move(val), out_loc); | ||||||
| 
 | 
 | ||||||
| // #define YY_INPUT(buf,result,max_size) \ | // #define YY_INPUT(buf,result,max_size) \ | ||||||
| // 	result = readsome(*extra->lexin, buf, max_size) | // 	result = readsome(*extra->lexin, buf, max_size) | ||||||
|  | @ -289,8 +289,8 @@ TIME_SCALE_SUFFIX [munpf]?s | ||||||
| [a-zA-Z_$][a-zA-Z0-9_$]*/[ \t\r\n]*:[ \t\r\n]*(assert|assume|cover|restrict)[^a-zA-Z0-9_$\.] { | [a-zA-Z_$][a-zA-Z0-9_$]*/[ \t\r\n]*:[ \t\r\n]*(assert|assume|cover|restrict)[^a-zA-Z0-9_$\.] { | ||||||
| 	if (!strcmp(YYText(), "default")) | 	if (!strcmp(YYText(), "default")) | ||||||
| 		return parser::make_TOK_DEFAULT(out_loc); | 		return parser::make_TOK_DEFAULT(out_loc); | ||||||
| 	string_t val = new std::string(std::string("\\") + YYText()); | 	string_t val = std::make_unique<std::string>(std::string("\\") + YYText()); | ||||||
| 	return parser::make_TOK_SVA_LABEL(val, out_loc); | 	return parser::make_TOK_SVA_LABEL(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| "assert"     { if (mode->formal) return parser::make_TOK_ASSERT(out_loc); SV_KEYWORD(parser::make_TOK_ASSERT(out_loc)); } | "assert"     { if (mode->formal) return parser::make_TOK_ASSERT(out_loc); SV_KEYWORD(parser::make_TOK_ASSERT(out_loc)); } | ||||||
|  | @ -339,35 +339,35 @@ TIME_SCALE_SUFFIX [munpf]?s | ||||||
| "packed"  { SV_KEYWORD(parser::make_TOK_PACKED(out_loc)); } | "packed"  { SV_KEYWORD(parser::make_TOK_PACKED(out_loc)); } | ||||||
| 
 | 
 | ||||||
| {UNSIGNED_NUMBER} { | {UNSIGNED_NUMBER} { | ||||||
| 	string_t val = new std::string(YYText()); | 	string_t val = std::make_unique<std::string>(YYText()); | ||||||
| 	return parser::make_TOK_CONSTVAL(val, out_loc); | 	return parser::make_TOK_CONSTVAL(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| \'[01zxZX] { | \'[01zxZX] { | ||||||
| 	string_t val = new std::string(YYText()); | 	string_t val = std::make_unique<std::string>(YYText()); | ||||||
| 	return parser::make_TOK_UNBASED_UNSIZED_CONSTVAL(val, out_loc); | 	return parser::make_TOK_UNBASED_UNSIZED_CONSTVAL(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| \'[sS]?[bodhBODH] { | \'[sS]?[bodhBODH] { | ||||||
| 	BEGIN(BASED_CONST); | 	BEGIN(BASED_CONST); | ||||||
| 	string_t val = new std::string(YYText()); | 	string_t val = std::make_unique<std::string>(YYText()); | ||||||
| 	return parser::make_TOK_BASE(val, out_loc); | 	return parser::make_TOK_BASE(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| <BASED_CONST>[0-9a-fA-FzxZX?][0-9a-fA-FzxZX?_]* { | <BASED_CONST>[0-9a-fA-FzxZX?][0-9a-fA-FzxZX?_]* { | ||||||
| 	BEGIN(0); | 	BEGIN(0); | ||||||
| 	string_t val = new std::string(YYText()); | 	string_t val = std::make_unique<std::string>(YYText()); | ||||||
| 	return parser::make_TOK_BASED_CONSTVAL(val, out_loc); | 	return parser::make_TOK_BASED_CONSTVAL(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| {FIXED_POINT_NUMBER_DEC} { | {FIXED_POINT_NUMBER_DEC} { | ||||||
| 	string_t val = new std::string(YYText()); | 	string_t val = std::make_unique<std::string>(YYText()); | ||||||
| 	return parser::make_TOK_REALVAL(val, out_loc); | 	return parser::make_TOK_REALVAL(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| {FIXED_POINT_NUMBER_NO_DEC} { | {FIXED_POINT_NUMBER_NO_DEC} { | ||||||
| 	string_t val = new std::string(YYText()); | 	string_t val = std::make_unique<std::string>(YYText()); | ||||||
| 	return parser::make_TOK_REALVAL(val, out_loc); | 	return parser::make_TOK_REALVAL(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| \"		{ BEGIN(STRING); } | \"		{ BEGIN(STRING); } | ||||||
|  | @ -407,33 +407,33 @@ TIME_SCALE_SUFFIX [munpf]?s | ||||||
| 		yystr[j++] = yystr[i++]; | 		yystr[j++] = yystr[i++]; | ||||||
| 	} | 	} | ||||||
| 	yystr[j] = 0; | 	yystr[j] = 0; | ||||||
| 	string_t val = new std::string(yystr, j); | 	string_t val = std::make_unique<std::string>(yystr, j); | ||||||
| 	free(yystr); | 	free(yystr); | ||||||
| 	return parser::make_TOK_STRING(val, out_loc); | 	return parser::make_TOK_STRING(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| and|nand|or|nor|xor|xnor|not|buf|bufif0|bufif1|notif0|notif1 { | and|nand|or|nor|xor|xnor|not|buf|bufif0|bufif1|notif0|notif1 { | ||||||
| 	auto val = new std::string(YYText()); | 	auto val = std::make_unique<std::string>(YYText()); | ||||||
| 	return parser::make_TOK_PRIMITIVE(val, out_loc); | 	return parser::make_TOK_PRIMITIVE(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| supply0 { return parser::make_TOK_SUPPLY0(out_loc); } | supply0 { return parser::make_TOK_SUPPLY0(out_loc); } | ||||||
| supply1 { return parser::make_TOK_SUPPLY1(out_loc); } | supply1 { return parser::make_TOK_SUPPLY1(out_loc); } | ||||||
| 
 | 
 | ||||||
| "$"(display[bho]?|write[bho]?|strobe|monitor|time|realtime|stop|finish|dumpfile|dumpvars|dumpon|dumpoff|dumpall) { | "$"(display[bho]?|write[bho]?|strobe|monitor|time|realtime|stop|finish|dumpfile|dumpvars|dumpon|dumpoff|dumpall) { | ||||||
| 	auto val = new std::string(YYText()); | 	auto val = std::make_unique<std::string>(YYText()); | ||||||
| 	return parser::make_TOK_ID(val, out_loc); | 	return parser::make_TOK_ID(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| "$"(setup|hold|setuphold|removal|recovery|recrem|skew|timeskew|fullskew|nochange) { | "$"(setup|hold|setuphold|removal|recovery|recrem|skew|timeskew|fullskew|nochange) { | ||||||
| 	if (!mode->specify) REJECT; | 	if (!mode->specify) REJECT; | ||||||
| 	auto val = new std::string(YYText()); | 	auto val = std::make_unique<std::string>(YYText()); | ||||||
| 	return parser::make_TOK_ID(val, out_loc); | 	return parser::make_TOK_ID(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| "$"(info|warning|error|fatal) { | "$"(info|warning|error|fatal) { | ||||||
| 	auto val = new std::string(YYText()); | 	auto val = std::make_unique<std::string>(YYText()); | ||||||
| 	return parser::make_TOK_MSG_TASKS(val, out_loc); | 	return parser::make_TOK_MSG_TASKS(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| "$signed"   { return parser::make_TOK_TO_SIGNED(out_loc); } | "$signed"   { return parser::make_TOK_TO_SIGNED(out_loc); } | ||||||
|  | @ -444,15 +444,15 @@ supply1 { return parser::make_TOK_SUPPLY1(out_loc); } | ||||||
| 	auto s = std::string("\\") + YYText(); | 	auto s = std::string("\\") + YYText(); | ||||||
| 	if (extra->pkg_user_types.count(s) > 0) { | 	if (extra->pkg_user_types.count(s) > 0) { | ||||||
| 		// package qualified typedefed name | 		// package qualified typedefed name | ||||||
| 		auto val = new std::string(s); | 		auto val = std::make_unique<std::string>(s); | ||||||
| 		return parser::make_TOK_PKG_USER_TYPE(val, out_loc); | 		return parser::make_TOK_PKG_USER_TYPE(std::move(val), out_loc); | ||||||
| 	} | 	} | ||||||
| 	else { | 	else { | ||||||
| 		// backup before :: just return first part | 		// backup before :: just return first part | ||||||
| 		size_t len = strchr(YYText(), ':') - YYText(); | 		size_t len = strchr(YYText(), ':') - YYText(); | ||||||
| 		yyless(len); | 		yyless(len); | ||||||
| 		auto val = new std::string(std::string("\\") + YYText()); | 		auto val = std::make_unique<std::string>(std::string("\\") + YYText()); | ||||||
| 		return parser::make_TOK_ID(val, out_loc); | 		return parser::make_TOK_ID(std::move(val), out_loc); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -460,18 +460,18 @@ supply1 { return parser::make_TOK_SUPPLY1(out_loc); } | ||||||
| 	auto s = std::string("\\") + YYText(); | 	auto s = std::string("\\") + YYText(); | ||||||
| 	if (isUserType(extra, s)) { | 	if (isUserType(extra, s)) { | ||||||
| 		// previously typedefed name | 		// previously typedefed name | ||||||
| 		auto val = new std::string(s); | 		auto val = std::make_unique<std::string>(s); | ||||||
| 		return parser::make_TOK_USER_TYPE(val, out_loc); | 		return parser::make_TOK_USER_TYPE(std::move(val), out_loc); | ||||||
| 	} | 	} | ||||||
| 	else { | 	else { | ||||||
| 		auto val = new std::string(std::string("\\") + YYText()); | 		auto val = std::make_unique<std::string>(std::string("\\") + YYText()); | ||||||
| 		return parser::make_TOK_ID(val, out_loc); | 		return parser::make_TOK_ID(std::move(val), out_loc); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| [a-zA-Z_$][a-zA-Z0-9_$\.]* { | [a-zA-Z_$][a-zA-Z0-9_$\.]* { | ||||||
| 	auto val = new std::string(std::string("\\") + YYText()); | 	auto val = std::make_unique<std::string>(std::string("\\") + YYText()); | ||||||
| 	return parser::make_TOK_ID(val, out_loc); | 	return parser::make_TOK_ID(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| "/*"[ \t]*(synopsys|synthesis)[ \t]*translate_off[ \t]*"*/" { | "/*"[ \t]*(synopsys|synthesis)[ \t]*translate_off[ \t]*"*/" { | ||||||
|  | @ -532,8 +532,8 @@ import[ \t\r\n]+\"(DPI|DPI-C)\"[ \t\r\n]+function[ \t\r\n]+ { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| <IMPORT_DPI>[a-zA-Z_$][a-zA-Z0-9_$]* { | <IMPORT_DPI>[a-zA-Z_$][a-zA-Z0-9_$]* { | ||||||
| 	auto val = new std::string(std::string("\\") + YYText()); | 	auto val = std::make_unique<std::string>(std::string("\\") + YYText()); | ||||||
| 	return parser::make_TOK_ID(val, out_loc); | 	return parser::make_TOK_ID(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| <IMPORT_DPI>[ \t\r\n] /* ignore whitespaces */ | <IMPORT_DPI>[ \t\r\n] /* ignore whitespaces */ | ||||||
|  | @ -548,8 +548,8 @@ import[ \t\r\n]+\"(DPI|DPI-C)\"[ \t\r\n]+function[ \t\r\n]+ { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| "\\"[^ \t\r\n]+ { | "\\"[^ \t\r\n]+ { | ||||||
| 	auto val = new std::string(YYText()); | 	auto val = std::make_unique<std::string>(YYText()); | ||||||
| 	return parser::make_TOK_ID(val, out_loc); | 	return parser::make_TOK_ID(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| "(*" { return parser::make_ATTR_BEGIN(out_loc); } | "(*" { return parser::make_ATTR_BEGIN(out_loc); } | ||||||
|  | @ -605,8 +605,8 @@ import[ \t\r\n]+\"(DPI|DPI-C)\"[ \t\r\n]+function[ \t\r\n]+ { | ||||||
| 
 | 
 | ||||||
| [-+]?[=*]> { | [-+]?[=*]> { | ||||||
| 	if (!mode->specify) REJECT; | 	if (!mode->specify) REJECT; | ||||||
| 	auto val = new std::string(YYText()); | 	auto val = std::make_unique<std::string>(YYText()); | ||||||
| 	return parser::make_TOK_SPECIFY_OPER(val, out_loc); | 	return parser::make_TOK_SPECIFY_OPER(std::move(val), out_loc); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| "&&&" { | "&&&" { | ||||||
|  |  | ||||||
|  | @ -244,7 +244,7 @@ | ||||||
| 			node->children.push_back(std::move(rangeNode)); | 			node->children.push_back(std::move(rangeNode)); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		static void checkLabelsMatch(const frontend_verilog_yy::parser::location_type& loc, const char *element, const std::string *before, const std::string *after) | 		static void checkLabelsMatch(const frontend_verilog_yy::parser::location_type& loc, const char *element, const std::string* before, const std::string *after) | ||||||
| 		{ | 		{ | ||||||
| 			if (!before && after) | 			if (!before && after) | ||||||
| 				err_at_loc(loc, "%s missing where end label (%s) was given.", | 				err_at_loc(loc, "%s missing where end label (%s) was given.", | ||||||
|  | @ -271,7 +271,6 @@ | ||||||
| 			node->is_custom_type = true; | 			node->is_custom_type = true; | ||||||
| 			node->children.push_back(std::make_unique<AstNode>(AST_WIRETYPE)); | 			node->children.push_back(std::make_unique<AstNode>(AST_WIRETYPE)); | ||||||
| 			node->children.back()->str = *name; | 			node->children.back()->str = *name; | ||||||
| 			delete name; |  | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		void ParseState::addTypedefNode(std::string *name, std::unique_ptr<AstNode> node) | 		void ParseState::addTypedefNode(std::string *name, std::unique_ptr<AstNode> node) | ||||||
|  | @ -287,7 +286,6 @@ | ||||||
| 				auto qname = current_ast_mod->str + "::" + (*name).substr(1); | 				auto qname = current_ast_mod->str + "::" + (*name).substr(1); | ||||||
| 				pkg_user_types[qname] = tnode; | 				pkg_user_types[qname] = tnode; | ||||||
| 			} | 			} | ||||||
| 			delete name; |  | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		void ParseState::enterTypeScope() | 		void ParseState::enterTypeScope() | ||||||
|  | @ -479,7 +477,7 @@ | ||||||
| 		specify_triple fall; | 		specify_triple fall; | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 	using string_t = std::string *; | 	using string_t = std::unique_ptr<std::string>; | ||||||
| 	using ast_t = std::unique_ptr<YOSYS_NAMESPACE_PREFIX AST::AstNode>; | 	using ast_t = std::unique_ptr<YOSYS_NAMESPACE_PREFIX AST::AstNode>; | ||||||
| 	using al_t = YOSYS_NAMESPACE_PREFIX dict<YOSYS_NAMESPACE_PREFIX RTLIL::IdString, std::unique_ptr<YOSYS_NAMESPACE_PREFIX AST::AstNode>>*; | 	using al_t = YOSYS_NAMESPACE_PREFIX dict<YOSYS_NAMESPACE_PREFIX RTLIL::IdString, std::unique_ptr<YOSYS_NAMESPACE_PREFIX AST::AstNode>>*; | ||||||
| 	using specify_target_ptr_t = std::unique_ptr<struct specify_target>; | 	using specify_target_ptr_t = std::unique_ptr<struct specify_target>; | ||||||
|  | @ -686,27 +684,27 @@ attr_assign: | ||||||
| 
 | 
 | ||||||
| hierarchical_id: | hierarchical_id: | ||||||
| 	TOK_ID { | 	TOK_ID { | ||||||
| 		$$ = $1; | 		$$ = std::move($1); | ||||||
| 	} | | 	} | | ||||||
| 	hierarchical_id TOK_PACKAGESEP TOK_ID { | 	hierarchical_id TOK_PACKAGESEP TOK_ID { | ||||||
| 		if ($3->compare(0, 1, "\\") == 0) | 		if ($3->compare(0, 1, "\\") == 0) | ||||||
| 			*$1 += "::" + $3->substr(1); | 			*$1 += "::" + $3->substr(1); | ||||||
| 		else | 		else | ||||||
| 			*$1 += "::" + *$3; | 			*$1 += "::" + *$3; | ||||||
| 		$$ = $1; | 		$$ = std::move($1); | ||||||
| 	} | | 	} | | ||||||
| 	hierarchical_id TOK_DOT TOK_ID { | 	hierarchical_id TOK_DOT TOK_ID { | ||||||
| 		if ($3->compare(0, 1, "\\") == 0) | 		if ($3->compare(0, 1, "\\") == 0) | ||||||
| 			*$1 += "." + $3->substr(1); | 			*$1 += "." + $3->substr(1); | ||||||
| 		else | 		else | ||||||
| 			*$1 += "." + *$3; | 			*$1 += "." + *$3; | ||||||
| 		$$ = $1; | 		$$ = std::move($1); | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| hierarchical_type_id: | hierarchical_type_id: | ||||||
| 	TOK_USER_TYPE | 	TOK_USER_TYPE {$$ = std::move($1); } | ||||||
| 	| TOK_PKG_USER_TYPE				// package qualified type name | 	| TOK_PKG_USER_TYPE {$$ = std::move($1); } // package qualified type name | ||||||
| 	| TOK_LPAREN TOK_USER_TYPE TOK_RPAREN	{ $$ = $2; }		// non-standard grammar | 	| TOK_LPAREN TOK_USER_TYPE TOK_RPAREN	{ $$ = std::move($2); }		// non-standard grammar | ||||||
| 	; | 	; | ||||||
| 
 | 
 | ||||||
| module: | module: | ||||||
|  | @ -727,7 +725,7 @@ module: | ||||||
| 		SET_AST_NODE_LOC(extra->ast_stack.back(), @2, @$); | 		SET_AST_NODE_LOC(extra->ast_stack.back(), @2, @$); | ||||||
| 		extra->ast_stack.pop_back(); | 		extra->ast_stack.pop_back(); | ||||||
| 		log_assert(extra->ast_stack.size() == 1); | 		log_assert(extra->ast_stack.size() == 1); | ||||||
| 		checkLabelsMatch(@11, "Module name", $4, $11); | 		checkLabelsMatch(@11, "Module name", $4.get(), $11.get()); | ||||||
| 		extra->current_ast_mod = nullptr; | 		extra->current_ast_mod = nullptr; | ||||||
| 		extra->exitTypeScope(); | 		extra->exitTypeScope(); | ||||||
| 	}; | 	}; | ||||||
|  | @ -835,7 +833,7 @@ package: | ||||||
| 		append_attr(mod, $1); | 		append_attr(mod, $1); | ||||||
| 	} TOK_SEMICOL package_body TOK_ENDPACKAGE opt_label { | 	} TOK_SEMICOL package_body TOK_ENDPACKAGE opt_label { | ||||||
| 		extra->ast_stack.pop_back(); | 		extra->ast_stack.pop_back(); | ||||||
| 		checkLabelsMatch(@9, "Package name", $4, $9); | 		checkLabelsMatch(@9, "Package name", $4.get(), $9.get()); | ||||||
| 		extra->current_ast_mod = nullptr; | 		extra->current_ast_mod = nullptr; | ||||||
| 		extra->exitTypeScope(); | 		extra->exitTypeScope(); | ||||||
| 	}; | 	}; | ||||||
|  | @ -1043,7 +1041,7 @@ logic_type: | ||||||
| 		extra->astbuf3->is_signed = true; | 		extra->astbuf3->is_signed = true; | ||||||
| 	} | | 	} | | ||||||
| 	hierarchical_type_id { | 	hierarchical_type_id { | ||||||
| 		extra->addWiretypeNode($1, extra->astbuf3.get()); | 		extra->addWiretypeNode($1.get(), extra->astbuf3.get()); | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| integer_atom_type: | integer_atom_type: | ||||||
|  | @ -1311,7 +1309,7 @@ specify_item: | ||||||
| 		auto en_expr = std::move($1); | 		auto en_expr = std::move($1); | ||||||
| 		char specify_edge = $3; | 		char specify_edge = $3; | ||||||
| 		auto src_expr = std::move($4); | 		auto src_expr = std::move($4); | ||||||
| 		string *oper = $5; | 		string *oper = $5.get(); | ||||||
| 		specify_target_ptr_t target = std::move($6); | 		specify_target_ptr_t target = std::move($6); | ||||||
| 		specify_rise_fall_ptr_t timing = std::move($9); | 		specify_rise_fall_ptr_t timing = std::move($9); | ||||||
| 
 | 
 | ||||||
|  | @ -1387,8 +1385,6 @@ specify_item: | ||||||
| 			cell->children.push_back(std::make_unique<AstNode>(AST_ARGUMENT, std::move(target->dat))); | 			cell->children.push_back(std::make_unique<AstNode>(AST_ARGUMENT, std::move(target->dat))); | ||||||
| 			cell->children.back()->str = "\\DAT"; | 			cell->children.back()->str = "\\DAT"; | ||||||
| 		} | 		} | ||||||
| 
 |  | ||||||
| 		delete oper; |  | ||||||
| 	} | | 	} | | ||||||
| 	TOK_ID TOK_LPAREN specify_edge expr specify_condition TOK_COMMA specify_edge expr specify_condition TOK_COMMA specify_triple specify_opt_triple TOK_RPAREN TOK_SEMICOL { | 	TOK_ID TOK_LPAREN specify_edge expr specify_condition TOK_COMMA specify_edge expr specify_condition TOK_COMMA specify_triple specify_opt_triple TOK_RPAREN TOK_SEMICOL { | ||||||
| 		if (*$1 != "$setup" && *$1 != "$hold" && *$1 != "$setuphold" && *$1 != "$removal" && *$1 != "$recovery" && | 		if (*$1 != "$setup" && *$1 != "$hold" && *$1 != "$setuphold" && *$1 != "$removal" && *$1 != "$recovery" && | ||||||
|  | @ -1725,7 +1721,7 @@ param_implicit_type: param_signed param_range; | ||||||
| param_type: | param_type: | ||||||
| 	param_integer_type | param_real | param_range_type | param_implicit_type | | 	param_integer_type | param_real | param_range_type | param_implicit_type | | ||||||
| 	hierarchical_type_id { | 	hierarchical_type_id { | ||||||
| 		extra->addWiretypeNode($1, extra->astbuf1.get()); | 		extra->addWiretypeNode($1.get(), extra->astbuf1.get()); | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| param_decl: | param_decl: | ||||||
|  | @ -1982,7 +1978,7 @@ member_type_token: | ||||||
| 
 | 
 | ||||||
| member_type: type_atom type_signing | member_type: type_atom type_signing | ||||||
| 	| type_vec type_signing | 	| type_vec type_signing | ||||||
| 	| hierarchical_type_id { extra->addWiretypeNode($1, extra->astbuf1.get()); } | 	| hierarchical_type_id { extra->addWiretypeNode($1.get(), extra->astbuf1.get()); } | ||||||
| 	; | 	; | ||||||
| 
 | 
 | ||||||
| struct_var_list: struct_var | struct_var_list: struct_var | ||||||
|  | @ -2161,8 +2157,8 @@ assign_expr: | ||||||
| 		SET_AST_NODE_LOC(node, @$, @$); | 		SET_AST_NODE_LOC(node, @$, @$); | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| type_name: TOK_ID		// first time seen | type_name: TOK_ID { $$ = std::move($1); } // first time seen | ||||||
| 	 | TOK_USER_TYPE	{ if (extra->isInLocalScope($1)) lexer->err("Duplicate declaration of TYPEDEF '%s'", $1->c_str()+1); $$ = std::move($1); } | 	 | TOK_USER_TYPE	{ if (extra->isInLocalScope($1.get())) lexer->err("Duplicate declaration of TYPEDEF '%s'", $1->c_str()+1); $$ = std::move($1); } | ||||||
| 	 ; | 	 ; | ||||||
| 
 | 
 | ||||||
| typedef_decl: | typedef_decl: | ||||||
|  | @ -2180,15 +2176,15 @@ typedef_decl: | ||||||
| 			} | 			} | ||||||
| 			rewriteAsMemoryNode(extra->astbuf1.get(), std::move($5)); | 			rewriteAsMemoryNode(extra->astbuf1.get(), std::move($5)); | ||||||
| 		} | 		} | ||||||
| 		extra->addTypedefNode($4, std::move(extra->astbuf1)); } | 		extra->addTypedefNode($4.get(), std::move(extra->astbuf1)); } | ||||||
| 	| TOK_TYPEDEF enum_struct_type type_name TOK_SEMICOL   { extra->addTypedefNode($3, std::move($2)); } | 	| TOK_TYPEDEF enum_struct_type type_name TOK_SEMICOL   { extra->addTypedefNode($3.get(), std::move($2)); } | ||||||
| 	; | 	; | ||||||
| 
 | 
 | ||||||
| typedef_base_type: | typedef_base_type: | ||||||
| 	hierarchical_type_id { | 	hierarchical_type_id { | ||||||
| 		$$ = std::make_unique<AstNode>(AST_WIRE); | 		$$ = std::make_unique<AstNode>(AST_WIRE); | ||||||
| 		$$->is_logic = true; | 		$$->is_logic = true; | ||||||
| 		extra->addWiretypeNode($1, $$.get()); | 		extra->addWiretypeNode($1.get(), $$.get()); | ||||||
| 	} | | 	} | | ||||||
| 	integer_vector_type opt_signedness_default_unsigned { | 	integer_vector_type opt_signedness_default_unsigned { | ||||||
| 		$$ = std::make_unique<AstNode>(AST_WIRE); | 		$$ = std::make_unique<AstNode>(AST_WIRE); | ||||||
|  | @ -2231,10 +2227,10 @@ cell_stmt: | ||||||
| 
 | 
 | ||||||
| tok_prim_wrapper: | tok_prim_wrapper: | ||||||
| 	TOK_PRIMITIVE { | 	TOK_PRIMITIVE { | ||||||
| 		$$ = $1; | 		$$ = std::move($1); | ||||||
| 	} | | 	} | | ||||||
| 	TOK_OR { | 	TOK_OR { | ||||||
| 		$$ = new std::string("or"); | 		$$ = std::make_unique<std::string>("or"); | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| cell_list: | cell_list: | ||||||
|  | @ -2474,7 +2470,7 @@ always_event: | ||||||
| 
 | 
 | ||||||
| opt_label: | opt_label: | ||||||
| 	TOK_COL TOK_ID { | 	TOK_COL TOK_ID { | ||||||
| 		$$ = $2; | 		$$ = std::move($2); | ||||||
| 	} | | 	} | | ||||||
| 	%empty { | 	%empty { | ||||||
| 		$$ = nullptr; | 		$$ = nullptr; | ||||||
|  | @ -2482,7 +2478,7 @@ opt_label: | ||||||
| 
 | 
 | ||||||
| opt_sva_label: | opt_sva_label: | ||||||
| 	TOK_SVA_LABEL TOK_COL { | 	TOK_SVA_LABEL TOK_COL { | ||||||
| 		$$ = $1; | 		$$ = std::move($1); | ||||||
| 	} | | 	} | | ||||||
| 	%empty { | 	%empty { | ||||||
| 		$$ = nullptr; | 		$$ = nullptr; | ||||||
|  | @ -2790,7 +2786,7 @@ behavioral_stmt: | ||||||
| 			node->str = *$4; | 			node->str = *$4; | ||||||
| 	} behavioral_stmt_list TOK_END opt_label { | 	} behavioral_stmt_list TOK_END opt_label { | ||||||
| 		extra->exitTypeScope(); | 		extra->exitTypeScope(); | ||||||
| 		checkLabelsMatch(@8, "Begin label", $4, $8); | 		checkLabelsMatch(@8, "Begin label", $4.get(), $8.get()); | ||||||
| 		AstNode *node = extra->ast_stack.back(); | 		AstNode *node = extra->ast_stack.back(); | ||||||
| 		// In SystemVerilog, unnamed blocks with block item declarations | 		// In SystemVerilog, unnamed blocks with block item declarations | ||||||
| 		// create an implicit hierarchy scope | 		// create an implicit hierarchy scope | ||||||
|  | @ -3173,7 +3169,7 @@ gen_block: | ||||||
| 		node->str = $3 ? *$3 : std::string(); | 		node->str = $3 ? *$3 : std::string(); | ||||||
| 	} module_gen_body TOK_END opt_label { | 	} module_gen_body TOK_END opt_label { | ||||||
| 		extra->exitTypeScope(); | 		extra->exitTypeScope(); | ||||||
| 		checkLabelsMatch(@7, "Begin label", $3, $7); | 		checkLabelsMatch(@7, "Begin label", $3.get(), $7.get()); | ||||||
| 		SET_AST_NODE_LOC(extra->ast_stack.back(), @1, @7); | 		SET_AST_NODE_LOC(extra->ast_stack.back(), @1, @7); | ||||||
| 		extra->ast_stack.pop_back(); | 		extra->ast_stack.pop_back(); | ||||||
| 	}; | 	}; | ||||||
|  | @ -3519,8 +3515,8 @@ concat_list: | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| integral_number: | integral_number: | ||||||
| 	TOK_CONSTVAL { $$ = $1; } | | 	TOK_CONSTVAL { $$ = std::move($1); } | | ||||||
| 	TOK_UNBASED_UNSIZED_CONSTVAL { $$ = $1; } | | 	TOK_UNBASED_UNSIZED_CONSTVAL { $$ = std::move($1); } | | ||||||
| 	TOK_BASE TOK_BASED_CONSTVAL { | 	TOK_BASE TOK_BASED_CONSTVAL { | ||||||
| 		$1->append(*$2); | 		$1->append(*$2); | ||||||
| 		$$ = std::move($1); | 		$$ = std::move($1); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue