I've been looking for a free (as in "free beer") library that can parse C# 3.0 code (actually, C# 2.0 with lambdas would do it) and return some sort of AST/code DOM for a personal project. However, most alternatives I've seen up to now are inadequate:
Microsoft.CSharp.CSharpCodeProvider.Parse
throws a NotImpementedException
;So... is there a free, working C# 3.0 parser out there, that can be plugged into another project?
C is a bit hard to parse because statements like `A * B();` will mean different things if A is defined as a type or note. C++ is much harder to parse because the template syntax is hard to disambiguate from less than or greater than.
Some programs can just process an entire file at once, and other programs need to examine the file line-by-line. In the latter case, you likely need to parse data in each line. Fortunately, the C programming language has a standard C library function to do just that.
The C/C++ parser is used for C and C++ language source files. The C/C++ parser uses syntax highlighting to identify language elements, including the following elements: Identifiers. Operators.
The getopt() function is a builtin function in C and is used to parse command line arguments. Syntax: getopt(int argc, char *const argv[], const char *optstring) optstring is simply a list of characters, each representing a single character option.
Take a look at http://antlrcsharp.codeplex.com/ It is a C# 4 grammar for the Antlr parser generator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With