summaryrefslogtreecommitdiffstats
path: root/src/lexcode.l
diff options
context:
space:
mode:
Diffstat (limited to 'src/lexcode.l')
-rw-r--r--src/lexcode.l97
1 files changed, 62 insertions, 35 deletions
diff --git a/src/lexcode.l b/src/lexcode.l
index 9d4c9ba..59b05b7 100644
--- a/src/lexcode.l
+++ b/src/lexcode.l
@@ -66,7 +66,6 @@ struct lexcodeYY_state
QCString CCodeBuffer;
int startCCodeLine = -1;
int roundCount = 0;
- int squareCount = 0;
bool insideCode = FALSE;
QCString delimiter;
QCString docBlockName;
@@ -93,7 +92,7 @@ static void startCodeLine(yyscan_t yyscanner);
static void endFontClass(yyscan_t yyscanner);
static void endCodeLine(yyscan_t yyscanner);
static void nextCodeLine(yyscan_t yyscanner);
-static void codifyLines(yyscan_t yyscanner,const char *text);
+static void codifyLines(yyscan_t yyscanner,const QCString &text);
static void startFontClass(yyscan_t yyscanner,const char *s);
static int countLines(yyscan_t yyscanner);
static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size);
@@ -114,12 +113,13 @@ LiteralStart "%{"{nl}
LiteralEnd "%}"{nl}
RulesStart "%%"{nl}
RulesEnd "%%"{nl}
-RulesSharp "<"[^>]*">"
+RulesSharp "<"[^>\n]*">"
RulesCurly "{"[^{}\n]*"}"
StartSquare "["
StartDouble "\""
StartRound "("
-EscapeRulesCharOpen "\\["|"\\<"|"\\{"|"\\("|"\\\""|"\\{"|"\\ "
+StartRoundQuest "(?"
+EscapeRulesCharOpen "\\["|"\\<"|"\\{"|"\\("|"\\\""|"\\ "|"\\\\"
EscapeRulesCharClose "\\]"|"\\>"|"\\}"|"\\)"
EscapeRulesChar {EscapeRulesCharOpen}|{EscapeRulesCharClose}
@@ -134,14 +134,15 @@ CODE [cC][oO][dD][eE]
RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
RAWEND ")"[^ \t\(\)\\]{0,16}\"
CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
+CHARCE "[:"[^:]*":]"
/* no comment start / end signs inside square brackets */
NCOMM [^/\*]
- // C start comment
+ // C start comment
CCS "/\*"
// C end comment
CCE "*\/"
- // Cpp comment
+ // Cpp comment
CPPC "/\/"
// doxygen start comment
DCOMM ("/\*!"|"/\**"|"/\/!"|"/\/\/")
@@ -160,6 +161,7 @@ NONLopt [^\n]*
%x RulesSquare
%x RulesRoundSquare
%x RulesRound
+%x RulesRoundQuest
%x UserSection
%x TopSection
@@ -326,28 +328,24 @@ NONLopt [^\n]*
yyextra->rulesPatternBuffer += yytext;
}
<RulesPattern>{StartSquare} {
- yyextra->squareCount++;
yyextra->rulesPatternBuffer += yytext;
yyextra->lastContext = YY_START;
BEGIN(RulesSquare);
}
-<RulesSquare,RulesRoundSquare>"\\[" |
-<RulesSquare,RulesRoundSquare>"\\]" {
+<RulesSquare,RulesRoundSquare>{CHARCE} {
yyextra->rulesPatternBuffer += yytext;
}
-<RulesSquare,RulesRoundSquare>"[" {
- yyextra->squareCount++;
+<RulesSquare,RulesRoundSquare>"\\[" |
+<RulesSquare,RulesRoundSquare>"\\]" {
yyextra->rulesPatternBuffer += yytext;
}
<RulesSquare>"]" {
- yyextra->squareCount--;
yyextra->rulesPatternBuffer += yytext;
- if (!yyextra->squareCount) BEGIN(RulesPattern) ;
+ BEGIN(RulesPattern) ;
}
<RulesRoundSquare>"]" {
- yyextra->squareCount--;
yyextra->rulesPatternBuffer += yytext;
- if (!yyextra->squareCount) BEGIN(RulesRound) ;
+ BEGIN(RulesRound) ;
}
<RulesSquare,RulesRoundSquare>"\\\\" {
yyextra->rulesPatternBuffer += yytext;
@@ -355,6 +353,28 @@ NONLopt [^\n]*
<RulesSquare,RulesRoundSquare>. {
yyextra->rulesPatternBuffer += yytext;
}
+<RulesPattern>{StartRoundQuest} {
+ yyextra->rulesPatternBuffer += yytext;
+ yyextra->lastContext = YY_START;
+ BEGIN(RulesRoundQuest);
+ }
+<RulesRoundQuest>{nl} {
+ yyextra->rulesPatternBuffer += yytext;
+ if (!yyextra->rulesPatternBuffer.isEmpty())
+ {
+ startFontClass(yyscanner,"stringliteral");
+ codifyLines(yyscanner,yyextra->rulesPatternBuffer.data());
+ yyextra->rulesPatternBuffer.resize(0);
+ endFontClass(yyscanner);
+ }
+ }
+<RulesRoundQuest>[^)] {
+ yyextra->rulesPatternBuffer += yytext;
+ }
+<RulesRoundQuest>")" {
+ yyextra->rulesPatternBuffer += yytext;
+ BEGIN(yyextra->lastContext);
+ }
<RulesPattern>{StartRound} {
yyextra->roundCount++;
yyextra->rulesPatternBuffer += yytext;
@@ -365,7 +385,6 @@ NONLopt [^\n]*
yyextra->rulesPatternBuffer += yytext;
}
<RulesRound>{StartSquare} {
- yyextra->squareCount++;
yyextra->rulesPatternBuffer += yytext;
BEGIN(RulesRoundSquare);
}
@@ -373,8 +392,7 @@ NONLopt [^\n]*
yyextra->rulesPatternBuffer += yytext;
BEGIN(RulesRoundDouble);
}
-<RulesRound>"\\(" |
-<RulesRound>"\\)" {
+<RulesRound>{EscapeRulesChar} {
yyextra->rulesPatternBuffer += yytext;
}
<RulesRound>"(" {
@@ -386,6 +404,13 @@ NONLopt [^\n]*
yyextra->rulesPatternBuffer += yytext;
if (!yyextra->roundCount) BEGIN( yyextra->lastContext ) ;
}
+<RulesRound>{nl} {
+ yyextra->rulesPatternBuffer += yytext;
+ yyextra->yyLineNr++;
+ }
+<RulesRound>{ws} {
+ yyextra->rulesPatternBuffer += yytext;
+ }
<RulesRound>. {
yyextra->rulesPatternBuffer += yytext;
}
@@ -393,7 +418,7 @@ NONLopt [^\n]*
if (!yyextra->rulesPatternBuffer.isEmpty())
{
startFontClass(yyscanner,"stringliteral");
- codifyLines(yyscanner,yyextra->rulesPatternBuffer.data());
+ codifyLines(yyscanner,yyextra->rulesPatternBuffer);
yyextra->rulesPatternBuffer.resize(0);
endFontClass(yyscanner);
}
@@ -413,7 +438,7 @@ NONLopt [^\n]*
if (!yyextra->rulesPatternBuffer.isEmpty())
{
startFontClass(yyscanner,"stringliteral");
- codifyLines(yyscanner,yyextra->rulesPatternBuffer.data());
+ codifyLines(yyscanner,yyextra->rulesPatternBuffer);
yyextra->rulesPatternBuffer.resize(0);
endFontClass(yyscanner);
}
@@ -428,7 +453,7 @@ NONLopt [^\n]*
if (!yyextra->rulesPatternBuffer.isEmpty())
{
startFontClass(yyscanner,"stringliteral");
- codifyLines(yyscanner,yyextra->rulesPatternBuffer.data());
+ codifyLines(yyscanner,yyextra->rulesPatternBuffer);
yyextra->rulesPatternBuffer.resize(0);
endFontClass(yyscanner);
}
@@ -500,7 +525,7 @@ NONLopt [^\n]*
}
<SkipCurly>{B}*{RAWBEGIN} {
QCString raw=QCString(yytext).stripWhiteSpace();
- yyextra->delimiter = raw.data()+2;
+ yyextra->delimiter = raw.mid(2);
yyextra->delimiter=yyextra->delimiter.left(yyextra->delimiter.length()-1);
yyextra->lastRawStringContext = YY_START;
yyextra->CCodeBuffer += yytext;
@@ -890,9 +915,10 @@ NONLopt [^\n]*
yyextra->CCodeBuffer += yytext;
yyextra->yyLineNr++;
}
- /*
+ /*
<*>. { fprintf(stderr,"Lex code scanner Def rule for %s: #%s#\n",stateToString(YY_START),yytext);}
- */
+<*>{nl} { fprintf(stderr,"Lex code scanner Def rule for newline %s: #%s#\n",stateToString(YY_START),yytext); yyextra->yyLineNr++;}
+ */
<*><<EOF>> {
handleCCode(yyscanner);
yyterminate();
@@ -930,7 +956,7 @@ static void startCodeLine(yyscan_t yyscanner)
{
yyextra->currentDefinition = d;
yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
- yyextra->classScope = d->name().copy();
+ yyextra->classScope = d->name();
QCString lineAnchor;
lineAnchor.sprintf("l%05d",yyextra->yyLineNr);
if (yyextra->currentMemberDef)
@@ -944,13 +970,13 @@ static void startCodeLine(yyscan_t yyscanner)
{
yyextra->code->writeLineNumber(d->getReference(),
d->getOutputFileBase(),
- 0,yyextra->yyLineNr);
+ QCString(),yyextra->yyLineNr);
setCurrentDoc(yyscanner,lineAnchor);
}
}
else
{
- yyextra->code->writeLineNumber(0,0,0,yyextra->yyLineNr);
+ yyextra->code->writeLineNumber(QCString(),QCString(),QCString(),yyextra->yyLineNr);
}
}
@@ -991,10 +1017,11 @@ static void nextCodeLine(yyscan_t yyscanner)
}
}
-static void codifyLines(yyscan_t yyscanner,const char *text)
+static void codifyLines(yyscan_t yyscanner,const QCString &text)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
- const char *p=text,*sp=p;
+ if (text.isEmpty()) return;
+ const char *p=text.data(),*sp=p;
char c;
bool done=false;
while (!done)
@@ -1148,11 +1175,11 @@ void LexCodeParser::resetCodeParserState()
}
void LexCodeParser::parseCode(CodeOutputInterface &codeOutIntf,
- const char *scopeName,
+ const QCString &scopeName,
const QCString &input,
SrcLangExt,
bool isExampleBlock,
- const char *exampleName,
+ const QCString &exampleName,
FileDef *fileDef,
int startLine,
int endLine,
@@ -1168,10 +1195,10 @@ void LexCodeParser::parseCode(CodeOutputInterface &codeOutIntf,
if (input.isEmpty()) return;
- printlex(yy_flex_debug, true, __FILE__, fileDef ? fileDef->fileName().data(): NULL);
+ printlex(yy_flex_debug, true, __FILE__, fileDef ? qPrint(fileDef->fileName()): NULL);
yyextra->code = &codeOutIntf;
- yyextra->inputString = input;
+ yyextra->inputString = input.data();
yyextra->inputPosition = 0;
yyextra->currentFontClass = 0;
yyextra->needsTermination = false;
@@ -1202,7 +1229,7 @@ void LexCodeParser::parseCode(CodeOutputInterface &codeOutIntf,
if (isExampleBlock && fileDef==0)
{
// create a dummy filedef for the example
- yyextra->sourceFileDef = createFileDef("",(exampleName?exampleName:"generated"));
+ yyextra->sourceFileDef = createFileDef(QCString(),!exampleName.isEmpty() ? exampleName : QCString("generated"));
cleanupSourceDef = true;
}
@@ -1230,7 +1257,7 @@ void LexCodeParser::parseCode(CodeOutputInterface &codeOutIntf,
yyextra->sourceFileDef=0;
}
- printlex(yy_flex_debug, false, __FILE__, fileDef ? fileDef->fileName().data(): NULL);
+ printlex(yy_flex_debug, false, __FILE__, fileDef ? qPrint(fileDef->fileName()): NULL);
}
//---------------------------------------------------------------------------------