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

📄 scanner.l

📁 tvapp用于播放tv程序
💻 L
📖 第 1 页 / 共 2 页
字号:
%{/*=========================================================================== Copyright (c) 1998-2000, The Santa Cruz Operation  All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. *Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. *Neither name of The Santa Cruz Operation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  =========================================================================*//*	cscope - interactive C symbol cross-reference * *	C symbol scanner */#include "global.h"#include "scanner.h"#include "lookup.h"/* the line counting has been moved from character reading for speed *//* comments are discarded */#define	IFLEVELINC	5	/* #if nesting level size increment */static char const rcsid[] = "$Id: scanner.l,v 1.6 2001/06/26 13:55:07 broeker Exp $";int	first;	/* buffer index for first char of symbol */int	last;	/* buffer index for last char of symbol */int	lineno;	/* symbol line number */int	myylineno = 1;static	BOOL	arraydimension;		/* inside array dimension declaration */static	BOOL	bplisting;		/* breakpoint listing */static	int	braces;			/* unmatched left brace count */static	BOOL	classdef;		/* c++ class definition */static	BOOL	elseelif;		/* #else or #elif found */static	BOOL	esudef;			/* enum/struct/union global definition */static	BOOL	external;		/* external definition */static	int	externalbraces;		/* external definition outer brace count */static	BOOL	fcndef;			/* function definition */static	BOOL	global;			/* file global scope (outside functions) */static	int	iflevel;		/* #if nesting level */static	BOOL	initializer;		/* data initializer */static	int	initializerbraces;	/* data initializer outer brace count */static	BOOL	lex;			/* lex file */static	int	miflevel = IFLEVELINC;	/* maximum #if nesting level */static	int	*maxifbraces;		/* maximum brace count within #if */static	int	*preifbraces;		/* brace count before #if */static	int	parens;			/* unmatched left parenthesis count */static	BOOL	ppdefine;		/* preprocessor define statement */static	BOOL	pseudoelif;		/* pseudo-#elif */static	BOOL	oldtype;		/* next identifier is an old type */static	BOOL	rules;			/* lex/yacc rules */static	BOOL	sdl;			/* sdl file */static	BOOL	structfield;		/* structure field declaration */static	int	tagdef;			/* class/enum/struct/union tag definition */static	BOOL	template;		/* function template */static	int	templateparens;		/* function template outer parentheses count */static	int	typedefbraces = -1;	/* initial typedef brace count */static	int	token;			/* token found */void	multicharconstant(char terminator);int	skipcomment_input(void);int	comment(void);#ifdef FLEX_SCANNER#define YY_INPUT(buf,result,max_size) \	{\		int c = skipcomment_input (); \		result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \	}#else/* Assume this is the AT&T/SCO style lex */#undef	input#define input()  ((yytchar=(yytchar=yysptr>yysbuf?*(unsigned char *)--yysptr:getc(yyin))=='/'?comment():yytchar)==EOF?0:yytchar)#define noncommentinput()  ((yytchar=yysptr>yysbuf?*--yysptr:getc(yyin))==EOF?0:yytchar)#undef	unput#define unput(c) (*yysptr++=(c))#endif%}identifier	[a-zA-Z_$][a-zA-Z_0-9$]*number		\.?[0-9][.0-9a-fA-FlLuUxX]*%start SDL%a 4000%o 7000%%%\{		{	/* lex/yacc C declarations/definitions */			global = YES;			goto more;			/* NOTREACHED */		}%\}		{			global = NO;			goto more;			/* NOTREACHED */		}^%%		{	/* lex/yacc rules delimiter */			braces = 0;			if (rules == NO) {				rules = YES;								/* simulate a yylex() or yyparse() definition */				(void) strcat(yytext, " /* ");				first = strlen(yytext);				if (lex == YES) {					(void) strcat(yytext, "yylex");				}				else {	/* yacc: yyparse implicitly calls yylex */					char *s = " yylex()";					char *cp = s + strlen(s);					while (--cp >= s) {						unput(*cp);					}					(void) strcat(yytext, "yyparse");				}				last = strlen(yytext);				(void) strcat(yytext, " */");				yyleng = strlen(yytext);				yymore();				return(FCNDEF);			}			else {				rules = NO;				global = YES;				last = first;				yymore();				return(FCNEND);				/* NOTREACHED */			}		}<SDL>STATE[ \t]+({identifier}|\*)	{ /* sdl state, treat as function def */			braces = 1;			fcndef = YES;			token = FCNDEF;			goto findident;			/* NOTREACHED */		}<SDL>ENDSTATE[ \t]	{ /* end of an sdl state, treat as end of a function */			goto endstate;			/* NOTREACHED */		}\{		{	/* count unmatched left braces for fcn def detection */			++braces;						/* mark an untagged enum/struct/union so its beginning			   can be found */			if (tagdef) {				if (braces == 1) {					esudef = YES;				}				token = tagdef;				tagdef = '\0';				last = first;				yymore();				return(token);			}			goto more;			/* NOTREACHED */		}\#[ \t]*endif/.*\n[ \t\n]*#[ \t]*if	{			/* attempt to correct erroneous brace count caused by:			 * 			 * #if ...			 * 	... {			 * #endif			 * #if ...			 * 	... {			 * #endif			 */			/* the current #if must not have an #else or #elif */			if (elseelif == YES) {				goto endif;				/* NOTREACHED */			}			pseudoelif = YES;			goto more;			/* NOTREACHED */		}\#[ \t]*ifn?(def)?	{ /* #if, #ifdef or #ifndef */			elseelif = NO;			if (pseudoelif == YES) {				pseudoelif = NO;				goto elif;				/* NOTREACHED */			}			/* make sure there is room for the current brace count */			if (iflevel == miflevel) {				miflevel += IFLEVELINC;				maxifbraces = myrealloc(maxifbraces, miflevel * sizeof(int));				preifbraces = myrealloc(preifbraces, miflevel * sizeof(int));			}			/* push the current brace count */			preifbraces[iflevel] = braces;			maxifbraces[iflevel++] = 0;			goto more;			/* NOTREACHED */		}\#[ \t]*el(se|if)	{ /* #elif or #else */			elseelif = YES;		elif:			if (iflevel > 0) {								/* save the maximum brace count for this #if */				if (braces > maxifbraces[iflevel - 1]) {					maxifbraces[iflevel - 1] = braces;				}				/* restore the brace count to before the #if */				braces = preifbraces[iflevel - 1];			}			goto more;			/* NOTREACHED */		}\#[ \t]*endif	{	/* #endif */		endif:			if (iflevel > 0) {								/* get the maximum brace count for this #if */				if (braces < maxifbraces[--iflevel]) {					braces = maxifbraces[iflevel];				}			}			goto more;			/* NOTREACHED */		}\}		{			/* could be the last enum member initializer */			if (braces == initializerbraces) {				initializerbraces = -1;				initializer = NO;			}			if (--braces <= 0) {		endstate:				braces = 0;				classdef = NO;			}			if (braces == 0 || (braces == 1 && classdef == YES)) {				/* if the end of an enum/struct/union definition */				if (esudef == YES) {					esudef = NO;				}				/* if the end of the function */				else if (fcndef == YES) {					fcndef = NO;					last = first;					yymore();					return(FCNEND);				}			}			goto more;			/* NOTREACHED */		}\(		{	/* count unmatched left parentheses for function templates */			++parens;			goto more;			/* NOTREACHED */		}\)		{			if (--parens <= 0) {				parens = 0;			}			/* if the end of a function template */			if (parens == templateparens) {				templateparens = -1;				template = NO;			}			goto more;			/* NOTREACHED */		}=		{	/* if a global definition initializer */			if (global == YES && ppdefine == NO && yytext[0] != '#') {				initializerbraces = braces;				initializer = YES;			}			goto more;			/* NOTREACHED */		}:		{	/* a if global structure field */			if (global == YES && ppdefine == NO && yytext[0] != '#') {				structfield = YES;			}			goto more;			/* NOTREACHED */		}\,		{			if (braces == initializerbraces) {				initializerbraces = -1;				initializer = NO;			}			structfield = NO;			goto more;			/* NOTREACHED */		};		{	/* if the enum/struct/union was not a definition */			if (braces == 0) {				esudef = NO;			}			/* if the end of a typedef */			if (braces == typedefbraces) {				typedefbraces = -1;			}			/* if the end of a external definition */			if (braces == externalbraces) {				externalbraces = -1;				external = NO;			}			structfield = NO;			initializer = NO;			goto more;			/* NOTREACHED */		}\#[ \t]*define[ \t]+{identifier}	{							/* preprocessor macro or constant definition */			ppdefine = YES;			token = DEFINE;			if (compress == YES) {				yytext[0] = '\1';	/* compress the keyword */			}		findident:			first = yyleng - 1;			while (yytext[first] != ' ' && yytext[first] != '\t') {				--first;			}			++first;			goto fcn;			/* NOTREACHED */		}class[ \t]+{identifier}[ \t\na-zA-Z0-9_():]*\{	{	/* class definition */			classdef = YES;			tagdef =  'c';			REJECT;			/* NOTREACHED */		}(enum|struct|union)/([ \t\n]+{identifier})[ \t\n]*\{	{ /* enum/struct/union definition */			tagdef = *(yytext + first);			goto ident;			/* NOTREACHED */		}(enum|struct|union)/[ \t\n]*\{		{ /* tag-less e/s/u definition */			tagdef = yytext[first];			if (braces == 0) {				esudef = YES;			}			last = first;			tagdef = '\0';			goto more;		}  			{identifier}/[ \t]*\([ \t\na-zA-Z0-9_*&[\]=,.]*\)[ \t\n()]*[:a-zA-Z_#{]	{						/* warning: "if (...)" must not overflow yytext, so the content			   of function argument definitions is restricted, in particular			   parentheses are not allowed */			/* if a function definition */			/* note: "#define a (b) {" and "#if defined(a)\n#" are not */			if ((braces == 0 && ppdefine == NO && yytext[0] != '#' && rules == NO) ||			    (braces == 1 && classdef == YES)) {				fcndef = YES;				token = FCNDEF;				goto fcn;				/* NOTREACHED */			}			goto fcncal;			/* NOTREACHED */		}{identifier}/[ \t]*\(	{ /* if a function call */

⌨️ 快捷键说明

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