Skip to content

Instantly share code, notes, and snippets.

@leppie
Created March 4, 2013 10:34
Show Gist options
  • Save leppie/5081390 to your computer and use it in GitHub Desktop.
Save leppie/5081390 to your computer and use it in GitHub Desktop.
Roslyn stuff
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