1 /****************************************************************************** 2 * 3 * $Id: $ 4 * 5 * 6 * Copyright (C) 1997-2015 by Dimitri van Heesch. 7 * 8 * Permission to use, copy, modify, and distribute this software and its 9 * documentation under the terms of the GNU General Public License is hereby 10 * granted. No representations are made about the suitability of this software 11 * for any purpose. It is provided "as is" without express or implied warranty. 12 * See the GNU General Public License for more details. 13 * 14 * Documents produced by Doxygen are derivative works derived from the 15 * input used in their production; they are not affected by this license. 16 * 17 */ 18 19 #ifndef DOCTOKENIZER_H 20 #define DOCTOKENIZER_H 21 22 #include <stdio.h> 23 #include <memory> 24 25 #include "htmlattrib.h" 26 #include "qcstring.h" 27 28 enum Tokens 29 { 30 TK_WORD = 1, 31 TK_LNKWORD = 2, 32 TK_WHITESPACE = 3, 33 TK_LISTITEM = 4, 34 TK_ENDLIST = 5, 35 TK_COMMAND_AT = 6, //! Command starting with `@` 36 TK_HTMLTAG = 7, 37 TK_SYMBOL = 8, 38 TK_NEWPARA = 9, 39 TK_RCSTAG = 10, 40 TK_URL = 11, 41 TK_COMMAND_BS = 12, //! Command starting with `\` 42 43 RetVal_OK = 0x10000, 44 RetVal_SimpleSec = 0x10001, 45 RetVal_ListItem = 0x10002, 46 RetVal_Section = 0x10003, 47 RetVal_Subsection = 0x10004, 48 RetVal_Subsubsection = 0x10005, 49 RetVal_Paragraph = 0x10006, 50 RetVal_SubParagraph = 0x10007, 51 RetVal_EndList = 0x10008, 52 RetVal_EndPre = 0x10009, 53 RetVal_DescData = 0x1000A, 54 RetVal_DescTitle = 0x1000B, 55 RetVal_EndDesc = 0x1000C, 56 RetVal_TableRow = 0x1000D, 57 RetVal_TableCell = 0x1000E, 58 RetVal_TableHCell = 0x1000F, 59 RetVal_EndTable = 0x10010, 60 RetVal_Internal = 0x10011, 61 RetVal_SwitchLang = 0x10012, 62 RetVal_CloseXml = 0x10013, 63 RetVal_EndBlockQuote = 0x10014, 64 RetVal_CopyDoc = 0x10015, 65 RetVal_EndInternal = 0x10016, 66 RetVal_EndParBlock = 0x10017 67 }; 68 69 /** @brief Data associated with a token used by the comment block parser. */ 70 struct TokenInfo 71 { TokenInfoTokenInfo72 TokenInfo() : isEnumList(FALSE), indent(0), id(-1), endTag(FALSE), emptyTag(FALSE), paramDir(Unspecified) {} 73 // command token 74 QCString name; 75 76 // command text (RCS tag) 77 QCString text; 78 79 // comment blocks 80 81 // list token info 82 bool isEnumList = false; 83 int indent = 0; 84 85 // sections 86 QCString sectionId; 87 88 // simple section 89 QCString simpleSectName; 90 QCString simpleSectText; 91 92 // verbatim fragment 93 QCString verb; 94 95 // xrefitem 96 int id = -1; 97 98 // html tag 99 HtmlAttribList attribs; 100 bool endTag = false; 101 bool emptyTag = false; 102 QCString attribsStr; 103 104 // whitespace 105 QCString chars; 106 107 // url 108 bool isEMailAddr = false; 109 110 // param attributes 111 enum ParamDir { In=1, Out=2, InOut=3, Unspecified=0 }; 112 ParamDir paramDir = Unspecified; 113 }; 114 115 class Definition; 116 117 class DocTokenizer 118 { 119 public: 120 DocTokenizer(); 121 ~DocTokenizer(); 122 123 TokenInfo *token(); 124 TokenInfo *newToken(); 125 void replaceToken(TokenInfo *newToken); 126 127 // helper functions 128 static const char *tokToString(int token); 129 static const char *retvalToString(int retval); 130 131 void setLineNr(int lineno); 132 int getLineNr(void); 133 134 // operations on the scanner 135 void findSections(const QCString &input,const Definition *d, 136 const QCString &fileName); 137 void init(const char *input,const QCString &fileName,bool markdownSupport); 138 void cleanup(); 139 void pushContext(); 140 bool popContext(); 141 int lex(); 142 void setStatePara(); 143 void setStateTitle(); 144 void setStateTitleAttrValue(); 145 void setStateCode(); 146 void setStateXmlCode(); 147 void setStateHtmlOnly(); 148 void setStateManOnly(); 149 void setStateLatexOnly(); 150 void setStateXmlOnly(); 151 void setStateDbOnly(); 152 void setStateRtfOnly(); 153 void setStateVerbatim(); 154 void setStateILiteral(); 155 void setStateILiteralOpt(); 156 void setStateDot(); 157 void setStateMsc(); 158 void setStateParam(); 159 void setStateXRefItem(); 160 void setStateFile(); 161 void setStatePattern(); 162 void setStateLink(); 163 void setStateCite(); 164 void setStateRef(); 165 void setStateInternalRef(); 166 void setStateText(); 167 void setStateSkipTitle(); 168 void setStateAnchor(); 169 void setInsidePre(bool b); 170 void pushBackHtmlTag(const QCString &tag); 171 void setStateSnippet(); 172 void startAutoList(); 173 void endAutoList(); 174 void setStatePlantUML(); 175 void setStateSetScope(); 176 void setStatePlantUMLOpt(); 177 void setStateOptions(); 178 void setStateBlock(); 179 void setStateEmoji(); 180 void setStateIline(); 181 182 private: 183 struct Private; 184 std::unique_ptr<Private> p; 185 }; 186 187 // globals 188 //extern TokenInfo *g_token; 189 190 191 #endif 192