简单输入输出问题 [英] simple input output question

查看:88
本文介绍了简单输入输出问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以c ++代码作为输入,并在该代码中提取函数名称及其参数列表.任何建议

taking c++ code as an input and extract names of functions along with their argument list in that code . any suggestions

推荐答案

我想您想做一些项目.

为此,您需要标记字符串并使用
对其进行解析 您的解析逻辑.

对于标记化,您需要了解正则表达式以及如何使用C来使用它们.

此链接可能对您有帮助
http://www.peope.net/old/regex.html [
I guess you want to do some project.

For doing so you need to tokenize the string and parse it using
your parsing logic.

For tokenizing you need to know regarding regular expression and how to use them using C.

This link can be helpfull for you
http://www.peope.net/old/regex.html[^]


是的,您需要标记化.

对于自己动手的方法:

标记为字符/数字字符串(标识符或文字常量)和标点符号(分隔符,运算符).丢弃空格,包括注释.不要忘记以成对出现的运算符,例如++,> = ...

尝试找到声明.为此,您需要将整个文件分为语句(以冒号;终止的令牌序列)和函数定义(以块{...}终止的令牌序列).确保成对匹配大括号以获得完整的块.您可以忽略块内容.

现在,在其余的定义中,您应该找到带有一对括号()的定义.这些是函数声明(除非它们出现在等号的右侧,这意味着它们是初始化程序调用).

解析完整的函数签名(属性,返回类型,参数类型和参数名称)应该没什么大不了的,要检查,分隔符.始终确保成对匹配内部引号,括号,括号或尖括号.
Yes, you need to tokenize.

For a do-it-yourself approach:

Tokenize into character/digit strings (identifiers or literal constants) and punctuation (separators, operators). Discard white spaces, including comments. Do not forget operators that occur as pairs like ++, >= ...

Try and find the declarations. For this, you will need to split the whole file into statements (token sequences terminated by a colon ; ) and function definitions (token sequences terminated by a block {...}). Make sure to match the braces in pairs to obtain full blocks. You can ignore the block content.

Now among the remaining definitions, you should find those having a pair of parenthesis (). These are the function declarations (unless they appear at the right of an equal sign, meaning that they are initializer calls).

Parsing the complete function signature (attributes, return type, argument types and argument names) shouldn''t be such a big deal, checking for , separators. Always make sure to match internal quotes, brackets, parenthesis or angle bracket in pairs.


这篇关于简单输入输出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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