Delphi JavaDoc 解析器
我需要用 Delphi 7 解析 JavaDoc(文档)注释语法。 它在 Java 世界中被称为“JavaDoc”,但我实际上是为 PHP 做这个,即在一些 PHP 代码中解析 JavaDoc。如果您愿意,可以将其称为 PHPDoc。 要了解这些注释是如何工作的,您可以查看 RAD IDE,例如 NetBeans 等。
添加功能的 JavaDoc 示例:
/**
* Adds to numbers together.
* @param integer $a The first number.
* @param integer $b The second number.
* @return integer The resulting number.
*/
function add($a,$b){
return $a+$b;
}
请注意,解析器不需要是完整的,即解析所有 PHP 代码。 我的意思是,如果它仅接受评论文本作为输入,那就完全没问题了。
干杯, 克里斯.
I need to parse JavaDoc (documentation) comment syntax with Delphi 7.
It is well known in the java world as "JavaDoc", but I'm actually doing this for PHP, ie, parsing JavaDoc in some PHP code. Call it PHPDoc if you want to.
To see how these comments work, you can see RAD IDEs like NetBeans etc.
Example of JavaDoc for addition function:
/**
* Adds to numbers together.
* @param integer $a The first number.
* @param integer $b The second number.
* @return integer The resulting number.
*/
function add($a,$b){
return $a+$b;
}
Please note that the parser need not be full, ie, parsing all of the PHP code.
I mean, it's perfectly fine if it accepted the comment text only as input.
Cheers,
Chris.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可能会受到 DelpiCodeToDoc 的启发:http://dephicodetodoc.sourceforge.net/
它是 Delphi 的文档系统,使用 JavaDoc 语法。
它并不完全是您想要的(您需要它来获取 PHP 源代码),但支持很好并且可以使用。反应性的,可能您的需求将包含在下一个版本中。
You may be inspired by DelpiCodeToDoc : http://dephicodetodoc.sourceforge.net/
It is a documentation system for Delphi, using the JavaDoc syntax.
It is not exactly what you want (you need it for PHP sources) but the support is good & reactive and may be your needs will be included in a next version.
我必须为我自己的 PHP IDE 实现 phpDoc 解析格式。我正在做的只是简单地逐个解析字符,帕斯卡代码与此类似:
代码并不完美(应该更多地检查索引是否> 0和< len等),但应该给你这样的想法我在说什么。
该代码尚未经过测试,甚至也没有编译 - 写在 SO 的“你的答案”框中;);)
I had to implement phpDoc parsing format for my own PHP IDE. What I'm doing is simply parsing char by char, the pascal code similar to this:
the code is not perfect (there should be more checking whether indexes are > 0 and < len, etc) but should give you the idea of what I'm talking about.
the code has not been tested, nor even compiled - written in the "your answer" box of SO ;) ;)
您是否在 Google 上搜索过 PHPDocumentor?
Have you googled on PHPDocumentor?
您可以使用正则表达式引擎(JCL 中包含基于 PCRE 的 IIRC)来轻松解析注释并提取您需要的信息。
You could use a regular expression engine (one based IIRC on PCRE is included in JCL) to parse comments easily and extract the information you need.