-
Notifications
You must be signed in to change notification settings - Fork 369
Mono support for "real life" script files #740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks @ztone I'll take a look ASAP. |
|
Thanks @adamralph, Sorry, I was not more verbose in my first comment … it was 2 am when I sent this PR. This PR should not be merged (at least not yet), as it's more of a spike now. The purpose for this PR is that I wanted to run a real life script file as POC for the mono engine, I was considering something like “Running bau script file to build ScriptCs on mono” … just saying that is crazy cool 😃 The problems I had when running baufile.csx was
If I removed those things the script worked. I just want to take this route if we have good success as it will complicate other stuff (for example debug implementation, script variable scoping in REPL), but bypasses some of hard issues with the mono evaluator. Cheers, |
|
Hi @ztone I grabbed this branch, rebased onto latest dev and tried it out but I ran into:
(using https://github.com/bau-build/bau-msbuild/blob/9b73f19dbb557099eddbdd6b8843a8fc8ca34b1a/baufile.csx) I guess the first problem is the same you observed with
I'm still a little hazy on how all this works. I think we may need @filipw to chime in since he wrote the initial mono engine implementation. One thing that does initially concern me is that, with this change, the script that gets compiled diverges from that which is written. E.g. If I use the latest dev build I get an output like:
I.e. I can relate the message back to a line in a file. But with this change I get:
|
|
@adamralph Thanks for looking into this. Can you grab the lastest and check if it works for you now. I've added support for loose functions. This is just an experimental spike. I just want to know if this is usable before continuing. Thanks again. |
|
OK, it now works for the bau-msbuild baufile! 👍 Unfortunately it still fails on the build script for the core Bau project (using https://github.com/bau-build/bau/blob/7b0e3a080f324d6a40b710f161fca76c7ea02d18/baufile.csx)
|
|
Thanks for testing this @adamralph This flushed out an issue I've known about that I think we need to deal with. The issue is how NRefactory is parsing blocks What is causing baufile.csx to fail here is .Task("default").DependsOn(string.IsNullOrWhiteSpace(ci)
? new[] { "unit", "component", "pack" }
: new[] { "unit", "component", "accept", "pack" })If you move the condition to a function string[] IsCI(string ci)
{
return string.IsNullOrWhiteSpace(ci)
? new[] { "unit", "component", "pack" }
: new[] { "unit", "component", "accept", "pack" }
}it should work. It's the block inside DependsOn method that is causing the NRefactory parser to fail. Another issue with NRefactory I found yesterday is that it removes statements it can't parse inside classes e.g. NRefactory wasn't built for scriptcs syntax, but what it does really well is converting methods into names function expressions so we can use loose functions in mono. I've been fiddling around with a simple pre-lexer that should help with the above issues. The idea is to use the pre-lexer is to extract classes, methods and evaluations from the code, instead of NRefactory. Doing this will give us more flexibility to handle the syntax but will probably take awhile to flush out all the bugs. However, it looks like the lexer doesn't have to be very sophisticated to handle this. It's been really helpful to have a real script been pushed through the mono engine. |
|
Interesting stuff! It would be great to wrap all this up to bring unformity with the Roslyn and Mono engines (it's something we've been discussing as a prereq. for 1.0) but it certainly appears to be quite involved... Thanks @ztone for the putting effort into this. Please keep us posted! Do you want this PR left open or has it served its purpose for now? |
|
Yes, I think it has served it purpose and can be closed now. |
|
Great. Looking forward to seeing the pre-lexer! |
@adamralph
Could you try this PR. I'm hoping this solves #713 and some other issues with the mono engine.
I had some luck with the "baufile.csx", but I'm hoping that you can help me get it all the way through the mono engine ...I had some issues in this PR that did seem to belong to Bau, rather than Mono.