diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2018-10-27 14:38:00 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2018-10-27 14:38:00 (GMT) |
commit | dff7c1af885ceb0210f6c529df4e16b0ebf19164 (patch) | |
tree | 5148a04aace214735468d2e3144f3efcbe7f6968 /src | |
parent | cf1c218d74ef52c22f9f22c33b1922c10d8291cd (diff) | |
download | Doxygen-dff7c1af885ceb0210f6c529df4e16b0ebf19164.zip Doxygen-dff7c1af885ceb0210f6c529df4e16b0ebf19164.tar.gz Doxygen-dff7c1af885ceb0210f6c529df4e16b0ebf19164.tar.bz2 |
Renamed command and moved duplicated code into a macro
Diffstat (limited to 'src')
-rw-r--r-- | src/docparser.cpp | 53 | ||||
-rw-r--r-- | src/doctokenizer.h | 4 | ||||
-rw-r--r-- | src/doctokenizer.l | 28 |
3 files changed, 48 insertions, 37 deletions
diff --git a/src/docparser.cpp b/src/docparser.cpp index f1c969b..bf9558f 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -56,6 +56,8 @@ #include "markdown.h" #include "htmlentity.h" +#define TK_COMMAND_CHAR(token) ((token)==TK_COMMAND_AT ? '@' : '\\') + // debug off #define DBG(x) do {} while(0) @@ -871,11 +873,12 @@ inline void errorHandleDefaultToken(DocNode *parent,int tok, { switch (tok) { - case TK_COMMAND: - case TK_COMMAND1: - children.append(new DocWord(parent,(tok == TK_COMMAND ? '@' : '\\') + g_token->name)); + case TK_COMMAND_AT: + // fall through + case TK_COMMAND_BS: + children.append(new DocWord(parent,TK_COMMAND_CHAR(tok) + g_token->name)); warn_doc_error(g_fileName,doctokenizerYYlineno,"Illegal command %s as part of a %s", - qPrint((tok == TK_COMMAND ? '@' : '\\') + g_token->name), txt); + qPrint(TK_COMMAND_CHAR(tok) + g_token->name), txt); break; case TK_SYMBOL: warn_doc_error(g_fileName,doctokenizerYYlineno,"Unsupported symbol %s found found as part of a %s", @@ -1371,7 +1374,7 @@ static bool defaultHandleToken(DocNode *parent,int tok, QList<DocNode> &children { DBG(("token %s at %d",tokToString(tok),doctokenizerYYlineno)); if (tok==TK_WORD || tok==TK_LNKWORD || tok==TK_SYMBOL || tok==TK_URL || - tok==TK_COMMAND || tok==TK_COMMAND1 || tok==TK_HTMLTAG + tok==TK_COMMAND_AT || tok==TK_COMMAND_BS || tok==TK_HTMLTAG ) { DBG((" name=%s",qPrint(g_token->name))); @@ -1381,8 +1384,9 @@ reparsetoken: QCString tokenName = g_token->name; switch (tok) { - case TK_COMMAND: - case TK_COMMAND1: + case TK_COMMAND_AT: + // fall through + case TK_COMMAND_BS: switch (Mappers::cmdMapper->map(tokenName)) { case CMD_BSLASH: @@ -2384,7 +2388,7 @@ void DocSecRefList::parse() // handle items while (tok) { - if (tok==TK_COMMAND || tok == TK_COMMAND1) + if (tok==TK_COMMAND_AT || tok == TK_COMMAND_BS) { switch (Mappers::cmdMapper->map(g_token->name)) { @@ -2722,8 +2726,9 @@ QCString DocLink::parse(bool isJavaLink,bool isXmlLink) { switch (tok) { - case TK_COMMAND: - case TK_COMMAND1: + case TK_COMMAND_AT: + // fall through + case TK_COMMAND_BS: switch (Mappers::cmdMapper->map(g_token->name)) { case CMD_ENDLINK: @@ -3231,8 +3236,9 @@ int DocIndexEntry::parse() } } break; - case TK_COMMAND: - case TK_COMMAND1: + case TK_COMMAND_AT: + // fall through + case TK_COMMAND_BS: switch (Mappers::cmdMapper->map(g_token->name)) { case CMD_BSLASH: m_entry+='\\'; break; @@ -3849,8 +3855,9 @@ int DocHtmlDescTitle::parse() { switch (tok) { - case TK_COMMAND: - case TK_COMMAND1: + case TK_COMMAND_AT: + // fall through + case TK_COMMAND_BS: { QCString cmdName=g_token->name; bool isJavaLink=FALSE; @@ -5340,7 +5347,7 @@ int DocPara::handleCommand(const QCString &cmdName, const int tok) switch (cmdId) { case CMD_UNKNOWN: - m_children.append(new DocWord(this,(tok == TK_COMMAND ? '@' : '\\') + cmdName)); + m_children.append(new DocWord(this,TK_COMMAND_CHAR(tok) + cmdName)); warn_doc_error(g_fileName,doctokenizerYYlineno,"Found unknown command `\\%s'",qPrint(cmdName)); break; case CMD_EMPHASIS: @@ -6443,7 +6450,7 @@ int DocPara::parse() reparsetoken: DBG(("token %s at %d",tokToString(tok),doctokenizerYYlineno)); if (tok==TK_WORD || tok==TK_LNKWORD || tok==TK_SYMBOL || tok==TK_URL || - tok==TK_COMMAND || tok == TK_COMMAND1 || tok==TK_HTMLTAG + tok==TK_COMMAND_AT || tok == TK_COMMAND_BS || tok==TK_HTMLTAG ) { DBG((" name=%s",qPrint(g_token->name))); @@ -6541,7 +6548,7 @@ reparsetoken: } else // other section { - tok = TK_COMMAND1; + tok = TK_COMMAND_BS; } DBG(("reparsing command %s\n",qPrint(g_token->name))); goto reparsetoken; @@ -6586,8 +6593,9 @@ reparsetoken: "list items"); } break; - case TK_COMMAND: - case TK_COMMAND1: + case TK_COMMAND_AT: + // fall through + case TK_COMMAND_BS: { // see if we have to start a simple section int cmd = Mappers::cmdMapper->map(g_token->name); @@ -6641,7 +6649,7 @@ reparsetoken: } else // other section { - tok = TK_COMMAND1; + tok = TK_COMMAND_BS; } DBG(("reparsing command %s\n",qPrint(g_token->name))); goto reparsetoken; @@ -6913,8 +6921,9 @@ void DocText::parse() } } break; - case TK_COMMAND: - case TK_COMMAND1: + case TK_COMMAND_AT: + // fall through + case TK_COMMAND_BS: switch (Mappers::cmdMapper->map(g_token->name)) { case CMD_BSLASH: diff --git a/src/doctokenizer.h b/src/doctokenizer.h index d0bdf06..c12e77e 100644 --- a/src/doctokenizer.h +++ b/src/doctokenizer.h @@ -34,13 +34,13 @@ enum Tokens TK_WHITESPACE = 3, TK_LISTITEM = 4, TK_ENDLIST = 5, - TK_COMMAND = 6, //! Command starting with `@` + TK_COMMAND_AT = 6, //! Command starting with `@` TK_HTMLTAG = 7, TK_SYMBOL = 8, TK_NEWPARA = 9, TK_RCSTAG = 10, TK_URL = 11, - TK_COMMAND1 = 12, //! Command starting with `\` + TK_COMMAND_BS = 12, //! Command starting with `\` RetVal_OK = 0x10000, RetVal_SimpleSec = 0x10001, diff --git a/src/doctokenizer.l b/src/doctokenizer.l index b4b0c18..5cd97a8 100644 --- a/src/doctokenizer.l +++ b/src/doctokenizer.l @@ -41,6 +41,8 @@ #define YY_NO_INPUT 1 #define YY_NO_UNISTD_H 1 + +#define TK_COMMAND_SEL() (yytext[0] == '@' ? TK_COMMAND_AT : TK_COMMAND_BS) //-------------------------------------------------------------------------- @@ -116,13 +118,13 @@ const char *tokToString(int token) case TK_WHITESPACE: return "TK_WHITESPACE"; case TK_LISTITEM: return "TK_LISTITEM"; case TK_ENDLIST: return "TK_ENDLIST"; - case TK_COMMAND: return "TK_COMMAND"; + case TK_COMMAND_AT: return "TK_COMMAND_AT"; case TK_HTMLTAG: return "TK_HTMLTAG"; case TK_SYMBOL: return "TK_SYMBOL"; case TK_NEWPARA: return "TK_NEWPARA"; case TK_RCSTAG: return "TK_RCSTAG"; case TK_URL: return "TK_URL"; - case TK_COMMAND1: return "TK_COMMAND1"; + case TK_COMMAND_BS: return "TK_COMMAND_BS"; } return "ERROR"; } @@ -559,11 +561,11 @@ REFWORD_NOCV {LABELID}|{REFWORD2_NOCV}|{REFWORD3}|{REFWORD4_NOCV} } <St_Para>"{"{BLANK}*"@link"/{BLANK}+ { g_token->name = "javalink"; - return TK_COMMAND; + return TK_COMMAND_AT; } <St_Para>"{"{BLANK}*"@inheritDoc"{BLANK}*"}" { g_token->name = "inheritdoc"; - return TK_COMMAND; + return TK_COMMAND_AT; } <St_Para>"@_fakenl" { // artificial new line yylineno++; @@ -573,14 +575,14 @@ REFWORD_NOCV {LABELID}|{REFWORD2_NOCV}|{REFWORD3}|{REFWORD4_NOCV} bool ok; g_token->id = QCString(yytext).right((int)yyleng-6).toInt(&ok); ASSERT(ok); - return (yytext[0] == '@' ? TK_COMMAND : TK_COMMAND1); + return TK_COMMAND_SEL(); } <St_Para>{CMD}"n"\n { /* \n followed by real newline */ yylineno++; g_token->name = yytext+1; g_token->name = g_token->name.stripWhiteSpace(); g_token->paramDir=TokenInfo::Unspecified; - return (yytext[0] == '@' ? TK_COMMAND : TK_COMMAND1); + return TK_COMMAND_SEL(); } <St_Para>{SPCMD1} | <St_Para>{SPCMD2} | @@ -588,7 +590,7 @@ REFWORD_NOCV {LABELID}|{REFWORD2_NOCV}|{REFWORD3}|{REFWORD4_NOCV} g_token->name = yytext+1; g_token->name = g_token->name.stripWhiteSpace(); g_token->paramDir=TokenInfo::Unspecified; - return (yytext[0] == '@' ? TK_COMMAND : TK_COMMAND1); + return TK_COMMAND_SEL(); } <St_Para>{PARAMIO} { /* param [in,out] command */ g_token->name = "param"; @@ -614,7 +616,7 @@ REFWORD_NOCV {LABELID}|{REFWORD2_NOCV}|{REFWORD3}|{REFWORD4_NOCV} { g_token->paramDir=TokenInfo::Unspecified; } - return (yytext[0] == '@' ? TK_COMMAND : TK_COMMAND1); + return TK_COMMAND_SEL(); } <St_Para>("http:"|"https:"|"ftp:"|"file:"|"news:"){URLMASK}/\. { // URL. g_token->name=yytext; @@ -734,7 +736,7 @@ REFWORD_NOCV {LABELID}|{REFWORD2_NOCV}|{REFWORD3}|{REFWORD4_NOCV} } <St_Text>[\\@<>&$#%~] { g_token->name = yytext; - return (yytext[0] == '@' ? TK_COMMAND : TK_COMMAND1); + return TK_COMMAND_SEL(); } <St_Para>({BLANK}*\n)+{BLANK}*\n/{LISTITEM} { /* skip trailing paragraph followed by new list item */ if (g_insidePre || g_autoListLevel==0) @@ -927,7 +929,7 @@ REFWORD_NOCV {LABELID}|{REFWORD2_NOCV}|{REFWORD3}|{REFWORD4_NOCV} <St_TitleN>{SPCMD2} { /* special command */ g_token->name = yytext+1; g_token->paramDir=TokenInfo::Unspecified; - return (yytext[0] == '@' ? TK_COMMAND : TK_COMMAND1); + return TK_COMMAND_SEL(); } <St_TitleN>{ID}"=" { /* attribute */ if (yytext[0]=='%') // strip % if present @@ -961,7 +963,7 @@ REFWORD_NOCV {LABELID}|{REFWORD2_NOCV}|{REFWORD3}|{REFWORD4_NOCV} <St_TitleQ>{SPCMD2} { /* special command */ g_token->name = yytext+1; g_token->paramDir=TokenInfo::Unspecified; - return (yytext[0] == '@' ? TK_COMMAND : TK_COMMAND1); + return TK_COMMAND_SEL(); } <St_TitleQ>{WORD1NQ} | <St_TitleQ>{WORD2NQ} { /* word */ @@ -1092,7 +1094,7 @@ REFWORD_NOCV {LABELID}|{REFWORD2_NOCV}|{REFWORD3}|{REFWORD4_NOCV} <St_Ref2>{SPCMD2} { /* special command */ g_token->name = yytext+1; g_token->paramDir=TokenInfo::Unspecified; - return (yytext[0] == '@' ? TK_COMMAND : TK_COMMAND1); + return TK_COMMAND_SEL(); } <St_Ref2>{WORD1NQ} | <St_Ref2>{WORD2NQ} { @@ -1324,7 +1326,7 @@ REFWORD_NOCV {LABELID}|{REFWORD2_NOCV}|{REFWORD3}|{REFWORD4_NOCV} <*>[\\@<>&$#%~"=] { /* unescaped special character */ //warn(g_fileName,yylineno,"Unexpected character `%s', assuming command \\%s was meant.",yytext,yytext); g_token->name = yytext; - return (yytext[0] == '@' ? TK_COMMAND : TK_COMMAND1); + return TK_COMMAND_SEL(); } <*>. { warn(g_fileName,yylineno,"Unexpected character `%s'",yytext); |