*/
int g_doctext_lineno;
+/**
+ * The First doctext comment
+ */
+char* g_program_doctext_candidate;
+int g_program_doctext_lineno = 0;
+PROGDOCTEXT_STATUS g_program_doctext_status = INVALID;
+
/**
* Whether or not negative field keys are accepted.
*/
g_doctext = NULL;
}
+/**
+ * Reset program doctext information after processing a file
+ */
+void reset_program_doctext_info() {
+ if(g_program_doctext_candidate != NULL) {
+ free(g_program_doctext_candidate);
+ g_program_doctext_candidate = NULL;
+ }
+ g_program_doctext_lineno = 0;
+ g_program_doctext_status = INVALID;
+}
+
+/**
+ * We are sure the program doctext candidate is really the program doctext.
+ */
+void declare_valid_program_doctext() {
+ if((g_program_doctext_candidate != NULL) && (g_program_doctext_status == STILL_CANDIDATE)) {
+ g_program_doctext_status = ABSOLUTELY_SURE;
+ }
+}
+
/**
* Cleans up text commonly found in doxygen-like comments
*
parse(*iter, program);
}
+ // reset program doctext status before parsing a new file
+ reset_program_doctext_info();
+
// Parse the program file
g_parse_mode = PROGRAM;
g_program = program;
HeaderList DefinitionList
{
pdebug("Program -> Headers DefinitionList");
- /*
- TODO(dreiss): Decide whether full-program doctext is worth the trouble.
- if ($1 != NULL) {
- g_program->set_doc($1);
+ if((g_program_doctext_candidate != NULL) && (g_program_doctext_status != ALREADY_PROCESSED))
+ {
+ g_program->set_doc(g_program_doctext_candidate);
+ g_program_doctext_status = ALREADY_PROCESSED;
}
- */
clear_doctext();
}
| tok_namespace tok_identifier tok_identifier
{
pdebug("Header -> tok_namespace tok_identifier tok_identifier");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace($2, $3);
}
| tok_namespace '*' tok_identifier
{
pdebug("Header -> tok_namespace * tok_identifier");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace("*", $3);
}
{
pwarning(1, "'cpp_namespace' is deprecated. Use 'namespace cpp' instead");
pdebug("Header -> tok_cpp_namespace tok_identifier");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace("cpp", $2);
}
| tok_cpp_include tok_literal
{
pdebug("Header -> tok_cpp_include tok_literal");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->add_cpp_include($2);
}
{
pwarning(1, "'php_namespace' is deprecated. Use 'namespace php' instead");
pdebug("Header -> tok_php_namespace tok_identifier");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace("php", $2);
}
{
pwarning(1, "'py_module' is deprecated. Use 'namespace py' instead");
pdebug("Header -> tok_py_module tok_identifier");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace("py", $2);
}
{
pwarning(1, "'perl_package' is deprecated. Use 'namespace perl' instead");
pdebug("Header -> tok_perl_namespace tok_identifier");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace("perl", $2);
}
{
pwarning(1, "'ruby_namespace' is deprecated. Use 'namespace rb' instead");
pdebug("Header -> tok_ruby_namespace tok_identifier");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace("rb", $2);
}
{
pwarning(1, "'smalltalk_category' is deprecated. Use 'namespace smalltalk.category' instead");
pdebug("Header -> tok_smalltalk_category tok_st_identifier");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace("smalltalk.category", $2);
}
{
pwarning(1, "'smalltalk_prefix' is deprecated. Use 'namespace smalltalk.prefix' instead");
pdebug("Header -> tok_smalltalk_prefix tok_identifier");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace("smalltalk.prefix", $2);
}
{
pwarning(1, "'java_package' is deprecated. Use 'namespace java' instead");
pdebug("Header -> tok_java_package tok_identifier");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace("java", $2);
}
{
pwarning(1, "'cocoa_prefix' is deprecated. Use 'namespace cocoa' instead");
pdebug("Header -> tok_cocoa_prefix tok_identifier");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace("cocoa", $2);
}
{
pwarning(1, "'xsd_namespace' is deprecated. Use 'namespace xsd' instead");
pdebug("Header -> tok_xsd_namespace tok_literal");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace("cocoa", $2);
}
{
pwarning(1, "'csharp_namespace' is deprecated. Use 'namespace csharp' instead");
pdebug("Header -> tok_csharp_namespace tok_identifier");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace("csharp", $2);
}
{
pwarning(1, "'delphi_namespace' is deprecated. Use 'namespace delphi' instead");
pdebug("Header -> tok_delphi_namespace tok_identifier");
+ declare_valid_program_doctext();
if (g_parse_mode == PROGRAM) {
g_program->set_namespace("delphi", $2);
}
tok_include tok_literal
{
pdebug("Include -> tok_include tok_literal");
+ declare_valid_program_doctext();
if (g_parse_mode == INCLUDES) {
std::string path = include_file(std::string($2));
if (!path.empty()) {