Doxygen
doctokenizer.h
浏览该文件的文档.
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,
49  RetVal_Paragraph = 0x10006,
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,
64  RetVal_CopyDoc = 0x10015,
65  RetVal_EndInternal = 0x10016,
67 };
68 
69 /** @brief Data associated with a token used by the comment block parser. */
70 struct TokenInfo
71 {
73  // command token
75 
76  // command text (RCS tag)
78 
79  // comment blocks
80 
81  // list token info
82  bool isEnumList = false;
83  int indent = 0;
84 
85  // sections
87 
88  // simple section
91 
92  // verbatim fragment
94 
95  // xrefitem
96  int id = -1;
97 
98  // html tag
100  bool endTag = false;
101  bool emptyTag = false;
103 
104  // whitespace
106 
107  // url
108  bool isEMailAddr = false;
109 
110  // param attributes
111  enum ParamDir { In=1, Out=2, InOut=3, Unspecified=0 };
113 };
114 
115 class Definition;
116 
118 {
119  public:
120  DocTokenizer();
121  ~DocTokenizer();
122 
123  TokenInfo *token();
124  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 setStateDot();
155  void setStateMsc();
156  void setStateParam();
157  void setStateXRefItem();
158  void setStateFile();
159  void setStatePattern();
160  void setStateLink();
161  void setStateCite();
162  void setStateRef();
163  void setStateInternalRef();
164  void setStateText();
165  void setStateSkipTitle();
166  void setStateAnchor();
167  void setInsidePre(bool b);
168  void pushBackHtmlTag(const QCString &tag);
169  void setStateSnippet();
170  void startAutoList();
171  void endAutoList();
172  void setStatePlantUML();
173  void setStateSetScope();
174  void setStatePlantUMLOpt();
175  void setStateOptions();
176  void setStateBlock();
177  void setStateEmoji();
178  void setStateIline();
179 
180  private:
181  struct Private;
182  std::unique_ptr<Private> p;
183 };
184 
185 // globals
186 //extern TokenInfo *g_token;
187 
188 
189 #endif
DocTokenizer::setStateAnchor
void setStateAnchor()
TokenInfo::emptyTag
bool emptyTag
Definition: doctokenizer.h:101
TokenInfo::endTag
bool endTag
Definition: doctokenizer.h:100
RetVal_Subsubsection
@ RetVal_Subsubsection
Definition: doctokenizer.h:64
RetVal_TableCell
@ RetVal_TableCell
Definition: doctokenizer.h:73
TokenInfo::attribsStr
QCString attribsStr
Definition: doctokenizer.h:102
DocTokenizer::p
std::unique_ptr< Private > p
Definition: doctokenizer.h:181
DocTokenizer::tokToString
static const char * tokToString(int token)
DocTokenizer::setStateBlock
void setStateBlock()
DocTokenizer::setStateInternalRef
void setStateInternalRef()
TK_WORD
@ TK_WORD
Definition: doctokenizer.h:46
DocTokenizer::setStatePlantUML
void setStatePlantUML()
Definition
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
RetVal_EndDesc
@ RetVal_EndDesc
Definition: doctokenizer.h:71
TokenInfo::isEnumList
bool isEnumList
Definition: doctokenizer.h:82
Private
@ Private
Definition: types.h:26
RetVal_SubParagraph
@ RetVal_SubParagraph
Definition: doctokenizer.h:66
HtmlAttribList
Class representing a list of HTML attributes.
Definition: htmlattrib.h:30
TokenInfo::InOut
@ InOut
Definition: doctokenizer.h:111
TokenInfo::name
QCString name
Definition: doctokenizer.h:74
DocTokenizer::findSections
void findSections(const QCString &input, const Definition *d, const QCString &fileName)
RetVal_OK
@ RetVal_OK
Command starting with \
Definition: doctokenizer.h:59
RetVal_CloseXml
@ RetVal_CloseXml
Definition: doctokenizer.h:78
DocTokenizer::setStateManOnly
void setStateManOnly()
TokenInfo::chars
QCString chars
Definition: doctokenizer.h:105
RetVal_EndTable
@ RetVal_EndTable
Definition: doctokenizer.h:75
DocTokenizer::setStateXmlOnly
void setStateXmlOnly()
RetVal_Subsection
@ RetVal_Subsection
Definition: doctokenizer.h:63
DocTokenizer::setStateParam
void setStateParam()
RetVal_TableRow
@ RetVal_TableRow
Definition: doctokenizer.h:72
TokenInfo::attribs
HtmlAttribList attribs
Definition: doctokenizer.h:99
DocTokenizer::setStateDot
void setStateDot()
DocTokenizer::init
void init(const char *input, const QCString &fileName, bool markdownSupport)
htmlattrib.h
TK_RCSTAG
@ TK_RCSTAG
Definition: doctokenizer.h:55
DocTokenizer::setStateMsc
void setStateMsc()
TokenInfo::simpleSectText
QCString simpleSectText
Definition: doctokenizer.h:90
DocTokenizer::setStateXmlCode
void setStateXmlCode()
TokenInfo::indent
int indent
Definition: doctokenizer.h:83
qcstring.h
TK_WHITESPACE
@ TK_WHITESPACE
Definition: doctokenizer.h:48
DocTokenizer::replaceToken
void replaceToken(TokenInfo *newToken)
TK_SYMBOL
@ TK_SYMBOL
Definition: doctokenizer.h:53
TK_LISTITEM
@ TK_LISTITEM
Definition: doctokenizer.h:49
TK_COMMAND_AT
@ TK_COMMAND_AT
Definition: doctokenizer.h:51
DocTokenizer::setStateLink
void setStateLink()
DocTokenizer::setStateVerbatim
void setStateVerbatim()
DocTokenizer::setStatePlantUMLOpt
void setStatePlantUMLOpt()
DocTokenizer::pushBackHtmlTag
void pushBackHtmlTag(const QCString &tag)
DocTokenizer::setStateIline
void setStateIline()
TokenInfo::verb
QCString verb
Definition: doctokenizer.h:93
RetVal_CopyDoc
@ RetVal_CopyDoc
Definition: doctokenizer.h:80
DocTokenizer::endAutoList
void endAutoList()
DocTokenizer::~DocTokenizer
~DocTokenizer()
DocTokenizer::setStateSkipTitle
void setStateSkipTitle()
TokenInfo::text
QCString text
Definition: doctokenizer.h:77
TokenInfo::paramDir
ParamDir paramDir
Definition: doctokenizer.h:112
RetVal_EndList
@ RetVal_EndList
Definition: doctokenizer.h:67
TokenInfo
Data associated with a token used by the comment block parser.
Definition: doctokenizer.h:70
RetVal_DescData
@ RetVal_DescData
Definition: doctokenizer.h:69
DocTokenizer::retvalToString
static const char * retvalToString(int retval)
RetVal_Internal
@ RetVal_Internal
Definition: doctokenizer.h:76
DocTokenizer::pushContext
void pushContext()
RetVal_ListItem
@ RetVal_ListItem
Definition: doctokenizer.h:61
DocTokenizer::setStateOptions
void setStateOptions()
DocTokenizer::startAutoList
void startAutoList()
DocTokenizer::getLineNr
int getLineNr(void)
DocTokenizer::setStateSnippet
void setStateSnippet()
DocTokenizer::setStateEmoji
void setStateEmoji()
TK_LNKWORD
@ TK_LNKWORD
Definition: doctokenizer.h:47
RetVal_EndInternal
@ RetVal_EndInternal
Definition: doctokenizer.h:81
DocTokenizer::popContext
bool popContext()
DocTokenizer::setStateRtfOnly
void setStateRtfOnly()
DocTokenizer::setStateText
void setStateText()
DocTokenizer::token
TokenInfo * token()
DocTokenizer::setStateCite
void setStateCite()
TokenInfo::Out
@ Out
Definition: doctokenizer.h:111
TokenInfo::Unspecified
@ Unspecified
Definition: doctokenizer.h:111
RetVal_EndBlockQuote
@ RetVal_EndBlockQuote
Definition: doctokenizer.h:79
RetVal_EndParBlock
@ RetVal_EndParBlock
Definition: doctokenizer.h:82
RetVal_SwitchLang
@ RetVal_SwitchLang
Definition: doctokenizer.h:77
TokenInfo::simpleSectName
QCString simpleSectName
Definition: doctokenizer.h:89
TokenInfo::id
int id
Definition: doctokenizer.h:96
DocTokenizer::setInsidePre
void setInsidePre(bool b)
DocTokenizer::setStateXRefItem
void setStateXRefItem()
DocTokenizer::setStateRef
void setStateRef()
RetVal_SimpleSec
@ RetVal_SimpleSec
Definition: doctokenizer.h:60
DocTokenizer
Definition: doctokenizer.h:117
TokenInfo::isEMailAddr
bool isEMailAddr
Definition: doctokenizer.h:108
DocTokenizer::setStateHtmlOnly
void setStateHtmlOnly()
DocTokenizer::setStateSetScope
void setStateSetScope()
DocTokenizer::setLineNr
void setLineNr(int lineno)
TK_ENDLIST
@ TK_ENDLIST
Definition: doctokenizer.h:50
TK_HTMLTAG
@ TK_HTMLTAG
Command starting with @
Definition: doctokenizer.h:52
RetVal_Section
@ RetVal_Section
Definition: doctokenizer.h:62
TokenInfo::ParamDir
ParamDir
Definition: doctokenizer.h:111
DocTokenizer::setStatePattern
void setStatePattern()
DocTokenizer::setStateCode
void setStateCode()
RetVal_DescTitle
@ RetVal_DescTitle
Definition: doctokenizer.h:70
RetVal_Paragraph
@ RetVal_Paragraph
Definition: doctokenizer.h:65
Tokens
Tokens
Definition: doctokenizer.h:28
TokenInfo::sectionId
QCString sectionId
Definition: doctokenizer.h:86
DocTokenizer::setStateTitle
void setStateTitle()
DocTokenizer::newToken
TokenInfo * newToken()
DocTokenizer::lex
int lex()
DocTokenizer::setStateFile
void setStateFile()
DocTokenizer::DocTokenizer
DocTokenizer()
TK_NEWPARA
@ TK_NEWPARA
Definition: doctokenizer.h:54
TokenInfo::TokenInfo
TokenInfo()
Definition: doctokenizer.h:72
DocTokenizer::setStatePara
void setStatePara()
DocTokenizer::setStateTitleAttrValue
void setStateTitleAttrValue()
DocTokenizer::setStateDbOnly
void setStateDbOnly()
RetVal_EndPre
@ RetVal_EndPre
Definition: doctokenizer.h:68
TK_COMMAND_BS
@ TK_COMMAND_BS
Definition: doctokenizer.h:57
RetVal_TableHCell
@ RetVal_TableHCell
Definition: doctokenizer.h:74
TokenInfo::In
@ In
Definition: doctokenizer.h:111
TK_URL
@ TK_URL
Definition: doctokenizer.h:56
DocTokenizer::setStateLatexOnly
void setStateLatexOnly()
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108
DocTokenizer::cleanup
void cleanup()