Compiling DMD parser?

davidl davidl at 126.com
Mon Jul 14 03:59:16 PDT 2008


在 Mon, 14 Jul 2008 14:01:48 +0800,Markus Koskimies  
<markus at reaaliaika.net> 写道:

> On Mon, 14 Jul 2008 05:45:59 +0000, Markus Koskimies wrote:
>
>> But that does not solve my problem to determine, which kind of statement
>> type there is in the tree; I can currently extract only those, which
>> have isXXXX functions in the Statement class.
>
> Here is an example:
>
> test.d:
> ---
> import std.stdio;
>
> void main()
> {
>     int x;
>    writefln("%d", x);
>    return;
> }
> ---
>
> When I walk through the module (test), I get following result:
>
> ---
> test: module
>     object: import
>     std: import
>     Func: void main()
>     Function body:
>         Compound statement:
>             Compound statement:
>                 Decl statement: int x = x (in a declar Exp)=  0;
>
> ==>             Unknown statement: (writefln)("%d",(x));
>
>                 Compound statement:
> ==>                 Unknown statement: 0;
>
>                     Return statement: return ;
> ---
>
> I'm wondering how to extract the type of those statements... At least
> they are not any of the Statement.isXXXX -types.

Oh, it's pretty awesome you get that far in such a short time.
I bet you can print instance.classinfo.name to get the type name of that  
instance.
And I want to have your code be integrated into the dparser trunk for  
illustrating
how to use dparser.


-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list