20%option never-interactive
21%option prefix="xmlcodeYY"
23%option extra-type="struct xmlcodeYY_state *"
30#define YY_TYPEDEF_YY_SCANNER_T
53#define YY_NEVER_INTERACTIVE 1
55#define YY_NO_UNISTD_H 1
105#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
This is an alternative implementation of QCString.
Web server based search engine.
const char * currentFontClass
const Definition * currentDefinition
const FileDef * sourceFileDef
const MemberDef * currentMemberDef
int yyLineNr
current line number
int inputPosition
read offset during parsing
std::unique_ptr< FileDef > exampleFileDef
const char * inputString
the code fragment as text
int inputLines
number of line in the code fragment
const Definition * searchCtx
A bunch of utility functions.
static void endCodeLine(yyscan_t yyscanner)
static void nextCodeLine(yyscan_t yyscanner)
static void startCodeLine(yyscan_t yyscanner)
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
static int countLines(yyscan_t yyscanner)
static const char * stateToString(int state)
static void startFontClass(yyscan_t yyscanner, const char *s)
static void codifyLines(yyscan_t yyscanner, const char *text)
static const char * getLexerFILE()
static void setCurrentDoc(yyscan_t yyscanner, const QCString &anchor)
static void codify(yyscan_t yyscanner, const char *text)
static void endFontClass(yyscan_t yyscanner)
117namestart [A-Za-z\200-\377_]
118namechar [:A-Za-z\200-\377_0-9.-]
119esc "&#"[0-9]+";"|"&#x"[0-9a-fA-F]+";"
120name {namestart}{namechar}*
121comment {open}"!--"([^-]|"-"[^-])*"--"{close}
122cdata {open}"![CDATA["([^\]]|"\]"[^\]])*"]]"{close}
123string \"([^\"&]|{esc})*\"|\'([^'&]|{esc})*\'
static void codifyLines(yyscan_t yyscanner, const QCString &text)
static void endFontClass(yyscan_t yyscanner, bool specialComment=false)
static void codify(yyscan_t yyscanner, const QCString &text)
static void startFontClass(yyscan_t yyscanner, const char *s, bool specialComment=false)
163 char openBracket[] = { yytext[0],
'\0' };
164 codify(yyscanner,openBracket);
174{open}{ws}?"/"{name} {
176 char closeBracket[] = { yytext[0], yytext[1],
'\0' };
178 codify(yyscanner,closeBracket);
213 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
214 int inputPosition = yyextra->inputPosition;
215 const char *s = yyextra->inputString + inputPosition;
217 while( c < max_size && *s)
222 yyextra->inputPosition += c;
228 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
229 yyextra->code->codify(text);
234 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
237 if (yyextra->searchCtx)
254 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
255 if (yyextra->sourceFileDef)
257 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
261 yyextra->currentDefinition = d;
262 yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
264 yyextra->classScope = d->
name();
266 lineAnchor.
sprintf(
"l%05d",yyextra->yyLineNr);
267 if (yyextra->currentMemberDef)
269 yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
270 yyextra->currentMemberDef->getOutputFileBase(),
271 yyextra->currentMemberDef->anchor(),yyextra->yyLineNr,
272 !yyextra->includeCodeFragment);
280 !yyextra->includeCodeFragment);
287 !yyextra->includeCodeFragment);
291 yyextra->code->startCodeLine(yyextra->yyLineNr);
292 yyextra->insideCodeLine =
true;
294 if (yyextra->currentFontClass)
296 yyextra->code->startFontClass(yyextra->currentFontClass);
302 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
303 if (yyextra->currentFontClass)
305 yyextra->code->endFontClass();
306 yyextra->currentFontClass=0;
312 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
314 yyextra->code->endCodeLine();
315 yyextra->insideCodeLine =
false;
320 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
321 const char *fc = yyextra->currentFontClass;
322 if (yyextra->insideCodeLine)
326 if (yyextra->yyLineNr<yyextra->inputLines)
328 yyextra->currentFontClass = fc;
335 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
336 const char *p=text,*sp=p;
342 while ((c=*p++) && c!=
'\n') { }
346 size_t l =
static_cast<size_t>(p-sp-1);
347 std::string tmp(sp,l);
348 yyextra->code->codify(tmp.c_str());
353 yyextra->code->codify(sp);
361 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
363 yyextra->code->startFontClass(s);
364 yyextra->currentFontClass=s;
370 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
371 const char *p=yyextra->inputString;
377 if (c==
'\n') count++;
379 if (p>yyextra->inputString && *(p-1)!=
'\n')
397 xmlcodeYYlex_init_extra(&
p->state,&
p->yyscanner);
406 xmlcodeYYlex_destroy(
p->yyscanner);
411 struct yyguts_t *yyg = (
struct yyguts_t*)
p->yyscanner;
412 yyextra->currentDefinition =
nullptr;
413 yyextra->currentMemberDef =
nullptr;
420 bool stripCodeComments,
434 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
439 yyextra->fileName = fileDef ? fileDef->
fileName():
"";
441 yyextra->code = &codeOutIntf;
442 yyextra->inputString = input.
data();
443 yyextra->inputPosition = 0;
444 yyextra->currentFontClass =
nullptr;
445 yyextra->insideCodeLine =
false;
446 yyextra->searchCtx = searchCtx;
449 yyextra->yyLineNr = startLine;
451 yyextra->yyLineNr = 1;
454 yyextra->inputLines = endLine+1;
456 yyextra->inputLines = yyextra->yyLineNr +
countLines(yyscanner) - 1;
458 yyextra->stripCodeComments = stripCodeComments;
459 yyextra->exampleBlock = isExampleBlock;
460 yyextra->exampleName = exampleName;
461 yyextra->sourceFileDef = fileDef;
463 if (isExampleBlock && fileDef==0)
466 yyextra->exampleFileDef =
createFileDef(
"",(!exampleName.
isEmpty()?exampleName:QCString(
"generated")));
467 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
470 if (yyextra->sourceFileDef)
475 yyextra->includeCodeFragment = inlineFragment;
479 xmlcodeYYrestart(
nullptr, yyscanner );
481 xmlcodeYYlex(yyscanner);
483 if (yyextra->insideCodeLine)
487 if (yyextra->exampleFileDef)
490 yyextra->exampleFileDef.reset();
491 yyextra->sourceFileDef=
nullptr;
496#include "xmlcode.l.h"
static bool isFlagSet(const DebugMask mask)
The common base class of all entity definitions found in the sources.
virtual bool isLinkableInProject() const =0
virtual QCString getReference() const =0
virtual QCString getOutputFileBase() const =0
virtual const QCString & name() const =0
static SearchIndexIntf searchIndex
A model of a file symbol.
virtual QCString fileName() const =0
A model of a class/file/namespace member symbol.
Class representing a list of different code generators.
bool isEmpty() const
Returns TRUE iff the string is empty.
QCString & sprintf(const char *format,...)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
std::unique_ptr< Private > p
void parseCode(OutputCodeList &codeOutIntf, const QCString &scopeName, const QCString &input, SrcLangExt, bool stripCodeComments, bool isExampleBlock, const QCString &exampleName=QCString(), const FileDef *fileDef=nullptr, int startLine=-1, int endLine=-1, bool inlineFragment=FALSE, const MemberDef *memberDef=nullptr, bool showLineNumbers=TRUE, const Definition *searchCtx=nullptr, bool collectXRefs=TRUE) override
Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
~XMLCodeParser() override
void resetCodeParserState() override
Resets the state of the code parser.
static void endCodeLine(yyscan_t yyscanner)
static void nextCodeLine(yyscan_t yyscanner)
static void startCodeLine(yyscan_t yyscanner)
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
static int countLines(yyscan_t yyscanner)
static void setCurrentDoc(yyscan_t yyscanner, const QCString &anchor)
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
const char * qPrint(const char *s)
SrcLangExt
Language as given by extension.