⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pre.l

📁 doxygen(一个自动从源代码生成文档的工具)的源代码
💻 L
📖 第 1 页 / 共 4 页
字号:
%x	Guard%x	DefinedExpr1%x	DefinedExpr2%x	SkipDoubleQuote%x	SkipSingleQuote%x	UndefName%x	IgnoreLine%x	FindDefineArgs%x	ReadString%%<*>\x06					<*>\x00<*>\r<Start>^{B}*"#"				{ BEGIN(Command); }<Start>^{B}*/[^#]			{ 					  outputArray(yytext,yyleng);   					  BEGIN(CopyLine); 					}<Start>^{B}*[_A-Z][_A-Z0-9]*"("[^\)\n]*")"/{BN}{1,10}*[:{] { // constructors?					  int i;					  for (i=yyleng-1;i>=0;i--)					  {					    unput(yytext[i]);					  }					  BEGIN(CopyLine);                                        }<Start>^{B}*[_A-Z][_A-Z0-9]*"("[^\)\n]*")"{B}*\n { // function like macro  					  static bool skipFuncMacros = Config_getBool("SKIP_FUNCTION_MACROS");					  QCString name(yytext);					  name=name.left(name.find('(')).stripWhiteSpace();					  Define *def=0;					  if (skipFuncMacros && 					      !(					         (g_includeStack.isEmpty() || g_curlyCount>0) &&					         g_macroExpansion &&					         (def=g_fileDefineDict->find(name)) &&					         (!g_expandOnlyPredef || def->isPredefined)					       )					     )					  {					    outputChar('\n');					    g_yyLineNr++;					  }					  else // don't skip					  {					    int i;					    for (i=yyleng-1;i>=0;i--)					    {					      unput(yytext[i]);					    }					    BEGIN(CopyLine);					  }  					}<CopyLine>"{"				{ // count brackets inside the main file  					  if (g_includeStack.isEmpty()) 					    g_curlyCount++;					  outputChar(*yytext);  					}<CopyLine>"}"				{ // count brackets inside the main file  					  if (g_includeStack.isEmpty()) 					    g_curlyCount--;					  outputChar(*yytext);					  // This should hold otherwise the preprocessor is confused					  //ASSERT(g_curlyCount>=0);   					}<CopyLine>"'"\\[0-7]{1,3}"'"		{   					  outputArray(yytext,yyleng);					}<CopyLine>"'"\\."'"			{   					  outputArray(yytext,yyleng);					}<CopyLine>"'"."'"			{   					  outputArray(yytext,yyleng);					}<CopyLine>\"				{					  outputChar(*yytext);					  BEGIN( CopyString );					}<CopyString>[^\"\\\r\n]+		{  					  outputArray(yytext,yyleng);					}<CopyString>\\.				{					  outputArray(yytext,yyleng);					}<CopyString>\"				{					  outputChar(*yytext);					  BEGIN( CopyLine );					}<CopyLine>{ID}/{BN}*"("			{  					  Define *def=0;					  //printf("Search for define %s\n",yytext);					  if ((g_includeStack.isEmpty() || g_curlyCount>0) &&					      g_macroExpansion &&					      /* (expandDefine=fileDefineCache->findDefine(g_yyFileName,yytext)) */					      (def=g_fileDefineDict->find(yytext)) &&					      (!g_expandOnlyPredef || def->isPredefined)					     )					  {					    //printf("Found it!\n");					    g_roundCount=0;					    g_defArgsStr=yytext;					    if (def->nargs==-1) // no function macro					    {					      QCString result = expandMacro(g_defArgsStr);					      //printf("result=`%s'\n",result.data());					      outputArray(result,result.length());					    }					    else // zero or more arguments					    {					      g_findDefArgContext = CopyLine;					      BEGIN(FindDefineArgs);					    }					  }					  else					  {					    outputArray(yytext,yyleng);					  }  					}<CopyLine>{ID}				{                                          Define *def=0;					  //printf("Search for define %s\n",yytext);  					  if ((g_includeStack.isEmpty() || g_curlyCount>0) && 					      g_macroExpansion &&					      (def=g_fileDefineDict->find(yytext)) &&					      def->nargs==-1 &&					      (!g_expandOnlyPredef || def->isPredefined)					     )					  {					    //printf("Found it!\n");                                            QCString name=yytext;					    QCString result=expandMacro(name); 					    //printf("result=`%s'\n",result.data());					    outputArray(result,result.length());					  }					  else					  {					    outputArray(yytext,yyleng);					  }  					}<CopyLine>.				{  					  outputChar(*yytext);  					}<CopyLine>\n				{  					  outputChar('\n');					  BEGIN(Start);					  g_yyLineNr++;  					}<FindDefineArgs>"("			{  					  g_defArgsStr+='(';  					  g_roundCount++;  					}<FindDefineArgs>")"			{  					  g_defArgsStr+=')';					  g_roundCount--;					  if (g_roundCount==0)					  {					    QCString result=expandMacro(g_defArgsStr);					    //printf("g_defArgsStr=`%s'->`%s'\n",g_defArgsStr.data(),result.data());					    if (g_findDefArgContext==CopyLine)					    {					      outputArray(result,result.length());					      BEGIN(g_findDefArgContext);					    }					    else // g_findDefArgContext==IncludeID					    {					      readIncludeFile(result);					      g_nospaces=FALSE;					      BEGIN(Start);					    }					  }  					}  /*<FindDefineArgs>")"{B}*"("		{  					  g_defArgsStr+=yytext;  					}  */<FindDefineArgs>\"			{  					  g_defArgsStr+=*yytext;  					  BEGIN(ReadString);  					}<FindDefineArgs>\n			{  					  g_yyLineNr++;					  outputChar('\n');  					}<FindDefineArgs>"@"			{  					  g_defArgsStr+="@@";  					}<FindDefineArgs>.			{  					  g_defArgsStr+=*yytext;  					}<ReadString>"\""			{  					  g_defArgsStr+=*yytext;					  BEGIN(FindDefineArgs);  					}<ReadString>"//"|"/*"			{  					  g_defArgsStr+=yytext;  					}<ReadString>\\.				{  					  g_defArgsStr+=yytext;  					}<ReadString>.				{  					  g_defArgsStr+=*yytext;  					}<Command>"include"{B}+/{ID}		{  					  if (g_macroExpansion) 					    BEGIN(IncludeID);  					}<Command>"include"{B}*[<"]		{ 					  char c[2];					  c[0]=yytext[yyleng-1];c[1]='\0';					  g_incName=c;  					  BEGIN(Include); 					}<Command>"define"{B}+			{   			                  //printf("!!!DefName\n");   					  BEGIN(DefName); 					}<Command>"ifdef"/{B}*"("		{  					  incrLevel();					  g_guardExpr.resize(0);  					  BEGIN(DefinedExpr2);  					}<Command>"ifdef"/{B}+			{  					  //printf("Pre.l: ifdef\n");  					  incrLevel();					  g_guardExpr.resize(0);  					  BEGIN(DefinedExpr1);  					}<Command>"ifndef"/{B}*"("		{  					  incrLevel();					  g_guardExpr="! ";  					  BEGIN(DefinedExpr2);					}<Command>"ifndef"/{B}+			{  					  incrLevel();					  g_guardExpr="! ";  					  BEGIN(DefinedExpr1);  					}<Command>"if"/[ \t(]			{  					  incrLevel();					  g_guardExpr.resize(0);					  BEGIN(Guard);					}<Command>("elif"|"else"{B}*"if")/[ \t(]	{  					  if (!otherCaseDone())					  {					    g_guardExpr.resize(0);					    BEGIN(Guard);  					  }					  else					  {					    g_ifcount=0;					    BEGIN(SkipCPPBlock);					  }  					}<Command>"else"/[^a-z_A-Z0-9]		{					  //printf("else g_levelGuard[%d]=%d\n",g_level-1,g_levelGuard[g_level-1]);  					  if (otherCaseDone())					  {					    g_ifcount=0;					    BEGIN(SkipCPPBlock);					  }					  else					  {					    setCaseDone(TRUE);					    //g_levelGuard[g_level-1]=TRUE;					  }   					}<Command>"undef"{B}+			{  					  BEGIN(UndefName);  					}<Command>("elif"|"else"{B}*"if")/[ \t(]	{  					  if (!otherCaseDone())					  {					    g_guardExpr.resize(0);  					    BEGIN(Guard);					  }  					}<Command>"endif"/[^a-z_A-Z0-9]		{  					  //printf("Pre.l: #endif\n");  					  decrLevel();  					}<Command,IgnoreLine>\n			{  					  outputChar('\n');  					  BEGIN(Start);					  g_yyLineNr++;  					}<Command>{ID}				{ // unknown directive					  BEGIN(IgnoreLine);					}<IgnoreLine>\\[\r]?\n			{  					  outputChar('\n');					  g_yyLineNr++;					}<IgnoreLine>.<Command>.<UndefName>{ID}				{  					  Define *def;  					  if ((def=isDefined(yytext)) && !def->isPredefined)					  {					    //printf("undefining %s\n",yytext);					    def->undef=TRUE;					  }					  BEGIN(Start);  					}<Guard>\\[\r]?\n			{  					  outputChar('\n');  					  g_guardExpr+=' ';					  g_yyLineNr++;  					}<Guard>"defined"/{B}*"("		{    					  BEGIN(DefinedExpr2);    					}<Guard>"defined"/{B}+			{    					  BEGIN(DefinedExpr1);    					}<Guard>.				{ g_guardExpr+=*yytext; }<Guard>\n				{  					  outputChar('\n');					  g_yyLineNr++;  					  //printf("Guard: `%s'\n",					  //    g_guardExpr.data());					  bool guard=computeExpression(g_guardExpr);					  setCaseDone(guard);					  //printf("if g_levelGuard[%d]=%d\n",g_level-1,g_levelGuard[g_level-1]);					  if (guard)					  {					    BEGIN(Start);					  } 					  else					  {					    g_ifcount=0;					    BEGIN(SkipCPPBlock);					  }  					}<DefinedExpr1,DefinedExpr2>\\\n		{ g_yyLineNr++; outputChar('\n'); }<DefinedExpr1>{ID}			{  					  if (isDefined(yytext))					    g_guardExpr+=" 1L ";					  else					    g_guardExpr+=" 0L ";					  g_lastGuardName=yytext;					  BEGIN(Guard);  					}<DefinedExpr2>{ID}			{  					  if (isDefined(yytext))					    g_guardExpr+=" 1L ";					  else					    g_guardExpr+=" 0L ";					  g_lastGuardName.resize(0);  					}<DefinedExpr1,DefinedExpr2>\n		{ // should not happen, handle anyway  					  g_ifcount=0; 					  BEGIN(SkipCPPBlock); 					}<DefinedExpr2>")"			{  					  BEGIN(Guard);  					}<DefinedExpr1,DefinedExpr2>.<SkipCPPBlock>^{B}*"#"			{ BEGIN(SkipCommand); }<SkipCPPBlock>^{B}*/[^#]		{ BEGIN(SkipLine); }<SkipCPPBlock>.<SkipCommand>"if"(("n")?("def"))?/[ \t(]	{   					  incrLevel();                                          g_ifcount++;   					  //printf("#if... depth=%d\n",g_ifcount);					}<SkipCommand>"else"			{					  //printf("Else! g_ifcount=%d otherCaseDone=%d\n",g_ifcount,otherCaseDone());  					  if (g_ifcount==0 && !otherCaseDone())					  {					    setCaseDone(TRUE);  					    //outputChar('\n');					    BEGIN(Start);					  }  					}<SkipCommand>("elif"|"else"{B}*"if")/[ \t(]		{  					  if (g_ifcount==0) 					  {  					    if (!otherCaseDone())					    {					      g_guardExpr.resize(0);					      g_lastGuardName.resize(0);  					      BEGIN(Guard);					    }					    else					    {					      BEGIN(SkipCPPBlock);					    }					  }					}<SkipCommand>"endif"			{   					  decrLevel();  				          if (--g_ifcount<0)  					  {  					    //outputChar('\n');					    BEGIN(Start);					  }					}<SkipCommand>\n				{   					  outputChar('\n');  					  g_yyLineNr++; 					  BEGIN(SkipCPPBlock);					}<SkipCommand>{ID}			{ // unknown directive   					  BEGIN(SkipLine); 					}<SkipCommand>.<SkipLine>[^/\n]+			<SkipLine>.<SkipLine,SkipCommand,SkipCPPBlock>"//"	{  					  g_lastCPPContext=YY_START;  					  BEGIN(RemoveCPPComment);					}<SkipLine,SkipCommand,SkipCPPBlock>"/*"	{					  g_lastCContext=YY_START;  					  BEGIN(RemoveCComment);  					}<SkipLine>\n				{  					  outputChar('\n');					  g_yyLineNr++;  					  BEGIN(SkipCPPBlock);					}<IncludeID>{ID}{B}*/"("			{  					  g_nospaces=TRUE;				          g_roundCount=0;					  g_defArgsStr=yytext;					  g_findDefArgContext = IncludeID;					  BEGIN(FindDefineArgs);					}<IncludeID>{ID}				{  					  g_nospaces=TRUE;                                          readIncludeFile(expandMacro(yytext));					  BEGIN(Start);  					}<Include>[^\">\n]+[\">]			{ 					  g_incName+=yytext;					  readIncludeFile(g_incName);					  					  BEGIN(Start);  					}<DefName>{ID}/"("			{  					  //printf("Define() `%s'\n",yytext);					  g_argDict = new QDict<int>(31);					  g_argDict->setAutoDelete(TRUE);					  g_defArgs = 0;                                           g_defArgsStr.resize(0);					  g_defText.resize(0);					  g_defLitText.resize(0);					  g_defName = yytext;					  g_defVarArgs = FALSE;					  BEGIN(DefineArg);  					}<DefName>{ID}/{B}*			{  					  //printf("Define `%s'\n",yytext);  					  g_argDict = 0;					  g_defArgs = -1;                                          g_defArgsStr.resize(0);					  g_defText.resize(0);					  g_defLitText.resize(0);					  g_defName = yytext;					  g_defVarArgs = FALSE;					  QCString tmp=(QCString)"#define "+g_defName+g_defArgsStr;					  outputArray(tmp.data(),tmp.length());					  g_quoteArg=FALSE;					  BEGIN(DefineText);   					}<DefName>{ID}/{B}*"\n"			{  					  g_argDict = 0;					  g_defArgs = -1;					  g_defName = yytext;                                          g_defArgsStr.resize(0);					  g_defText.resize(0);					  g_defLitText.resize(0);					  g_defVarArgs = FALSE;					  if ( g_defName!=g_lastGuardName )					  { // define may appear in the output					    QCString tmp=(QCString)"#define "+g_defName+g_defArgsStr;					    outputArray(tmp.data(),tmp.length());					    g_quoteArg=FALSE;					    BEGIN(DefineText);					  }					  else // define is a guard => hide					  {					    //printf("Found a guard %s\n",yytext);  					    Define *def=0;					    //if (g_includeStack.isEmpty()) 					    //{					    //  addDefine();					    //}					    if ((def=g_fileDefineDict->find(g_defName))==0)					    {					      g_fileDefineDict->insert(g_defName,newDefine());					    }					    else if (def)// name already exists					    {					      if (def->undef) // undefined name					      {					        def->undef = FALSE;					        def->name = g_defName;					        def->definition = g_defText.stripWhiteSpace();					        def->nargs = g_defArgs;					        def->fileName = g_yyFileName.copy(); 					        def->lineNr = g_yyLineNr;					      }					      else					      {					        //printf("Error: define %s is defined more than once!\n",g_defName.data());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -