summaryrefslogtreecommitdiff
path: root/src/sqlcode.l
diff options
context:
space:
mode:
authorJinWang An <jinwang.an@samsung.com>2022-12-27 12:33:07 +0900
committerJinWang An <jinwang.an@samsung.com>2022-12-27 12:33:07 +0900
commit15e5c5601a13a41757e2a5e1a9105d1714d40215 (patch)
treeb3d78685874664026425debdf3298c29c8eb5dda /src/sqlcode.l
parent558fa54c62ec59357cb5c40a411f16f1c1754f33 (diff)
downloaddoxygen-15e5c5601a13a41757e2a5e1a9105d1714d40215.tar.gz
doxygen-15e5c5601a13a41757e2a5e1a9105d1714d40215.tar.bz2
doxygen-15e5c5601a13a41757e2a5e1a9105d1714d40215.zip
Imported Upstream version 1.9.3upstream/1.9.3
Diffstat (limited to 'src/sqlcode.l')
-rw-r--r--src/sqlcode.l35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/sqlcode.l b/src/sqlcode.l
index a674c71..b82cf34 100644
--- a/src/sqlcode.l
+++ b/src/sqlcode.l
@@ -21,6 +21,10 @@
%option extra-type="struct sqlcodeYY_state *"
%top{
#include <stdint.h>
+// forward declare yyscan_t to improve type safety
+#define YY_TYPEDEF_YY_SCANNER_T
+struct yyguts_t;
+typedef yyguts_t *yyscan_t;
}
%{
@@ -51,9 +55,10 @@ struct sqlcodeYY_state
CodeOutputInterface * code;
const char *inputString; //!< the code fragment as text
yy_size_t inputPosition; //!< read offset during parsing
+ QCString fileName;
int inputLines; //!< number of line in the code fragment
int yyLineNr; //!< current line number
- bool needsTermination;
+ bool insideCodeLine;
const Definition *searchCtx;
bool exampleBlock;
@@ -84,6 +89,10 @@ static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size);
#undef YY_INPUT
#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
+// otherwise the filename would be the name of the converted file (*.cpp instead of *.l)
+static inline const char *getLexerFILE() {return __FILE__;}
+#include "doxygen_lex.h"
+
%}
nl (\r\n|\r|\n)
@@ -238,24 +247,28 @@ static void startCodeLine(yyscan_t yyscanner)
{
yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
yyextra->currentMemberDef->getOutputFileBase(),
- yyextra->currentMemberDef->anchor(),yyextra->yyLineNr);
+ yyextra->currentMemberDef->anchor(),yyextra->yyLineNr,
+ !yyextra->includeCodeFragment);
setCurrentDoc(yyscanner,lineAnchor);
}
else
{
yyextra->code->writeLineNumber(d->getReference(),
d->getOutputFileBase(),
- QCString(),yyextra->yyLineNr);
+ QCString(),yyextra->yyLineNr,
+ !yyextra->includeCodeFragment);
setCurrentDoc(yyscanner,lineAnchor);
}
}
else
{
- yyextra->code->writeLineNumber(QCString(),QCString(),QCString(),yyextra->yyLineNr);
+ yyextra->code->writeLineNumber(QCString(),QCString(),QCString(),yyextra->yyLineNr,
+ !yyextra->includeCodeFragment);
}
}
yyextra->code->startCodeLine(yyextra->sourceFileDef);
+ yyextra->insideCodeLine=true;
if (yyextra->currentFontClass)
{
@@ -278,13 +291,17 @@ static void endCodeLine(yyscan_t yyscanner)
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
endFontClass(yyscanner);
yyextra->code->endCodeLine();
+ yyextra->insideCodeLine=false;
}
static void nextCodeLine(yyscan_t yyscanner)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
const char *fc = yyextra->currentFontClass;
- endCodeLine(yyscanner);
+ if (yyextra->insideCodeLine)
+ {
+ endCodeLine(yyscanner);
+ }
if (yyextra->yyLineNr<yyextra->inputLines)
{
yyextra->currentFontClass = fc;
@@ -344,8 +361,7 @@ static int countLines(yyscan_t yyscanner)
if (p>yyextra->inputString && *(p-1)!='\n')
{ // last line does not end with a \n, so we add an extra
// line and explicitly terminate the line after parsing.
- count++,
- yyextra->needsTermination=true;
+ count++;
}
return count;
}
@@ -417,12 +433,13 @@ void SQLCodeParser::parseCode(CodeOutputInterface &codeOutIntf,
if (input.isEmpty()) return;
printlex(yy_flex_debug, true, __FILE__, fileDef ? qPrint(fileDef->fileName()): NULL);
+ yyextra->fileName = fileDef ? fileDef->fileName():"";
yyextra->code = &codeOutIntf;
yyextra->inputString = input.data();
yyextra->inputPosition = 0;
yyextra->currentFontClass = 0;
- yyextra->needsTermination = false;
+ yyextra->insideCodeLine = false;
yyextra->searchCtx=searchCtx;
if (startLine!=-1)
@@ -461,7 +478,7 @@ void SQLCodeParser::parseCode(CodeOutputInterface &codeOutIntf,
sqlcodeYYlex(yyscanner);
- if (yyextra->needsTermination)
+ if (yyextra->insideCodeLine)
{
endCodeLine(yyscanner);
}