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

📄 config.l

📁 doxygen(一个自动从源代码生成文档的工具)的源代码
💻 L
📖 第 1 页 / 共 5 页
字号:
  //printf("Searching for `%s'\n",incFileName.data());  if ((f=findFile(inc))) // see if the include file can be found  {    // For debugging#if SHOW_INCLUDES    for (i=0;i<includeStack.count();i++) msg("  ");    msg("@INCLUDE = %s: parsing...\n",inc.data());#endif    // store the state of the old file     ConfigFileState *fs=new ConfigFileState;    fs->oldState=YY_CURRENT_BUFFER;    fs->lineNr=yyLineNr;    fs->fileName=yyFileName;    fs->filePtr=f;    // push the state on the stack    includeStack.push(fs);    // set the scanner to the include file    yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));    fs->newState=YY_CURRENT_BUFFER;    yyFileName=inc;    includeDepth++;  }   else  {    config_err("Error: @INCLUDE = %s: not found!\n",inc.data());    exit(1);  }}%}%option noyywrap%x      Start%x	SkipComment%x      SkipInvalid%x      GetString%x      GetBool%x      GetStrList%x      GetQuotedString%x      GetEnvVar%x      Include%%<*>\0x0d<Start,GetString,GetStrList,GetBool,SkipInvalid>"#"	 { BEGIN(SkipComment); }<Start>[a-z_A-Z][a-z_A-Z0-9]*[ \t]*"="	 { QCString cmd=yytext;                                           cmd=cmd.left(cmd.length()-1).stripWhiteSpace(); 					   ConfigOption *option = config->get(cmd);					   if (option==0) // oops not known					   {					     config_err("Warning: ignoring unsupported tag `%s' at line %d, file %s\n",						 yytext,yyLineNr,yyFileName.data()); 					     BEGIN(SkipInvalid);					   }					   else // known tag					   {					     switch(option->kind())					     {					       case ConfigOption::O_Info:						 // shouldn't get here!					         BEGIN(SkipInvalid);						 break;					       case ConfigOption::O_List:						 l = ((ConfigList *)option)->valueRef();					         l->clear();						 elemStr="";					         BEGIN(GetStrList);					         break;					       case ConfigOption::O_Enum:						 s = ((ConfigEnum *)option)->valueRef();					         s->resize(0);					         BEGIN(GetString);					         break;					       case ConfigOption::O_String:						 s = ((ConfigString *)option)->valueRef();					         s->resize(0);					         BEGIN(GetString);					         break;					       case ConfigOption::O_Int:						 s = ((ConfigInt *)option)->valueStringRef();					         s->resize(0);					         BEGIN(GetString);					         break;					       case ConfigOption::O_Bool:						 s = ((ConfigBool *)option)->valueStringRef();					         s->resize(0);					         BEGIN(GetString);						 break;					     }					   }					}<Start>[a-z_A-Z][a-z_A-Z0-9]*[ \t]*"+="	{ QCString cmd=yytext;                                          cmd=cmd.left(cmd.length()-2).stripWhiteSpace(); 					  ConfigOption *option = config->get(cmd);					  if (option==0) // oops not known					  {					    config_err("Warning: ignoring unsupported tag `%s' at line %d, file %s\n",						yytext,yyLineNr,yyFileName.data()); 					    BEGIN(SkipInvalid);					  }					  else // known tag					  {					    switch(option->kind())					    {					      case ConfigOption::O_Info:					        // shouldn't get here!					        BEGIN(SkipInvalid);						break;					      case ConfigOption::O_List:					        l = ((ConfigList *)option)->valueRef();						elemStr="";					        BEGIN(GetStrList);					        break;					      case ConfigOption::O_Enum:					      case ConfigOption::O_String:					      case ConfigOption::O_Int:					      case ConfigOption::O_Bool:					        config_err("Warning: operator += not supported for `%s'. Ignoring line at line %d, file %s\n",						    yytext,yyLineNr,yyFileName.data()); 					        BEGIN(SkipInvalid);						break;					     }					   }					}<Start>"@INCLUDE_PATH"[ \t]*"=" 	{ BEGIN(GetStrList); l=&includePathList; l->clear(); elemStr=""; }  /* include a config file */<Start>"@INCLUDE"[ \t]*"="     		{ BEGIN(Include);}<Include>([^ \"\t\r\n]+)|("\""[^\n\"]+"\"") {   					  readIncludeFile(yytext);   					  BEGIN(Start);					}<<EOF>>					{                                          //printf("End of include file\n");					  //printf("Include stack depth=%d\n",g_includeStack.count());                                          if (includeStack.isEmpty())					  {					    //printf("Terminating scanner!\n");					    yyterminate();					  }					  else					  {					    ConfigFileState *fs=includeStack.pop();					    fclose(fs->filePtr);					    YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;					    yy_switch_to_buffer( fs->oldState );					    yy_delete_buffer( oldBuf );					    yyLineNr=fs->lineNr;					    yyFileName=fs->fileName;					    delete fs; fs=0;                                            includeDepth--;					  }  					}<Start>[a-z_A-Z0-9]+			{ config_err("Warning: ignoring unknown tag `%s' at line %d, file %s\n",yytext,yyLineNr,yyFileName.data()); }<GetString,GetBool,SkipInvalid>\n	{ yyLineNr++; BEGIN(Start); }<GetStrList>\n				{   					  yyLineNr++; 					  if (!elemStr.isEmpty())					  {					    //printf("elemStr1=`%s'\n",elemStr.data());					    l->append(elemStr);					  }					  BEGIN(Start); 					}<GetStrList>[ \t]+			{  				          if (!elemStr.isEmpty())					  {					    //printf("elemStr2=`%s'\n",elemStr.data());  					    l->append(elemStr);					  }					  elemStr.resize(0);  					}<GetString>[^ \"\t\r\n]+		{ (*s)+=yytext; }<GetString,GetStrList,SkipInvalid>"\""	{ lastState=YY_START;  					  BEGIN(GetQuotedString);                                           tmpString.resize(0); 					}<GetQuotedString>"\""|"\n" 		{   					  //printf("Quoted String = `%s'\n",tmpString.data());  					  if (lastState==GetString)					    (*s)+=tmpString;					  else					    elemStr+=tmpString;					  if (*yytext=='\n')					  {					    config_err("Warning: Missing end quote (\") on line %d, file %s\n",yyLineNr,yyFileName.data());					    yyLineNr++;					  }					  BEGIN(lastState);  					}<GetQuotedString>"\\\""			{  					  tmpString+='"';  					}<GetQuotedString>.			{ tmpString+=*yytext; }<GetBool>[a-zA-Z]+			{   					  QCString bs=yytext;   					  bs=bs.upper();  					  if (bs=="YES" || bs=="1")					    *b=TRUE;					  else if (bs=="NO" || bs=="0")					    *b=FALSE;					  else 					  {					    *b=FALSE; 					    config_warn("Warning: Invalid value `%s' for "						 "boolean tag in line %d, file %s; use YES or NO\n",						 bs.data(),yyLineNr,yyFileName.data());					  }					}<GetStrList>[^ \#\"\t\r\n]+		{  					  elemStr+=yytext;  					}<SkipComment>\n				{ yyLineNr++; BEGIN(Start); }<SkipComment>\\[ \r\t]*\n		{ yyLineNr++; BEGIN(Start); }<*>\\[ \r\t]*\n				{ yyLineNr++; }<*>.					<*>\n					{ yyLineNr++ ; }%%/*@ ---------------------------------------------------------------------------- */#if 0static void writeBoolValue(QTextStream &t,bool v){  if (v) t << "YES"; else t << "NO";}static void writeIntValue(QTextStream &t,int i){  t << i;}static void writeStringValue(QTextStream &t,QCString &s){  const char *p=s.data();  char c;  bool hasBlanks=FALSE;  if (p)  {    while ((c=*p++)!=0 && !hasBlanks) hasBlanks = (c==' ' || c=='\n' || c=='\t');    if (hasBlanks)       t << "\"" << s << "\"";    else      t << s;  }}static void writeStringList(QTextStream &t,QStrList &l){  const char *p = l.first();  bool first=TRUE;  while (p)  {    char c;    const char *s=p;    bool hasBlanks=FALSE;    while ((c=*p++)!=0 && !hasBlanks) hasBlanks = (c==' ' || c=='\n' || c=='\t');    if (!first) t << "                         ";    first=FALSE;    if (hasBlanks) t << "\"" << s << "\""; else t << s;    p = l.next();    if (p) t << " \\" << endl;  }}#endifvoid Config::writeTemplate(QFile *f,bool sl,bool upd){  QTextStream t(f);  t << "# Doxyfile " << versionString << endl << endl;  if (!sl)  {    t << "# This file describes the settings to be used by the documentation system\n";    t << "# doxygen (www.doxygen.org) for a project\n";    t << "#\n";    t << "# All text after a hash (#) is considered a comment and will be ignored\n";    t << "# The format is:\n";    t << "#       TAG = value [value, ...]\n";    t << "# For lists items can also be appended using:\n";    t << "#       TAG += value [value, ...]\n";    t << "# Values that contain spaces should be placed between quotes (\" \")\n";  }  ConfigOption *option = m_options->first();  while (option)  {    option->writeTemplate(t,sl,upd);    option = m_options->next();  }}void Config::convertStrToVal(){  ConfigOption *option = m_options->first();  while (option)  {    option->convertStrToVal();    option = m_options->next();  }}static void substEnvVarsInString(QCString &s){  static QRegExp re("\\$\\([a-z_A-Z0-9]+\\)");  if (s.isEmpty()) return;  int p=0;  int i,l;  //printf("substEnvVarInString(%s) start\n",s.data());  while ((i=re.match(s,p,&l))!=-1)  {    //printf("Found environment var s.mid(%d,%d)=`%s'\n",i+2,l-3,s.mid(i+2,l-3).data());    QCString env=getenv(s.mid(i+2,l-3));    substEnvVarsInString(env); // recursively expand variables if needed.    s = s.left(i)+env+s.right(s.length()-i-l);    p=i+env.length(); // next time start at the end of the expanded string  }  //printf("substEnvVarInString(%s) end\n",s.data());}static void substEnvVarsInStrList(QStrList &sl){  char *s = sl.first();  while (s)  {    QCString result(s);    bool wasQuoted = (result.find(' ')!=-1) || (result.find('\t')!=-1);    substEnvVarsInString(result);    if (!wasQuoted) /* as a result of the expansion, a single string		       may have expanded into a list, which we'll		       add to sl. If the orginal string already 		       contained multiple elements no further 		       splitting is done to allow quoted items with spaces! */    {      int l=result.length();      int i,p=0;      // skip spaces      // search for a "word"      for (i=0;i<l;i++)      {	char c;	// skip until start of new word	while (i<l && ((c=result.at(i))==' ' || c=='\t')) i++; 	p=i; // p marks the start index of the word	// skip until end of a word	while (i<l && ((c=result.at(i))!=' ' && c!='\t' && c!='"')) i++;	if (i<l) // not at the end of the string	{	  if (c=='"') // word within quotes	  {	    p=i+1;	    for (i++;i<l;i++)	    {	      c=result.at(i);	      if (c=='"') // end quote	      {		// replace the string in the list and go to the next item.		sl.insert(sl.at(),result.mid(p,i-p)); // insert new item before current item.		sl.next();                 // current item is now the old item		p=i+1;		break; 

⌨️ 快捷键说明

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