qwertie / ecsharp

Home of LoycCore, the LES language of Loyc trees, the Enhanced C# parser, the LeMP macro preprocessor, and the LLLPG parser generator.
http://ecsharp.net
Other
172 stars 25 forks source link

#r "path" works only with absolute path in compileTime directive #117

Closed dadhi closed 3 years ago

dadhi commented 3 years ago

I tried project source and binary relative pathes without success. Here is the code: https://github.com/dadhi/LempTest/blob/9ce17d16a8d7c71fc475921e1414e5bc64d72f9d/LibWithEcs/ServiceRegistrations.ecs.include#L3

Also I am not sure how to pass the ditectory via --set:key=value. Should I wrap the key or value in quotes, escape the slashes? And if I succeed in passing, could I #get(key) in compileTime section and somehow use it for #r?

qwertie commented 3 years ago

Um, don't forget to use StackOverflow.

qwertie commented 3 years ago

Relative paths are working for me in the Visual Studio extension. The path should be relative to the source file location.

To find out the file's #inputFolder value, write #get(#inputFolder); at the top of the file and then look at LeMP's output. If the output says _numget(_numinputFolder), something's wrong - the variable is unset, but it is possible to set its value on the command line: --set:#inputFolder="C:\\Dev\\MyFolder"

After --set:, key=value is parsed as an assignment expression whose syntax is LES or the current input language if any (--inlang=ecs for EC#) - so you should wrap the value in quotes and escape backslashes.

Yes, you can use #get(key) inside compileTime; however the #r directive is parsed in a very dumb way because of the directive's very dumb syntax. As a result, macros cannot be used on the #r line. You probably don't need to hack around this limitation, but if you do, you can replace #r dir\Foo.dll with its equivalent Loyc tree ##reference(@"""dir\\Foo.dll"""); (the extra quotes are optional) and then you can use macros in the modified line.

It did not occur to me that one could use precompute inside compileTime, but you can and it works. So for example you can do ##reference(precompute(System.IO.Path.Combine(@"dir", "Foo.dll")));.

dadhi commented 3 years ago

My bad, here is the question https://stackoverflow.com/q/62852154/2492669

dadhi commented 3 years ago

reference(precompute(System.IO.Path.Combine(@"dir", "Foo.dll")));.

This is great and provides the needed flexibility. The syntax is fine too. Thanks again!