Doxygen
Loading...
Searching...
No Matches
doctokenizer.l File Reference
#include <stdint.h>
#include <ctype.h>
#include <stack>
#include <string>
#include <cassert>
#include "doctokenizer.h"
#include "cmdmapper.h"
#include "config.h"
#include "message.h"
#include "section.h"
#include "membergroup.h"
#include "definition.h"
#include "doxygen.h"
#include "portable.h"
#include "cite.h"
#include "regex.h"
#include "debug.h"
#include "docnode.h"
#include "doxygen_lex.h"
#include "doctokenizer.l.h"
+ Include dependency graph for doctokenizer.l:

Go to the source code of this file.

Classes

struct  DocLexerContext
 
struct  doctokenizerYY_state
 
struct  DocTokenizer::Private
 

Macros

#define YY_TYPEDEF_YY_SCANNER_T
 
#define YY_NO_INPUT   1
 
#define YY_NO_UNISTD_H   1
 
#define lineCount(s, len)
 
#define unput_string(yytext, yyleng)
 
#define YY_INPUT(buf, result, max_size)
 
#define YY_DECL   static Token doctokenizerYYlex(yyscan_t yyscanner)
 
#define yyterminate()
 

Typedefs

typedef yyguts_t * yyscan_t
 

Functions

static const char * stateToString (int state)
 
static int yyread (yyscan_t yyscanner, char *buf, int max_size)
 
static void handleHtmlTag (yyscan_t yyscanner, const char *text)
 
static void processSection (yyscan_t yyscanner)
 
QCString extractPartAfterNewLine (const QCString &text)
 
static int computeIndent (const char *str, size_t length)
 
static const char * getLexerFILE ()
 
int yylex (yyscan_t yyscanner)
 

Macro Definition Documentation

◆ lineCount

#define lineCount ( s,
len )
Value:
do { for(int i=0;i<(int)len;i++) if (s[i]=='\n') yyextra->yyLineNr++; } while(0)

Definition at line 96 of file doctokenizer.l.

Referenced by endBrief(), initMethodProtection(), and CitationManager::insertCrossReferencesForBibFile().

◆ unput_string

#define unput_string ( yytext,
yyleng )
Value:
do { for (int i=(int)yyleng-1;i>=0;i--) unput(yytext[i]); } while(0)

Definition at line 158 of file doctokenizer.l.

◆ YY_DECL

#define YY_DECL   static Token doctokenizerYYlex(yyscan_t yyscanner)

Definition at line 169 of file doctokenizer.l.

◆ YY_INPUT

#define YY_INPUT ( buf,
result,
max_size )
Value:
result=yyread(yyscanner,buf,max_size);
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
Definition code.l:3989

Definition at line 162 of file doctokenizer.l.

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 52 of file doctokenizer.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 53 of file doctokenizer.l.

◆ YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 26 of file doctokenizer.l.

◆ yyterminate

#define yyterminate ( )
Value:
return Token::make_TK_EOF()

Definition at line 172 of file doctokenizer.l.

Typedef Documentation

◆ yyscan_t

typedef yyguts_t* yyscan_t

Definition at line 28 of file doctokenizer.l.

Function Documentation

◆ computeIndent()

static int computeIndent ( const char * str,
size_t length )
static

Definition at line 125 of file doctokenizer.l.

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;
#define Config_getInt(name)
Definition config.h:34
int qstrncmp(const char *str1, const char *str2, size_t len)
Definition qcstring.h:75
154}

References Config_getInt, and qstrncmp().

◆ extractPartAfterNewLine()

QCString extractPartAfterNewLine ( const QCString & text)

Definition at line 107 of file doctokenizer.l.

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;
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
121}

References QCString::at(), QCString::find(), and QCString::mid().

◆ getLexerFILE()

static const char * getLexerFILE ( )
inlinestatic

Definition at line 165 of file doctokenizer.l.

165{return __FILE__;}

◆ handleHtmlTag()

static void handleHtmlTag ( yyscan_t yyscanner,
const char * text )
static

Definition at line 1605 of file doctokenizer.l.

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;
This is an alternative implementation of QCString.
Definition qcstring.h:101
#define FALSE
Definition qcstring.h:34
1614
1615 // Check for end tag
1616 int startNamePos=1;
1617 if (tagText.at(1)=='/')
1618 {
1619 yyextra->token.endTag = TRUE;
1620 startNamePos++;
1621 }
#define TRUE
Definition qcstring.h:37
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;
QCString lower() const
Definition qcstring.h:234
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}

References QCString::at(), QCString::clear(), FALSE, QCString::lower(), QCString::mid(), and TRUE.

◆ processSection()

static void processSection ( yyscan_t yyscanner)
static

Definition at line 1584 of file doctokenizer.l.

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 }
const T * find(const std::string &key) const
Definition linkedmap.h:47
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
#define warn(file, line, fmt,...)
Definition message.h:97
1603}

References LinkedMap< T, Hash, KeyEqual, Map >::find(), SectionManager::instance(), SectionInfo::setFileName(), SectionInfo::setType(), and warn.

◆ stateToString()

static const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 334 of file doctokenizer.l.

336 {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 }
#define lineCount(s, len)
static int computeIndent(const char *str, size_t length)
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
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
QCString extractPartAfterNewLine(const QCString &text)
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
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 }
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 }
static void handleHtmlTag(yyscan_t yyscanner, const char *text)
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
static void processSection(yyscan_t yyscanner)
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%%

◆ yyread()

static int yyread ( yyscan_t yyscanner,
char * buf,
int max_size )
static

Definition at line 1574 of file doctokenizer.l.

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}