Doxygen
Loading...
Searching...
No Matches
doctokenizer.l File Reference
#include <stdint.h>
#include "doctokenizer.h"
#include <cctype>
#include <stack>
#include <string>
#include "cmdmapper.h"
#include "config.h"
#include "debug.h"
#include "definition.h"
#include "docnode.h"
#include "message.h"
#include "portable.h"
#include "regex.h"
#include "section.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 yyguts_t   doctokenizerYYguts_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)
DString extractPartAfterNewLine (const DString &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 100 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 162 of file doctokenizer.l.

◆ YY_DECL

#define YY_DECL   static Token doctokenizerYYlex(yyscan_t yyscanner)

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

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 54 of file doctokenizer.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 55 of file doctokenizer.l.

◆ YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 26 of file doctokenizer.l.

◆ yyguts_t

#define yyguts_t   doctokenizerYYguts_t

Definition at line 27 of file doctokenizer.l.

◆ yyterminate

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

Definition at line 176 of file doctokenizer.l.

Typedef Documentation

◆ yyscan_t

typedef yyguts_t* yyscan_t

Definition at line 29 of file doctokenizer.l.

Function Documentation

◆ computeIndent()

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

Definition at line 129 of file doctokenizer.l.

130{
131 if (str==0 || length==std::string::npos) return 0;
132 size_t i;
133 int indent=0;
134 int tabSize=Config_getInt(TAB_SIZE);
135 for (i=0;i<length;i++)
136 {
137 if (str[i]=='\t')
138 {
139 indent+=tabSize - (indent%tabSize);
140 }
141 else if (str[i]=='\n')
142 {
143 indent=0;
144 }
145 else if (literal_at(&str[i],"\\ilinebr"))
146 {
147 indent=0;
148 i+=7;
149 if (str[i+1]==' ') i++; // also eat space after \\ilinebr if present
150 }
151 else
152 {
153 indent++;
154 }
155 }
156 //printf("input('%s')=%d\n",str,indent);
157 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:101
158}

References Config_getInt, and literal_at().

◆ extractPartAfterNewLine()

DString extractPartAfterNewLine ( const DString & text)

Definition at line 111 of file doctokenizer.l.

112{
113 size_t nl1 = text.find('\n');
114 size_t nl2 = text.find("\\ilinebr");
115 if (nl1!=DString::npos && nl2!=DString::npos && nl1<nl2)
116 {
117 return text.mid(nl1+1);
118 }
119 if (nl2!=DString::npos)
120 {
121 if (text.at(nl2+8)==' ') nl2++; // skip space after \\ilinebr
122 return text.mid(nl2+8);
123 }
124 return text;
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:318
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
Definition dstring.h:178
char & at(size_t i)
Returns a reference to the character at index i.
Definition dstring.h:686
size_t find(char c, size_t pos=0) const
Definition dstring.h:239
125}

References DString::at(), DString::find(), DString::mid(), and DString::npos.

◆ getLexerFILE()

const char * getLexerFILE ( )
inlinestatic

Definition at line 169 of file doctokenizer.l.

169{return __FILE__;}

◆ handleHtmlTag()

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

Definition at line 1696 of file doctokenizer.l.

1697{
1698 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
#define yyguts_t
Definition code.l:23
1699
1700 DString tagText(text);
1701 yyextra->token.text = tagText;
1702 yyextra->token.attribs.clear();
1703 yyextra->token.endTag = false;
1704 yyextra->token.emptyTag = false;
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
1705
1706 // Check for end tag
1707 int startNamePos=1;
1708 if (tagText.at(1)=='/')
1709 {
1710 yyextra->token.endTag = true;
1711 startNamePos++;
1712 }
1713
1714 // Parse the name portion
1715 int i = startNamePos;
1716 for (i=startNamePos; i < (int)yyleng; i++)
1717 {
1718 // Check for valid HTML/XML name chars (including namespaces)
1719 char c = tagText.at(i);
1720 if (!(isalnum(c) || c=='-' || c=='_' || c==':')) break;
1721 }
1722 yyextra->token.name = tagText.mid(startNamePos,i-startNamePos);
1723
1724 // Parse the attributes. Each attribute is a name, value pair
1725 // The result is stored in yyextra->token.attribs.
1726 int startAttribList = i;
1727 while (i<(int)yyleng)
1728 {
1729 char c=tagText.at(i);
1730 // skip spaces
1731 while (i<(int)yyleng && isspace((uint8_t)c)) { c=tagText.at(++i); }
1732 // check for end of the tag
1733 if (c == '>') break;
1734 // Check for XML style "empty" tag.
1735 if (c == '/')
1736 {
1737 yyextra->token.emptyTag = true;
1738 break;
1739 }
1740 int startName=i;
1741 // search for end of name
1742 while (i<(int)yyleng && !isspace((uint8_t)c) && c!='=' && c!= '>') { c=tagText.at(++i); }
1743 int endName=i;
1744 DString optName,optValue;
1745 optName = tagText.mid(startName,endName-startName).lower();
1746 // skip spaces
1747 while (i<(int)yyleng && isspace((uint8_t)c)) { c=tagText.at(++i); }
1748 if (tagText.at(i)=='=') // option has value
1749 {
1750 int startAttrib=0, endAttrib=0;
1751 c=tagText.at(++i);
1752 // skip spaces
1753 while (i<(int)yyleng && isspace((uint8_t)c)) { c=tagText.at(++i); }
1754 if (tagText.at(i)=='\'') // option '...'
1755 {
1756 c=tagText.at(++i);
1757 startAttrib=i;
DString lower() const
Definition dstring.h:326
1758
1759 // search for matching quote
1760 while (i<(int)yyleng && c!='\'') { c=tagText.at(++i); }
1761 endAttrib=i;
1762 if (i<(int)yyleng) { c=tagText.at(++i);}
1763 }
1764 else if (tagText.at(i)=='"') // option "..."
1765 {
1766 c=tagText.at(++i);
1767 startAttrib=i;
1768 // search for matching quote
1769 while (i<(int)yyleng && c!='"') { c=tagText.at(++i); }
1770 endAttrib=i;
1771 if (i<(int)yyleng) { c=tagText.at(++i);}
1772 }
1773 else // value without any quotes
1774 {
1775 startAttrib=i;
1776 // search for separator or end symbol
1777 while (i<(int)yyleng && !isspace((uint8_t)c) && c!='>') { c=tagText.at(++i); }
1778 endAttrib=i;
1779 if (i<(int)yyleng) { c=tagText.at(++i);}
1780 }
1781 optValue = tagText.mid(startAttrib,endAttrib-startAttrib);
1782 if (optName == "align") optValue = optValue.lower();
1783 else if (optName == "valign")
1784 {
1785 optValue = optValue.lower();
1786 if (optValue == "center") optValue="middle";
1787 }
1788 }
1789 else // start next option
1790 {
1791 }
1792 //printf("=====> Adding option name=<%s> value=<%s>\n",
1793 // qPrint(optName),qPrint(optValue));
1794 yyextra->token.attribs.emplace_back(optName,optValue);
1795 }
1796 yyextra->token.attribsStr = tagText.mid(startAttribList,i-startAttribList);
1797}

References DString::at(), DString::clear(), DString::lower(), DString::mid(), and yyguts_t.

◆ processSection()

void processSection ( yyscan_t yyscanner)
static

Definition at line 1675 of file doctokenizer.l.

1676{
1677 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1678 //printf("%s: found section/anchor with name '%s'\n",qPrint(yyextra->fileName),qPrint(yyextra->secLabel));
1679 DString file;
1680 if (yyextra->definition)
1681 {
1682 file = yyextra->definition->getOutputFileBase();
1683 }
1684 else
1685 {
1686 warn(yyextra->fileName,yyextra->yyLineNr,"Found section/anchor {} without context",yyextra->secLabel);
1687 }
1688 SectionInfo *si = SectionManager::instance().find(yyextra->secLabel);
1689 if (si)
1690 {
1691 si->setFileName(file);
1692 si->setType(yyextra->secType);
1693 }
const T * find(const std::string &key) const
Definition linkedmap.h:47
class that provide information about a section.
Definition section.h:58
void setType(SectionType t)
Definition section.h:81
void setFileName(const DString &fn)
Definition section.h:80
static SectionManager & instance()
returns a reference to the singleton
Definition section.h:179
#define warn(file, line, fmt,...)
Definition message.h:97
1694}

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

◆ stateToString()

const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 343 of file doctokenizer.l.

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

◆ yyread()

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

Definition at line 1665 of file doctokenizer.l.

1666{
1667 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1668 int c=0;
1669 const char *p = yyextra->inputString + yyextra->inputPos;
1670 while ( c < max_size && *p ) { *buf++ = *p++; c++; }
1671 yyextra->inputPos+=c;
1672 return c;
1673}

References yyguts_t.