Changes to scanner and parser to allow record field comments.

The scanner can now be told to start/stop producing new token types that
assist in documenting record field types (and eventually enums also).

TOK_DOC:
    Produced on "##" style comments; documents the field that follows.

TOK_POST_DOC:
    Produced on "##<" style comments; documents the previous field.
This commit is contained in:
Jon Siwek 2011-03-14 13:10:49 -05:00
parent 4b0eb8127d
commit c4ca6f098c
3 changed files with 87 additions and 9 deletions

View file

@ -113,6 +113,7 @@ static void report_file();
%x RE
%x IGNORE
%s DOC
OWS [ \t]*
WS [ \t]+
@ -143,6 +144,17 @@ ESCSEQ (\\([^\n]|[0-7]+|x[[:xdigit:]]+))
);
}
<DOC>##<.* {
yylval.str = copy_string(yytext + 3);
return TOK_POST_DOC;
}
<DOC>##[^#\n].* {
yylval.str = copy_string(yytext + 2);
return TOK_DOC;
}
##[^#\n].* {
if ( generate_documentation )
{
@ -156,7 +168,7 @@ ESCSEQ (\\([^\n]|[0-7]+|x[[:xdigit:]]+))
{WS} /* eat whitespace */
<INITIAL,IGNORE>\n {
<INITIAL,IGNORE,DOC>\n {
report_file();
++line_number;
++yylloc.first_line;
@ -664,6 +676,16 @@ void do_atendif()
--current_depth;
}
void do_doc_token_start()
{
if ( generate_documentation ) BEGIN(DOC);
}
void do_doc_token_stop()
{
if ( generate_documentation ) BEGIN(INITIAL);
}
// Be careful to never delete things from this list, as the strings
// are referred to (in order to save the locations of tokens and statements,
// for error reporting and debugging).