Parsing D Maybe Not Such a Good Idea <_<;

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 14 21:25:15 PDT 2016


On Wednesday, 15 June 2016 at 03:59:43 UTC, cy wrote:
> So I was toying with the idea of writing a D parser, and this 
> happened.
>
> const(/*
> 				D is kind of hard to parse. /*
> 			/**/
> 			int//) foo(T//
> 			) foo(T//
> 						)(T /* I mean,
> 										 seriously
> 										 */ bar)
> 	if ( is (T == // how on earth do they do it?
> 		 int) ) {
> 		return
> 			cast /+  where does the function name /+ even start? +/
> 						+/
> 			( const (int) )
> 			bar//;}
> 			;}
> 			
> void main() {
> 	import std.stdio;
> 	writeln(foo(42));
> }
>
> I don't think I'm going to write a D parser.

That's hard to read, for a human, there is nothing in that 
example that is especially difficult for a machine to muddle 
through.


More information about the Digitalmars-d mailing list