将源代码划分为块. [英] Divide a source code to blocks.

查看:94
本文介绍了将源代码划分为块.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个源代码,我想将源代码划分为块:

例如
程序的输入:

I have a source code and I would like to divide the source code to blocks:

for example
an input to the program:

int x,y,z;
     x=10;
    
     if (x==10)
          y=8;

      while(x>8)
       {
         y=10+5;
         z=3;
          if(z==3)
               x=9;

       }



我希望输出看起来像这样:(CFG)



I would like the output looks something like this: (CFG)

block 0: int x,y,z;
         x=10;
         if (x==10)

block 1:(Yes) y=8;

block 2:(No) while(x>8)

block 3: y=10+5;
         z=3;
         if(z==3)

block 4: x=9;




有任何主意吗?




Any Idea?

推荐答案

大家好,

我有一个答案,但我怀疑您可能不喜欢它;).
要进行所需的分析,您需要一个C#解析器.
我找到了一个,但是它只能解析.NET 1.0的C#:

http://csparser.codeplex.com/

您当然可以踏上漫长的黑暗旅程,并使用 ANTLR 开发C#解析器,但是我真的没有看到任何快速解决方案为了您的努力.对不起! :sigh:


干杯


曼弗雷德(Manfred)
Hi alrowaithy,

I do have an answer, but I suspect you might not like it ;) .
To do the kind of analysis you want, you''d need a C# parser.
I found one but it only parses C# of .NET 1.0:

http://csparser.codeplex.com/

You could of course embark on a long dark journey and develop a C# parser using ANTLR, but I don''t really see any quick solution for your endevour. Sorry! :sigh:


Cheers


Manfred


这篇关于将源代码划分为块.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