mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-03 21:09:12 +00:00 
			
		
		
		
	verilog: strip leading and trailing spaces in macro args
This commit is contained in:
		
							parent
							
								
									98afe2b758
								
							
						
					
					
						commit
						27257a419f
					
				
					 2 changed files with 25 additions and 1 deletions
				
			
		| 
						 | 
					@ -390,12 +390,16 @@ static void input_file(std::istream &f, std::string filename)
 | 
				
			||||||
// the argument list); false if we finished with ','.
 | 
					// the argument list); false if we finished with ','.
 | 
				
			||||||
static bool read_argument(std::string &dest)
 | 
					static bool read_argument(std::string &dest)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						skip_spaces();
 | 
				
			||||||
	std::vector<char> openers;
 | 
						std::vector<char> openers;
 | 
				
			||||||
	for (;;) {
 | 
						for (;;) {
 | 
				
			||||||
		std::string tok = next_token(true);
 | 
							std::string tok = next_token(true);
 | 
				
			||||||
		if (tok == ")") {
 | 
							if (tok == ")") {
 | 
				
			||||||
			if (openers.empty())
 | 
								if (openers.empty()) {
 | 
				
			||||||
 | 
									while (dest.size() && (dest.back() == ' ' || dest.back() == '\t'))
 | 
				
			||||||
 | 
										dest = dest.substr(0, dest.size() - 1);
 | 
				
			||||||
				return true;
 | 
									return true;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			if (openers.back() != '(')
 | 
								if (openers.back() != '(')
 | 
				
			||||||
				log_error("Mismatched brackets in macro argument: %c and %c.\n",
 | 
									log_error("Mismatched brackets in macro argument: %c and %c.\n",
 | 
				
			||||||
				          openers.back(), tok[0]);
 | 
									          openers.back(), tok[0]);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										20
									
								
								tests/simple/macro_arg_surrounding_spaces.v
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								tests/simple/macro_arg_surrounding_spaces.v
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					module top(
 | 
				
			||||||
 | 
						IDENT_V_,
 | 
				
			||||||
 | 
						IDENT_W_,
 | 
				
			||||||
 | 
						IDENT_X_,
 | 
				
			||||||
 | 
						IDENT_Y_,
 | 
				
			||||||
 | 
						IDENT_Z_,
 | 
				
			||||||
 | 
						IDENT_A_,
 | 
				
			||||||
 | 
						IDENT_B_,
 | 
				
			||||||
 | 
						IDENT_C_
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
						`define MACRO(dummy, x) IDENT_``x``_
 | 
				
			||||||
 | 
						output wire IDENT_V_;
 | 
				
			||||||
 | 
						output wire `MACRO(_,W);
 | 
				
			||||||
 | 
						output wire `MACRO(_, X);
 | 
				
			||||||
 | 
						output wire `MACRO(_,Y );
 | 
				
			||||||
 | 
						output wire `MACRO(_, Z );
 | 
				
			||||||
 | 
						output wire `MACRO(_,	 A);
 | 
				
			||||||
 | 
						output wire `MACRO(_,B	 );
 | 
				
			||||||
 | 
						output wire `MACRO(_, C	);
 | 
				
			||||||
 | 
					endmodule
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue