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 "stringutil.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 98 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 160 of file doctokenizer.l.

◆ YY_DECL

#define YY_DECL   static Token doctokenizerYYlex(yyscan_t yyscanner)

Definition at line 171 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:3963

Definition at line 164 of file doctokenizer.l.

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 53 of file doctokenizer.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 54 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 174 of file doctokenizer.l.

Typedef Documentation

◆ yyscan_t

typedef yyguts_t* yyscan_t

Definition at line 28 of file doctokenizer.l.

Function Documentation

◆ computeIndent()

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

Definition at line 127 of file doctokenizer.l.

128{
129 if (str==0 || length==std::string::npos) return 0;
130 size_t i;
131 int indent=0;
132 int tabSize=Config_getInt(TAB_SIZE);
133 for (i=0;i<length;i++)
134 {
135 if (str[i]=='\t')
136 {
137 indent+=tabSize - (indent%tabSize);
138 }
139 else if (str[i]=='\n')
140 {
141 indent=0;
142 }
143 else if (literal_at(&str[i],"\\ilinebr"))
144 {
145 indent=0;
146 i+=7;
147 if (str[i+1]==' ') i++; // also eat space after \\ilinebr if present
148 }
149 else
150 {
151 indent++;
152 }
153 }
154 //printf("input('%s')=%d\n",str,indent);
155 return indent;
#define Config_getInt(name)
Definition config.h:34
bool literal_at(const char *data, const char(&str)[N])
returns TRUE iff data points to a substring that matches string literal str
Definition stringutil.h:98
156}

References Config_getInt, and literal_at().

◆ extractPartAfterNewLine()

QCString extractPartAfterNewLine ( const QCString & text)

Definition at line 109 of file doctokenizer.l.

110{
111 int nl1 = text.find('\n');
112 int nl2 = text.find("\\ilinebr");
113 if (nl1!=-1 && nl1<nl2)
114 {
115 return text.mid(nl1+1);
116 }
117 if (nl2!=-1)
118 {
119 if (text.at(nl2+8)==' ') nl2++; // skip space after \\ilinebr
120 return text.mid(nl2+8);
121 }
122 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:241
char & at(size_t i)
Returns a reference to the character at index i.
Definition qcstring.h:593
123}

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

◆ getLexerFILE()

const char * getLexerFILE ( )
inlinestatic

Definition at line 167 of file doctokenizer.l.

167{return __FILE__;}

◆ handleHtmlTag()

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

Definition at line 1615 of file doctokenizer.l.

1616{
1617 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1618
1619 QCString tagText(text);
1620 yyextra->token.text = tagText;
1621 yyextra->token.attribs.clear();
1622 yyextra->token.endTag = FALSE;
1623 yyextra->token.emptyTag = FALSE;
This is an alternative implementation of QCString.
Definition qcstring.h:101
#define FALSE
Definition qcstring.h:34
1624
1625 // Check for end tag
1626 int startNamePos=1;
1627 if (tagText.at(1)=='/')
1628 {
1629 yyextra->token.endTag = TRUE;
1630 startNamePos++;
1631 }
#define TRUE
Definition qcstring.h:37
1632
1633 // Parse the name portion
1634 int i = startNamePos;
1635 for (i=startNamePos; i < (int)yyleng; i++)
1636 {
1637 // Check for valid HTML/XML name chars (including namespaces)
1638 char c = tagText.at(i);
1639 if (!(isalnum(c) || c=='-' || c=='_' || c==':')) break;
1640 }
1641 yyextra->token.name = tagText.mid(startNamePos,i-startNamePos);
1642
1643 // Parse the attributes. Each attribute is a name, value pair
1644 // The result is stored in yyextra->token.attribs.
1645 int startAttribList = i;
1646 while (i<(int)yyleng)
1647 {
1648 char c=tagText.at(i);
1649 // skip spaces
1650 while (i<(int)yyleng && isspace((uint8_t)c)) { c=tagText.at(++i); }
1651 // check for end of the tag
1652 if (c == '>') break;
1653 // Check for XML style "empty" tag.
1654 if (c == '/')
1655 {
1656 yyextra->token.emptyTag = TRUE;
1657 break;
1658 }
1659 int startName=i;
1660 // search for end of name
1661 while (i<(int)yyleng && !isspace((uint8_t)c) && c!='=' && c!= '>') { c=tagText.at(++i); }
1662 int endName=i;
1663 QCString optName,optValue;
1664 optName = tagText.mid(startName,endName-startName).lower();
1665 // skip spaces
1666 while (i<(int)yyleng && isspace((uint8_t)c)) { c=tagText.at(++i); }
1667 if (tagText.at(i)=='=') // option has value
1668 {
1669 int startAttrib=0, endAttrib=0;
1670 c=tagText.at(++i);
1671 // skip spaces
1672 while (i<(int)yyleng && isspace((uint8_t)c)) { c=tagText.at(++i); }
1673 if (tagText.at(i)=='\'') // option '...'
1674 {
1675 c=tagText.at(++i);
1676 startAttrib=i;
QCString lower() const
Definition qcstring.h:249
1677
1678 // search for matching quote
1679 while (i<(int)yyleng && c!='\'') { c=tagText.at(++i); }
1680 endAttrib=i;
1681 if (i<(int)yyleng) { c=tagText.at(++i);}
1682 }
1683 else if (tagText.at(i)=='"') // option "..."
1684 {
1685 c=tagText.at(++i);
1686 startAttrib=i;
1687 // search for matching quote
1688 while (i<(int)yyleng && c!='"') { c=tagText.at(++i); }
1689 endAttrib=i;
1690 if (i<(int)yyleng) { c=tagText.at(++i);}
1691 }
1692 else // value without any quotes
1693 {
1694 startAttrib=i;
1695 // search for separator or end symbol
1696 while (i<(int)yyleng && !isspace((uint8_t)c) && c!='>') { c=tagText.at(++i); }
1697 endAttrib=i;
1698 if (i<(int)yyleng) { c=tagText.at(++i);}
1699 }
1700 optValue = tagText.mid(startAttrib,endAttrib-startAttrib);
1701 if (optName == "align") optValue = optValue.lower();
1702 else if (optName == "valign")
1703 {
1704 optValue = optValue.lower();
1705 if (optValue == "center") optValue="middle";
1706 }
1707 }
1708 else // start next option
1709 {
1710 }
1711 //printf("=====> Adding option name=<%s> value=<%s>\n",
1712 // qPrint(optName),qPrint(optValue));
1713 yyextra->token.attribs.emplace_back(optName,optValue);
1714 }
1715 yyextra->token.attribsStr = tagText.mid(startAttribList,i-startAttribList);
1716}

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

◆ processSection()

void processSection ( yyscan_t yyscanner)
static

Definition at line 1594 of file doctokenizer.l.

1595{
1596 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1597 //printf("%s: found section/anchor with name '%s'\n",qPrint(yyextra->fileName),qPrint(yyextra->secLabel));
1598 QCString file;
1599 if (yyextra->definition)
1600 {
1601 file = yyextra->definition->getOutputFileBase();
1602 }
1603 else
1604 {
1605 warn(yyextra->fileName,yyextra->yyLineNr,"Found section/anchor {} without context",yyextra->secLabel);
1606 }
1607 SectionInfo *si = SectionManager::instance().find(yyextra->secLabel);
1608 if (si)
1609 {
1610 si->setFileName(file);
1611 si->setType(yyextra->secType);
1612 }
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:178
#define warn(file, line, fmt,...)
Definition message.h:97
1613}

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

◆ stateToString()

const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 336 of file doctokenizer.l.

