📄 scanner.l
字号:
/***************************************************************************** * * $Id: scanner.l,v 1.80 2001/03/19 19:27:41 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 <assert.h>#include <ctype.h>#include "qtbc.h"#include <qarray.h>#include <qstack.h>#include <qregexp.h>#include <unistd.h> #include "scanner.h"#include "entry.h"#include "doxygen.h"#include "message.h"#include "config.h"#include "util.h"#include "index.h"#include "defargs.h"#include "language.h"#include "outputlist.h"#include "membergroup.h"#include "reflist.h"#include "code.h" #define YY_NEVER_INTERACTIVE 1 /* ----------------------------------------------------------------- * * statics */static const char * inputString;static int inputPosition;static int lastContext;static int lastCContext;static int lastDocContext;static int lastDocRelContext;static int lastCPPContext;static int lastSkipSharpContext;static int lastSkipRoundContext;static int lastBriefContext;static int lastVerbState;static int lastStringContext;static int lastCurlyContext;static int lastRoundContext;static int lastSquareContext;static int lastCodeState;static int lastAfterDocContext;static int lastGroupContext;static int lastFormulaContext;static int lastAnchorContext;static int lastInitializerContext;static int lastClassTemplSpecContext;static int lastSkipHtmlCommentContext;static int lastIfContext;static int nextDefContext;static int overloadContext;static Protection protection;static Protection baseProt;static int sharpCount = 0 ;static int roundCount = 0 ;static int curlyCount = 0 ;static int squareCount = 0 ;static int padCount = 0 ;static int todoStartContext = 0;static QCString todoString;static int testStartContext = 0;static QCString testString;static int bugStartContext = 0;static QCString bugString;static Entry* current_root = 0 ;static Entry* global_root = 0 ;static Entry* current = 0 ;static Entry* previous = 0 ;static Entry* tempEntry = 0 ;static int yyLineNr = 1 ;static int anonCount = 0 ; static char yyFileName[4096] ;static int lastMemberGroupLine;static MethodTypes mtype;static bool gstat;static bool removeSlashes;static Specifier virt;static Specifier baseVirt;static QCString msType,msName,msArgs;static int memberGroupId = NOGROUP;static QCString memberGroupHeader;static QCString memberGroupDocs;static bool isTypedef;static char afterDocTerminator;static int tmpDocType;static QCString sectionLabel;static QCString sectionTitle;static SectionInfo::SectionType sectionType;static QCString funcPtrType;static QCString templateStr;static QCString aliasName;static QCString baseName;static QCString* specName;static QCString formulaText;static bool insideIDL = FALSE;static bool insideJava = FALSE;static bool insideCppQuote = FALSE;static int argRoundCount;static int argSharpCount;static int currentArgumentContext;static int lastCopyArgStringContext;static int lastCopyArgContext;static QCString *copyArgString;static QCString fullArgString;static ArgumentList *currentArgumentList;static QCString *currentTemplateSpec;static char lastCopyArgChar;static QCString *pCopyRoundString;static QCString *pCopyCurlyString;static QCString *pCopyQuotedString;static QCString *pSkipDoc;static QStack<Grouping> autoGroupStack;static Grouping lastDefGroup( "", Grouping::GROUPING_LOWEST );static bool insideFormula;static bool insideTryBlock=FALSE;static bool needsSemi;static int depthIf;static int initializerSharpCount;static QCString memberGroupRelates;static QCString memberGroupInside;//-----------------------------------------------------------------------------static void initParser(){ sectionLabel.resize(0); sectionTitle.resize(0); baseName.resize(0); formulaText.resize(0); protection = Public; baseProt = Public; sharpCount = 0; roundCount = 0; curlyCount = 0; memberGroupId = NOGROUP; memberGroupRelates.resize(0); memberGroupInside.resize(0); mtype = Method; gstat = FALSE; virt = Normal; baseVirt = Normal; isTypedef = FALSE; autoGroupStack.clear(); insideTryBlock = FALSE; insideIDL = FALSE; autoGroupStack.setAutoDelete(TRUE); lastDefGroup.groupname.resize(0);}static void initEntry(){ current->protection = protection ; current->mtype = mtype; current->virt = virt; current->stat = gstat; current->mGrpId = memberGroupId; current->relates = memberGroupRelates.copy(); current->inside = memberGroupInside.copy(); if (!autoGroupStack.isEmpty()) { current->groups->append(new Grouping(*autoGroupStack.top())); }}//-----------------------------------------------------------------------------/// remove any automatic grouping and add new one (if given)static void setCurrentGroup( QCString *newgroup, Grouping::GroupPri_t pri ){ /* remove auto group name from current entry and discard it */ Grouping *g = current->groups->first(); int i=0; while (g) { if (g->pri <= Grouping::GROUPING_AUTO_DEF) { current->groups->remove(i); i--; } g=current->groups->next(); i++; } /* use new group name instead? */ if ( newgroup ) { current->groups->append(new Grouping(*newgroup, pri)); } }static int newMemberGroupId(){ static int curGroupId=0; return curGroupId++;}static void startGroup();static void endGroup();//-----------------------------------------------------------------------------static void lineCount(){ for( const char* c = yytext ; *c ; ++c ) yyLineNr += (*c == '\n') ;}static void addType( Entry* current ){ uint tl=current->type.length(); if( tl>0 && !current->name.isEmpty() && current->type.at(tl-1)!='.') { current->type += ' ' ; } current->type += current->name ; current->name.resize(0) ; tl=current->type.length(); if( tl>0 && !current->args.isEmpty() && current->type.at(tl-1)!='.') { current->type += ' ' ; } current->type += current->args ; current->args.resize(0) ; current->argList->clear();}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 void newDocState();//-----------------------------------------------------------------static void addSection(){ //printf("New section pageName=%s label=%s title=%s\n", // current->name.data(),sectionLabel.data(),sectionTitle.data()); if (sectionLabel.isEmpty()) return; if (Doxygen::sectionDict.find(sectionLabel)==0) { SectionInfo *si=new SectionInfo(sectionLabel,sectionTitle,sectionType); si->fileName = current->name; //printf("Adding section addr=%p label=`%s' sectionTitle=`%s' fileName=%s\n",si,sectionLabel.data(),sectionTitle.data(),si->fileName.data()); Doxygen::sectionDict.insert(sectionLabel,si); current->anchors->append(new QCString(sectionLabel)); } else { warn(yyFileName,yyLineNr, "Warning: Duplicate label %s found!",sectionLabel.data()); } sectionTitle.resize(0);}// Adds a formula text to the list/dictionary of formulas if it was// not already added. Returns the label of the formula.static QCString addFormula(){ QCString formLabel; QCString fText=formulaText.simplifyWhiteSpace(); Formula *f=0; if ((f=Doxygen::formulaDict[fText])==0) { f = new Formula(fText); Doxygen::formulaList.append(f); Doxygen::formulaDict.insert(fText,f); formLabel.sprintf("\\form#%d",f->getId()); Doxygen::formulaNameDict.insert(formLabel,f); } else { formLabel.sprintf("\\form#%d",f->getId()); } return formLabel;}static bool nameIsOperator(QCString &name){ return name.right(8)=="operator" && (name.length()==8 || !isId(name.at(name.length()-9)));}static void checkFormula(){ if (insideFormula) { warn(yyFileName,yyLineNr,"Warning: End of comment block while inside formula."); }}static void checkDocs(){ checkFormula(); if ((current->brief.length()>2 && current->brief.at(0)=='<' && current->brief.at(1)==' ') || (current->doc.length()>2 && current->doc.at(0)=='<' && current->doc.at(1)==' ') ) { warn(yyFileName,yyLineNr,"Warning: Found lonely '<' symbol at the start of the documentation."); }}#if 0static QCString extractName(const QCString &s){ //static const QRegExp id("[a-z_A-Z][a-z_A-Z0-9]*"); //int i,p=0,l; //while ((i=id.match(s,p,&l))!=-1) //{ // QCString idstr=s.mid(i,l); // if (idstr!="struct" && idstr!="class" && idstr!="union") // { // // return idstr; // } // p=i+l; //} //return ""; QCString result=s; if (result.left(7)=="struct ") result=result.right(result.length()-7); if (result.left(6)=="class " ) result=result.right(result.length()-6); if (result.left(6)=="union " ) result=result.right(result.length()-6); int l=result.length()-1; while (l>=0 && (result.at(l)=='*' || result.at(l)==' ' || isspace(result.at(l))) ) l--; return removeRedundantWhiteSpace(result.left(l+1));}#endifstatic void setContext(){ QCString fileName = yyFileName; insideIDL = fileName.right(4)==".idl"; insideJava = fileName.right(5)==".java";}static void prependScope(){ if (current_root->section & Entry::SCOPE_MASK) { //printf("--- prependScope %s to %s\n",current_root->name.data(),current->name.data()); current->name.prepend(current_root->name+"::"); if (current_root->tArgLists) { if (current->tArgLists==0) { current->tArgLists = new QList<ArgumentList>; current->tArgLists->setAutoDelete(TRUE); } //printf("prependScope #=%d #current=%d\n",current_root->tArgLists->count(),current->tArgLists->count()); QListIterator<ArgumentList> talsi(*current_root->tArgLists); ArgumentList *srcAl=0; for (talsi.toLast();(srcAl=talsi.current());--talsi) { ArgumentList *dstAl = new ArgumentList; dstAl->setAutoDelete(TRUE); QListIterator<Argument> tali(*srcAl); Argument *a; for (;(a=tali.current());++tali) { dstAl->append(new Argument(*a)); //printf("appending argument %s %s\n",a->type.data(),a->name.data()); } current->tArgLists->insert(0,dstAl); } } }}/* ----------------------------------------------------------------- */#undef YY_INPUT#define YY_INPUT(buf,result,max_size) result=yyread(buf,max_size);static int yyread(char *buf,int max_size){ int c=0; while( c < max_size && inputString[inputPosition] ) { *buf = inputString[inputPosition++] ; //printf("%d (%c)\n",*buf,*buf); c++; buf++; } return c;}%}CMD ("\\"|"@")SECTIONCMD {CMD}("image"|"author"|"internal"|"version"|"date"|"deprecated"|"param"|"exception"|"return"[s]?|"retval"|"bug"|"warning"|"par"|"sa"|"see"|"pre"|"post"|"invariant"|"note"|"remark"[s]?|"todo"|"test"|"ingroup"|"latexonly"|"htmlonly"|"{"|"verbatim")BN [ \t\n\r]BL [ \t\r]*"\n"B [ \t]BS ^(({B}*"//")?)(({B}*"*"+)?){B}*FILESCHAR [a-z_A-Z0-9\\:\\\/\-\+]FILEECHAR [a-z_A-Z0-9\-\+]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -