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

📄 doc2tex.ll

📁 Doc++,可以根据你的C/C++和java的源码文件中的注释行自动生成Html说明文件的工具
💻 LL
📖 第 1 页 / 共 3 页
字号:
/*  doc2tex.ll  Copyright (c) 1996 Roland Wunderling, Malte Zoeckler  Copyright (c) 1998-2000 Dragos Acostachioaie  This file is part of DOC++.  DOC++ is free software; you can redistribute it and/or  modify it under the terms of the GNU General Public  License as published by the Free Software Foundation; either  version 2 of the license, or (at your option) any later version.  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  General Public License for more details.  You should have received a copy of the GNU General Public  License along with this library; if not, write to the Free  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/%{#include <assert.h>#include <fstream.h>#include <iostream.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include "classgraph.h"#include "doc.h"#define YY_DECL int yylex()#undef	YY_INPUT#define	YY_INPUT(buf, result, max_size) result = yyread(buf, max_size);static Entry*	current;static int	inPos;static int	lastContext;static const char*	inStr;static McString	img, imgArg1, imgArg2;static enum {    C_COMMENT,    SHORT_C_COMMENT,    CC_COMMENT} commentMode;static int	escapePercent	= 0;static int	verbMode	= 0;static int	skip		= 0;static int	tab		= 0;static int	yyLineNr	= 0;static int	texBracketCount	= 0;static McString	refStr		= "";static Entry*	ref		= 0;static Entry*	noref		= ref + 1;static char	yyFileName[264];bool		mathmode	= false;static int	tabFlag		= 0;static int yyread(char *buf, int max_size){    int c = 0;    while(c < max_size && inStr[inPos])	{	*buf = inStr[inPos++];	c++;	buf++;	}    return c;}extern "C" {    int doc2texYYwrap()	{	return 1;	}}static void setupVerbMode(){    if(skip)	{	fprintf(out, "\\strut\\goodbreak\n");	fprintf(out, "\\noindent{\\tiny\\em %s}", yyFileName);	fprintf(out, "\\strut\\nopagebreak\\\\\n");	skip = 0;	}    fprintf(out, "\\cxxCodeLine{%d} ", yyLineNr);    verbMode = 1;    tab = 0;}static void closeVerbMode(){    fprintf(out, "%c\n", 3);    verbMode = 0;}%}%x	Code%x	Verb%x	Ref%x	texmode%x	URL%x	Link%x	Image
%x	ImageArg1
%x	ImageArg2
%x	Label%x	Listing%x	Comment%x	LVerb%x	ShortComment%x	RealComment%x	Graph%x	texverbatim%x	TeXlist%x	HTMLlist%x	HTML%x	HTMLverbatim%%"#\\#"			{			fprintf(out, "$\\backslash$");			}"\\#"			{			fprintf(out, "%s", yytext);			}"#"			{			fprintf(out, "{\\tt\\strut ");			BEGIN(Verb);			}"#define"		{			fprintf(out, "\\#define");			BEGIN(Verb);			}"\\"[T|t][E|e][X|x][ \t]*"{"	{			BEGIN(texmode);			texBracketCount = 1;			}<texmode>"\\}"		{			yymore();			}<texmode>"\\{"		{			yymore();			}<texmode>"{"		{			++texBracketCount;			yymore();			}<texmode>"}"		{			if(--texBracketCount == 0)			    {			    yytext[--yyleng] = 0;			    fprintf(out, yytext);			    BEGIN(0);			    }			else			    yymore();			}<texmode>.|\n		{			yymore();			}"\\Ref"[ \t]*"{"	{			BEGIN(Ref);			}<Ref>[^}]*		{			if(ref == 0)			    {			    refStr = McString(yytext, 0, yyleng - 2);			    ref = getRefEntry(refStr, current);			    }			REJECT;			}<Ref>"}"		{			if(ref && ref != noref)			    {			    fprintf(out, " ($\\rightarrow$ ");			    if(MAKE_DOC(ref))				{				ref->dumpNumber(out);				fprintf(out, ",");				}			    fprintf(out, " {\\em page }\\pageref{cxx.");			    ref->dumpNumber(out);			    fprintf(out, "})");			    }			else			    fprintf(out, refStr.c_str());			ref = 0;			refStr.clear();			BEGIN(0);			}"\\URL["		{			BEGIN(URL);			}<URL>[^\]]*		{			char *p = yytext;			while(*p != '\0')			    {			    switch(*p)				{				case '%':				case '_':				case '&':				case '$':				    fputc('\\', out);				default:				    fputc(*p, out);				    break;				}			    ++p;			    }			}<URL>"]{"[^}]*"}"	{			BEGIN(0);			}"{@link"[ \t]*		{			BEGIN(Link);			}<Link>[^ ]*		{			if(ref == 0)			    {			    McString tmp = yytext;			    ref = getRefEntry(tmp, current);			    }			REJECT;			}<Link>"}"		{			if(ref && ref != noref)			    {			    fprintf(out, " ($\\rightarrow$ ");			    if(MAKE_DOC(ref))				{				ref->dumpNumber(out);				fprintf(out, ",");				}			    fprintf(out, " {\\em page }\\pageref{cxx.");			    ref->dumpNumber(out);			    fprintf(out, "})");			    }			ref = 0;			BEGIN(0);			}"\\Label{"[^}]*"}"	{			}"\\"([I|i][M|m][G|g]|"includegraphics")[ \t]*"{"	{			img.clear();			imgArg1.clear();			imgArg2.clear();			BEGIN(Image);			}"\\"([I|i][M|m][G|g]|"includegraphics")[ \t]*"["	{			img.clear();			imgArg1.clear();			imgArg2.clear();			BEGIN(ImageArg1);			}<ImageArg1>[^\]]*"]{"	{    			if(strlen(yytext) > 2 && imgArg1.length() == 0)			    imgArg1 = McString(yytext, 0, strlen(yytext) - 2);			BEGIN(Image);			}<ImageArg1>[^\]]*"]["	{    			if(strlen(yytext) > 2 && imgArg1.length() == 0)			    imgArg1 = McString(yytext, 0, strlen(yytext) - 2);			BEGIN(ImageArg2);			}<ImageArg2>[^\]]*"]{"	{			if(strlen(yytext) > 2 && imgArg2.length() == 0)	    		    imgArg2 = McString(yytext, 0, strlen(yytext) - 2);			BEGIN(Image);			}<Image>[^}]*"}"		{			if(strlen(yytext) > 1 && img.length() == 0)			    img = McString(yytext, 0, strlen(yytext) - 1);			if(img.length() > 0)			    {        		    fprintf(out, "\\includegraphics");        		    if(imgArg2.length() > 0)            			{            			fprintf(out, "[");				fprintf(out, imgArg2.c_str());				fprintf(out, "]");            			}        		    // remove extension if present			    int i = img.index('.');			    if(i > 0)				img.remove(i, img.length() - i);        		    fprintf(out, "{%s.eps}", img.c_str());			    }			img.clear();			imgArg1.clear();			imgArg2.clear();                	BEGIN(0);                	}"\\"([D|d][A|a][T|t][E|e]|"today")	{			time_t ltime;			(void)time(&ltime);			char timebuf[64];			strftime(timebuf, 64, "%c", localtime(&ltime));			fprintf(out, timebuf);			}<Code>[#]		{			fprintf(out, "\\%c", *yytext);			}<Verb>"#"		{			fprintf(out, "}");			BEGIN(0);			}<LVerb>"#"		{			fprintf(out, "}");			BEGIN(Comment);			}<TeXlist>[ \t\n]*	{			fprintf(out, "} & ");			BEGIN(0);			}<HTMLlist>[ \t\n]*	{			fprintf(out, "} & ");			BEGIN(HTML);			}<HTMLlist,TeXlist,Ref,LVerb,Verb,Code>[%_&><{}$ ] {			fprintf(out, "\\%c", *yytext);			}<HTMLlist,TeXlist,Ref,LVerb,Verb,Code>"~"	{			fprintf(out, "\\cxxtilde ");			}<HTMLlist,TeXlist,Ref,LVerb,Verb,Code>\\	{			fprintf(out, "{$\\backslash$\\relax}");			}<HTMLlist,TeXlist,Ref,LVerb,Verb,Code>\^	{			fprintf(out, "$\\hat{\\;}$");			}<HTMLlist,TeXlist,Ref,LVerb,Verb,Code>(.|\n)	{			fprintf(out, "%c", *yytext);			}"<"			{			fprintf(out, (mathmode ? "<" : "\\<"));			}">"			{			fprintf(out, (mathmode ? ">" : "\\>"));			}"_"			{			fprintf(out, (mathmode ? "_" : "\\_"));			}"$"			{			fprintf(out, "$");			mathmode = !mathmode;			}"%"			{			fprintf(out, "\\%c", *yytext);			}"~"			{			fprintf(out, "\\cxxtilde ");			}"&"			{			fprintf(out, tabFlag ? "&" : "\\&");			}"\\["			{			fprintf(out, "\\[");			mathmode = true;			}"\\]"			{			fprintf(out, "\\]");			mathmode = false;			}"\\"[%_&><{}$ ]		{			fprintf(out, "%s", yytext);			}"\\begin{"("tabular"|"array")"}{"[lrc|]+"}"	{			fprintf(out, "%s", yytext);			tabFlag++;			}"\\end{"("tabular"|"array")"}"	{			fprintf(out, "%s", yytext);			tabFlag--;			}"\\begin{"("eqnarray"|"eqnarray\*"|"equation"|"displaymath")"}"	{			fprintf(out, "%s", yytext);			mathmode = true;			}"\\end{"("eqnarray"|"eqnarray\*"|"equation"|"displaymath")"}"	{			fprintf(out, "%s", yytext);			mathmode = false;			}"\\begin{verbatim}"	{			fprintf(out, "%s", yytext);			BEGIN(texverbatim);			}<texverbatim>.		{			fprintf(out, "%s", yytext);			}<texverbatim>\n		{			fprintf(out, "%s", yytext);			}<texverbatim>"\\end{verbatim}"	{			fprintf(out, "%s", yytext);			BEGIN(0);			}.			{			fprintf(out, "%s", yytext);			}\n			{			fprintf(out, "%s", yytext);			}<HTML>[_$#%{}&]		{			fprintf(out, "\\%s", yytext);			}<HTML>[><]		{			fprintf(out, "$%s$", yytext);			}<HTML>"<"[ \t]*[eE][mM][ \t]*">"	{			fprintf(out, "{\\em ");			}<HTML>"<"[ \t]*([bB]|[sS][tT][rR][oO][nN][gG])[ \t]*">"	{			fprintf(out, "{\\bf ");			}<HTML>"<"[ \t]*[iI][ \t]*">"	{			fprintf(out, "{\\it ");			}<HTML>"</"[ \t]*([eE][mM]|[bB]|[sS][tT][rR][oO][nN][gG]|[iI])[ \t]*">"	{			fprintf(out, "}");			}<HTML>"<"[ \t]*[tT][tT][ \t]*">"	{			fprintf(out, "{\\tt\\strut ");			}<HTML>"<"[ \t]*"/"[tT][tT][ \t]*">"	{			fprintf(out, "}");			}<HTML>"<"[ \t]*([pP][rR][eE]|[cC][oO][dD][eE])[ \t]*">"	{			fprintf(out, "\\begin{verbatim}\n");			lastContext = YY_START;			BEGIN(HTMLverbatim);			}<HTML>"<"[ \t]*[oO][lL][ \t]*">"	{			fprintf(out, "\\begin{enumerate}\n");			}<HTML>"</"[ \t]*[oO][lL][ \t]*">"	{			fprintf(out, "\\end{enumerate}\n");			}<HTML>"<"[ \t]*[dD][lL][ \t]*">"	{			fprintf(out, "\\begin{description}\n");			}<HTML>"</"[ \t]*[dD][lL][ \t]*">"	{			fprintf(out, "\\end{description}\n");			}<HTML>"<"[ \t]*[dD][tT][ \t]*">"	{			fprintf(out, "\\item[");			}<HTML>"<"[ \t]*[dD][dD][ \t]*">"	{			fprintf(out, "]\t");			}<HTML>"<"[ \t]*[uU][lL][ \t]*">"	{			fprintf(out, "\\begin{itemize}\n");			}<HTML>"</"[ \t]*[uU][lL][ \t]*">"	{			fprintf(out, "\\end{itemize}\n");			}<HTML>"<"[ \t]*[lL][iI][ \t]*">"	{			fprintf(out, "\\item\t");			}<HTML>"<"[ \t]*[pP][ \t]*">"	{			fprintf(out, "\\strut\\\\");			}<HTML>"&lt;"		{			fprintf(out, "\\<");			}<HTML>"&gt;"		{			fprintf(out, "\\>");			}<HTML>"&amp;"		{			fprintf(out, "&");			}<HTML>"&nbsp;"		{			fprintf(out, "~");			}<HTML>"&forall;"	{			fprintf(out, "$\\forall$");			}<HTML>"&exist;" 	{			fprintf(out, "$\\exists$");			}<HTML>"&ne;"	 	{			fprintf(out, "$\\neq$");			}<HTML>"&le;"	 	{			fprintf(out, "$\\le$");			}<HTML>"&ge;"	 	{			fprintf(out, "$\\ge$");			}<HTML>"&isin;"	 	{			fprintf(out, "$\\in$");			}<HTML>"&notin;" 	{			fprintf(out, "$\\not\\in$");

⌨️ 快捷键说明

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