How does the compiler look for the files of imports?
BCS
ao at pathlink.com
Wed Sep 19 07:51:42 PDT 2007
Reply to Jarrett,
> "Jakob" <a at b.com> wrote in message
> news:fcr3a2$2g3j$1 at digitalmars.com...
>
>> Well, i'm writing a tool which creates makefiles.
>>
>> And if the compiler would analyze the module name to get the module
>> root, it would be much simpler for me :P
>>
> How on earth is it supposed to do that? Scan every directory in the
> system looking for a sequence of directory names that match the
> package name of the module? What if the module has no package names?
> What exactly is "the module root"?
>
>> Besides, the compiler would not read wrong files as in Kirk's
>> example.
>>
> That's entirely not the compiler's fault. You can't say "import foo,
> but not the foo that looks blindingly obvious, I mean the foo that's
> in some other arbitrary directory on my system. Yeah, that one. You
> know what I'm talking about."
>
What I'm thinking of is; start with the given file, if you can't find the
imports and they share a common package prefix, check if the containing directory
has your package as a suffix. If it does try removing the sufix and then
check for the modules. For consistency, If you can't find /all/ imports using
this new root in replacement of the current directly, then fail
More information about the Digitalmars-d
mailing list