Ejemplo n.º 1
0
ULONG fstk_RunInclude(char *s)
{
	FILE *f;
	char tzFileName[_MAX_PATH + 1];

	//printf( "INCLUDE: %s\n", s );

	strcpy(tzFileName, s);
	fstk_FindFile(tzFileName);
	//printf( "INCLUDING: %s\n", tzFileName );

	if ((f = fopen(tzFileName, "rt")) != NULL) {
		pushcontext();
		nLineNo = 1;
		nCurrentStatus = STAT_isInclude;
		strcpy(tzCurrentFileName, tzFileName);
		pCurrentFile = f;
		CurrentFlexHandle = yy_create_buffer(pCurrentFile);
		yy_switch_to_buffer(CurrentFlexHandle);

		//      Dirty hack to give the INCLUDE directive a linefeed

		yyunput('\n');
		nLineNo -= 1;

		return (1);
	} else
		return (0);
}
Ejemplo n.º 2
0
/*
 * Set up an include file for parsing
 */
void
fstk_RunInclude(char *tzFileName)
{
	FILE *f;

	f = fstk_FindFile(tzFileName);

	if (f == NULL) {
		err(1, "Unable to open included file '%s'",
		    tzFileName);
	}

	pushcontext();
	nLineNo = 1;
	nCurrentStatus = STAT_isInclude;
	strcpy(tzCurrentFileName, tzFileName);
	pCurrentFile = f;
	CurrentFlexHandle = yy_create_buffer(pCurrentFile);
	yy_switch_to_buffer(CurrentFlexHandle);

	//Dirty hack to give the INCLUDE directive a linefeed

	yyunput('\n');
	nLineNo -= 1;
}
void
CBCSharpScanner::Undo
	(
	const JIndexRange&	range,
	const JString&		text
	)
{
	for (JIndex i=text.GetLength(); i>=1; i--)
		{
		yyunput(text.GetCharacter(i), yytext);
		}

	itsCurrentRange.first = itsCurrentRange.last = range.first - 1;
}
Ejemplo n.º 4
0
int
yyracc(int m)
{

	yyolsp = yylsp;
	if(yyextra[m]) {
		while(yyback((*yylsp)->yystops, -m) != 1 && yylsp > yylstate) {
			yylsp--;
			yyunput(yytext[--yyleng]);
		}
	}
	yyprevious = yytext[yyleng-1];
	yytext[yyleng] = 0;
	return m;
}
Ejemplo n.º 5
0
void
yyless(int x)
{
	char *lastch, *ptr;

	lastch = yytext+yyleng;
	if(x>=0 && x <= yyleng)
		ptr = x + yytext;
	else
		ptr = (char*)x;
	while(lastch > ptr)
		yyunput(*--lastch);
	*lastch = 0;
	if (ptr >yytext)
		yyprevious = lastch[-1];
	yyleng = ptr-yytext;
}
Ejemplo n.º 6
0
int
yyreject(void)
{
	for(; yylsp < yyolsp; yylsp++)
		yytext[yyleng++] = yyinput();
	if(*yyfnd > 0)
		return yyracc(*yyfnd++);
	while(yylsp-- > yylstate) {
		yyunput(yytext[yyleng-1]);
		yytext[--yyleng] = 0;
		if(*yylsp != 0 && (yyfnd = (*yylsp)->yystops) && *yyfnd > 0)
			return yyracc(*yyfnd++);
	}
	if(yytext[0] == 0)
		return 0;
	yyoutput(yyprevious = yyinput());
	yyleng = 0;
	return -1;
}
Ejemplo n.º 7
0
/*
 * Set up an include file for parsing
 */
