python判断C语言是否被#if 0注掉
来源:互联网 发布:windows怎么激活 编辑:程序博客网 时间:2024/05/01 20:35
def getValidBlockIndex(indexList): startPos = 0 endPos = -1 count = 0 zeroFlag = 1 validBlockIndex = [] for element in indexList: count += element[0] if (count == 1 and zeroFlag == 1): endPos = element[1] validBlockIndex.append([startPos, endPos]) zeroFlag = 0 if (count == 0): startPos = element[1] zeroFlag = 1 validBlockIndex.append([startPos, -1]) return validBlockIndexdef getValidBlockList(string): index = 0 pos = 0 indexList = [] while(True): index = string.find('#if 0', pos) if (index == -1): break else: pos = index + len('#if 0') indexList.append([1, index]) pos = 0 index = 0 while(True): index = string.find('#endif', pos) if (index == -1): break else: pos = index + len('#endif') indexList.append([-1, pos]) indexList = sorted(indexList, key = lambda x:x[1]) validBlockIndex = getValidBlockIndex(indexList) print validBlockIndex validBlockList = [] for element in validBlockIndex: if element[1] == -1: validBlockList.append(string[element[0]:]) else: validBlockList.append(string[element[0]:element[1]]) return validBlockListif __name__ == "__main__": string = "#if 0xxx#if 0yyyy#endifwwww#if 0zzz#endifuuuu#endif" validBlockList = getValidBlockList(string) print validBlockList
0 0
- python判断C语言是否被#if 0注掉
- C语言if判断是否为0的问题
- <c:if>判断参数是否为空
- <c:if>的用法判断是否换行
- <c:if> 判断变量是否为null
- <c:if> 判断是否为空
- c:if 判断集合是否为空
- <s:if><c:if>判断参数是否为空
- C语言 判断是否素数
- C语言if语句判断闰年平年
- C语言if判断成绩及不及格
- JSTL C标签 <c:if>判断参数是否为空
- JSTL C标签 <c:if>判断参数是否为空
- JSTL C标签 <c:if>判断参数是否为空!
- JSTL C标签 <c:if>判断参数是否为空
- c语言:不用if,else语句,也不用循环条件等,输入一个字符,判断是否为大写字母
- c:if 判断指定的url参数是否为空
- jsp <c:if>判断List是否为空
- UILaber 设置动态高度,获取高度
- box2d
- ios 动态获取第三方路径
- xmpp 聊天室
- xmpp 登陆
- python判断C语言是否被#if 0注掉
- xmpp 好友列表,删除好友
- xmpp 好友上下线
- XMPPFrameWork IOS 开发(七)消息回执
- UIApplication sharedApplication详细解释-IOS
- ios 获取当前时间
- ios NSRunloop
- ASI
- IOS uiimage 拉伸的方法