338 {LISTITEM} { /* list item */
339 if (yyextra->insideHtmlLink || yyextra->insidePre) REJECT;
340 lineCount(yytext,yyleng);
341 QCString text(yytext);
342 uint32_t dashPos = static_cast<uint32_t>(text.findRev('-'));
343 assert(dashPos!=static_cast<uint32_t>(-1));
344 yyextra->token.isEnumList = text.at(dashPos+1)=='#';
345 yyextra->token.isCheckedList = false;
346 yyextra->token.id = -1;
347 yyextra->token.indent = computeIndent(yytext,dashPos);
348 return Token::make_TK_LISTITEM();
349 }
#define lineCount(s, len)
static int computeIndent(const char *str, size_t length)
350<St_Para>^{CLISTITEM} { /* checkbox item */
351 QCString text=yytext;
352 int dashPos = text.findRev('-');
353 yyextra->token.isEnumList = false;
354 yyextra->token.isCheckedList = true;
355 if (text.find('x') != -1) yyextra->token.id = DocAutoList::Checked_x;
356 else if (text.find('X') != -1) yyextra->token.id = DocAutoList::Checked_X;
357 else yyextra->token.id = DocAutoList::Unchecked;
358 yyextra->token.indent = computeIndent(yytext,dashPos);
359 return Token::make_TK_LISTITEM();
360 }
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:96
361<St_Para>^{MLISTITEM} { /* list item */
362 if (yyextra->insideHtmlLink || !yyextra->markdownSupport || yyextra->insidePre)
363 {
364 REJECT;
365 }
366 else
367 {
368 lineCount(yytext,yyleng);
369 std::string text(yytext);
370 static const reg::Ex re(R"([*+][^*+]*$)"); // find last + or *
372 reg::search(text,match,re);
373 size_t listPos = match.position();
374 assert(listPos!=std::string::npos);
375 yyextra->token.isEnumList = false;
376 yyextra->token.isCheckedList = false;
377 yyextra->token.id = -1;
378 yyextra->token.indent = computeIndent(yytext,listPos);
379 return Token::make_TK_LISTITEM();
380 }
381 }
Class representing a regular expression.
Definition regex.h:39
Object representing the matching results.
Definition regex.h:151
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:842
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:853
382<St_Para>^{OLISTITEM} { /* numbered list item */
383 if (yyextra->insideHtmlLink || !yyextra->markdownSupport || yyextra->insidePre)
384 {
385 REJECT;
386 }
387 else
388 {
389 std::string text(yytext);
390 static const reg::Ex re(R"(\d+)");
392 reg::search(text,match,re);
393 size_t markPos = match.position();
394 assert(markPos!=std::string::npos);
395 yyextra->token.isEnumList = true;
396 yyextra->token.isCheckedList = false;
397 bool ok = false;
398 int id = QCString(match.str()).toInt(&ok);
399 yyextra->token.id = ok ? id : -1;
400 if (!ok)
401 {
402 warn(yyextra->fileName,yyextra->yyLineNr,"Invalid number for list item '{}' ",match.str());
403 }
404 yyextra->token.indent = computeIndent(yytext,markPos);
405 return Token::make_TK_LISTITEM();
406 }
407 }
int toInt(bool *ok=nullptr, int base=10) const
Definition qcstring.cpp:254
408<St_Para>{BLANK}*(\n|"\\ilinebr"){LISTITEM} { /* list item on next line */
409 if (yyextra->insideHtmlLink || yyextra->insidePre) REJECT;
410 lineCount(yytext,yyleng);
412 uint32_t dashPos = static_cast<uint32_t>(text.findRev('-'));
413 assert(dashPos!=static_cast<uint32_t>(-1));
414 yyextra->token.isEnumList = text.at(dashPos+1)=='#';
415 yyextra->token.isCheckedList = false;
416 yyextra->token.id = -1;
417 yyextra->token.indent = computeIndent(text.data(),dashPos);
418 return Token::make_TK_LISTITEM();
419 }
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:172
QCString extractPartAfterNewLine(const QCString &text)
420<St_Para>{BLANK}*\n{CLISTITEM} { /* checkbox item on next line */
421 QCString text=yytext;
422 text=text.right(text.length()-text.find('\n')-1);
423 int dashPos = text.findRev('-');
424 yyextra->token.isEnumList = false;
425 yyextra->token.isCheckedList = true;
426 if (text.find('x') != -1) yyextra->token.id = DocAutoList::Checked_x;
427 else if (text.find('X') != -1) yyextra->token.id = DocAutoList::Checked_X;
428 else yyextra->token.id = DocAutoList::Unchecked;
429 yyextra->token.indent = computeIndent(text.data(),dashPos);
430 return Token::make_TK_LISTITEM();
431 }
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
QCString right(size_t len) const
Definition qcstring.h:234
432<St_Para>{BLANK}*(\n|"\\ilinebr"){MLISTITEM} { /* list item on next line */
433 if (yyextra->insideHtmlLink || !yyextra->markdownSupport || yyextra->insidePre)
434 {
435 REJECT;
436 }
437 else
438 {
439 lineCount(yytext,yyleng);
440 std::string text=extractPartAfterNewLine(yytext).str();
441 static const reg::Ex re(R"([*+][^*+]*$)"); // find last + or *
443 reg::search(text,match,re);
444 size_t markPos = match.position();
445 assert(markPos!=std::string::npos);
446 yyextra->token.isEnumList = FALSE;
447 yyextra->token.isCheckedList = false;
448 yyextra->token.id = -1;
449 yyextra->token.indent = computeIndent(text.c_str(),markPos);
450 return Token::make_TK_LISTITEM();
451 }
452 }
const std::string & str() const
Definition qcstring.h:552
453<St_Para>{BLANK}*(\n|"\\ilinebr"){OLISTITEM} { /* list item on next line */
454 if (yyextra->insideHtmlLink || !yyextra->markdownSupport || yyextra->insidePre)
455 {
456 REJECT;
457 }
458 else
459 {
460 lineCount(yytext,yyleng);
461 std::string text=extractPartAfterNewLine(yytext).str();
462 static const reg::Ex re(R"(\d+)");
464 reg::search(text,match,re);
465 size_t markPos = match.position();
466 assert(markPos!=std::string::npos);
467 yyextra->token.isEnumList = true;
468 yyextra->token.isCheckedList = false;
469 bool ok = false;
470 int id = QCString(match.str()).toInt(&ok);
471 yyextra->token.id = ok ? id : -1;
472 if (!ok)
473 {
474 warn(yyextra->fileName,yyextra->yyLineNr,"Invalid number for list item '{}' ",match.str());
475 }
476 yyextra->token.indent = computeIndent(text.c_str(),markPos);
477 return Token::make_TK_LISTITEM();
478 }
479 }
480<St_Para>^{ENDLIST} { /* end list */
481 if (yyextra->insideHtmlLink || yyextra->insidePre) REJECT;
482 lineCount(yytext,yyleng);
483 size_t dotPos = static_cast<size_t>(QCString(yytext).findRev('.'));
484 yyextra->token.indent = computeIndent(yytext,dotPos);
485 return Token::make_TK_ENDLIST();
486 }
487<St_Para>{BLANK}*(\n|"\\ilinebr"){ENDLIST} { /* end list on next line */
488 if (yyextra->insideHtmlLink || yyextra->insidePre) REJECT;
489 lineCount(yytext,yyleng);
491 size_t dotPos = static_cast<size_t>(text.findRev('.'));
492 yyextra->token.indent = computeIndent(text.data(),dotPos);
493 return Token::make_TK_ENDLIST();
494 }
495<St_Para>"{"{BLANK}*"@linkplain"/{WS}+ {
496 yyextra->token.name = "javalinkplain";
497 return Token::make_TK_COMMAND_AT();
498 }
499<St_Para>"{"{BLANK}*"@link"/{WS}+ {
500 yyextra->token.name = "javalink";
501 return Token::make_TK_COMMAND_AT();
502 }
503<St_Para>"{"{BLANK}*"@inheritDoc"{BLANK}*"}" {
504 yyextra->token.name = "inheritdoc";
505 return Token::make_TK_COMMAND_AT();
506 }
507<St_Para>"@_fakenl" { // artificial new line
508 //yyextra->yyLineNr++;
509 }
510<St_Para>{SPCMD3} {
511 yyextra->token.name = "_form";
512 bool ok;
513 yyextra->token.id = QCString(yytext).right((int)yyleng-7).toInt(&ok);
514 ASSERT(ok);
515 return Token::char_to_command(yytext[0]);
516 }
static Token char_to_command(char c)
#define ASSERT(x)
Definition qcstring.h:39
517<St_Para>{CMD}"n"\n { /* \n followed by real newline */
518 lineCount(yytext,yyleng);
519 //yyextra->yyLineNr++;
520 yyextra->token.name = yytext+1;
521 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
522 yyextra->token.paramDir=TokenInfo::Unspecified;
523 return Token::char_to_command(yytext[0]);
524 }
525<St_Para>"\\ilinebr" {
526 }
527<St_Para>{SPCMD1} |
528<St_Para>{SPCMD2} |
529<St_Para>{SPCMD5} |
530<St_Para>{SPCMD4} { /* special command */
531 yyextra->token.name = yytext+1;
532 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
533 yyextra->token.paramDir=TokenInfo::Unspecified;
534 return Token::char_to_command(yytext[0]);
535 }
536<St_Para>{PARAMIO} { /* param [in,out] command */
537 yyextra->token.name = "param";
538 QCString s(yytext);
539 bool isIn = s.find("in")!=-1;
540 bool isOut = s.find("out")!=-1;
541 if (isIn)
542 {
543 if (isOut)
544 {
545 yyextra->token.paramDir=TokenInfo::InOut;
546 }
547 else
548 {
549 yyextra->token.paramDir=TokenInfo::In;
550 }
551 }
552 else if (isOut)
553 {
554 yyextra->token.paramDir=TokenInfo::Out;
555 }
556 else
557 {
558 yyextra->token.paramDir=TokenInfo::Unspecified;
559 }
560 return Token::char_to_command(yytext[0]);
561 }
562<St_Para>{URLPROTOCOL}{URLMASK}/[,\.] { // URL, or URL.
563 yyextra->token.name=yytext;
564 yyextra->token.isEMailAddr=FALSE;
565 return Token::make_TK_URL();
566 }
567<St_Para>{URLPROTOCOL}{URLMASK} { // URL
568 yyextra->token.name=yytext;
569 yyextra->token.isEMailAddr=FALSE;
570 return Token::make_TK_URL();
571 }
572<St_Para>"<"{URLPROTOCOL}{URLMASK}">" { // URL
573 yyextra->token.name=yytext;
574 yyextra->token.name = yyextra->token.name.mid(1,yyextra->token.name.length()-2);
575 yyextra->token.isEMailAddr=FALSE;
576 return Token::make_TK_URL();
577 }
578<St_Para>{MAILADDR} { // Mail address
579 yyextra->token.name=yytext;
580 yyextra->token.name.stripPrefix("mailto:");
581 yyextra->token.isEMailAddr=TRUE;
582 return Token::make_TK_URL();
583 }
584<St_Para>"<"{MAILADDR}">" { // Mail address
585 yyextra->token.name=yytext;
586 yyextra->token.name = yyextra->token.name.mid(1,yyextra->token.name.length()-2);
587 yyextra->token.name.stripPrefix("mailto:");
588 yyextra->token.isEMailAddr=TRUE;
589 return Token::make_TK_URL();
590 }
591<St_Para>"<"{MAILADDR2}">" { // anti spam mail address
592 yyextra->token.name=yytext;
593 return Token::make_TK_WORD();
594 }
595<St_Para>{RCSID} { /* RCS tag */
596 QCString tagName(yytext+1);
597 int index=tagName.find(':');
598 if (index<0) index=0; // should never happen
599 yyextra->token.name = tagName.left(index);
600 int text_begin = index+2;
601 int text_end = static_cast<int>(tagName.length())-1;
602 if (tagName[text_begin-1]==':') /* check for Subversion fixed-length keyword */
603 {
604 ++text_begin;
605 if (tagName[text_end-1]=='#')
606 {
607 --text_end;
608 }
609 }
610 yyextra->token.text = tagName.mid(text_begin,text_end-text_begin);
611 return Token::make_TK_RCSTAG();
612 }
613<St_Para,St_HtmlOnly,St_ManOnly,St_LatexOnly,St_RtfOnly,St_XmlOnly,St_DbOnly>"$("{ID}")" | /* environment variable */
614<St_Para,St_HtmlOnly,St_ManOnly,St_LatexOnly,St_RtfOnly,St_XmlOnly,St_DbOnly>"$("{ID}"("{ID}"))" { /* environment variable */
615 QCString name(&yytext[2]);
616 name = name.left(static_cast<int>(name.length())-1);
617 QCString value = Portable::getenv(name);
618 for (int i=static_cast<int>(value.length())-1;i>=0;i--) unput(value.at(i));
619 }
QCString getenv(const QCString &variable)
Definition portable.cpp:322
620<St_Para>"<blockquote>&zwj;" {
621 // for a markdown inserted block quote,
622 // tell flex that after putting the last indent
623 // back we are at the beginning of the line, see issue #11309
624 YY_CURRENT_BUFFER->yy_at_bol=1;
625 lineCount(yytext,yyleng);
626 handleHtmlTag(yyscanner,yytext);
627 return Token::make_TK_HTMLTAG();
628 }
static void handleHtmlTag(yyscan_t yyscanner, const char *text)
629<St_Para>{HTMLTAG} { /* html tag */
630 lineCount(yytext,yyleng);
631 handleHtmlTag(yyscanner,yytext);
632 return Token::make_TK_HTMLTAG();
633 }
634<St_Para,St_Text>"&"{ID}";" { /* special symbol */
635 yyextra->token.name = yytext;
636 return Token::make_TK_SYMBOL();
637 }
638
639 /********* patterns for linkable words ******************/
640
641<St_Para>{ID}/"<"{HTMLKEYW}">"+ { /* this rule is to prevent opening html
642 * tag to be recognized as a templated classes
643 */
644 yyextra->token.name = yytext;
645 return Token::make_TK_LNKWORD();
646 }
647<St_Para>{LNKWORDN}/("<"{HTMLKEYW}">")+ { // prevent <br> html tag to be parsed as template arguments
648 yyextra->token.name = yytext;
649 return Token::make_TK_LNKWORD();
650 }
651<St_Para>{LNKWORD1} |
652<St_Para>{LNKWORD1}{FUNCARG} |
653<St_Para>{LNKWORD2} |
654<St_Para>{LNKWORD3} {
655 yyextra->token.name = yytext;
656 return Token::make_TK_LNKWORD();
657 }
658<St_Para>{LNKWORD1}{FUNCARG}{CVSPEC}[^a-z_A-Z0-9] {
659 yyextra->token.name = yytext;
660 yyextra->token.name = yyextra->token.name.left(yyextra->token.name.length()-1);
661 unput(yytext[(int)yyleng-1]);
662 return Token::make_TK_LNKWORD();
663 }
664 /********* patterns for normal words ******************/
665
666<St_Para,St_Text>[\-+0-9] |
667<St_Para,St_Text>{WORD1} |
668<St_Para,St_Text>{WORD2} { /* function call */
669 if (QCString(yytext).find("\\ilinebr")!=-1) REJECT; // see issue #8311
670 lineCount(yytext,yyleng);
671 if (yytext[0]=='%') // strip % if present
672 yyextra->token.name = &yytext[1];
673 else
674 yyextra->token.name = yytext;
675 return Token::make_TK_WORD();
676 }
677<St_Text>({ID}".")+{ID} {
678 yyextra->token.name = yytext;
679 return Token::make_TK_WORD();
680 }
681<St_Para,St_Text>"operator"/{BLANK}*"<"[a-zA-Z_0-9]+">" { // Special case: word "operator" followed by a HTML command
682 // avoid interpretation as "operator <"
683 yyextra->token.name = yytext;
684 return Token::make_TK_WORD();
685 }
686
687 /*******************************************************/
688
689<St_Para,St_Text>{BLANK}+ |
690<St_Para,St_Text>{BLANK}*\n{BLANK}* { /* white space */
691 lineCount(yytext,yyleng);
692 yyextra->token.chars=yytext;
693 return Token::make_TK_WHITESPACE();
694 }
695<St_Text>[\\@<>&$#%~] {
696 yyextra->token.name = yytext;
697 return Token::char_to_command(yytext[0]);
698 }
699<St_Para>({BLANK}*\n)+{BLANK}*\n/{LISTITEM} { /* skip trailing paragraph followed by new list item */
700 if (yyextra->insidePre || yyextra->autoListLevel==0)
701 {
702 REJECT;
703 }
704 lineCount(yytext,yyleng);
705 }
706<St_Para>({BLANK}*\n)+{BLANK}*\n/{CLISTITEM} { /* skip trailing paragraph followed by new checkbox item */
707 if (yyextra->insidePre || yyextra->autoListLevel==0)
708 {
709 REJECT;
710 }
711 }
712<St_Para>({BLANK}*\n)+{BLANK}*\n/{MLISTITEM} { /* skip trailing paragraph followed by new list item */
713 if (!yyextra->markdownSupport || yyextra->insidePre || yyextra->autoListLevel==0)
714 {
715 REJECT;
716 }
717 lineCount(yytext,yyleng);
718 }
719<St_Para>({BLANK}*\n)+{BLANK}*\n/{OLISTITEM} { /* skip trailing paragraph followed by new list item */
720 if (!yyextra->markdownSupport || yyextra->insidePre || yyextra->autoListLevel==0)
721 {
722 REJECT;
723 }
724 lineCount(yytext,yyleng);
725 }
726<St_Para,St_Param>({BLANK}*(\n|"\\ilinebr"))+{BLANK}*(\n|"\\ilinebr"){BLANK}*/" \\ifile" | // we don't want to count the space before \ifile
727<St_Para,St_Param>({BLANK}*(\n|"\\ilinebr"))+{BLANK}*(\n|"\\ilinebr"){BLANK}* {
728 lineCount(yytext,yyleng);
729 if (yyextra->insidePre)
730 {
731 yyextra->token.chars=yytext;
732 return Token::make_TK_WHITESPACE();
733 }
734 else
735 {
736 yyextra->token.indent=computeIndent(yytext,yyleng);
737 int i;
738 // put back the indentation (needed for list items)
739 //printf("token.indent=%d\n",yyextra->token.indent);
740 for (i=0;i<yyextra->token.indent;i++)
741 {
742 unput(' ');
743 }
744 // tell flex that after putting the last indent
745 // back we are at the beginning of the line
746 YY_CURRENT_BUFFER->yy_at_bol=1;
747 // start of a new paragraph
748 return Token::make_TK_NEWPARA();
749 }
750 }
751<St_CodeOpt>{BLANK}*"{"(".")?{CODEID}"}" {
752 yyextra->token.name = yytext;
753 int i=yyextra->token.name.find('{'); /* } to keep vi happy */
754 yyextra->token.name = yyextra->token.name.mid(i+1,yyextra->token.name.length()-i-2);
755 BEGIN(St_Code);
756 }
757<St_iCodeOpt>{BLANK}*"{"(".")?{CODEID}"}" {
758 yyextra->token.name = yytext;
759 int i=yyextra->token.name.find('{'); /* } to keep vi happy */
760 yyextra->token.name = yyextra->token.name.mid(i+1,yyextra->token.name.length()-i-2);
761 BEGIN(St_iCode);
762 }
763<St_CodeOpt>"\\ilinebr" |
764<St_CodeOpt>\n |
765<St_CodeOpt>. {
766 unput_string(yytext,yyleng);
767 BEGIN(St_Code);
768 }
#define unput_string(yytext, yyleng)
769<St_iCodeOpt>"\\ilinebr" |
770<St_iCodeOpt>\n |
771<St_iCodeOpt>. {
772 unput_string(yytext,yyleng);
773 BEGIN(St_iCode);
774 }
775<St_Code>{WS}*{CMD}"endcode" {
776 lineCount(yytext,yyleng);
777 return Token::make_RetVal_OK();
778 }
779<St_iCode>{WS}*{CMD}"endicode" {
780 lineCount(yytext,yyleng);
781 return Token::make_RetVal_OK();
782 }
783<St_XmlCode>{WS}*"</code>" {
784 lineCount(yytext,yyleng);
785 return Token::make_RetVal_OK();
786 }
787<St_Code,St_iCode,St_XmlCode>[^\\@\n<]+ |
788<St_Code,St_iCode,St_XmlCode>\n |
789<St_Code,St_iCode,St_XmlCode>. {
790 lineCount(yytext,yyleng);
791 yyextra->token.verb+=yytext;
792 }
793<St_HtmlOnlyOption>" [block]" { // the space is added in commentscan.l
794 yyextra->token.name="block";
795 BEGIN(St_HtmlOnly);
796 }
797<St_HtmlOnlyOption>.|\n {
798 unput(*yytext);
799 BEGIN(St_HtmlOnly);
800 }
801<St_HtmlOnlyOption>"\\ilinebr" {
802 unput_string(yytext,yyleng);
803 BEGIN(St_HtmlOnly);
804 }
805<St_HtmlOnly>{CMD}"endhtmlonly" {
806 return Token::make_RetVal_OK();
807 }
808<St_HtmlOnly>[^\\@\n$]+ |
809<St_HtmlOnly>\n |
810<St_HtmlOnly>. {
811 lineCount(yytext,yyleng);
812 yyextra->token.verb+=yytext;
813 }
814<St_ManOnly>{CMD}"endmanonly" {
815 return Token::make_RetVal_OK();
816 }
817<St_ManOnly>[^\\@\n$]+ |
818<St_ManOnly>\n |
819<St_ManOnly>. {
820 lineCount(yytext,yyleng);
821 yyextra->token.verb+=yytext;
822 }
823<St_RtfOnly>{CMD}"endrtfonly" {
824 return Token::make_RetVal_OK();
825 }
826<St_RtfOnly>[^\\@\n$]+ |
827<St_RtfOnly>\n |
828<St_RtfOnly>. {
829 lineCount(yytext,yyleng);
830 yyextra->token.verb+=yytext;
831 }
832<St_LatexOnly>{CMD}"endlatexonly" {
833 return Token::make_RetVal_OK();
834 }
835<St_LatexOnly>[^\\@\n]+ |
836<St_LatexOnly>\n |
837<St_LatexOnly>. {
838 lineCount(yytext,yyleng);
839 yyextra->token.verb+=yytext;
840 }
841<St_XmlOnly>{CMD}"endxmlonly" {
842 return Token::make_RetVal_OK();
843 }
844<St_XmlOnly>[^\\@\n]+ |
845<St_XmlOnly>\n |
846<St_XmlOnly>. {
847 lineCount(yytext,yyleng);
848 yyextra->token.verb+=yytext;
849 }
850<St_DbOnly>{CMD}"enddocbookonly" {
851 return Token::make_RetVal_OK();
852 }
853<St_DbOnly>[^\\@\n]+ |
854<St_DbOnly>\n |
855<St_DbOnly>. {
856 lineCount(yytext,yyleng);
857 yyextra->token.verb+=yytext;
858 }
859<St_Verbatim>{CMD}"endverbatim" {
860 yyextra->token.verb = yyextra->token.verb.stripLeadingAndTrailingEmptyLines();
861 return Token::make_RetVal_OK();
862 }
863<St_ILiteral>{CMD}"endiliteral " { // note extra space as this is artificially added
864 // remove spaces that have been added
865 yyextra->token.verb = yyextra->token.verb.mid(1,yyextra->token.verb.length()-2);
866 return Token::make_RetVal_OK();
867 }
868<St_iVerbatim>{CMD}"endiverbatim" {
869 yyextra->token.verb = yyextra->token.verb.stripLeadingAndTrailingEmptyLines();
870 return Token::make_RetVal_OK();
871 }
872<St_Verbatim,St_iVerbatim,St_ILiteral>[^\\@\n]+ |
873<St_Verbatim,St_iVerbatim,St_ILiteral>\n |
874<St_Verbatim,St_iVerbatim,St_ILiteral>. { /* Verbatim text */
875 lineCount(yytext,yyleng);
876 yyextra->token.verb+=yytext;
877 }
878<St_ILiteralOpt>{BLANK}*"{"[a-zA-Z_,:0-9\. ]*"}" { // option(s) present
879 yyextra->token.verb = QCString(yytext).stripWhiteSpace();
880 return Token::make_RetVal_OK();
881 }
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:260
882<St_ILiteralOpt>"\\ilinebr" |
883<St_ILiteralOpt>"\n" |
884<St_ILiteralOpt>. {
885 yyextra->token.sectionId = "";
886 unput_string(yytext,yyleng);
887 return Token::make_RetVal_OK();
888 }
889<St_Dot>{CMD}"enddot" {
890 return Token::make_RetVal_OK();
891 }
892<St_Dot>[^\\@\n]+ |
893<St_Dot>\n |
894<St_Dot>. { /* dot text */
895 lineCount(yytext,yyleng);
896 yyextra->token.verb+=yytext;
897 }
898<St_Msc>{CMD}("endmsc") {
899 return Token::make_RetVal_OK();
900 }
901<St_Msc>[^\\@\n]+ |
902<St_Msc>\n |
903<St_Msc>. { /* msc text */
904 lineCount(yytext,yyleng);
905 yyextra->token.verb+=yytext;
906 }
907<St_PlantUMLOpt>{BLANK}*"{"[a-zA-Z_,:0-9\. ]*"}" { // case 1: options present
908 yyextra->token.sectionId = QCString(yytext).stripWhiteSpace();
909 return Token::make_RetVal_OK();
910 }
911<St_PlantUMLOpt>{BLANK}*{FILEMASK}{BLANK}+/{ID}"=" { // case 2: plain file name specified followed by an attribute
912 yyextra->token.sectionId = QCString(yytext).stripWhiteSpace();
913 return Token::make_RetVal_OK();
914 }
915<St_PlantUMLOpt>{BLANK}*{FILEMASK}{BLANK}+/"\"" { // case 3: plain file name specified followed by a quoted title
916 yyextra->token.sectionId = QCString(yytext).stripWhiteSpace();
917 return Token::make_RetVal_OK();
918 }
919<St_PlantUMLOpt>{BLANK}*{FILEMASK}{BLANKopt}/\n { // case 4: plain file name specified without title or attributes
920 yyextra->token.sectionId = QCString(yytext).stripWhiteSpace();
921 return Token::make_RetVal_OK();
922 }
923<St_PlantUMLOpt>{BLANK}*{FILEMASK}{BLANKopt}/"\\ilinebr" { // case 5: plain file name specified without title or attributes
924 yyextra->token.sectionId = QCString(yytext).stripWhiteSpace();
925 return Token::make_RetVal_OK();
926 }
927<St_PlantUMLOpt>"\\ilinebr" |
928<St_PlantUMLOpt>"\n" |
929<St_PlantUMLOpt>. {
930 yyextra->token.sectionId = "";
931 unput_string(yytext,yyleng);
932 return Token::make_RetVal_OK();
933 }
934<St_PlantUML>{CMD}"enduml" {
935 return Token::make_RetVal_OK();
936 }
937<St_PlantUML>[^\\@\n]+ |
938<St_PlantUML>\n |
939<St_PlantUML>. { /* plantuml text */
940 lineCount(yytext,yyleng);
941 yyextra->token.verb+=yytext;
942 }
943<St_Title>"\"" { // quoted title
944 BEGIN(St_TitleQ);
945 }
946<St_Title>[ \t]+ {
947 yyextra->token.chars=yytext;
948 return Token::make_TK_WHITESPACE();
949 }
950<St_Title>. { // non-quoted title
951 unput(*yytext);
952 BEGIN(St_TitleN);
953 }
954<St_Title>\n {
955 unput(*yytext);
956 return Token::make_TK_NONE();
957 }
958<St_Title>"\\ilinebr" {
959 unput_string(yytext,yyleng);
960 return Token::make_TK_NONE();
961 }
962<St_TitleN>"&"{ID}";" { /* symbol */
963 yyextra->token.name = yytext;
964 return Token::make_TK_SYMBOL();
965 }
966<St_TitleN>{HTMLTAG} {
967 yyextra->token.name = yytext;
968 handleHtmlTag(yyscanner,yytext);
969 return Token::make_TK_HTMLTAG();
970 }
971<St_TitleN>\n { /* new line => end of title */
972 unput(*yytext);
973 return Token::make_TK_NONE();
974 }
975<St_TitleN>"\\ilinebr" { /* new line => end of title */
976 unput_string(yytext,yyleng);
977 return Token::make_TK_NONE();
978 }
979<St_TitleN>{SPCMD1} |
980<St_TitleN>{SPCMD2} { /* special command */
981 yyextra->token.name = yytext+1;
982 yyextra->token.paramDir=TokenInfo::Unspecified;
983 return Token::char_to_command(yytext[0]);
984 }
985<St_TitleN>{ID}"=" { /* attribute */
986 if (yytext[0]=='%') // strip % if present
987 yyextra->token.name = &yytext[1];
988 else
989 yyextra->token.name = yytext;
990 return Token::make_TK_WORD();
991 }
992<St_TitleN>[\-+0-9] |
993<St_TitleN>{WORD1} |
994<St_TitleN>{WORD2} { /* word */
995 if (QCString(yytext).find("\\ilinebr")!=-1) REJECT; // see issue #8311
996 lineCount(yytext,yyleng);
997 if (yytext[0]=='%') // strip % if present
998 yyextra->token.name = &yytext[1];
999 else
1000 yyextra->token.name = yytext;
1001 return Token::make_TK_WORD();
1002 }
1003<St_TitleN>[ \t]+ {
1004 yyextra->token.chars=yytext;
1005 return Token::make_TK_WHITESPACE();
1006 }
1007<St_TitleQ>"&"{ID}";" { /* symbol */
1008 yyextra->token.name = yytext;
1009 return Token::make_TK_SYMBOL();
1010 }
1011<St_TitleQ>(\n|"\\ilinebr") { /* new line => end of title */
1012 unput_string(yytext,yyleng);
1013 return Token::make_TK_NONE();
1014 }
1015<St_TitleQ>{SPCMD1} |
1016<St_TitleQ>{SPCMD2} { /* special command */
1017 yyextra->token.name = yytext+1;
1018 yyextra->token.paramDir=TokenInfo::Unspecified;
1019 return Token::char_to_command(yytext[0]);
1020 }
1021<St_TitleQ>{WORD1NQ} |
1022<St_TitleQ>{WORD2NQ} { /* word */
1023 yyextra->token.name = yytext;
1024 return Token::make_TK_WORD();
1025 }
1026<St_TitleQ>[ \t]+ {
1027 yyextra->token.chars=yytext;
1028 return Token::make_TK_WHITESPACE();
1029 }
1030<St_TitleQ>"\"" { /* closing quote => end of title */
1031 BEGIN(St_TitleA);
1032 return Token::make_TK_NONE();
1033 }
1034<St_TitleA>{BLANK}*{ID}{BLANK}*"="{BLANK}* { // title attribute
1035 yyextra->token.name = yytext;
1036 int pos = yyextra->token.name.find('=');
1037 if (pos<0) pos=0; // should never happen
1038 yyextra->token.name = yyextra->token.name.left(pos).stripWhiteSpace();
1039 BEGIN(St_TitleV);
1040 }
1041<St_TitleV>[^ \t\r\n]+ { // attribute value
1042 lineCount(yytext,yyleng);
1043 yyextra->token.chars = yytext;
1044 BEGIN(St_TitleN);
1045 return Token::make_TK_WORD();
1046 }
1047<St_TitleV,St_TitleA>. {
1048 unput(*yytext);
1049 return Token::make_TK_NONE();
1050 }
1051<St_TitleV,St_TitleA>(\n|"\\ilinebr") {
1052 unput_string(yytext,yyleng);
1053 return Token::make_TK_NONE();
1054 }
1055
1056<St_Anchor>{LABELID}{WS}? { // anchor
1057 lineCount(yytext,yyleng);
1058 yyextra->token.name = QCString(yytext).stripWhiteSpace();
1059 return Token::make_TK_WORD();
1060 }
1061<St_Anchor>. {
1062 unput(*yytext);
1063 return Token::make_TK_NONE();
1064 }
1065<St_Cite>{CITEID} { // label to cite
1066 if (yytext[0] =='"')
1067 {
1068 yyextra->token.name=yytext+1;
1069 yyextra->token.name=yyextra->token.name.left(static_cast<uint32_t>(yyleng)-2);
1070 }
1071 else
1072 {
1073 yyextra->token.name=yytext;
1074 }
1075 return Token::make_TK_WORD();
1076 }
1077<St_Cite>{BLANK} { // white space
1078 unput(' ');
1079 return Token::make_TK_NONE();
1080 }
1081<St_Cite>(\n|"\\ilinebr") { // new line
1082 unput_string(yytext,yyleng);
1083 return Token::make_TK_NONE();
1084 }
1085<St_Cite>. { // any other character
1086 unput(*yytext);
1087 return Token::make_TK_NONE();
1088 }
1089<St_DoxyConfig>{DOXYCFG} { // config option
1090 yyextra->token.name=yytext;
1091 return Token::make_TK_WORD();
1092 }
1093<St_DoxyConfig>{BLANK} { // white space
1094 unput(' ');
1095 return Token::make_TK_NONE();
1096 }
1097<St_DoxyConfig>(\n|"\\ilinebr") { // new line
1098 unput_string(yytext,yyleng);
1099 return Token::make_TK_NONE();
1100 }
1101<St_DoxyConfig>. { // any other character
1102 unput(*yytext);
1103 return Token::make_TK_NONE();
1104 }
1105<St_Ref>{REFWORD_NOCV}/{BLANK}("const")[a-z_A-Z0-9] { // see bug776988
1106 yyextra->token.name=yytext;
1107 return Token::make_TK_WORD();
1108 }
1109<St_Ref>{REFWORD_NOCV}/{BLANK}("volatile")[a-z_A-Z0-9] { // see bug776988
1110 yyextra->token.name=yytext;
1111 return Token::make_TK_WORD();
1112 }
1113<St_Ref>{REFWORD} { // label to refer to
1114 yyextra->token.name=yytext;
1115 return Token::make_TK_WORD();
1116 }
1117<St_Ref>{BLANK} { // white space
1118 unput(' ');
1119 return Token::make_TK_NONE();
1120 }
1121<St_Ref>{WS}+"\""{WS}* { // white space following by quoted string
1122 yyextra->expectQuote=true;
1123 lineCount(yytext,yyleng);
1124 BEGIN(St_Ref2);
1125 }
1126<St_Ref>(\n|"\\ilinebr") { // new line
1127 unput_string(yytext,yyleng);
1128 return Token::make_TK_NONE();
1129 }
1130<St_Ref>"\""[^"\n]+"\"" { // quoted first argument -> return without quotes
1131 yyextra->token.name=QCString(yytext).mid(1,yyleng-2);
1132 return Token::make_TK_WORD();
1133 }
1134<St_Ref>. { // any other character
1135 unput(*yytext);
1136 return Token::make_TK_NONE();
1137 }
1138<St_IntRef>[A-Z_a-z0-9.:/#\-\+\‍(\‍)]+ {
1139 yyextra->token.name = yytext;
1140 return Token::make_TK_WORD();
1141 }
1142<St_IntRef>{BLANK}+"\"" {
1143 BEGIN(St_Ref2);
1144 }
1145<St_SetScope>({SCOPEMASK}|{ANONNS}){BLANK}|{FILEMASK} {
1146 yyextra->token.name = yytext;
1147 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
1148 return Token::make_TK_WORD();
1149 }
1150<St_SetScope>{SCOPEMASK}"<" {
1151 yyextra->token.name = yytext;
1152 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
1153 yyextra->sharpCount=1;
1154 BEGIN(St_SetScopeEnd);
1155 }
1156<St_SetScope>{BLANK} {
1157 }
1158<St_SetScopeEnd>"<" {
1159 yyextra->token.name += yytext;
1160 yyextra->sharpCount++;
1161 }
1162<St_SetScopeEnd>">" {
1163 yyextra->token.name += yytext;
1164 yyextra->sharpCount--;
1165 if (yyextra->sharpCount<=0)
1166 {
1167 return Token::make_TK_WORD();
1168 }
1169 }
1170<St_SetScopeEnd>. {
1171 yyextra->token.name += yytext;
1172 }
1173<St_Ref2>"&"{ID}";" { /* symbol */
1174 yyextra->token.name = yytext;
1175 return Token::make_TK_SYMBOL();
1176 }
1177<St_Ref2>"\""|\n|"\\ilinebr" { /* " or \n => end of title? */
1178 lineCount(yytext,yyleng);
1179 if (!yyextra->expectQuote || yytext[0]=='"')
1180 {
1181 return Token::make_TK_NONE();
1182 }
1183 else
1184 {
1185 yyextra->token.name += yytext;
1186 }
1187 }
1188<St_Ref2>{HTMLTAG_STRICT} { /* html tag */
1189 lineCount(yytext,yyleng);
1190 handleHtmlTag(yyscanner,yytext);
1191 return Token::make_TK_HTMLTAG();
1192 }
1193<St_Ref2>{SPCMD1} |
1194<St_Ref2>{SPCMD2} { /* special command */
1195 yyextra->token.name = yytext+1;
1196 yyextra->token.paramDir=TokenInfo::Unspecified;
1197 return Token::char_to_command(yytext[0]);
1198 }
1199<St_Ref2>{WORD1NQ} |
1200<St_Ref2>{WORD2NQ} {
1201 /* word */
1202 yyextra->token.name = yytext;
1203 return Token::make_TK_WORD();
1204 }
1205<St_Ref2>[ \t]+ {
1206 yyextra->token.chars=yytext;
1207 return Token::make_TK_WHITESPACE();
1208 }
1209<St_XRefItem>{LABELID} {
1210 yyextra->token.name=yytext;
1211 }
1212<St_XRefItem>" " {
1213 BEGIN(St_XRefItem2);
1214 }
1215<St_XRefItem2>[0-9]+"." {
1216 QCString numStr(yytext);
1217 numStr=numStr.left((int)yyleng-1);
1218 yyextra->token.id=numStr.toInt();
1219 return Token::make_RetVal_OK();
1220 }
1221<St_Para,St_Title,St_Ref2>"<!--" { /* html style comment block */
1222 yyextra->commentState = YY_START;
1223 BEGIN(St_Comment);
1224 }
1225<St_Param>"\""[^\n\"]+"\"" {
1226 yyextra->token.name = yytext+1;
1227 yyextra->token.name = yyextra->token.name.left((int)yyleng-2);
1228 return Token::make_TK_WORD();
1229 }
1230<St_Param>({PHPTYPE}{BLANK}*("["{BLANK}*"]")*{BLANK}*"|"{BLANK}*)*{PHPTYPE}{BLANK}*("["{BLANK}*"]")*{WS}+("&")?"$"{LABELID} {
1231 lineCount(yytext,yyleng);
1232 QCString params(yytext);
1233 int j = params.find('&');
1234 int i = params.find('$');
1235 if (i<0) i=0; // should never happen
1236 if (j<i && j>=0) i=j;
1237 QCString types = params.left(i).stripWhiteSpace();
1238 yyextra->token.name = types+"#"+params.mid(i);
1239 return Token::make_TK_WORD();
1240 }
QCString left(size_t len) const
Definition qcstring.h:229
1241<St_Param>[^ \t\n,@\\‍]+ {
1242 yyextra->token.name = yytext;
1243 if (yyextra->token.name.at(static_cast<uint32_t>(yyleng)-1)==':')
1244 {
1245 yyextra->token.name=yyextra->token.name.left(static_cast<uint32_t>(yyleng)-1);
1246 }
1247 return Token::make_TK_WORD();
1248 }
1249<St_Param>{WS}*","{WS}* /* param separator */
1250<St_Param>{WS} {
1251 lineCount(yytext,yyleng);
1252 yyextra->token.chars=yytext;
1253 return Token::make_TK_WHITESPACE();
1254 }
1255<St_Prefix>"\""[^\n\"]*"\"" {
1256 yyextra->token.name = yytext+1;
1257 yyextra->token.name = yyextra->token.name.left((int)yyleng-2);
1258 return Token::make_TK_WORD();
1259 }
1260<St_Prefix>. {
1261 unput(*yytext);
1262 return Token::make_TK_NONE();
1263 }
1264<St_Options>{ID} {
1265 yyextra->token.name+=yytext;
1266 }
1267<St_Options>{WS}*":"{WS}* {
1268 lineCount(yytext,yyleng);
1269 yyextra->token.name+=":";
1270 }
1271<St_Options>{WS}*","{WS}* |
1272<St_Options>{WS} { /* option separator */
1273 lineCount(yytext,yyleng);
1274 yyextra->token.name+=",";
1275 }
1276<St_Options>"}" {
1277 return Token::make_TK_WORD();
1278 }
1279<St_Block>{ID} {
1280 yyextra->token.name+=yytext;
1281 }
1282<St_Block>"]" {
1283 return Token::make_TK_WORD();
1284 }
1285<St_Emoji>[:0-9_a-z+-]+ {
1286 yyextra->token.name=yytext;
1287 return Token::make_TK_WORD();
1288 }
1289<St_Emoji>. {
1290 unput(*yytext);
1291 return Token::make_TK_NONE();
1292 }
1293<St_QuotedString>"\"" {
1294 yyextra->token.name="";
1295 BEGIN(St_QuotedContent);
1296 }
1297<St_QuotedString>(\n|"\\ilinebr") {
1298 unput_string(yytext,yyleng);
1299 return Token::make_TK_NONE();
1300 }
1301<St_QuotedString>. {
1302 unput(*yytext);
1303 return Token::make_TK_NONE();
1304 }
1305<St_QuotedContent>"\"" {
1306 return Token::make_TK_WORD();
1307 }
1308<St_QuotedContent>. {
1309 yyextra->token.name+=yytext;
1310 }
1311<St_ShowDate>{WS}+{SHOWDATE} {
1312 lineCount(yytext,yyleng);
1313 yyextra->token.name=yytext;
1314 return Token::make_TK_WORD();
1315 }
1316<St_ShowDate>(\n|"\\ilinebr") {
1317 unput_string(yytext,yyleng);
1318 return Token::make_TK_NONE();
1319 }
1320<St_ShowDate>. {
1321 unput(*yytext);
1322 return Token::make_TK_NONE();
1323 }
1324<St_ILine>{LINENR}/[\\@\n\.] |
1325<St_ILine>{LINENR}{BLANK} {
1326 bool ok = false;
1327 int nr = QCString(yytext).toInt(&ok);
1328 if (!ok)
1329 {
1330 warn(yyextra->fileName,yyextra->yyLineNr,"Invalid line number '{}' for iline command",yytext);
1331 }
1332 else
1333 {
1334 yyextra->yyLineNr = nr;
1335 }
1336 return Token::make_TK_WORD();
1337 }
1338<St_ILine>. {
1339 return Token::make_TK_NONE();
1340 }
1341<St_IFile>{BLANK}*{FILEMASK} {
1342 yyextra->fileName = QCString(yytext).stripWhiteSpace();
1343 return Token::make_TK_WORD();
1344 }
1345<St_IFile>{BLANK}*"\""[^\n\"]+"\"" {
1346 QCString text(yytext);
1347 text = text.stripWhiteSpace();
1348 yyextra->fileName = text.mid(1,text.length()-2);
1349 return Token::make_TK_WORD();
1350 }
1351<St_File>{FILEMASK} {
1352 yyextra->token.name = yytext;
1353 return Token::make_TK_WORD();
1354 }
1355<St_File>"\""[^\n\"]+"\"" {
1356 QCString text(yytext);
1357 yyextra->token.name = text.mid(1,text.length()-2);
1358 return Token::make_TK_WORD();
1359 }
1360<St_Pattern>[^\\\r\n]+ {
1361 yyextra->token.name += yytext;
1362 }
1363<St_Pattern>"\\ilinebr" {
1364 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
1365 return Token::make_TK_WORD();
1366 }
1367<St_Pattern>\n {
1368 lineCount(yytext,yyleng);
1369 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
1370 return Token::make_TK_WORD();
1371 }
1372<St_Pattern>. {
1373 yyextra->token.name += yytext;
1374 }
1375<St_Link>{LINKMASK}|{REFWORD} {
1376 yyextra->token.name = yytext;
1377 return Token::make_TK_WORD();
1378 }
1379<St_Comment>"-->" { /* end of html comment */
1380 BEGIN(yyextra->commentState);
1381 }
1382<St_Comment>[^-]+ /* inside html comment */
1383<St_Comment>. /* inside html comment */
1384
1385 /* State for skipping title (all chars until the end of the line) */
1386
1387<St_SkipTitle>.
1388<St_SkipTitle>(\n|"\\ilinebr") {
1389 if (*yytext == '\n') unput('\n');
1390 return Token::make_TK_NONE();
1391 }
1392
1393 /* State for the pass used to find the anchors and sections */
1394
1395<St_Sections>[^\n@\<]+
1396<St_Sections>{CMD}("<"|{CMD})
1397<St_Sections>"<"{CAPTION}({WS}+{ATTRIB})*">" {
1398 lineCount(yytext,yyleng);
1399 QCString tag(yytext);
1400 int s=tag.find("id=");
1401 if (s!=-1) // command has id attribute
1402 {
1403 char c=tag[s+3];
1404 if (c=='\'' || c=='"') // valid start
1405 {
1406 int e=tag.find(c,s+4);
1407 if (e!=-1) // found matching end
1408 {
1409 yyextra->secType = SectionType::Table;
1410 yyextra->secLabel=tag.mid(s+4,e-s-4); // extract id
1411 processSection(yyscanner);
1412 }
1413 }
1414 }
1415 }
static constexpr int Table
Definition section.h:41
static void processSection(yyscan_t yyscanner)
1416<St_Sections>{CMD}"anchor"{BLANK}+ {
1417 yyextra->secType = SectionType::Anchor;
1418 BEGIN(St_SecLabel1);
1419 }
static constexpr int Anchor
Definition section.h:40
1420<St_Sections>{CMD}"ianchor"{BLANK}+ {
1421 yyextra->secType = SectionType::Anchor;
1422 BEGIN(St_SecLabel1);
1423 }
1424<St_Sections>{CMD}"section"{BLANK}+ {
1425 yyextra->secType = SectionType::Section;
1426 BEGIN(St_SecLabel2);
1427 }
static constexpr int Section
Definition section.h:33
1428<St_Sections>{CMD}"subsection"{BLANK}+ {
1429 yyextra->secType = SectionType::Subsection;
1430 BEGIN(St_SecLabel2);
1431 }
static constexpr int Subsection
Definition section.h:34
1432<St_Sections>{CMD}"subsubsection"{BLANK}+ {
1433 yyextra->secType = SectionType::Subsubsection;
1434 BEGIN(St_SecLabel2);
1435 }
static constexpr int Subsubsection
Definition section.h:35
1436<St_Sections>{CMD}"paragraph"{BLANK}+ {
1437 yyextra->secType = SectionType::Paragraph;
1438 BEGIN(St_SecLabel2);
1439 }
static constexpr int Paragraph
Definition section.h:36
1440<St_Sections>{CMD}"subparagraph"{BLANK}+ {
1441 yyextra->secType = SectionType::Subparagraph;
1442 BEGIN(St_SecLabel2);
1443 }
static constexpr int Subparagraph
Definition section.h:37
1444<St_Sections>{CMD}"subsubparagraph"{BLANK}+ {
1445 yyextra->secType = SectionType::Subsubparagraph;
1446 BEGIN(St_SecLabel2);
1447 }
static constexpr int Subsubparagraph
Definition section.h:38
1448<St_Sections>{CMD}"verbatim"/[^a-z_A-Z0-9] {
1449 yyextra->endMarker="endverbatim";
1450 BEGIN(St_SecSkip);
1451 }
1452<St_Sections>{CMD}"iverbatim"/[^a-z_A-Z0-9] {
1453 yyextra->endMarker="endiverbatim";
1454 BEGIN(St_SecSkip);
1455 }
1456<St_Sections>{CMD}"iliteral"/[^a-z_A-Z0-9] {
1457 yyextra->endMarker="endiliteral";
1458 BEGIN(St_SecSkip);
1459 }
1460<St_Sections>{CMD}"dot"/[^a-z_A-Z0-9] {
1461 yyextra->endMarker="enddot";
1462 BEGIN(St_SecSkip);
1463 }
1464<St_Sections>{CMD}"msc"/[^a-z_A-Z0-9] {
1465 yyextra->endMarker="endmsc";
1466 BEGIN(St_SecSkip);
1467 }
1468<St_Sections>{CMD}"startuml"/[^a-z_A-Z0-9] {
1469 yyextra->endMarker="enduml";
1470 BEGIN(St_SecSkip);
1471 }
1472<St_Sections>{CMD}"htmlonly"/[^a-z_A-Z0-9] {
1473 yyextra->endMarker="endhtmlonly";
1474 BEGIN(St_SecSkip);
1475 }
1476<St_Sections>{CMD}"latexonly"/[^a-z_A-Z0-9] {
1477 yyextra->endMarker="endlatexonly";
1478 BEGIN(St_SecSkip);
1479 }
1480<St_Sections>{CMD}"manonly"/[^a-z_A-Z0-9] {
1481 yyextra->endMarker="endmanonly";
1482 BEGIN(St_SecSkip);
1483 }
1484<St_Sections>{CMD}"rtfonly"/[^a-z_A-Z0-9] {
1485 yyextra->endMarker="endrtfonly";
1486 BEGIN(St_SecSkip);
1487 }
1488<St_Sections>{CMD}"xmlonly"/[^a-z_A-Z0-9] {
1489 yyextra->endMarker="endxmlonly";
1490 BEGIN(St_SecSkip);
1491 }
1492<St_Sections>{CMD}"docbookonly"/[^a-z_A-Z0-9] {
1493 yyextra->endMarker="enddocbookonly";
1494 BEGIN(St_SecSkip);
1495 }
1496<St_Sections>{CMD}"code"/[^a-z_A-Z0-9] {
1497 yyextra->endMarker="endcode";
1498 BEGIN(St_SecSkip);
1499 }
1500<St_Sections>{CMD}"icode"/[^a-z_A-Z0-9] {
1501 yyextra->endMarker="endicode";
1502 BEGIN(St_SecSkip);
1503 }
1504<St_Sections>"<!--" {
1505 yyextra->endMarker="-->";
1506 BEGIN(St_SecSkip);
1507 }
1508<St_SecSkip>{CMD}{ID} {
1509 if (yyextra->endMarker==yytext+1)
1510 {
1511 BEGIN(St_Sections);
1512 }
1513 }
1514<St_SecSkip>"-->" {
1515 if (yyextra->endMarker==yytext)
1516 {
1517 BEGIN(St_Sections);
1518 }
1519 }
1520<St_SecSkip>[^a-z_A-Z0-9\-\\\@]+
1521<St_SecSkip>.
1522<St_SecSkip>(\n|"\\ilinebr")
1523<St_Sections>.
1524<St_Sections>(\n|"\\ilinebr")
1525<St_SecLabel1>{LABELID} {
1526 lineCount(yytext,yyleng);
1527 yyextra->secLabel = yytext;
1528 processSection(yyscanner);
1529 BEGIN(St_Sections);
1530 }
1531<St_SecLabel2>{LABELID}{BLANK}+ |
1532<St_SecLabel2>{LABELID} {
1533 yyextra->secLabel = yytext;
1534 yyextra->secLabel = yyextra->secLabel.stripWhiteSpace();
1535 BEGIN(St_SecTitle);
1536 }
1537<St_SecTitle>[^\n]+ |
1538<St_SecTitle>[^\n]*\n {
1539 lineCount(yytext,yyleng);
1540 yyextra->secTitle = yytext;
1541 yyextra->secTitle = yyextra->secTitle.stripWhiteSpace();
1542 if (yyextra->secTitle.endsWith("\\ilinebr"))
1543 {
1544 yyextra->secTitle.left(yyextra->secTitle.length()-8);
1545 }
1546 processSection(yyscanner);
1547 BEGIN(St_Sections);
1548 }
1549<St_SecTitle,St_SecLabel1,St_SecLabel2>. {
1550 warn(yyextra->fileName,yyextra->yyLineNr,"Unexpected character '{}' while looking for section label or title",yytext);
1551 }
1552
1553<St_Snippet>[^\\\n]+ {
1554 yyextra->token.name += yytext;
1555 }
1556<St_Snippet>"\\" {
1557 yyextra->token.name += yytext;
1558 }
1559<St_Snippet>(\n|"\\ilinebr") {
1560 unput_string(yytext,yyleng);
1561 yyextra->token.name = yyextra->token.name.stripWhiteSpace();
1562 return Token::make_TK_WORD();
1563 }
1564
1565 /* Generic rules that work for all states */
1566<*>\n {
1567 lineCount(yytext,yyleng);
1568 warn(yyextra->fileName,yyextra->yyLineNr,"Unexpected new line character");
1569 }
1570<*>"\\ilinebr" {
1571 }
1572<*>[\\@<>&$#%~"=] { /* unescaped special character */
1573 //warn(yyextra->fileName,yyextra->yyLineNr,"Unexpected character '{}', assuming command \\{} was meant.",yytext,yytext);
1574 yyextra->token.name = yytext;
1575 return Token::char_to_command(yytext[0]);
1576 }
1577<*>. {
1578 warn(yyextra->fileName,yyextra->yyLineNr,"Unexpected character '{}'",yytext);
1579 }
1580%%

◆ yyread()

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

Definition at line 1584 of file doctokenizer.l.

1585{
1586 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1587 int c=0;
1588 const char *p = yyextra->inputString + yyextra->inputPos;
1589 while ( c < max_size && *p ) { *buf++ = *p++; c++; }
1590 yyextra->inputPos+=c;
1591 return c;
1592}