void fstk_RunInclude(char *tzFileName)
{
	char *incPathUsed = "";
	FILE *f = fstk_FindFile(tzFileName, &incPathUsed);

	if (f == NULL)
		err(1, "Unable to open included file '%s'", tzFileName);

	pushcontext();
	nLineNo = 1;
	nCurrentStatus = STAT_isInclude;
	snprintf(tzCurrentFileName, sizeof(tzCurrentFileName), "%s%s",
		 incPathUsed, tzFileName);
	pCurrentFile = f;
	CurrentFlexHandle = yy_create_buffer(pCurrentFile);
	yy_switch_to_buffer(CurrentFlexHandle);

	/* Dirty hack to give the INCLUDE directive a linefeed */

	yyunput('\n');
	nLineNo -= 1;
}
Ejemplo n.º 8
0
int yyclexer::yylex()
{
	while (1) {
		int state = 1 + yystart;
		if (yyeol) {
			state++;
		}
	
		// yymore
		if (yymoreflg) {
			yymoreflg = 0;		// clear flag
		}
		else {
			yyleng = 0;
			yyoldeol = yyeol;
		}
		int oldleng = yyleng;

		// look for a string
		do {
			// get input character (lookahead character)
			int ch = yyinput();
			yyassert(ch >= 0 && ch <= UCHAR_MAX || ch == EOF);
			if (ch == EOF) {
				break;
			}
			
			// check for possible overflow
			if (yyleng == yytext_size) {
				do {
					if (yytextgrow) {
						if (yytext_size != 0) {
							int size = yytext_size * 2;
							if (size / 2 == yytext_size) {		// overflow check
								if (yysettextsize(size)) {
									break;
								}
							}
						}
						else {
							if (yysettextsize(100)) {
								break;
							}
						}
					}
					yytextoverflow();
					exit(EXIT_FAILURE);
				}
				while (0);
			}

			// look for a transition
			int index = yystate[state].base;
			while (1) {
				if (yyctransition[index].next == 0) {
					state = yystate[state].def;
					if (state <= 0) {
						if (state < 0) {
							if (ch >= 0 && ch <= 0xff) {
								state = -state;
							}
							else {
								state = 0;
							}
						}
						break;
					}
				}
				if (ch >= yyctransition[index].first &&
					ch <= yyctransition[index].last) {
					state = yyctransition[index].next;
					break;
				}
				index++;
			}

			int leng = yyleng;		// slightly more efficient code
			yytext[leng] = (char)ch;
			yystatebuf[leng] = state;
			leng++;
			yyleng = leng;
		}
		while (state != 0 && (yystate[state].def != 0 || yystate[state].base != 0));

		// now find a match
		if (yyleng > oldleng) {
			int rejectmatch = 0;
			while (1) {
				int match = yystate[yystatebuf[yyleng - 1]].match;
				if (rejectmatch != 0) {
					if (match < 0) {
						int index = -match;
						do {
							match = yymatch[index++];
						}
						while (match > 0 && match <= rejectmatch);
					}
					else {
						if (match == rejectmatch) {
							match = 0;
						}
					}
					rejectmatch = 0;
				}
				else {
					if (match < 0) {
						match = yymatch[-match];
					}
				}
				if (match > 0) {
					// check for backup
					if (yybackup[match]) {
						while (yyleng > oldleng) {
							int index = yystate[yystatebuf[yyleng - 1]].match;
							if (index < 0) {
								if (yyback(&yymatch[-index], -match)) {
									break;	// found an expression
								}
							}
							yyleng--;
							yyunput((unsigned char)yytext[yyleng]);
						}
					}
					yytext[yyleng] = '\0';
#ifdef YYDEBUG
					yydmatch(match);
#endif
					yyrejectflg = 0;		// clear flag
					int rejectleng = yyleng;

					if (yyleng > 0) {
						yyeol = (unsigned char)(yytext[yyleng - 1] == '\n');
					}
					else {
						yyeol = yyoldeol;
					}

					// perform user action
					int token = yyaction(match);

					if (yyreturnflg) {
						return token;
					}
					if (!yyrejectflg) {
						break;
					}
					if (rejectleng == yyleng) {
						rejectmatch = match;
					}
				}
				else if (yyleng > oldleng + 1) {
					yyleng--;
					yyunput((unsigned char)yytext[yyleng]);
				}
				else {
					yyeol = (unsigned char)(yytext[0] == '\n');
					yyoutput(yytext[0]);	// non-matched character
					break;
				}
			}
		}
		else {
			yyassert(yyleng == oldleng);

			// handles <<EOF>> rules
			int index = 0;
			int match = yystate[state].match;
			if (match < 0) {
				index = -match;
				match = yymatch[index++];
			}
			while (match > 0) {
				yytext[yyleng] = '\0';
#ifdef YYDEBUG
				yydmatch(match);
#endif
				yyrejectflg = 0;		// clear flag

				// perform user action
				int token = yyaction(match);

				if (yyreturnflg) {
					return token;
				}
				if (!yyrejectflg) {
					break;
				}

				if (index == 0) {
					break;
				}
				match = yymatch[index++];
			}

			if (yywrap()) {
				yyoldeol = 1;
				yyeol = 1;
				yystart = 0;
				return 0;			// eof reached
			}
		}
	}
}
JBoolean
CBPerlScanner::SlurpQuoted
	(
	const JSize			count,
	const JCharacter*	suffixList
	)
{
	assert( count > 0 );

	const int startChar = yyinput();
	if (startChar == EOF || startChar == 0)
		{
		return kJFalse;
		}
	itsCurrentRange.last++;

	int endChar = startChar;
	if (startChar == '(')
		{
		endChar = ')';
		}
	else if (startChar == '<')
		{
		endChar = '>';
		}
	else if (startChar == '[')
		{
		endChar = ']';
		}
	else if (startChar == '{')
		{
		endChar = '}';
		}

	JSize remainder = count;
	while (1)
		{
		int c = yyinput();
		if (c == EOF || c == 0)
			{
			return kJFalse;
			}
		itsCurrentRange.last++;

		if (startChar != endChar && c == startChar)
			{
			remainder++;
			}
		else if (c == endChar)	// check for endChar before '\\' because qq\abc\ is legal
			{
			if (remainder > 0)
				{
				remainder--;
				}
			if (remainder == 0)
				{
				while (1)		// slurp in characters in suffixList
					{
					c = yyinput();
					if (c == EOF || c == 0)
						{
						return kJTrue;
						}
					else if (strchr(suffixList, c) == NULL)
						{
						yyunput(c, yytext);
						return kJTrue;
						}
					itsCurrentRange.last++;
					}
				}
			else if (count > 1 && remainder < count)
				{
				remainder--;	// compensate for extra openChar in s(a)(b)g
				}
			}
		else if (c == '\\')
			{
			c = yyinput();
			if (c == EOF || c == 0)
				{
				return kJFalse;
				}
			itsCurrentRange.last++;
			}
		}
}
Ejemplo n.º 10
-3
void yyunputstr(char *s)
{
	SLONG i;

	i = strlen(s) - 1;

	while (i >= 0)
		yyunput(s[i--]);
}