Search code examples
c#parsingtokenize

Need to construct a XML representation for C# code


I need to convert C# code to an equivalent XML representation.
I plan to convert the C# code (C# 2.0 code snippets, no generics or nullable types) to an AST and then convert the AST to XML. Looking for a simple lexer/parser for C# which outputs an AST.
Any pointers on converting C# code to an XML representation (which can be converted back to C#) would also be very helpful.

Kind regards,


Solution

  • MinosseCC: a lexer/parser generator for C#

    Also SO questions:

    Parser-generator that outputs C# given a BNF grammar? which suggests using ANTLR

    Translate C# code into AST?

    C# String to Expression Tree

    Developing a simple parser