-
Notifications
You must be signed in to change notification settings - Fork 818
Implements extended if grammar #55
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
Migrated from CodePlex (mainly because I wanted a clean-slate as the history of this PR is quite long) |
After pouring through the F# parser on how to do error handling I have incorporated similar techniques now. The result should be a more stable preprocessor parser and with support for better error messages to the user. I ran the test suites (including VS integration) I saw no errors that were due to extended if grammar. There are two "small" issues remaining: Inside visual studio the squiggle for unrecognized characters are rendered in the wrong place: The error message from the compiler looks correct though but I think its due to that I consume all characters. If I go back to a previous pattern and simpler pattern it's probably fixed. The unit test for: This generates a parse error (and indication the preprocessor parser needs to be extended to handle this case). I have code that are supposed to handle it but it doesn't pick it up properly yet. Conclusion:
Therefore to my current knowledge I think this could be good to merge and schedule some minor bug fixes for later. |
| comment { PPParser.EOF } | ||
| mcomment { fail args lexbuf (FSComp.SR.pplexExpectedSingleLineComment()) } | ||
| _ { | ||
let lex = lexeme lexbuf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect consuming "rest" is what causes the squiggle to be rendered in the wrong place on this error. Should be ok with just consuming '_'
Please consider to revert the changes in |
@@ -0,0 +1,178 @@ | |||
# 3 "..\pplex.fsl" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should not be included in the commit
I think the code looks good - the addition of FSharp.Compiler.UnitTests as well as the actual implementation of the feature. I'm not sure if this has made the Jan 16 deadline for F# 4.0 though? |
This has been in-progress and earmarked for F# 4.0 for a long time. Given Marten's responsiveness to my requests and feedback over the past weeks/months (see original Codeplex thread) I think it's only fair to merge this for 4.0. |
Great, let's do it :) |
5f8880c
to
417d3d1
Compare
Origin: https://fslang.uservoice.com/forums/245727-f-language/suggestions/6079342-allow-extended-if-grammar This commit adds the possibility to write condtional compilation expressions like this: #if SILVERLIGHT || NETFX #endif or a bit more advanced: #if (SILVERLIGHT || NETFX) && COMPILED || !DEBUG #endif This commit doesn't add #elif which is an orthogonal problem.
417d3d1
to
42e0766
Compare
Fantastic!!! |
Hi @mrange, We need to add a "Speclet" to this feature to this collection. The format should follow the others: Links, Aim, Background, Design, Specification and so on. The "specification" section should give a guide for how the F# Language Specification will be updated for this feature. Could you submit a PR to that repo with an initial design/spec document please, and we'll iterate with you. If you need help doing the doc please let me know. Thanks |
closes #55 commit 677a7e799fd5350fd166411004a734f56e9c4e4b Author: latkin <latkin@microsoft.com> Date: Tue Jan 20 11:34:49 2015 -0800 Update DEVGUIDE and TESTGUIDE to include compiler unit test suite commit 90f33737381c0932a478746fc566532da862f3c3 Author: latkin <latkin@microsoft.com> Date: Tue Jan 20 11:20:56 2015 -0800 Simplifying ExtendedIfGrammar tests commit 78b8ff4e325dc37a6d4ca0777b05a2abe85f961c Author: latkin <latkin@microsoft.com> Date: Tue Jan 20 11:20:10 2015 -0800 Adding compilerunit to RunTests.cmd usage commit ba861296fe847faa217ab76ec1cb76aef7bc4d02 Merge: 28da5c0 42e0766 Author: latkin <latkin@microsoft.com> Date: Tue Jan 20 11:05:01 2015 -0800 Merge branch 'pr/extended_if_grammar' of https://github.com/mrange/visualfsharp into mrange-pr/extended_if_grammar Conflicts: tests/fsharpqa/Source/Conformance/LexicalAnalysis/ConditionalCompilation/ExtendedIfGrammar.fs commit 28da5c0800a28cc2044a8d3bb4a22751803433aa Author: latkin <latkin@microsoft.com> Date: Mon Jan 19 18:38:11 2015 -0800 Removing generated .fs/.fsi files from repo commit 47b61d5460f4c84c1b985d50ce96d944c8791efa Author: latkin <latkin@microsoft.com> Date: Mon Jan 19 18:36:15 2015 -0800 Use dedicated fsharp-compiler-unittests-build.proj so portable/net20 build of library unit tests is not broken commit 95e1af8c8bac8b4bc6312a171e675392bff67626 Merge: c5e6699 5f8880c Author: latkin <latkin@microsoft.com> Date: Mon Jan 19 18:14:12 2015 -0800 Merge branch 'pr/extended_if_grammar' of https://github.com/mrange/visualfsharp into mrange-pr/extended_if_grammar commit 5f8880c Author: mrange <marten_range@hotmail.com> Date: Sun Jan 18 14:50:47 2015 +0100 Implements extended if grammar Origin: https://fslang.uservoice.com/forums/245727-f-language/suggestions/6079342-allow-extended-if-grammar This commit adds the possibility to write condtional compilation expressions like this: #if SILVERLIGHT || NETFX #endif or a bit more advanced: #if (SILVERLIGHT || NETFX) && COMPILED || !DEBUG #endif This commit doesn't add #elif which is an orthogonal problem.
@dsyme - I threw together a speclet: fsharp/fslang-design#40 |
Origin: https://fslang.uservoice.com/forums/245727-f-language/suggestions/6079342-allow-extended-if-grammar
This commit adds the possibility to write condtional compilation expressions like this:
#if SILVERLIGHT || NETFX
#endif
or a bit more advanced:
#if (SILVERLIGHT || NETFX) && COMPILED || !DEBUG
#endif
This commit doesn't add #elif which is an orthogonal problem.