Doxygen
Loading...
Searching...
No Matches
doctokenizer.l
Go to the documentation of this file.
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%option never-interactive
20%option prefix="doctokenizerYY"
21%option reentrant
22%option extra-type="struct doctokenizerYY_state *"
23%top{
24#include <stdint.h>
25// forward declare yyscan_t to improve type safety
26#define YY_TYPEDEF_YY_SCANNER_T
27struct yyguts_t;
28typedef yyguts_t *yyscan_t;
yyguts_t * yyscan_t
Definition code.l:24
29}
30
31%{
32
33#include <ctype.h>
34#include <stack>
35#include <string>
36#include <cassert>
37
38#include "doctokenizer.h"
39#include "cmdmapper.h"
40#include "config.h"
41#include "message.h"
42#include "section.h"
43#include "membergroup.h"
44#include "definition.h"
45#include "doxygen.h"
46#include "portable.h"
47#include "cite.h"
48#include "regex.h"
49#include "debug.h"
50#include "docnode.h"
51
52#define YY_NO_INPUT 1
53#define YY_NO_UNISTD_H 1
54
55//--------------------------------------------------------------------------
56
58{
59 DocLexerContext(const TokenInfo &tk,int r,int lvl,yy_size_t pos,const char *s,YY_BUFFER_STATE bs)
60 : token(tk), rule(r), autoListLevel(lvl), inputPos(pos), inputString(s), state(bs) {}
62 int rule;
64 yy_size_t inputPos;
65 const char *inputString;
66 YY_BUFFER_STATE state;
67};
68
70{
71
72 // context for tokenizer phase
75 yy_size_t inputPos = 0;
76 const char *inputString = nullptr;
78 bool insidePre = false;
80 bool markdownSupport=true;
81 bool insideHtmlLink=false;
82
83 // context for section finding phase
84 const Definition *definition = nullptr;
90 std::stack< std::unique_ptr<DocLexerContext> > lexerStack;
91 std::stack<int> stateStack;
92
93 int yyLineNr = 0;
94};
95
96#define lineCount(s,len) do { for(int i=0;i<(int)len;i++) if (s[i]=='\n') yyextra->yyLineNr++; } while(0)
97
98
99[[maybe_unused]] static const char *stateToString(int state);
100
101static int yyread(yyscan_t yyscanner,char *buf,int max_size);
102static void handleHtmlTag(yyscan_t yyscanner,const char *text);
103static void processSection(yyscan_t yyscanner);
104
105//--------------------------------------------------------------------------
106
108{
109 int nl1 = text.find('\n');
110 int nl2 = text.find("\\ilinebr");
111 if (nl1!=-1 && nl1<nl2)
112 {
113 return text.mid(nl1+1);
114 }
115 if (nl2!=-1)
116 {
117 if (text.at(nl2+8)==' ') nl2++; // skip space after \\ilinebr
118 return text.mid(nl2+8);
119 }
120 return text;
121}
122
123//--------------------------------------------------------------------------
124
125static int computeIndent(const char *str,size_t length)
126{
127 if (str==0 || length==std::string::npos) return 0;
128 size_t i;
129 int indent=0;
130 int tabSize=Config_getInt(TAB_SIZE);
131 for (i=0;i<length;i++)
132 {
133 if (str[i]=='\t')
134 {
135 indent+=tabSize - (indent%tabSize);
136 }
137 else if (str[i]=='\n')
138 {
139 indent=0;
140 }
141 else if (str[i]=='\\' && qstrncmp(str+i+1,"ilinebr",7)==0)
142 {
143 indent=0;
144 i+=7;
145 if (str[i+1]==' ') i++; // also eat space after \\ilinebr if present
146 }
147 else
148 {
149 indent++;
150 }
151 }
152 //printf("input('%s')=%d\n",str,indent);
153 return indent;
154}
155
156//--------------------------------------------------------------------------
157
158#define unput_string(yytext,yyleng) do { for (int i=(int)yyleng-1;i>=0;i--) unput(yytext[i]); } while(0)
159//--------------------------------------------------------------------------
160
161#undef YY_INPUT
162#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
163
164// otherwise the filename would be the name of the converted file (*.cpp instead of *.l)
165static inline const char *getLexerFILE() {return __FILE__;}
166#include "doxygen_lex.h"
167
168//--------------------------------------------------------------------------
169#define YY_DECL static Token doctokenizerYYlex(yyscan_t yyscanner)
170//#define LOCAL_YY_DECL local_doctokenizer(yyscan_t yyscanner)
171#ifndef yyterminate
172#define yyterminate() return Token::make_TK_EOF()
173#endif
174
The common base class of all entity definitions found in the sources.
Definition definition.h:76
This is an alternative implementation of QCString.
Definition qcstring.h:101
int find(char c, int index=0, bool cs=TRUE) const
Definition qcstring.cpp:43
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:226
char & at(size_t i)
Returns a reference to the character at index i.
Definition qcstring.h:578
#define Config_getInt(name)
Definition config.h:34
QCString extractPartAfterNewLine(const QCString &text)
static void processSection(yyscan_t yyscanner)
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
static const char * stateToString(int state)
static void handleHtmlTag(yyscan_t yyscanner, const char *text)
static const char * getLexerFILE()
static int computeIndent(const char *str, size_t length)
Portable versions of functions that are platform dependent.
int qstrncmp(const char *str1, const char *str2, size_t len)
Definition qcstring.h:75
TokenInfo token
const char * inputString
yy_size_t inputPos
DocLexerContext(const TokenInfo &tk, int r, int lvl, yy_size_t pos, const char *s, YY_BUFFER_STATE bs)
YY_BUFFER_STATE state
Data associated with a token used by the comment block parser.
const Definition * definition
std::stack< int > stateStack
const char * inputString
std::stack< std::unique_ptr< DocLexerContext > > lexerStack
175%}
176
177CMD ("\\"|"@")
178WS [ \t\r\n]
179BLANK [ \t\r]
180BLANKopt {BLANK}*
181ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
182LABELID [a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF\-]*
183CODEID [a-zA-Z][a-zA-Z0-9+]*
184PHPTYPE [?]?[\\:a-z_A-Z0-9\x80-\xFF\-]+
185CITESCHAR [a-z_A-Z0-9\x80-\xFF\-\?]
186CITEECHAR [a-z_A-Z0-9\x80-\xFF\-\+:\/\?]
187CITEID {CITESCHAR}{CITEECHAR}*("."{CITESCHAR}{CITEECHAR}*)*|"\""{CITESCHAR}{CITEECHAR}*("."{CITESCHAR}{CITEECHAR}*)*"\""
188DOXYCFG [A-Z][A-Z_0-9]*
189MAILADDR ("mailto:")?[a-z_A-Z0-9\x80-\xFF.+-]+"@"[a-z_A-Z0-9\x80-\xFf-]+("."[a-z_A-Z0-9\x80-\xFf\-]+)+[a-z_A-Z0-9\x80-\xFf\-]+
190MAILWS [\t a-z_A-Z0-9\x80-\xFF+-]
191MAILADDR2 {MAILWS}+{BLANK}+("at"|"AT"|"_at_"|"_AT_"){BLANK}+{MAILWS}+("dot"|"DOT"|"_dot_"|"_DOT_"|"point"|"POINT"|"_point_"|"_POINT_"){BLANK}+{MAILWS}+
192LISTITEM {BLANK}*[-]("#")?{WS}
193MLISTITEM {BLANK}*[+*]{WS}
194OLISTITEM {BLANK}*("0"|[1-9][0-9]*)"."{BLANK}
195CLISTITEM {BLANK}*[-]{BLANK}*"\["[ xX]"\]"
196ENDLIST {BLANK}*"."{BLANK}*(\n|"\\ilinebr")
197ATTRNAME [a-z_A-Z\x80-\xFF][:a-z_A-Z0-9\x80-\xFF\-]*
198ATTRIB {ATTRNAME}{WS}*("="{WS}*(("\""[^\"]*"\"")|("'"[^\']*"'")|[^ \t\r\n'"><]+))?
199URLCHAR [a-z_A-Z0-9\!\~\,\:\;\'\$\?\@\&\%\#\.\-\+\/\=\x80-\xFF]
200URLMASK ({URLCHAR}+([({]{URLCHAR}*[)}])?)+
201URLPROTOCOL ("http:"|"https:"|"ftp:"|"ftps:"|"sftp:"|"file:"|"news:"|"irc:"|"ircs:")
202FILEICHAR [a-z_A-Z0-9\x80-\xFF\\:\\\/\-\+=&#@~]
203FILEECHAR [a-z_A-Z0-9\x80-\xFF\-\+=&#@~]
204FILECHARS {FILEICHAR}*{FILEECHAR}+
205HFILEMASK {FILEICHAR}*("."{FILEICHAR}+)+{FILECHARS}*
206VFILEMASK {FILECHARS}("."{FILECHARS})*
207FILEMASK {VFILEMASK}|{HFILEMASK}
208LINKMASK [^ \t\n\r\\@<&${}]+("("[^\n)]*")")?({BLANK}*("const"|"volatile"){BLANK}+)?
209VERBATIM "verbatim"{BLANK}*
210SPCMD1 {CMD}([a-z_A-Z][a-z_A-Z0-9]*|{VERBATIM}|"--"|"---")
211SPCMD2 {CMD}[\\@<>&$#%~".+=|!?-]
212SPCMD3 {CMD}_form#[0-9]+
213SPCMD4 {CMD}"::"
214SPCMD5 {CMD}":"
215INOUT "in"|"out"|("in"{BLANK}*","?{BLANK}*"out")|("out"{BLANK}*","?{BLANK}*"in")
216PARAMIO {CMD}param{BLANK}*"["{BLANK}*{INOUT}{BLANK}*"]"
217VARARGS "..."
218TEMPCHAR [a-z_A-Z0-9.,: \t\*\&\‍(\‍)\[\]]
219FUNCCHAR [a-z_A-Z0-9,:<> \t\n\^\*\&\[\]]|{VARARGS}|"\\ilinebr"
220FUNCPART {FUNCCHAR}*("("{FUNCCHAR}*")"{FUNCCHAR}*)?
221SCOPESEP "::"|"#"|"."
222TEMPLPART "<"{TEMPCHAR}*("<"{TEMPCHAR}*("<"{TEMPCHAR}*">")?">")?">"
223ANONNS "anonymous_namespace{"[^}]*"}"
224SCOPEPRE (({ID}{TEMPLPART}?)|{ANONNS}){SCOPESEP}
225SCOPEKEYS ":"({ID}":")*
226SCOPECPP {SCOPEPRE}*(~)?{ID}{TEMPLPART}?
227SCOPECPPN {SCOPEPRE}*(~)?{ID}
228SCOPEOBJC {SCOPEPRE}?{ID}{SCOPEKEYS}?
229SCOPEMASK {SCOPECPP}|{SCOPEOBJC}
230SCOPEMSKN {SCOPECPPN}|{SCOPEOBJC}
231FUNCARG "("{FUNCPART}")"({BLANK}*("volatile"|"const"){BLANK})?
232FUNCARG2 "("{FUNCPART}")"({BLANK}*("volatile"|"const"))?
233OPNEW {BLANK}+"new"({BLANK}*"[]")?
234OPDEL {BLANK}+"delete"({BLANK}*"[]")?
235OPNORM {OPNEW}|{OPDEL}|"+"|"-"|"*"|"/"|"%"|"^"|"&"|"|"|"~"|"!"|"="|"<"|">"|"+="|"-="|"*="|"/="|"%="|"^="|"&="|"|="|"<<"|">>"|"<<="|">>="|"=="|"!="|"<="|">="|"&&"|"||"|"++"|"--"|","|"->*"|"->"|"[]"|"()"|"<=>"
236OPCAST {BLANK}+[^<(\r\n.,][^(\r\n.,]*
237OPMASK ({BLANK}*{OPNORM}{FUNCARG})
238OPMASKOPT ({BLANK}*{OPNORM}{FUNCARG}?)|({OPCAST}{FUNCARG})
239OPMASKOP2 ({BLANK}*{OPNORM}{FUNCARG2}?)|({OPCAST}{FUNCARG2})
240LNKWORD1 ("::"|"#")?{SCOPEMASK}
241LNKWORDN ("::"|"#")?{SCOPEMSKN}
242CVSPEC {BLANK}*("const"|"volatile")
243LNKWORD2 (({SCOPEPRE}*"operator"{OPMASK})|({SCOPEPRE}"operator"{OPMASKOPT})|(("::"|"#"){SCOPEPRE}*"operator"{OPMASKOPT})){CVSPEC}?
244LNKWORD3 ([0-9a-z_A-Z\-]+("/"|"\\"))*[0-9a-z_A-Z\-]+("."[0-9a-z_A-Z]+)+
245CHARWORDQ [^ \t\n\r\\@<>()\[\]:;\?{}&%$#,."=']
246ESCWORD ("%"{ID}(("::"|"."){ID})*)|("%'")
247CHARWORDQ1 [^ \-+0-9\t\n\r\\@<>()\[\]:;\?{}&%$#,."=']
248WORD1 {ESCWORD}|{CHARWORDQ1}{CHARWORDQ}*|"{"|"}"|"'\"'"|("\""([^"\n]*(\\\"|\n)?)*[^"\n]*"\"")
249WORD2 "."|","|"("|")"|"["|"]"|"::"|":"|";"|"\?"|"="|"'"
250WORD1NQ {ESCWORD}|{CHARWORDQ}+|"{"|"}"
251WORD2NQ "."|","|"("|")"|"["|"]"|"::"|":"|";"|"\?"|"="|"'"
252CAPTION [cC][aA][pP][tT][iI][oO][nN]
253HTMLTAG "<"(("/")?){ID}({WS}+{ATTRIB})*{WS}*(("/")?)">"
254HTMLKEYL "strong"|"center"|"table"|"caption"|"small"|"code"|"dfn"|"var"|"img"|"pre"|"sub"|"sup"|"tr"|"td"|"th"|"ol"|"ul"|"li"|"tt"|"kbd"|"em"|"hr"|"dl"|"dt"|"dd"|"br"|"i"|"a"|"b"|"p"|"strike"|"u"|"del"|"ins"|"s"
255HTMLKEYU "STRONG"|"CENTER"|"TABLE"|"CAPTION"|"SMALL"|"CODE"|"DFN"|"VAR"|"IMG"|"PRE"|"SUB"|"SUP"|"TR"|"TD"|"TH"|"OL"|"UL"|"LI"|"TT"|"KBD"|"EM"|"HR"|"DL"|"DT"|"DD"|"BR"|"I"|"A"|"B"|"P"|"STRIKE"|"U"|"DEL"|"INS"|"S"
256HTMLKEYW {HTMLKEYL}|{HTMLKEYU}
257HTMLTAG_STRICT "<"(("/")?){HTMLKEYW}({WS}+{ATTRIB})*{WS}*(("/")?)">"
258REFWORD2_PRE ("#"|"::")?((({ID}{TEMPLPART}?)|{ANONNS})("."|"#"|"::"|"-"|"/"))*({ID}{TEMPLPART}?(":")?)
259REFWORD2 {REFWORD2_PRE}{FUNCARG2}?
260REFWORD2_NOCV {REFWORD2_PRE}("("{FUNCPART}")")?
261REFWORD3 ({ID}":")*{ID}":"?
262REFWORD4_NOCV (({SCOPEPRE}*"operator"{OPMASKOP2})|(("::"|"#"){SCOPEPRE}*"operator"{OPMASKOP2}))
263REFWORD4 {REFWORD4_NOCV}{CVSPEC}?
264REFWORD {FILEMASK}|{LABELID}|{REFWORD2}|{REFWORD3}|{REFWORD4}
265REFWORD_NOCV {FILEMASK}|{LABELID}|{REFWORD2_NOCV}|{REFWORD3}|{REFWORD4_NOCV}
266RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revision"|"Source"|"State")":"[^:\n$][^\n$]*"$"
267LINENR {BLANK}*([1-9][0-9]*|"0"|"-1")
268
269SHOWDATE ([0-9]{4}"-"[0-9]{1,2}"-"[0-9]{1,2})?({WS}*[0-9]{1,2}":"[0-9]{1,2}(":"[0-9]{1,2})?)?
270
271%option noyywrap
272
273%x St_Para
274%x St_Comment
275%x St_Title
276%x St_TitleN
277%x St_TitleQ
278%x St_TitleA
279%x St_TitleV
280%x St_Code
281%x St_iCode
282%x St_CodeOpt
283%x St_iCodeOpt
284%x St_XmlCode
285%x St_HtmlOnly
286%x St_HtmlOnlyOption
287%x St_ManOnly
288%x St_LatexOnly
289%x St_RtfOnly
290%x St_XmlOnly
291%x St_DbOnly
292%x St_Verbatim
293%x St_iVerbatim
294%x St_ILiteral
295%x St_ILiteralOpt
296%x St_Dot
297%x St_Msc
298%x St_PlantUMLOpt
299%x St_PlantUML
300%x St_Param
301%x St_XRefItem
302%x St_XRefItem2
303%x St_File
304%x St_IFile
305%x St_Pattern
306%x St_Link
307%x St_Cite
308%x St_DoxyConfig
309%x St_Ref
310%x St_Ref2
311%x St_IntRef
312%x St_Text
313%x St_SkipTitle
314%x St_Anchor
315%x St_Prefix
316%x St_Snippet
317%x St_SetScope
318%x St_SetScopeEnd
319%x St_Options
320%x St_Block
321%x St_Emoji
322%x St_ILine
323%x St_ShowDate
324
325%x St_Sections
326%s St_SecLabel1
327%s St_SecLabel2
328%s St_SecTitle
329%x St_SecSkip
330
331%x St_QuotedString
332%x St_QuotedContent
333
335<St_Para>\r /* skip carriage return */
336<St_Para>^{LISTITEM} { /* list item */
337 if (yyextra->insideHtmlLink || yyextra->insidePre) REJECT;
338 lineCount(yytext,yyleng);
339 QCString text(yytext);
340 uint32_t dashPos = static_cast<uint32_t>(text.findRev('-'));
341 assert(dashPos!=static_cast<uint32_t>(-1));
342 yyextra->token.isEnumList = text.at(dashPos+1)=='#';
343 yyextra->token.isCheckedList = false;
344 yyextra->token.id = -1;
345 yyextra->token.indent = computeIndent(yytext,dashPos);
346 return Token::make_TK_LISTITEM();
347 }
static int computeIndent(const char *s)
#define lineCount(s, len)
348<St_Para>^{CLISTITEM} { /* checkbox item */
349 QCString text=yytext;
350 int dashPos = text.findRev('-');
351 yyextra->token.isEnumList = false;
352 yyextra->token.isCheckedList = true;
353 if (text.find('x') != -1) yyextra->token.id = DocAutoList::Checked_x;
354 else if (text.find('X') != -1) yyextra->token.id = DocAutoList::Checked_X;
355 else yyextra->token.id = DocAutoList::Unchecked;
356 yyextra->token.indent = computeIndent(yytext,dashPos);
357 return Token::make_TK_LISTITEM();
358 }
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:91
359<St_Para>^{MLISTITEM} { /* list item */
360 if (yyextra->insideHtmlLink || !yyextra->markdownSupport || yyextra->insidePre)
361 {
362 REJECT;
363 }
364 else
365 {
366 lineCount(yytext,yyleng);
367 std::string text(yytext);
368 static const reg::Ex re(R"([*+][^*+]*$)"); // find last + or *
370 reg::search(text,match,re);
371 size_t listPos = match.position();
372 assert(listPos!=std::string::npos);
373 yyextra->token.isEnumList = false;
374 yyextra->token.isCheckedList = false;
375 yyextra->token.id = -1;
376 yyextra->token.indent = computeIndent(yytext,listPos);
377 return Token::make_TK_LISTITEM();
378 }
379 }
Class representing a regular expression.
Definition regex.h:39
Object representing the matching results.
Definition regex.h:153
bool search(std::string_view str, Match &match, const Ex &re, size_t pos)
Search in a given string str starting at position pos for a match against regular expression re.
Definition regex.cpp:748
bool match(std::string_view str, Match &match, const Ex &re)
Matches a given string str for a match against regular expression re.
Definition regex.cpp:759
380<St_Para>^{OLISTITEM} { /* numbered list item */
381 if (yyextra->insideHtmlLink || !yyextra->markdownSupport || yyextra->insidePre)
382 {
383 REJECT;
384 }
385 else
386 {
387 std::string text(yytext);
388 static const reg::Ex re(R"(\d+)");
390 reg::search(text,match,re);
391 size_t markPos = match.position();
392 assert(markPos!=std::string::npos);
393 yyextra->token.isEnumList = true;
394 yyextra->token.isCheckedList = false;
395 bool ok = false;
396 int id = QCString(match.str()).toInt(&ok);
397 yyextra->token.id = ok ? id : -1;
398 if (!ok)
399 {
400 warn(yyextra->fileName,yyextra->yyLineNr,"Invalid number for list item '{}' ",match.str());
401 }
402 yyextra->token.indent = computeIndent(yytext,markPos);
403 return Token::make_TK_LISTITEM();
404 }
405 }
int toInt(bool *ok=nullptr, int base=10) const
Definition qcstring.cpp:249
#define warn(file, line, fmt,...)
Definition message.h:97
406<St_Para>{BLANK}*(\n|"\\ilinebr"){LISTITEM} { /* list item on next line */
407 if (yyextra->insideHtmlLink || yyextra->insidePre) REJECT;
408 lineCount(yytext,yyleng);
410 uint32_t dashPos = static_cast<uint32_t>(text.findRev('-'));
411 assert(dashPos!=static_cast<uint32_t>(-1));
412 yyextra->token.isEnumList = text.at(dashPos+1)=='#';
413 yyextra->token.isCheckedList = false;
414 yyextra->token.id = -1;
415 yyextra->token.indent = computeIndent(text.data(),dashPos);
416 return Token::make_TK_LISTITEM();
417 }
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:159
418<St_Para>{BLANK}*\n{CLISTITEM} { /* checkbox item on next line */
419 QCString text=yytext;
420 text=text.right(text.length()-text.find('\n')-1);
421 int dashPos = text.findRev('-');
422 yyextra->token.isEnumList = false;
423 yyextra->token.isCheckedList = true;
424 if (text.find('x') != -1) yyextra->token.id = DocAutoList::Checked_x;
425 else if (text.find('X') != -1) yyextra->token.id = DocAutoList::Checked_X;
426 else yyextra->token.id = DocAutoList::Unchecked;
427 yyextra->token.indent = computeIndent(text.data(),dashPos);
428 return Token::make_TK_LISTITEM();
429 }
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
QCString right(size_t len) const
Definition qcstring.h:219
430<St_Para>{BLANK}*(\n|"\\ilinebr"){MLISTITEM} { /* list item on next line */
431 if (yyextra->insideHtmlLink || !yyextra->markdownSupport || yyextra->insidePre)
432 {
433 REJECT;
434 }
435 else
436 {
437 lineCount(yytext,yyleng);
438 std::string text=extractPartAfterNewLine(QCString(yytext)).str();
439 static const reg::Ex re(R"([*+][^*+]*$)"); // find last + or *
441 reg::search(text,match,re);
442 size_t markPos = match.position();
443 assert(markPos!=std::string::npos);
444 yyextra->token.isEnumList = FALSE;
445 yyextra->token.isCheckedList = false;
446 yyextra->token.id = -1;
447 yyextra->token.indent = computeIndent(text.c_str(),markPos);
448 return Token::make_TK_LISTITEM();
449 }
450 }
const std::string & str() const
Definition qcstring.h:537
#define FALSE
Definition qcstring.h:34
451<St_Para>{BLANK}*(\n|"\\ilinebr"){OLISTITEM} { /* list item on next line */
452 if (yyextra->insideHtmlLink || !yyextra->markdownSupport || yyextra->insidePre)
453 {
454 REJECT;
455 }
456 else
457 {
458 lineCount(yytext,yyleng);
459 std::string text=extractPartAfterNewLine(QCString(yytext)).str();
460 static const reg::Ex re(R"(\d+)");
462 reg::search(text,match,re);
463 size_t markPos = match.position();
464 assert(markPos!=std::string::npos);
465 yyextra->token.isEnumList = true;
466 yyextra->token.isCheckedList = false;
467 bool ok = false;
468 int id = QCString(match.str()).toInt(&ok);
469 yyextra->token.id = ok ? id : -1;
470 if (!ok)
471 {
472 warn(yyextra->fileName,yyextra->yyLineNr,"Invalid number for list item '{}' ",match.str());
473 }
474 yyextra->token.indent = computeIndent(text.c_str(),markPos);
475 return Token::make_TK_LISTITEM();
476 }
477 }
478<St_Para>^{ENDLIST} { /* end list */
479 if (yyextra->insideHtmlLink || yyextra->insidePre) REJECT;
480 lineCount(yytext,yyleng);
481 size_t dotPos = static_cast<size_t>(QCString(yytext).findRev('.'));
482 yyextra->token.indent = computeIndent(yytext,dotPos);
483 return Token::make_TK_ENDLIST();
484 }
485<St_Para>{BLANK}*(\n|"\\ilinebr"){ENDLIST} { /* end list on next line */
486 if (yyextra->insideHtmlLink || yyextra->insidePre) REJECT;
487 lineCount(yytext,yyleng);
489 size_t dotPos = static_cast<size_t>(text.findRev('.'));
490 yyextra->token.indent = computeIndent(text.data(),dotPos);
491 return Token::make_TK_ENDLIST();
492 }
493<St_Para>"{"{BLANK}*"@linkplain"/{WS}+ {
494 yyextra->token.name = "javalinkplain";
495 return Token::make_TK_COMMAND_AT();
496 }
497<St_Para>"{"{BLANK}*"@link"/{WS}+ {
498 yyextra->token.name = "javalink";
499 return Token::make_TK_COMMAND_AT();
500 }
501<St_Para>"{"{BLANK}*"@inheritDoc"{BLANK}*"}" {
502 yyextra->token.name = "inheritdoc";
503 return Token::make_TK_COMMAND_AT();
504 }
505<St_Para>"@_fakenl" { // artificial new line
506 //yyextra->yyLineNr++;
507 }
508<St_Para>{SPCMD3} {
509 yyextra->token.name = "_form";
510 bool ok;
511 yyextra->token.id = QCString(yytext).right((int)yyleng-7).toInt(&ok);
512 ASSERT(ok);
513 return Token::char_to_command(yytext[0]);
514 }
static Token char_to_command(char c)
#define ASSERT(x)
Definition qcstring.h:39
515<St_Para>{CMD}"n"\n { /* \n followed by real newline */
516 lineCount(yytext,yyleng);
517 //yyextra->yyLineNr++;
518 yyextra->token.name = yytext+1;
519 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
520 yyextra->token.paramDir=TokenInfo::Unspecified;
521 return Token::char_to_command(yytext[0]);
522 }
523<St_Para>"\\ilinebr" {
524 }
525<St_Para>{SPCMD1} |
526<St_Para>{SPCMD2} |
527<St_Para>{SPCMD5} |
528<St_Para>{SPCMD4} { /* special command */
529 yyextra->token.name = yytext+1;
530 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
531 yyextra->token.paramDir=TokenInfo::Unspecified;
532 return Token::char_to_command(yytext[0]);
533 }
534<St_Para>{PARAMIO} { /* param [in,out] command */
535 yyextra->token.name = "param";
536 QCString s(yytext);
537 bool isIn = s.find("in")!=-1;
538 bool isOut = s.find("out")!=-1;
539 if (isIn)
540 {
541 if (isOut)
542 {
543 yyextra->token.paramDir=TokenInfo::InOut;
544 }
545 else
546 {
547 yyextra->token.paramDir=TokenInfo::In;
548 }
549 }
550 else if (isOut)
551 {
552 yyextra->token.paramDir=TokenInfo::Out;
553 }
554 else
555 {
556 yyextra->token.paramDir=TokenInfo::Unspecified;
557 }
558 return Token::char_to_command(yytext[0]);
559 }
560<St_Para>{URLPROTOCOL}{URLMASK}/[,\.] { // URL, or URL.
561 yyextra->token.name=yytext;
562 yyextra->token.isEMailAddr=FALSE;
563 return Token::make_TK_URL();
564 }
565<St_Para>{URLPROTOCOL}{URLMASK} { // URL
566 yyextra->token.name=yytext;
567 yyextra->token.isEMailAddr=FALSE;
568 return Token::make_TK_URL();
569 }
570<St_Para>"<"{URLPROTOCOL}{URLMASK}">" { // URL
571 yyextra->token.name=yytext;
572 yyextra->token.name = yyextra->token.name.mid(1,yyextra->token.name.length()-2);
573 yyextra->token.isEMailAddr=FALSE;
574 return Token::make_TK_URL();
575 }
576<St_Para>{MAILADDR} { // Mail address
577 yyextra->token.name=yytext;
578 yyextra->token.name.stripPrefix("mailto:");
579 yyextra->token.isEMailAddr=TRUE;
580 return Token::make_TK_URL();
581 }
#define TRUE
Definition qcstring.h:37
582<St_Para>"<"{MAILADDR}">" { // Mail address
583 yyextra->token.name=yytext;
584 yyextra->token.name = yyextra->token.name.mid(1,yyextra->token.name.length()-2);
585 yyextra->token.name.stripPrefix("mailto:");
586 yyextra->token.isEMailAddr=TRUE;
587 return Token::make_TK_URL();
588 }
589<St_Para>"<"{MAILADDR2}">" { // anti spam mail address
590 yyextra->token.name=yytext;
591 return Token::make_TK_WORD();
592 }
593<St_Para>{RCSID} { /* RCS tag */
594 QCString tagName(yytext+1);
595 int index=tagName.find(':');
596 if (index<0) index=0; // should never happen
597 yyextra->token.name = tagName.left(index);
598 int text_begin = index+2;
599 int text_end = static_cast<int>(tagName.length())-1;
600 if (tagName[text_begin-1]==':') /* check for Subversion fixed-length keyword */
601 {
602 ++text_begin;
603 if (tagName[text_end-1]=='#')
604 {
605 --text_end;
606 }
607 }
608 yyextra->token.text = tagName.mid(text_begin,text_end-text_begin);
609 return Token::make_TK_RCSTAG();
610 }
611<St_Para,St_HtmlOnly,St_ManOnly,St_LatexOnly,St_RtfOnly,St_XmlOnly,St_DbOnly>"$("{ID}")" | /* environment variable */
612<St_Para,St_HtmlOnly,St_ManOnly,St_LatexOnly,St_RtfOnly,St_XmlOnly,St_DbOnly>"$("{ID}"("{ID}"))" { /* environment variable */
613 QCString name(&yytext[2]);
614 name = name.left(static_cast<int>(name.length())-1);
615 QCString value = Portable::getenv(name);
616 for (int i=static_cast<int>(value.length())-1;i>=0;i--) unput(value.at(i));
617 }
QCString getenv(const QCString &variable)
Definition portable.cpp:338
618<St_Para>"<blockquote>&zwj;" {
619 // for a markdown inserted block quote,
620 // tell flex that after putting the last indent
621 // back we are at the beginning of the line, see issue #11309
622 YY_CURRENT_BUFFER->yy_at_bol=1;
623 lineCount(yytext,yyleng);
624 handleHtmlTag(yyscanner,yytext);
625 return Token::make_TK_HTMLTAG();
626 }
627<St_Para>{HTMLTAG} { /* html tag */
628 lineCount(yytext,yyleng);
629 handleHtmlTag(yyscanner,yytext);
630 return Token::make_TK_HTMLTAG();
631 }
632<St_Para,St_Text>"&"{ID}";" { /* special symbol */
633 yyextra->token.name = yytext;
634 return Token::make_TK_SYMBOL();
635 }
636
637 /********* patterns for linkable words ******************/
638
639<St_Para>{ID}/"<"{HTMLKEYW}">"+ { /* this rule is to prevent opening html
640 * tag to be recognized as a templated classes
641 */
642 yyextra->token.name = yytext;
643 return Token::make_TK_LNKWORD();
644 }
645<St_Para>{LNKWORDN}/("<"{HTMLKEYW}">")+ { // prevent <br> html tag to be parsed as template arguments
646 yyextra->token.name = yytext;
647 return Token::make_TK_LNKWORD();
648 }
649<St_Para>{LNKWORD1} |
650<St_Para>{LNKWORD1}{FUNCARG} |
651<St_Para>{LNKWORD2} |
652<St_Para>{LNKWORD3} {
653 yyextra->token.name = yytext;
654 return Token::make_TK_LNKWORD();
655 }
656<St_Para>{LNKWORD1}{FUNCARG}{CVSPEC}[^a-z_A-Z0-9] {
657 yyextra->token.name = yytext;
658 yyextra->token.name = yyextra->token.name.left(yyextra->token.name.length()-1);
659 unput(yytext[(int)yyleng-1]);
660 return Token::make_TK_LNKWORD();
661 }
662 /********* patterns for normal words ******************/
663
664<St_Para,St_Text>[\-+0-9] |
665<St_Para,St_Text>{WORD1} |
666<St_Para,St_Text>{WORD2} { /* function call */
667 if (QCString(yytext).find("\\ilinebr")!=-1) REJECT; // see issue #8311
668 lineCount(yytext,yyleng);
669 if (yytext[0]=='%') // strip % if present
670 yyextra->token.name = &yytext[1];
671 else
672 yyextra->token.name = yytext;
673 return Token::make_TK_WORD();
674 }
675<St_Text>({ID}".")+{ID} {
676 yyextra->token.name = yytext;
677 return Token::make_TK_WORD();
678 }
679<St_Para,St_Text>"operator"/{BLANK}*"<"[a-zA-Z_0-9]+">" { // Special case: word "operator" followed by a HTML command
680 // avoid interpretation as "operator <"
681 yyextra->token.name = yytext;
682 return Token::make_TK_WORD();
683 }
684
685 /*******************************************************/
686
687<St_Para,St_Text>{BLANK}+ |
688<St_Para,St_Text>{BLANK}*\n{BLANK}* { /* white space */
689 lineCount(yytext,yyleng);
690 yyextra->token.chars=yytext;
691 return Token::make_TK_WHITESPACE();
692 }
693<St_Text>[\\@<>&$#%~] {
694 yyextra->token.name = yytext;
695 return Token::char_to_command(yytext[0]);
696 }
697<St_Para>({BLANK}*\n)+{BLANK}*\n/{LISTITEM} { /* skip trailing paragraph followed by new list item */
698 if (yyextra->insidePre || yyextra->autoListLevel==0)
699 {
700 REJECT;
701 }
702 lineCount(yytext,yyleng);
703 }
704<St_Para>({BLANK}*\n)+{BLANK}*\n/{CLISTITEM} { /* skip trailing paragraph followed by new checkbox item */
705 if (yyextra->insidePre || yyextra->autoListLevel==0)
706 {
707 REJECT;
708 }
709 }
710<St_Para>({BLANK}*\n)+{BLANK}*\n/{MLISTITEM} { /* skip trailing paragraph followed by new list item */
711 if (!yyextra->markdownSupport || yyextra->insidePre || yyextra->autoListLevel==0)
712 {
713 REJECT;
714 }
715 lineCount(yytext,yyleng);
716 }
717<St_Para>({BLANK}*\n)+{BLANK}*\n/{OLISTITEM} { /* skip trailing paragraph followed by new list item */
718 if (!yyextra->markdownSupport || yyextra->insidePre || yyextra->autoListLevel==0)
719 {
720 REJECT;
721 }
722 lineCount(yytext,yyleng);
723 }
724<St_Para,St_Param>({BLANK}*(\n|"\\ilinebr"))+{BLANK}*(\n|"\\ilinebr"){BLANK}*/" \\ifile" | // we don't want to count the space before \ifile
725<St_Para,St_Param>({BLANK}*(\n|"\\ilinebr"))+{BLANK}*(\n|"\\ilinebr"){BLANK}* {
726 lineCount(yytext,yyleng);
727 if (yyextra->insidePre)
728 {
729 yyextra->token.chars=yytext;
730 return Token::make_TK_WHITESPACE();
731 }
732 else
733 {
734 yyextra->token.indent=computeIndent(yytext,yyleng);
735 int i;
736 // put back the indentation (needed for list items)
737 //printf("token.indent=%d\n",yyextra->token.indent);
738 for (i=0;i<yyextra->token.indent;i++)
739 {
740 unput(' ');
741 }
742 // tell flex that after putting the last indent
743 // back we are at the beginning of the line
744 YY_CURRENT_BUFFER->yy_at_bol=1;
745 // start of a new paragraph
746 return Token::make_TK_NEWPARA();
747 }
748 }
749<St_CodeOpt>{BLANK}*"{"(".")?{CODEID}"}" {
750 yyextra->token.name = yytext;
751 int i=yyextra->token.name.find('{'); /* } to keep vi happy */
752 yyextra->token.name = yyextra->token.name.mid(i+1,yyextra->token.name.length()-i-2);
753 BEGIN(St_Code);
754 }
755<St_iCodeOpt>{BLANK}*"{"(".")?{CODEID}"}" {
756 yyextra->token.name = yytext;
757 int i=yyextra->token.name.find('{'); /* } to keep vi happy */
758 yyextra->token.name = yyextra->token.name.mid(i+1,yyextra->token.name.length()-i-2);
759 BEGIN(St_iCode);
760 }
761<St_CodeOpt>"\\ilinebr" |
762<St_CodeOpt>\n |
763<St_CodeOpt>. {
764 unput_string(yytext,yyleng);
765 BEGIN(St_Code);
766 }
#define unput_string(yytext, yyleng)
767<St_iCodeOpt>"\\ilinebr" |
768<St_iCodeOpt>\n |
769<St_iCodeOpt>. {
770 unput_string(yytext,yyleng);
771 BEGIN(St_iCode);
772 }
773<St_Code>{WS}*{CMD}"endcode" {
774 lineCount(yytext,yyleng);
775 return Token::make_RetVal_OK();
776 }
777<St_iCode>{WS}*{CMD}"endicode" {
778 lineCount(yytext,yyleng);
779 return Token::make_RetVal_OK();
780 }
781<St_XmlCode>{WS}*"</code>" {
782 lineCount(yytext,yyleng);
783 return Token::make_RetVal_OK();
784 }
785<St_Code,St_iCode,St_XmlCode>[^\\@\n<]+ |
786<St_Code,St_iCode,St_XmlCode>\n |
787<St_Code,St_iCode,St_XmlCode>. {
788 lineCount(yytext,yyleng);
789 yyextra->token.verb+=yytext;
790 }
791<St_HtmlOnlyOption>" [block]" { // the space is added in commentscan.l
792 yyextra->token.name="block";
793 BEGIN(St_HtmlOnly);
794 }
795<St_HtmlOnlyOption>.|\n {
796 unput(*yytext);
797 BEGIN(St_HtmlOnly);
798 }
799<St_HtmlOnlyOption>"\\ilinebr" {
800 unput_string(yytext,yyleng);
801 BEGIN(St_HtmlOnly);
802 }
803<St_HtmlOnly>{CMD}"endhtmlonly" {
804 return Token::make_RetVal_OK();
805 }
806<St_HtmlOnly>[^\\@\n$]+ |
807<St_HtmlOnly>\n |
808<St_HtmlOnly>. {
809 lineCount(yytext,yyleng);
810 yyextra->token.verb+=yytext;
811 }
812<St_ManOnly>{CMD}"endmanonly" {
813 return Token::make_RetVal_OK();
814 }
815<St_ManOnly>[^\\@\n$]+ |
816<St_ManOnly>\n |
817<St_ManOnly>. {
818 lineCount(yytext,yyleng);
819 yyextra->token.verb+=yytext;
820 }
821<St_RtfOnly>{CMD}"endrtfonly" {
822 return Token::make_RetVal_OK();
823 }
824<St_RtfOnly>[^\\@\n$]+ |
825<St_RtfOnly>\n |
826<St_RtfOnly>. {
827 lineCount(yytext,yyleng);
828 yyextra->token.verb+=yytext;
829 }
830<St_LatexOnly>{CMD}"endlatexonly" {
831 return Token::make_RetVal_OK();
832 }
833<St_LatexOnly>[^\\@\n]+ |
834<St_LatexOnly>\n |
835<St_LatexOnly>. {
836 lineCount(yytext,yyleng);
837 yyextra->token.verb+=yytext;
838 }
839<St_XmlOnly>{CMD}"endxmlonly" {
840 return Token::make_RetVal_OK();
841 }
842<St_XmlOnly>[^\\@\n]+ |
843<St_XmlOnly>\n |
844<St_XmlOnly>. {
845 lineCount(yytext,yyleng);
846 yyextra->token.verb+=yytext;
847 }
848<St_DbOnly>{CMD}"enddocbookonly" {
849 return Token::make_RetVal_OK();
850 }
851<St_DbOnly>[^\\@\n]+ |
852<St_DbOnly>\n |
853<St_DbOnly>. {
854 lineCount(yytext,yyleng);
855 yyextra->token.verb+=yytext;
856 }
857<St_Verbatim>{CMD}"endverbatim" {
858 yyextra->token.verb = yyextra->token.verb.stripLeadingAndTrailingEmptyLines();
859 return Token::make_RetVal_OK();
860 }
861<St_ILiteral>{CMD}"endiliteral " { // note extra space as this is artificially added
862 // remove spaces that have been added
863 yyextra->token.verb = yyextra->token.verb.mid(1,yyextra->token.verb.length()-2);
864 return Token::make_RetVal_OK();
865 }
866<St_iVerbatim>{CMD}"endiverbatim" {
867 yyextra->token.verb = yyextra->token.verb.stripLeadingAndTrailingEmptyLines();
868 return Token::make_RetVal_OK();
869 }
870<St_Verbatim,St_iVerbatim,St_ILiteral>[^\\@\n]+ |
871<St_Verbatim,St_iVerbatim,St_ILiteral>\n |
872<St_Verbatim,St_iVerbatim,St_ILiteral>. { /* Verbatim text */
873 lineCount(yytext,yyleng);
874 yyextra->token.verb+=yytext;
875 }
876<St_ILiteralOpt>{BLANK}*"{"[a-zA-Z_,:0-9\. ]*"}" { // option(s) present
877 yyextra->token.verb = QCString(yytext).stripWhiteSpace();
878 return Token::make_RetVal_OK();
879 }
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:245
880<St_ILiteralOpt>"\\ilinebr" |
881<St_ILiteralOpt>"\n" |
882<St_ILiteralOpt>. {
883 yyextra->token.sectionId = "";
884 unput_string(yytext,yyleng);
885 return Token::make_RetVal_OK();
886 }
887<St_Dot>{CMD}"enddot" {
888 return Token::make_RetVal_OK();
889 }
890<St_Dot>[^\\@\n]+ |
891<St_Dot>\n |
892<St_Dot>. { /* dot text */
893 lineCount(yytext,yyleng);
894 yyextra->token.verb+=yytext;
895 }
896<St_Msc>{CMD}("endmsc") {
897 return Token::make_RetVal_OK();
898 }
899<St_Msc>[^\\@\n]+ |
900<St_Msc>\n |
901<St_Msc>. { /* msc text */
902 lineCount(yytext,yyleng);
903 yyextra->token.verb+=yytext;
904 }
905<St_PlantUMLOpt>{BLANK}*"{"[a-zA-Z_,:0-9\. ]*"}" { // case 1: options present
906 yyextra->token.sectionId = QCString(yytext).stripWhiteSpace();
907 return Token::make_RetVal_OK();
908 }
909<St_PlantUMLOpt>{BLANK}*{FILEMASK}{BLANK}+/{ID}"=" { // case 2: plain file name specified followed by an attribute
910 yyextra->token.sectionId = QCString(yytext).stripWhiteSpace();
911 return Token::make_RetVal_OK();
912 }
913<St_PlantUMLOpt>{BLANK}*{FILEMASK}{BLANK}+/"\"" { // case 3: plain file name specified followed by a quoted title
914 yyextra->token.sectionId = QCString(yytext).stripWhiteSpace();
915 return Token::make_RetVal_OK();
916 }
917<St_PlantUMLOpt>{BLANK}*{FILEMASK}{BLANKopt}/\n { // case 4: plain file name specified without title or attributes
918 yyextra->token.sectionId = QCString(yytext).stripWhiteSpace();
919 return Token::make_RetVal_OK();
920 }
921<St_PlantUMLOpt>{BLANK}*{FILEMASK}{BLANKopt}/"\\ilinebr" { // case 5: plain file name specified without title or attributes
922 yyextra->token.sectionId = QCString(yytext).stripWhiteSpace();
923 return Token::make_RetVal_OK();
924 }
925<St_PlantUMLOpt>"\\ilinebr" |
926<St_PlantUMLOpt>"\n" |
927<St_PlantUMLOpt>. {
928 yyextra->token.sectionId = "";
929 unput_string(yytext,yyleng);
930 return Token::make_RetVal_OK();
931 }
932<St_PlantUML>{CMD}"enduml" {
933 return Token::make_RetVal_OK();
934 }
935<St_PlantUML>[^\\@\n]+ |
936<St_PlantUML>\n |
937<St_PlantUML>. { /* plantuml text */
938 lineCount(yytext,yyleng);
939 yyextra->token.verb+=yytext;
940 }
941<St_Title>"\"" { // quoted title
942 BEGIN(St_TitleQ);
943 }
944<St_Title>[ \t]+ {
945 yyextra->token.chars=yytext;
946 return Token::make_TK_WHITESPACE();
947 }
948<St_Title>. { // non-quoted title
949 unput(*yytext);
950 BEGIN(St_TitleN);
951 }
952<St_Title>\n {
953 unput(*yytext);
954 return Token::make_TK_NONE();
955 }
956<St_Title>"\\ilinebr" {
957 unput_string(yytext,yyleng);
958 return Token::make_TK_NONE();
959 }
960<St_TitleN>"&"{ID}";" { /* symbol */
961 yyextra->token.name = yytext;
962 return Token::make_TK_SYMBOL();
963 }
964<St_TitleN>{HTMLTAG} {
965 yyextra->token.name = yytext;
966 handleHtmlTag(yyscanner,yytext);
967 return Token::make_TK_HTMLTAG();
968 }
969<St_TitleN>\n { /* new line => end of title */
970 unput(*yytext);
971 return Token::make_TK_NONE();
972 }
973<St_TitleN>"\\ilinebr" { /* new line => end of title */
974 unput_string(yytext,yyleng);
975 return Token::make_TK_NONE();
976 }
977<St_TitleN>{SPCMD1} |
978<St_TitleN>{SPCMD2} { /* special command */
979 yyextra->token.name = yytext+1;
980 yyextra->token.paramDir=TokenInfo::Unspecified;
981 return Token::char_to_command(yytext[0]);
982 }
983<St_TitleN>{ID}"=" { /* attribute */
984 if (yytext[0]=='%') // strip % if present
985 yyextra->token.name = &yytext[1];
986 else
987 yyextra->token.name = yytext;
988 return Token::make_TK_WORD();
989 }
990<St_TitleN>[\-+0-9] |
991<St_TitleN>{WORD1} |
992<St_TitleN>{WORD2} { /* word */
993 if (QCString(yytext).find("\\ilinebr")!=-1) REJECT; // see issue #8311
994 lineCount(yytext,yyleng);
995 if (yytext[0]=='%') // strip % if present
996 yyextra->token.name = &yytext[1];
997 else
998 yyextra->token.name = yytext;
999 return Token::make_TK_WORD();
1000 }
1001<St_TitleN>[ \t]+ {
1002 yyextra->token.chars=yytext;
1003 return Token::make_TK_WHITESPACE();
1004 }
1005<St_TitleQ>"&"{ID}";" { /* symbol */
1006 yyextra->token.name = yytext;
1007 return Token::make_TK_SYMBOL();
1008 }
1009<St_TitleQ>(\n|"\\ilinebr") { /* new line => end of title */
1010 unput_string(yytext,yyleng);
1011 return Token::make_TK_NONE();
1012 }
1013<St_TitleQ>{SPCMD1} |
1014<St_TitleQ>{SPCMD2} { /* special command */
1015 yyextra->token.name = yytext+1;
1016 yyextra->token.paramDir=TokenInfo::Unspecified;
1017 return Token::char_to_command(yytext[0]);
1018 }
1019<St_TitleQ>{WORD1NQ} |
1020<St_TitleQ>{WORD2NQ} { /* word */
1021 yyextra->token.name = yytext;
1022 return Token::make_TK_WORD();
1023 }
1024<St_TitleQ>[ \t]+ {
1025 yyextra->token.chars=yytext;
1026 return Token::make_TK_WHITESPACE();
1027 }
1028<St_TitleQ>"\"" { /* closing quote => end of title */
1029 BEGIN(St_TitleA);
1030 return Token::make_TK_NONE();
1031 }
1032<St_TitleA>{BLANK}*{ID}{BLANK}*"="{BLANK}* { // title attribute
1033 yyextra->token.name = yytext;
1034 int pos = yyextra->token.name.find('=');
1035 if (pos<0) pos=0; // should never happen
1036 yyextra->token.name = yyextra->token.name.left(pos).stripWhiteSpace();
1037 BEGIN(St_TitleV);
1038 }
1039<St_TitleV>[^ \t\r\n]+ { // attribute value
1040 lineCount(yytext,yyleng);
1041 yyextra->token.chars = yytext;
1042 BEGIN(St_TitleN);
1043 return Token::make_TK_WORD();
1044 }
1045<St_TitleV,St_TitleA>. {
1046 unput(*yytext);
1047 return Token::make_TK_NONE();
1048 }
1049<St_TitleV,St_TitleA>(\n|"\\ilinebr") {
1050 unput_string(yytext,yyleng);
1051 return Token::make_TK_NONE();
1052 }
1053
1054<St_Anchor>{LABELID}{WS}? { // anchor
1055 lineCount(yytext,yyleng);
1056 yyextra->token.name = QCString(yytext).stripWhiteSpace();
1057 return Token::make_TK_WORD();
1058 }
1059<St_Anchor>. {
1060 unput(*yytext);
1061 return Token::make_TK_NONE();
1062 }
1063<St_Cite>{CITEID} { // label to cite
1064 if (yytext[0] =='"')
1065 {
1066 yyextra->token.name=yytext+1;
1067 yyextra->token.name=yyextra->token.name.left(static_cast<uint32_t>(yyleng)-2);
1068 }
1069 else
1070 {
1071 yyextra->token.name=yytext;
1072 }
1073 return Token::make_TK_WORD();
1074 }
1075<St_Cite>{BLANK} { // white space
1076 unput(' ');
1077 return Token::make_TK_NONE();
1078 }
1079<St_Cite>(\n|"\\ilinebr") { // new line
1080 unput_string(yytext,yyleng);
1081 return Token::make_TK_NONE();
1082 }
1083<St_Cite>. { // any other character
1084 unput(*yytext);
1085 return Token::make_TK_NONE();
1086 }
1087<St_DoxyConfig>{DOXYCFG} { // config option
1088 yyextra->token.name=yytext;
1089 return Token::make_TK_WORD();
1090 }
1091<St_DoxyConfig>{BLANK} { // white space
1092 unput(' ');
1093 return Token::make_TK_NONE();
1094 }
1095<St_DoxyConfig>(\n|"\\ilinebr") { // new line
1096 unput_string(yytext,yyleng);
1097 return Token::make_TK_NONE();
1098 }
1099<St_DoxyConfig>. { // any other character
1100 unput(*yytext);
1101 return Token::make_TK_NONE();
1102 }
1103<St_Ref>{REFWORD_NOCV}/{BLANK}("const")[a-z_A-Z0-9] { // see bug776988
1104 yyextra->token.name=yytext;
1105 return Token::make_TK_WORD();
1106 }
1107<St_Ref>{REFWORD_NOCV}/{BLANK}("volatile")[a-z_A-Z0-9] { // see bug776988
1108 yyextra->token.name=yytext;
1109 return Token::make_TK_WORD();
1110 }
1111<St_Ref>{REFWORD} { // label to refer to
1112 yyextra->token.name=yytext;
1113 return Token::make_TK_WORD();
1114 }
1115<St_Ref>{BLANK} { // white space
1116 unput(' ');
1117 return Token::make_TK_NONE();
1118 }
1119<St_Ref>{WS}+"\""{WS}* { // white space following by quoted string
1120 lineCount(yytext,yyleng);
1121 BEGIN(St_Ref2);
1122 }
1123<St_Ref>(\n|"\\ilinebr") { // new line
1124 unput_string(yytext,yyleng);
1125 return Token::make_TK_NONE();
1126 }
1127<St_Ref>"\""[^"\n]+"\"" { // quoted first argument -> return without quotes
1128 yyextra->token.name=QCString(yytext).mid(1,yyleng-2);
1129 return Token::make_TK_WORD();
1130 }
1131<St_Ref>. { // any other character
1132 unput(*yytext);
1133 return Token::make_TK_NONE();
1134 }
1135<St_IntRef>[A-Z_a-z0-9.:/#\-\+\‍(\‍)]+ {
1136 yyextra->token.name = yytext;
1137 return Token::make_TK_WORD();
1138 }
1139<St_IntRef>{BLANK}+"\"" {
1140 BEGIN(St_Ref2);
1141 }
1142<St_SetScope>({SCOPEMASK}|{ANONNS}){BLANK}|{FILEMASK} {
1143 yyextra->token.name = yytext;
1144 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
1145 return Token::make_TK_WORD();
1146 }
1147<St_SetScope>{SCOPEMASK}"<" {
1148 yyextra->token.name = yytext;
1149 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
1150 yyextra->sharpCount=1;
1151 BEGIN(St_SetScopeEnd);
1152 }
1153<St_SetScope>{BLANK} {
1154 }
1155<St_SetScopeEnd>"<" {
1156 yyextra->token.name += yytext;
1157 yyextra->sharpCount++;
1158 }
1159<St_SetScopeEnd>">" {
1160 yyextra->token.name += yytext;
1161 yyextra->sharpCount--;
1162 if (yyextra->sharpCount<=0)
1163 {
1164 return Token::make_TK_WORD();
1165 }
1166 }
1167<St_SetScopeEnd>. {
1168 yyextra->token.name += yytext;
1169 }
1170<St_Ref2>"&"{ID}";" { /* symbol */
1171 yyextra->token.name = yytext;
1172 return Token::make_TK_SYMBOL();
1173 }
1174<St_Ref2>"\""|\n|"\\ilinebr" { /* " or \n => end of title */
1175 lineCount(yytext,yyleng);
1176 return Token::make_TK_NONE();
1177 }
1178<St_Ref2>{HTMLTAG_STRICT} { /* html tag */
1179 lineCount(yytext,yyleng);
1180 handleHtmlTag(yyscanner,yytext);
1181 return Token::make_TK_HTMLTAG();
1182 }
1183<St_Ref2>{SPCMD1} |
1184<St_Ref2>{SPCMD2} { /* special command */
1185 yyextra->token.name = yytext+1;
1186 yyextra->token.paramDir=TokenInfo::Unspecified;
1187 return Token::char_to_command(yytext[0]);
1188 }
1189<St_Ref2>{WORD1NQ} |
1190<St_Ref2>{WORD2NQ} {
1191 /* word */
1192 yyextra->token.name = yytext;
1193 return Token::make_TK_WORD();
1194 }
1195<St_Ref2>[ \t]+ {
1196 yyextra->token.chars=yytext;
1197 return Token::make_TK_WHITESPACE();
1198 }
1199<St_XRefItem>{LABELID} {
1200 yyextra->token.name=yytext;
1201 }
1202<St_XRefItem>" " {
1203 BEGIN(St_XRefItem2);
1204 }
1205<St_XRefItem2>[0-9]+"." {
1206 QCString numStr(yytext);
1207 numStr=numStr.left((int)yyleng-1);
1208 yyextra->token.id=numStr.toInt();
1209 return Token::make_RetVal_OK();
1210 }
1211<St_Para,St_Title,St_Ref2>"<!--" { /* html style comment block */
1212 yyextra->commentState = YY_START;
1213 BEGIN(St_Comment);
1214 }
1215<St_Param>"\""[^\n\"]+"\"" {
1216 yyextra->token.name = yytext+1;
1217 yyextra->token.name = yyextra->token.name.left((int)yyleng-2);
1218 return Token::make_TK_WORD();
1219 }
1220<St_Param>({PHPTYPE}{BLANK}*("["{BLANK}*"]")*{BLANK}*"|"{BLANK}*)*{PHPTYPE}{BLANK}*("["{BLANK}*"]")*{WS}+("&")?"$"{LABELID} {
1221 lineCount(yytext,yyleng);
1222 QCString params(yytext);
1223 int j = params.find('&');
1224 int i = params.find('$');
1225 if (i<0) i=0; // should never happen
1226 if (j<i && j>=0) i=j;
1227 QCString types = params.left(i).stripWhiteSpace();
1228 yyextra->token.name = types+"#"+params.mid(i);
1229 return Token::make_TK_WORD();
1230 }
QCString left(size_t len) const
Definition qcstring.h:214
1231<St_Param>[^ \t\n,@\\]+ {
1232 yyextra->token.name = yytext;
1233 if (yyextra->token.name.at(static_cast<uint32_t>(yyleng)-1)==':')
1234 {
1235 yyextra->token.name=yyextra->token.name.left(static_cast<uint32_t>(yyleng)-1);
1236 }
1237 return Token::make_TK_WORD();
1238 }
1239<St_Param>{WS}*","{WS}* /* param separator */
1240<St_Param>{WS} {
1241 lineCount(yytext,yyleng);
1242 yyextra->token.chars=yytext;
1243 return Token::make_TK_WHITESPACE();
1244 }
1245<St_Prefix>"\""[^\n\"]*"\"" {
1246 yyextra->token.name = yytext+1;
1247 yyextra->token.name = yyextra->token.name.left((int)yyleng-2);
1248 return Token::make_TK_WORD();
1249 }
1250<St_Prefix>. {
1251 unput(*yytext);
1252 return Token::make_TK_NONE();
1253 }
1254<St_Options>{ID} {
1255 yyextra->token.name+=yytext;
1256 }
1257<St_Options>{WS}*":"{WS}* {
1258 lineCount(yytext,yyleng);
1259 yyextra->token.name+=":";
1260 }
1261<St_Options>{WS}*","{WS}* |
1262<St_Options>{WS} { /* option separator */
1263 lineCount(yytext,yyleng);
1264 yyextra->token.name+=",";
1265 }
1266<St_Options>"}" {
1267 return Token::make_TK_WORD();
1268 }
1269<St_Block>{ID} {
1270 yyextra->token.name+=yytext;
1271 }
1272<St_Block>"]" {
1273 return Token::make_TK_WORD();
1274 }
1275<St_Emoji>[:0-9_a-z+-]+ {
1276 yyextra->token.name=yytext;
1277 return Token::make_TK_WORD();
1278 }
1279<St_Emoji>. {
1280 unput(*yytext);
1281 return Token::make_TK_NONE();
1282 }
1283<St_QuotedString>"\"" {
1284 yyextra->token.name="";
1285 BEGIN(St_QuotedContent);
1286 }
1287<St_QuotedString>(\n|"\\ilinebr") {
1288 unput_string(yytext,yyleng);
1289 return Token::make_TK_NONE();
1290 }
1291<St_QuotedString>. {
1292 unput(*yytext);
1293 return Token::make_TK_NONE();
1294 }
1295<St_QuotedContent>"\"" {
1296 return Token::make_TK_WORD();
1297 }
1298<St_QuotedContent>. {
1299 yyextra->token.name+=yytext;
1300 }
1301<St_ShowDate>{WS}+{SHOWDATE} {
1302 lineCount(yytext,yyleng);
1303 yyextra->token.name=yytext;
1304 return Token::make_TK_WORD();
1305 }
1306<St_ShowDate>(\n|"\\ilinebr") {
1307 unput_string(yytext,yyleng);
1308 return Token::make_TK_NONE();
1309 }
1310<St_ShowDate>. {
1311 unput(*yytext);
1312 return Token::make_TK_NONE();
1313 }
1314<St_ILine>{LINENR}/[\\@\n\.] |
1315<St_ILine>{LINENR}{BLANK} {
1316 bool ok = false;
1317 int nr = QCString(yytext).toInt(&ok);
1318 if (!ok)
1319 {
1320 warn(yyextra->fileName,yyextra->yyLineNr,"Invalid line number '{}' for iline command",yytext);
1321 }
1322 else
1323 {
1324 yyextra->yyLineNr = nr;
1325 }
1326 return Token::make_TK_WORD();
1327 }
1328<St_ILine>. {
1329 return Token::make_TK_NONE();
1330 }
1331<St_IFile>{BLANK}*{FILEMASK} {
1332 yyextra->fileName = QCString(yytext).stripWhiteSpace();
1333 return Token::make_TK_WORD();
1334 }
1335<St_IFile>{BLANK}*"\""[^\n\"]+"\"" {
1336 QCString text(yytext);
1337 text = text.stripWhiteSpace();
1338 yyextra->fileName = text.mid(1,text.length()-2);
1339 return Token::make_TK_WORD();
1340 }
1341<St_File>{FILEMASK} {
1342 yyextra->token.name = yytext;
1343 return Token::make_TK_WORD();
1344 }
1345<St_File>"\""[^\n\"]+"\"" {
1346 QCString text(yytext);
1347 yyextra->token.name = text.mid(1,text.length()-2);
1348 return Token::make_TK_WORD();
1349 }
1350<St_Pattern>[^\\\r\n]+ {
1351 yyextra->token.name += yytext;
1352 }
1353<St_Pattern>"\\ilinebr" {
1354 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
1355 return Token::make_TK_WORD();
1356 }
1357<St_Pattern>\n {
1358 lineCount(yytext,yyleng);
1359 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
1360 return Token::make_TK_WORD();
1361 }
1362<St_Pattern>. {
1363 yyextra->token.name += yytext;
1364 }
1365<St_Link>{LINKMASK}|{REFWORD} {
1366 yyextra->token.name = yytext;
1367 return Token::make_TK_WORD();
1368 }
1369<St_Comment>"-->" { /* end of html comment */
1370 BEGIN(yyextra->commentState);
1371 }
1372<St_Comment>[^-]+ /* inside html comment */
1373<St_Comment>. /* inside html comment */
1374
1375 /* State for skipping title (all chars until the end of the line) */
1376
1377<St_SkipTitle>.
1378<St_SkipTitle>(\n|"\\ilinebr") {
1379 if (*yytext == '\n') unput('\n');
1380 return Token::make_TK_NONE();
1381 }
1382
1383 /* State for the pass used to find the anchors and sections */
1384
1385<St_Sections>[^\n@\<]+
1386<St_Sections>{CMD}("<"|{CMD})
1387<St_Sections>"<"{CAPTION}({WS}+{ATTRIB})*">" {
1388 lineCount(yytext,yyleng);
1389 QCString tag(yytext);
1390 int s=tag.find("id=");
1391 if (s!=-1) // command has id attribute
1392 {
1393 char c=tag[s+3];
1394 if (c=='\'' || c=='"') // valid start
1395 {
1396 int e=tag.find(c,s+4);
1397 if (e!=-1) // found matching end
1398 {
1399 yyextra->secType = SectionType::Table;
1400 yyextra->secLabel=tag.mid(s+4,e-s-4); // extract id
1401 processSection(yyscanner);
1402 }
1403 }
1404 }
1405 }
static constexpr int Table
Definition section.h:41
1406<St_Sections>{CMD}"anchor"{BLANK}+ {
1407 yyextra->secType = SectionType::Anchor;
1408 BEGIN(St_SecLabel1);
1409 }
static constexpr int Anchor
Definition section.h:40
1410<St_Sections>{CMD}"ianchor"{BLANK}+ {
1411 yyextra->secType = SectionType::Anchor;
1412 BEGIN(St_SecLabel1);
1413 }
1414<St_Sections>{CMD}"section"{BLANK}+ {
1415 yyextra->secType = SectionType::Section;
1416 BEGIN(St_SecLabel2);
1417 }
static constexpr int Section
Definition section.h:33
1418<St_Sections>{CMD}"subsection"{BLANK}+ {
1419 yyextra->secType = SectionType::Subsection;
1420 BEGIN(St_SecLabel2);
1421 }
static constexpr int Subsection
Definition section.h:34
1422<St_Sections>{CMD}"subsubsection"{BLANK}+ {
1423 yyextra->secType = SectionType::Subsubsection;
1424 BEGIN(St_SecLabel2);
1425 }
static constexpr int Subsubsection
Definition section.h:35
1426<St_Sections>{CMD}"paragraph"{BLANK}+ {
1427 yyextra->secType = SectionType::Paragraph;
1428 BEGIN(St_SecLabel2);
1429 }
static constexpr int Paragraph
Definition section.h:36
1430<St_Sections>{CMD}"subparagraph"{BLANK}+ {
1431 yyextra->secType = SectionType::Subparagraph;
1432 BEGIN(St_SecLabel2);
1433 }
static constexpr int Subparagraph
Definition section.h:37
1434<St_Sections>{CMD}"subsubparagraph"{BLANK}+ {
1435 yyextra->secType = SectionType::Subsubparagraph;
1436 BEGIN(St_SecLabel2);
1437 }
static constexpr int Subsubparagraph
Definition section.h:38
1438<St_Sections>{CMD}"verbatim"/[^a-z_A-Z0-9] {
1439 yyextra->endMarker="endverbatim";
1440 BEGIN(St_SecSkip);
1441 }
1442<St_Sections>{CMD}"iverbatim"/[^a-z_A-Z0-9] {
1443 yyextra->endMarker="endiverbatim";
1444 BEGIN(St_SecSkip);
1445 }
1446<St_Sections>{CMD}"iliteral"/[^a-z_A-Z0-9] {
1447 yyextra->endMarker="endiliteral";
1448 BEGIN(St_SecSkip);
1449 }
1450<St_Sections>{CMD}"dot"/[^a-z_A-Z0-9] {
1451 yyextra->endMarker="enddot";
1452 BEGIN(St_SecSkip);
1453 }
1454<St_Sections>{CMD}"msc"/[^a-z_A-Z0-9] {
1455 yyextra->endMarker="endmsc";
1456 BEGIN(St_SecSkip);
1457 }
1458<St_Sections>{CMD}"startuml"/[^a-z_A-Z0-9] {
1459 yyextra->endMarker="enduml";
1460 BEGIN(St_SecSkip);
1461 }
1462<St_Sections>{CMD}"htmlonly"/[^a-z_A-Z0-9] {
1463 yyextra->endMarker="endhtmlonly";
1464 BEGIN(St_SecSkip);
1465 }
1466<St_Sections>{CMD}"latexonly"/[^a-z_A-Z0-9] {
1467 yyextra->endMarker="endlatexonly";
1468 BEGIN(St_SecSkip);
1469 }
1470<St_Sections>{CMD}"manonly"/[^a-z_A-Z0-9] {
1471 yyextra->endMarker="endmanonly";
1472 BEGIN(St_SecSkip);
1473 }
1474<St_Sections>{CMD}"rtfonly"/[^a-z_A-Z0-9] {
1475 yyextra->endMarker="endrtfonly";
1476 BEGIN(St_SecSkip);
1477 }
1478<St_Sections>{CMD}"xmlonly"/[^a-z_A-Z0-9] {
1479 yyextra->endMarker="endxmlonly";
1480 BEGIN(St_SecSkip);
1481 }
1482<St_Sections>{CMD}"docbookonly"/[^a-z_A-Z0-9] {
1483 yyextra->endMarker="enddocbookonly";
1484 BEGIN(St_SecSkip);
1485 }
1486<St_Sections>{CMD}"code"/[^a-z_A-Z0-9] {
1487 yyextra->endMarker="endcode";
1488 BEGIN(St_SecSkip);
1489 }
1490<St_Sections>{CMD}"icode"/[^a-z_A-Z0-9] {
1491 yyextra->endMarker="endicode";
1492 BEGIN(St_SecSkip);
1493 }
1494<St_Sections>"<!--" {
1495 yyextra->endMarker="-->";
1496 BEGIN(St_SecSkip);
1497 }
1498<St_SecSkip>{CMD}{ID} {
1499 if (yyextra->endMarker==yytext+1)
1500 {
1501 BEGIN(St_Sections);
1502 }
1503 }
1504<St_SecSkip>"-->" {
1505 if (yyextra->endMarker==yytext)
1506 {
1507 BEGIN(St_Sections);
1508 }
1509 }
1510<St_SecSkip>[^a-z_A-Z0-9\-\\\@]+
1511<St_SecSkip>.
1512<St_SecSkip>(\n|"\\ilinebr")
1513<St_Sections>.
1514<St_Sections>(\n|"\\ilinebr")
1515<St_SecLabel1>{LABELID} {
1516 lineCount(yytext,yyleng);
1517 yyextra->secLabel = yytext;
1518 processSection(yyscanner);
1519 BEGIN(St_Sections);
1520 }
1521<St_SecLabel2>{LABELID}{BLANK}+ |
1522<St_SecLabel2>{LABELID} {
1523 yyextra->secLabel = yytext;
1524 yyextra->secLabel = yyextra->secLabel.stripWhiteSpace();
1525 BEGIN(St_SecTitle);
1526 }
1527<St_SecTitle>[^\n]+ |
1528<St_SecTitle>[^\n]*\n {
1529 lineCount(yytext,yyleng);
1530 yyextra->secTitle = yytext;
1531 yyextra->secTitle = yyextra->secTitle.stripWhiteSpace();
1532 if (yyextra->secTitle.endsWith("\\ilinebr"))
1533 {
1534 yyextra->secTitle.left(yyextra->secTitle.length()-8);
1535 }
1536 processSection(yyscanner);
1537 BEGIN(St_Sections);
1538 }
1539<St_SecTitle,St_SecLabel1,St_SecLabel2>. {
1540 warn(yyextra->fileName,yyextra->yyLineNr,"Unexpected character '{}' while looking for section label or title",yytext);
1541 }
1542
1543<St_Snippet>[^\\\n]+ {
1544 yyextra->token.name += yytext;
1545 }
1546<St_Snippet>"\\" {
1547 yyextra->token.name += yytext;
1548 }
1549<St_Snippet>(\n|"\\ilinebr") {
1550 unput_string(yytext,yyleng);
1551 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
1552 return Token::make_TK_WORD();
1553 }
1554
1555 /* Generic rules that work for all states */
1556<*>\n {
1557 lineCount(yytext,yyleng);
1558 warn(yyextra->fileName,yyextra->yyLineNr,"Unexpected new line character");
1559 }
1560<*>"\\ilinebr" {
1561 }
1562<*>[\\@<>&$#%~"=] { /* unescaped special character */
1563 //warn(yyextra->fileName,yyextra->yyLineNr,"Unexpected character '{}', assuming command \\{} was meant.",yytext,yytext);
1564 yyextra->token.name = yytext;
1565 return Token::char_to_command(yytext[0]);
1566 }
1567<*>. {
1568 warn(yyextra->fileName,yyextra->yyLineNr,"Unexpected character '{}'",yytext);
1569 }
1570%%
1571
1572//--------------------------------------------------------------------------
1573
1574static int yyread(yyscan_t yyscanner,char *buf,int max_size)
1575{
1576 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1577 int c=0;
1578 const char *p = yyextra->inputString + yyextra->inputPos;
1579 while ( c < max_size && *p ) { *buf++ = *p++; c++; }
1580 yyextra->inputPos+=c;
1581 return c;
1582}
1583
1584static void processSection(yyscan_t yyscanner)
1585{
1586 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1587 //printf("%s: found section/anchor with name '%s'\n",qPrint(g_fileName),qPrint(g_secLabel));
1588 QCString file;
1589 if (yyextra->definition)
1590 {
1591 file = yyextra->definition->getOutputFileBase();
1592 }
1593 else
1594 {
1595 warn(yyextra->fileName,yyextra->yyLineNr,"Found section/anchor {} without context",yyextra->secLabel);
1596 }
1597 SectionInfo *si = SectionManager::instance().find(yyextra->secLabel);
1598 if (si)
1599 {
1600 si->setFileName(file);
1601 si->setType(yyextra->secType);
1602 }
1603}
1604
1605static void handleHtmlTag(yyscan_t yyscanner,const char *text)
1606{
1607 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1608
1609 QCString tagText(text);
1610 yyextra->token.text = tagText;
1611 yyextra->token.attribs.clear();
1612 yyextra->token.endTag = FALSE;
1613 yyextra->token.emptyTag = FALSE;
1614
1615 // Check for end tag
1616 int startNamePos=1;
1617 if (tagText.at(1)=='/')
1618 {
1619 yyextra->token.endTag = TRUE;
1620 startNamePos++;
1621 }
1622
1623 // Parse the name portion
1624 int i = startNamePos;
1625 for (i=startNamePos; i < (int)yyleng; i++)
1626 {
1627 // Check for valid HTML/XML name chars (including namespaces)
1628 char c = tagText.at(i);
1629 if (!(isalnum(c) || c=='-' || c=='_' || c==':')) break;
1630 }
1631 yyextra->token.name = tagText.mid(startNamePos,i-startNamePos);
1632
1633 // Parse the attributes. Each attribute is a name, value pair
1634 // The result is stored in yyextra->token.attribs.
1635 int startAttribList = i;
1636 while (i<(int)yyleng)
1637 {
1638 char c=tagText.at(i);
1639 // skip spaces
1640 while (i<(int)yyleng && isspace((uint8_t)c)) { c=tagText.at(++i); }
1641 // check for end of the tag
1642 if (c == '>') break;
1643 // Check for XML style "empty" tag.
1644 if (c == '/')
1645 {
1646 yyextra->token.emptyTag = TRUE;
1647 break;
1648 }
1649 int startName=i;
1650 // search for end of name
1651 while (i<(int)yyleng && !isspace((uint8_t)c) && c!='=' && c!= '>') { c=tagText.at(++i); }
1652 int endName=i;
1653 QCString optName,optValue;
1654 optName = tagText.mid(startName,endName-startName).lower();
1655 // skip spaces
1656 while (i<(int)yyleng && isspace((uint8_t)c)) { c=tagText.at(++i); }
1657 if (tagText.at(i)=='=') // option has value
1658 {
1659 int startAttrib=0, endAttrib=0;
1660 c=tagText.at(++i);
1661 // skip spaces
1662 while (i<(int)yyleng && isspace((uint8_t)c)) { c=tagText.at(++i); }
1663 if (tagText.at(i)=='\'') // option '...'
1664 {
1665 c=tagText.at(++i);
1666 startAttrib=i;
1667
1668 // search for matching quote
1669 while (i<(int)yyleng && c!='\'') { c=tagText.at(++i); }
1670 endAttrib=i;
1671 if (i<(int)yyleng) { c=tagText.at(++i);}
1672 }
1673 else if (tagText.at(i)=='"') // option "..."
1674 {
1675 c=tagText.at(++i);
1676 startAttrib=i;
1677 // search for matching quote
1678 while (i<(int)yyleng && c!='"') { c=tagText.at(++i); }
1679 endAttrib=i;
1680 if (i<(int)yyleng) { c=tagText.at(++i);}
1681 }
1682 else // value without any quotes
1683 {
1684 startAttrib=i;
1685 // search for separator or end symbol
1686 while (i<(int)yyleng && !isspace((uint8_t)c) && c!='>') { c=tagText.at(++i); }
1687 endAttrib=i;
1688 if (i<(int)yyleng) { c=tagText.at(++i);}
1689 }
1690 optValue = tagText.mid(startAttrib,endAttrib-startAttrib);
1691 if (optName == "align") optValue = optValue.lower();
1692 else if (optName == "valign")
1693 {
1694 optValue = optValue.lower();
1695 if (optValue == "center") optValue="middle";
1696 }
1697 }
1698 else // start next option
1699 {
1700 }
1701 //printf("=====> Adding option name=<%s> value=<%s>\n",
1702 // qPrint(optName),qPrint(optValue));
1703 yyextra->token.attribs.emplace_back(optName,optValue);
1704 }
1705 yyextra->token.attribsStr = tagText.mid(startAttribList,i-startAttribList);
1706}
1707
1713
1714
1716{
1717 yyscan_t yyscanner = p->yyscanner;
1718 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1719 //printf("DocTokenizer::pushContext() stack=%zu\n",yyextra->lexerStack.size());
1720 yyextra->lexerStack.push(
1721 std::make_unique<DocLexerContext>(
1722 yyextra->token,YY_START,
1723 yyextra->autoListLevel,
1724 yyextra->inputPos,
1725 yyextra->inputString,
1726 YY_CURRENT_BUFFER));
1727 yy_switch_to_buffer(yy_create_buffer(0, YY_BUF_SIZE, yyscanner), yyscanner);
1728}
1729
1731{
1732 yyscan_t yyscanner = p->yyscanner;
1733 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1734 //printf("DocTokenizer::popContext() stack=%zu\n",yyextra->lexerStack.size());
1735 if (yyextra->lexerStack.empty()) return FALSE;
1736 const auto &ctx = yyextra->lexerStack.top();
1737 yyextra->autoListLevel = ctx->autoListLevel;
1738 yyextra->inputPos = ctx->inputPos;
1739 yyextra->inputString = ctx->inputString;
1740 yyextra->token = ctx->token;
1741
1742 yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner);
1743 yy_switch_to_buffer(ctx->state, yyscanner);
1744
1745 BEGIN(ctx->rule);
1746 yyextra->lexerStack.pop();
1747 return TRUE;
1748}
1749
1750
1751DocTokenizer::DocTokenizer() : p(std::make_unique<Private>())
1752{
1753 //printf("%p:DocTokenizer::DocTokenizer()\n",(void*)this);
1754 doctokenizerYYlex_init_extra(&p->extra,&p->yyscanner);
1755#ifdef FLEX_DEBUG
1756 doctokenizerYYset_debug(Debug::isFlagSet(Debug::Lex_doctokenizer)?1:0,p->yyscanner);
1757#endif
1758}
1759
1761{
1762 //printf("%p:DocTokenizer::~DocTokenizer()\n",(void*)this);
1763 doctokenizerYYlex_destroy(p->yyscanner);
1764}
1765
1767{
1768 return doctokenizerYYlex(p->yyscanner);
1769}
1770
1772{
1773 yyscan_t yyscanner = p->yyscanner;
1774 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1775 unput_string(tag.data(),tag.length());
1776}
1777
1779 const QCString &fileName)
1780{
1781 yyscan_t yyscanner = p->yyscanner;
1782 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1783
1784 if (input.isEmpty()) return;
1785 DebugLex debugLex(Debug::Lex_doctokenizer, __FILE__, qPrint(fileName));
1786 yyextra->inputString = input.data();
1787 //printf("parsing --->'%s'<---\n",input);
1788 yyextra->inputPos = 0;
1789 yyextra->definition = d;
1790 yyextra->fileName = fileName;
1791 BEGIN(St_Sections);
1792 yyextra->yyLineNr = 1;
1793 doctokenizerYYlex(yyscanner);
1794}
1795
1796void DocTokenizer::init(const char *input,const QCString &fileName,bool markdownSupport, bool insideHtmlLink)
1797{
1798 yyscan_t yyscanner = p->yyscanner;
1799 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1800 yyextra->autoListLevel = 0;
1801 yyextra->inputString = input;
1802 yyextra->inputPos = 0;
1803 yyextra->fileName = fileName;
1804 yyextra->insidePre = FALSE;
1805 yyextra->markdownSupport = markdownSupport;
1806 yyextra->insideHtmlLink = insideHtmlLink;
1807 BEGIN(St_Para);
1808}
1809
1811{
1812 yyscan_t yyscanner = p->yyscanner;
1813 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1814 return &yyextra->token;
1815}
1816
1818{
1819 yyscan_t yyscanner = p->yyscanner;
1820 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1821 yyextra->token = TokenInfo();
1822 return &yyextra->token;
1823}
1824
1826{
1827 yyscan_t yyscanner = p->yyscanner;
1828 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1829 yyextra->insideHtmlLink = false;
1830 BEGIN(St_Para);
1831}
1832
1834{
1835 yyscan_t yyscanner = p->yyscanner;
1836 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1837 BEGIN(St_Title);
1838}
1839
1841{
1842 yyscan_t yyscanner = p->yyscanner;
1843 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1844 BEGIN(St_TitleV);
1845}
1846
1848{
1849 yyscan_t yyscanner = p->yyscanner;
1850 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1851 yyextra->token.verb="";
1852 yyextra->token.name="";
1853 BEGIN(St_CodeOpt);
1854}
1855
1857{
1858 yyscan_t yyscanner = p->yyscanner;
1859 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1860 yyextra->token.verb="";
1861 yyextra->token.name="";
1862 BEGIN(St_iCodeOpt);
1863}
1864
1866{
1867 yyscan_t yyscanner = p->yyscanner;
1868 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1869 yyextra->token.verb="";
1870 yyextra->token.name="";
1871 BEGIN(St_XmlCode);
1872}
1873
1875{
1876 yyscan_t yyscanner = p->yyscanner;
1877 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1878 yyextra->token.verb="";
1879 yyextra->token.name="";
1880 BEGIN(St_HtmlOnlyOption);
1881}
1882
1884{
1885 yyscan_t yyscanner = p->yyscanner;
1886 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1887 yyextra->token.verb="";
1888 BEGIN(St_ManOnly);
1889}
1890
1892{
1893 yyscan_t yyscanner = p->yyscanner;
1894 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1895 yyextra->token.verb="";
1896 BEGIN(St_RtfOnly);
1897}
1898
1900{
1901 yyscan_t yyscanner = p->yyscanner;
1902 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1903 yyextra->token.verb="";
1904 BEGIN(St_XmlOnly);
1905}
1906
1908{
1909 yyscan_t yyscanner = p->yyscanner;
1910 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1911 yyextra->token.verb="";
1912 BEGIN(St_DbOnly);
1913}
1914
1916{
1917 yyscan_t yyscanner = p->yyscanner;
1918 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1919 yyextra->token.verb="";
1920 BEGIN(St_LatexOnly);
1921}
1922
1924{
1925 yyscan_t yyscanner = p->yyscanner;
1926 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1927 yyextra->token.verb="";
1928 BEGIN(St_ILiteral);
1929}
1930
1932{
1933 yyscan_t yyscanner = p->yyscanner;
1934 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1935 yyextra->token.verb="";
1936 BEGIN(St_ILiteralOpt);
1937}
1938
1940{
1941 yyscan_t yyscanner = p->yyscanner;
1942 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1943 yyextra->token.verb="";
1944 BEGIN(St_Verbatim);
1945}
1946
1948{
1949 yyscan_t yyscanner = p->yyscanner;
1950 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1951 yyextra->token.verb="";
1952 BEGIN(St_iVerbatim);
1953}
1954
1956{
1957 yyscan_t yyscanner = p->yyscanner;
1958 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1959 yyextra->token.verb="";
1960 BEGIN(St_Dot);
1961}
1962
1964{
1965 yyscan_t yyscanner = p->yyscanner;
1966 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1967 yyextra->token.verb="";
1968 BEGIN(St_Msc);
1969}
1970
1972{
1973 yyscan_t yyscanner = p->yyscanner;
1974 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1975 yyextra->token.verb="";
1976 yyextra->token.sectionId="";
1977 BEGIN(St_PlantUMLOpt);
1978}
1979
1981{
1982 yyscan_t yyscanner = p->yyscanner;
1983 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1984 yyextra->token.verb="";
1985 BEGIN(St_PlantUML);
1986}
1987
1989{
1990 yyscan_t yyscanner = p->yyscanner;
1991 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1992 BEGIN(St_Param);
1993}
1994
1996{
1997 yyscan_t yyscanner = p->yyscanner;
1998 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1999 BEGIN(St_XRefItem);
2000}
2001
2003{
2004 yyscan_t yyscanner = p->yyscanner;
2005 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2006 BEGIN(St_File);
2007}
2008
2010{
2011 yyscan_t yyscanner = p->yyscanner;
2012 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2013 BEGIN(St_IFile);
2014}
2015
2017{
2018 yyscan_t yyscanner = p->yyscanner;
2019 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2020 yyextra->token.name = "";
2021 BEGIN(St_Pattern);
2022}
2023
2025{
2026 yyscan_t yyscanner = p->yyscanner;
2027 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2028 BEGIN(St_Link);
2029}
2030
2032{
2033 yyscan_t yyscanner = p->yyscanner;
2034 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2035 BEGIN(St_Cite);
2036}
2037
2039{
2040 yyscan_t yyscanner = p->yyscanner;
2041 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2042 BEGIN(St_DoxyConfig);
2043}
2044
2046{
2047 yyscan_t yyscanner = p->yyscanner;
2048 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2049 BEGIN(St_Ref);
2050}
2051
2053{
2054 yyscan_t yyscanner = p->yyscanner;
2055 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2056 BEGIN(St_IntRef);
2057}
2058
2060{
2061 yyscan_t yyscanner = p->yyscanner;
2062 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2063 BEGIN(St_Text);
2064}
2065
2067{
2068 yyscan_t yyscanner = p->yyscanner;
2069 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2070 BEGIN(St_SkipTitle);
2071}
2072
2074{
2075 yyscan_t yyscanner = p->yyscanner;
2076 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2077 BEGIN(St_Anchor);
2078}
2079
2081{
2082 yyscan_t yyscanner = p->yyscanner;
2083 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2084 BEGIN(St_Prefix);
2085}
2086
2088{
2089 yyscan_t yyscanner = p->yyscanner;
2090 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2091 yyextra->token.name="";
2092 BEGIN(St_Snippet);
2093}
2094
2096{
2097 yyscan_t yyscanner = p->yyscanner;
2098 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2099 BEGIN(St_SetScope);
2100}
2101
2103{
2104 yyscan_t yyscanner = p->yyscanner;
2105 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2106 yyextra->token.name="";
2107 BEGIN(St_Options);
2108}
2109
2111{
2112 yyscan_t yyscanner = p->yyscanner;
2113 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2114 yyextra->token.name="";
2115 BEGIN(St_Block);
2116}
2117
2119{
2120 yyscan_t yyscanner = p->yyscanner;
2121 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2122 yyextra->token.name="";
2123 BEGIN(St_Emoji);
2124}
2125
2127{
2128 yyscan_t yyscanner = p->yyscanner;
2129 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2130 BEGIN(St_ILine);
2131}
2132
2134{
2135 yyscan_t yyscanner = p->yyscanner;
2136 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2137 BEGIN(St_QuotedString);
2138}
2139
2141{
2142 yyscan_t yyscanner = p->yyscanner;
2143 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2144 BEGIN(St_ShowDate);
2145}
2146
2148{
2149 yyscan_t yyscanner = p->yyscanner;
2150 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2151 yy_delete_buffer( YY_CURRENT_BUFFER, yyscanner );
2152}
2153
2155{
2156 yyscan_t yyscanner = p->yyscanner;
2157 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2158 yyextra->insidePre = b;
2159}
2160
2162{
2163 yyscan_t yyscanner = p->yyscanner;
2164 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2165 QCString tagName = tag;
2166 int l = static_cast<int>(tagName.length());
2167 unput('>');
2168 for (int i=l-1;i>=0;i--)
2169 {
2170 unput(tag[i]);
2171 }
2172 unput('<');
2173}
2174
2176{
2177 yyscan_t yyscanner = p->yyscanner;
2178 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2179 yyextra->autoListLevel++;
2180}
2181
2183{
2184 yyscan_t yyscanner = p->yyscanner;
2185 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2186 yyextra->autoListLevel--;
2187}
2188
2190{
2191 yyscan_t yyscanner = p->yyscanner;
2192 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2193 yyextra->yyLineNr = lineno;
2194}
2195
2197{
2198 yyscan_t yyscanner = p->yyscanner;
2199 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2200 return yyextra->yyLineNr;
2201}
2202
2204{
2205 yyscan_t yyscanner = p->yyscanner;
2206 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2207 yyextra->stateStack.push(YYSTATE);
2208}
2209
2211{
2212 yyscan_t yyscanner = p->yyscanner;
2213 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2214 assert(!yyextra->stateStack.empty());
2215 BEGIN(yyextra->stateStack.top());
2216 yyextra->stateStack.pop();
2217}
2218
2219#include "doctokenizer.l.h"
@ Lex_doctokenizer
Definition debug.h:59
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
TokenInfo * token()
void setStateTitleAttrValue()
void setStateILiteralOpt()
void setStateILiteral()
void setStateCite()
void setStateSnippet()
void setStatePrefix()
void setStateEmoji()
void init(const char *input, const QCString &fileName, bool markdownSupport, bool insideHtmlLink)
void setLineNr(int lineno)
void setStateCode()
void setStatePattern()
void startAutoList()
void setStateIFile()
void setStateSkipTitle()
void setStateParam()
void setStateBlock()
void setStatePlantUMLOpt()
void setStateAnchor()
void findSections(const QCString &input, const Definition *d, const QCString &fileName)
void setStateRtfOnly()
void setStateVerbatim()
void setStateLink()
void setStateTitle()
void setStateFile()
void setStateLatexOnly()
void setStateManOnly()
void setStateShowDate()
void setInsidePre(bool b)
void setStateXRefItem()
void setStateText()
void setStateXmlCode()
void unputString(const QCString &tag)
void setStateDbOnly()
void setStateHtmlOnly()
void setStateInternalRef()
void setStateILine()
void setStateICode()
void setStateOptions()
void setStateDoxyConfig()
void setStateQuotedString()
void setStatePara()
int getLineNr(void)
void setStatePlantUML()
TokenInfo * resetToken()
void setStateIVerbatim()
void setStateXmlOnly()
std::unique_ptr< Private > p
void setStateSetScope()
void pushBackHtmlTag(const QCString &tag)
const T * find(const std::string &key) const
Definition linkedmap.h:47
QCString lower() const
Definition qcstring.h:234
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
void clear()
Definition qcstring.h:169
class that provide information about a section.
Definition section.h:57
void setType(SectionType t)
Definition section.h:80
void setFileName(const QCString &fn)
Definition section.h:79
static SectionManager & instance()
returns a reference to the singleton
Definition section.h:175
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
Definition code.l:3989
#define YY_BUF_SIZE
Definition commentcnv.l:19
const char * qPrint(const char *s)
Definition qcstring.h:672
doctokenizerYY_state extra