📄 doc.l
字号:
/***************************************************************************** * * $Id: doc.l,v 1.3 2001/03/19 19:27:40 root Exp $ * * Copyright (C) 1997-2001 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * * Documents produced by Doxygen are derivative works derived from the * input used in their production; they are not affected by this license. * */ %{/* * includes */#include <stdio.h>#include <stdlib.h>//#include <iostream.h>#include <assert.h>#include <ctype.h>#include "qtbc.h"#include <qarray.h>#include <qstack.h>#include <qregexp.h> #include "doc.h"#include "code.h"#include "message.h"#include "doxygen.h"#include "config.h"#include "util.h"#include "language.h"#include "outputlist.h"#include "reflist.h"#ifndef WIN32#include <unistd.h>#endif #define YY_NEVER_INTERACTIVE 1 /* ----------------------------------------------------------------- * * scanner's state variables */static OutputDocInterface * outDoc;static bool insideArgumentList;static QCString className;static QCString memberName;static QCString linkRef;static QCString linkText;static QCString codeBlock;static const char * inputString;static int inputPosition;static char yyFileName[4096] ;static int yyLineNr = 1 ;static bool exampleDoc;static QCString exampleName;static QCString htmlUrl,htmlText;static QCString currentIncludeFile;static int includeFileOffset = 0;static int includeFileLength = 0;static bool firstLine;static bool inParamBlock;static bool inRetValBlock;static bool inExceptionBlock;static bool inSeeBlock;static bool inReturnBlock;static bool inAuthorBlock;static bool inDeprecatedBlock;static bool inVersionBlock;static bool inSinceBlock;static bool inDateBlock;static bool inBugBlock;static bool inNoteBlock;static bool inPreBlock;static bool inPostBlock;static bool inInvarBlock;static bool inWarningBlock;static bool inRemarkBlock;static bool inAttentionBlock;static bool inParBlock;static bool insideHtmlLink;static QCString sectionRef;static bool insideVerbatim = FALSE;static bool insidePre = FALSE;static int depthIf;static QCString curImageName;static QCString curImageCaption;static QCString curDotFileName;static QCString curDotFileCaption;static QCString internalRefFile;static QCString internalRefAnchor;static QStack<char> currentListIndent; // indent stack of all list items static bool insideItemList = FALSE;//-----------------------------------------------------------------------------static void initParser(){ insideArgumentList=FALSE; className.resize(0); memberName.resize(0); linkRef.resize(0); linkText.resize(0); codeBlock.resize(0); htmlUrl.resize(0); htmlText.resize(0); currentIncludeFile.resize(0); includeFileOffset = 0; includeFileLength = 0; firstLine = TRUE; inParamBlock = FALSE; inRetValBlock = FALSE; inExceptionBlock = FALSE; inSeeBlock = FALSE; inReturnBlock = FALSE; inAuthorBlock = FALSE; inDeprecatedBlock = FALSE; inVersionBlock = FALSE; inSinceBlock = FALSE; inDateBlock = FALSE; inBugBlock = FALSE; inNoteBlock = FALSE; inPreBlock = FALSE; inPostBlock = FALSE; inInvarBlock = FALSE; inWarningBlock = FALSE; inRemarkBlock = FALSE; inAttentionBlock = FALSE; inParBlock = FALSE; insideHtmlLink = FALSE;}//-----------------------------------------------------------------------------void scanString(const char *s);void scanDoc(const char *s);void internalParseDocument(const char *s);//-----------------------------------------------------------------------------class TableElem{ public: TableElem(int r,int c); ~TableElem(); int getRow() { return row; } int getCol() { return col; } OutputDocInterface *outputDocInterface() { return od; } private: OutputDocInterface *od; int row; int col;};TableElem::TableElem(int r,int c){ //printf("TableElem::TableElem(%d,%d)\n",r,c); od=outDoc->clone(); outDoc=od; row=r; col=c;}TableElem::~TableElem(){ //printf("TableElem::~TableElem(%d,%d)\n",row,col); delete od; od=0;}class Table{ public: Table(); ~Table(); void newRow(); void newElem(); private: OutputDocInterface *parentDoc; QList<TableElem> *elemList; int curRow; int curCol; int rows; int cols;}; Table::Table() { parentDoc=outDoc; elemList=new QList<TableElem>; elemList->setAutoDelete(TRUE); curRow=curCol=rows=cols=0;}Table::~Table(){ //printf("Table::~Table()\n"); // use elemList & cols & rows if (cols>0 && rows>0) { parentDoc->startTable(cols); TableElem *e=elemList->first(); while (e) { if (e->getRow()>0) { if (e->getCol()==0) { if (e->getRow()>1) parentDoc->endTableRow(); parentDoc->nextTableRow(); } else { parentDoc->nextTableColumn(); } parentDoc->append(e->outputDocInterface()); parentDoc->endTableColumn(); } e=elemList->next(); } parentDoc->endTable(); } delete elemList; elemList=0; outDoc=parentDoc;}void Table::newRow(){ //printf("Table::newRow()\n"); curRow++; if (curRow>rows) rows=curRow; curCol=0;}void Table::newElem(){ //printf("Table::newElem(%d,%d)\n",curRow,curCol); TableElem *te = new TableElem(curRow,curCol); elemList->append(te); curCol++; if (curCol>cols) cols=curCol;}static QStack<Table> tableStack;static Table *curTable;static void startTable(){ //printf("startTable()\n"); curTable=new Table; tableStack.push(curTable);}static void endTable(){ //printf("endTable()\n"); delete tableStack.pop(); // the destructor adds the table to the stream! curTable=tableStack.top();}static void forceEndTable(){ err("Error: More <table> tags found than </table> " "tags in documentation block in file %s!\n",yyFileName); while (!tableStack.isEmpty()) { endTable(); }}//-----------------------------------------------------------------------------static void includeFile(OutputDocInterface &od,const char *fileName,bool quiet){ bool ambig; FileDef *fd; if ((fd=findFileDef(Doxygen::exampleNameDict,fileName,ambig))) { currentIncludeFile=fileToString(fd->absFilePath()); includeFileOffset=0; includeFileLength=currentIncludeFile.length(); OutputDocInterface *codeFrag = od.clone(); parseCode(*codeFrag,0,currentIncludeFile,exampleDoc,exampleName); if (!quiet) { od.startCodeFragment(); od.append(codeFrag); od.endCodeFragment(); } delete codeFrag; } else if (ambig) { QCString text; text.sprintf("Include file name %s is ambigious.\n",fileName); text+="Possible candidates:\n"; text+=showFileDefMatches(Doxygen::exampleNameDict,fileName); warn(yyFileName,yyLineNr,text); } else { warn(yyFileName,yyLineNr, "Warning: example file %s is not found. " "Check your EXAMPLE_PATH",fileName ); }}static void verbIncludeFile(OutputDocInterface &od,const char *name){ bool ambig; FileDef *fd; if ((fd=findFileDef(Doxygen::exampleNameDict,name,ambig))) { od.startCodeFragment(); od.codify(fileToString(fd->absFilePath())+"\n"); od.endCodeFragment(); } else if (ambig) { QCString text; text.sprintf("Include file name %s is ambigious.\n",name); text+=("Possible candidates:\n"); text+=showFileDefMatches(Doxygen::exampleNameDict,name); warn(yyFileName,yyLineNr,text); } else { warn(yyFileName,yyLineNr, "Warning: example file %s is not found. " "Check your EXAMPLE_PATH",name); }}static void rawIncludeFile(OutputDocInterface &od,const char *name){ bool ambig; FileDef *fd; if ((fd=findFileDef(Doxygen::exampleNameDict,name,ambig))) { od.writeString(fileToString(fd->absFilePath())); } else if (ambig) { QCString text; text.sprintf("Include file name %s is ambigious.\n",name); text+=("Possible candidates:\n"); text+=showFileDefMatches(Doxygen::exampleNameDict,name); warn(yyFileName,yyLineNr,text); } else { warn(yyFileName,yyLineNr, "Warning: include file %s is not found. " "Check your EXAMPLE_PATH",name); }}static QCString stripQuotes(const char *s){ QCString name; if (s==0 || *s==0) return name; name=s; if (name.at(0)=='"' && name.at(name.length()-1)=='"') { name=name.mid(1,name.length()-2); } return name;}static QCString stripKnownExtensions(const char *text){ QCString result=text; if (result.right(4)==".tex") result=result.left(result.length()-4); else if (result.right(5)==".html") result=result.left(result.length()-5); //printf("%s stripKnowExtensions(%s)\n",result.data(),text); return result;}static void skipLine(OutputDocInterface &od,const char *key){ bool found=FALSE; while (!found) { QCString s; char c; while ( includeFileOffset<includeFileLength && (c=currentIncludeFile[includeFileOffset++])!='\n' && c!=0 ) s+=c; if (s.find(key)!=-1) { found=TRUE; od.writeString(" "); parseCode(od,className,s,exampleDoc,exampleName); //od.writeString("\n"); } else if (includeFileOffset==includeFileLength) found=TRUE; }}static void skipUntil(const char *key){ bool found=FALSE; while (!found) { QCString s; int i=includeFileOffset; char c; while ( i<includeFileLength && (c=currentIncludeFile[i++])!='\n' && c!=0 ) s+=c; if (s.find(key)!=-1 || i==includeFileLength) { found=TRUE; } else { includeFileOffset=i; } }}static void showLine(OutputDocInterface &od,const char *key){ QCString s; char c; bool found=FALSE; while (!found) { while ( includeFileOffset<includeFileLength && (c=currentIncludeFile[includeFileOffset++])!='\n' && c!=0 ) s+=c; if (!s.stripWhiteSpace().isEmpty() ||
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -