tooling quality and some random rant
    Michel Fortin 
    michel.fortin at michelf.com
       
    Sun Feb 13 12:27:33 PST 2011
    
    
  
On 2011-02-13 14:38:20 -0500, Walter Bright <newshound2 at digitalmars.com> said:
> Denis Koroskin wrote:
>>> It's not impossible, but is a tremendous amount of work in order to 
>>> improve one error message, and one error message that generations of C 
>>> and C++ programmers are comfortable dealing with.
>> 
>> What's wrong with parsing low-level linker error messages and output 
>> them in human-readable form? E.g. demangle missing symbols.
> 
> Yes, that can be done. The downside is since dmd does not control what 
> linker the user has, it becomes a constant source of problems trying to 
> keep it working as it constantly breaks with linker changes and an 
> arbitrarily long list of linkers on various distributions.
Parsing error messages is a problem indeed. But demangling symbol names 
is easy. Try this:
	dmd ... 2>&1 | ddemangle
With ddemangle being a compiled version of this program:
import std.stdio;
import core.demangle;
void main()
{
	foreach (line; stdin.byLine())
	{
		size_t beginIdx, endIdx;
		enum State { searching_, searchingD, searchingEnd, done }
		State state;
		foreach (i, char c; line)
		{
			switch (state)
			{
			case State.searching_:
				if (c == '_')
				{
					beginIdx = i;
					state = State.searchingD;
				}
				break;
			case State.searchingD:
				if (c == 'D')
					state = State.searchingEnd;
				else if (c != '_')
					state = State.searching_;
				break;
			case State.searchingEnd:
				if (c == ' ' || c == '"' || c == '\'')
				{
					endIdx = i;
					state = State.done;
				}
				break;
			}
			if (state == State.done)
				break;
		}
		if (endIdx > beginIdx)
			writeln(line[0..beginIdx], demangle(line[beginIdx..endIdx]), 
line[endIdx..$]);
		else
			writeln(line);
	}
}
-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
    
    
More information about the Digitalmars-d
mailing list