Compile simple string

后端 未结 6 1807
星月不相逢
星月不相逢 2021-02-15 13:57

Was just wondering if there are any built in functions in c++ OR c# that lets you use the compiler at runtime? Like for example if i want to translate:

!print \"         


        
6条回答
  •  误落风尘
    2021-02-15 14:32

    The .NET-framework provides a few classes which give you access to compilers and code generators for C# and VB.NET, resulting in either an assembly loaded into memory or a simple .exe-file. See CSharpCodeProvider and this article.

    Alternately, you can just create the source files and compile them manually (command-line calls (system) to the compiler, makefiles).

    Concerning the translation of your source: You'll have to use parsing mechanisms like regular expressions here, or use a compiler-compiler tool like Coco/R, yacc etc. (Note that under C++, boost::spirit can also be quite useful)

提交回复
热议问题