![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
让代码飞
自动化编程,终极目标是取消人和机器 - 程序员
HockerF
这个作者很懒,什么都没留下…
展开
-
将c++程序的注释替换成空格-python
# c++ 程序 文件 filename = '/data/workspace/source_got/ssr/src/Main.cpp' with open(filename) as fr: src = fr.read() c_i = 0 sl = len(src) # 去掉注释部分 lt1 = ['\'','\"','\n'] lt2 = ['/','*'] lt3 = ['//','/*','*/'] # 0-0 1-1 33-2 34-43原创 2020-12-06 23:01:03 · 201 阅读 · 0 评论 -
1. 去除c语言中的注释
注释是为了让人更容易理解代码,但是机器不需要,所以在要去除这部分的注释,方便后面做处理。 用的python做实现。 from copy import deepcopy import sys define_debug = False def is_alnum(c): if ('0' <= c and c <= '9') or ('a' <= c and c <=...原创 2019-08-30 09:04:29 · 1066 阅读 · 0 评论 -
2. 将代码转换结构化
将第一篇获得的去注释后的代码进行结构化,我这里将代码划分为变量和符号等单位的list列表。 import json from copy import deepcopy define_debug = False # 解析的代码 code_parse = [] # 解析的当前节点的状态 cur_node = {} # print(symbols) def is_alnum(c): if...原创 2019-08-30 12:03:24 · 267 阅读 · 0 评论