##Summary
C# grammar with full support of C# 6 features and below. CSharpLexer.g4 and CSharpPreprocessor.g4 are .NET runtime dependent (contains specific actions), because of directive preprocessors and string interpolation (these things make grammar context-sensitive). But CSharpParser.g4 is runtime independent. This ANTLR 4 C# grammar is based on the C# ANTLR 3 grammar from ChristianWulf/CSharpGrammar
##Using
Due to uncompilied code can be placed after such preprocessor directives:
#if SILVERLIGHT && WINDOWS_PHONE || DEBUG || foo == true
// Some code
#endif
at first stage it's necessary to calculate whether condition satisfied in directive. This step performed by runtime code in gist: CSharpAntlrParser.
##Testing
I put into repository AllInOne.cs file (from Roslyn) with most common syntax and also I tested this grammar on the following most popular .NET projects:
- Roslyn-1.1.1.
- Corefx-1.0.0-rc2.
- EntityFramework-7.0.0-rc1.
- aspnet-mvc-6.0.0-rc1.
- ImageProcessor-2.3.0.
- Newtonsoft.Json-8.0.2.
There are some problems with deep recursion (TestData.g.cs in CoreFx), unicode chars (sjis.cs in Roslyn) and preprocessor directives.
ANTLR parser from this grammar approximately ~5-7 slowly than Roslyn parser.
##License Eclipse Public License - v 1.0 (http://www.eclipse.org/legal/epl-v10.html)