以下python代码主要用于匹配各种类型的C语言函数,使用的为re.search,意味着包含,如果需要完全匹配请用re.match。
# coding=utf-8
import re
# 匹配函数,包含函数体
function_return_type = r'''
(\s*) #匹配所有的空白字符
(
(const)?(volatile)?(static)?\s*(inline)?\s*(extern)?\s*
(
(VOID)|(void)|(enum)|
((unsigned)?(signed)?(long)?\s*(int)|(char)|(float)|(short)|(long)|(double))|
(bool)|(struct\s*\w+)|(union\s*\w+)|(wait_queue_t)|(wait_queue_head_t)
)
\s*(fastcall)?