正则表达式来拔出C函数原型声明? [英] Regex to pull out C function prototype declarations?

查看:263
本文介绍了正则表达式来拔出C函数原型声明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在什么地方学习曲线,当涉及到普通EX pressions,我需要用它们来自动修改函数原型在一堆C头文件。有谁知道一个像样的正规前pression找到在C头的任何和所有函数原型,而排除其他一切?

编辑:三件事情并没有初步明确:


  1. 我不关心C ++中,只有直C.这意味着没有模板等可担心的。

  2. 解决方案必须以typedef和结构,不局限于只有基本的C类型的工作。

  3. 这是一种一次性的事情。它并不需要是pretty。我不在乎多少杂牌它,只要它的作品,但我不想要一个复杂的,难以实施的解决方案。


解决方案

您可以实现使用解析器的 ANSI C的yacc /法语法

I'm somewhere on the learning curve when it comes to regular expressions, and I need to use them to automatically modify function prototypes in a bunch of C headers. Does anyone know of a decent regular expression to find any and all function prototypes in a C header, while excluding everything else?

Edit: Three things that weren't clear initially:

  1. I do not care about C++, only straight C. This means no templates, etc. to worry about.
  2. The solution must work with typedefs and structs, no limiting to only basic C types.
  3. This is kind of a one-off thing. It does not need to be pretty. I do not care how much of a kludge it is as long as it works, but I don't want a complex, hard to implement solution.

解决方案

You may implement a parser using ANSI C yacc/lex grammar.

这篇关于正则表达式来拔出C函数原型声明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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