Created
March 4, 2013 10:34
-
-
Save leppie/5081390 to your computer and use it in GitHub Desktop.
Roslyn stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ast = SyntaxTree.ParseText(@" | |
namespace Foo { | |
#define MyIf = if | |
#define MyElse = else | |
public class some | |
{ | |
public void someMethod() | |
{ | |
MyFor(int i = 0; i < 10; i++) | |
{ | |
Console.WriteLine(i); | |
} | |
} | |
} | |
}"); | |
/* Notes (mostly problems): | |
1. Compiler directives (aka #define) is assigned globally, no lexical scoping available | |
2. MyFor(...){...} is parsed as: | |
- ExpressionStatement: MyFor(int i = 0; | |
- MethodInvoke: MyFor | |
- Args: | |
- [0]: int | |
- [1]: i = 0 | |
- ExpressionStatement: i < 10 | |
- ExpressionStatement: i++) | |
- BlockStatement: { ... } <- this is OK | |
3. No indication of broken grammar; Roslyn makes a best guess (is this consistent?) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment