Skip to content

Commit

Permalink
update tab.c file
Browse files Browse the repository at this point in the history
  • Loading branch information
mseminatore committed May 28, 2024
1 parent 5c5fb73 commit 4b778f8
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions as09.tab.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,15 +623,15 @@ void pop_file_stack()
//-----------------------------------
// next next char from input stream
//-----------------------------------
int getchar()
int getch()
{
return fgetc(yyin);
}

//-----------------------------------
// put char back to input stream
//-----------------------------------
int ungetchar(int c)
int ungetch(int c)
{
return ungetc(c, yyin);
}
Expand Down Expand Up @@ -4453,11 +4453,11 @@ void skipToEOL(void)

// skip to EOL
do {
c = getchar();
c = getch();
} while (c != '\n' && c != EOF);

// put last character back
ungetchar(c);
ungetch(c);
}

//----------------------------------
Expand All @@ -4467,11 +4467,11 @@ int follow(int expect, int ifyes, int ifno)
{
int chr;

chr = getchar();
chr = getch();
if (chr == expect)
return ifyes;

ungetchar(chr);
ungetch(chr);
return ifno;
}

Expand All @@ -4486,32 +4486,32 @@ int getNumber()
int base = 10;

// look for hex numbers
c = getchar();
c = getch();

if (c == '-' || c == '+')
{
*bufptr++ = c;
c = getchar();
c = getch();
}

if (c == '$' || (c == '0' && (follow('X', 1, 0) || follow('x', 1, 0))))
base = 16;
else
ungetchar(c);
ungetch(c);

if (base == 16)
{
while (isxdigit(c = getchar()))
while (isxdigit(c = getch()))
*bufptr++ = c;
}
else
{
while (isdigit((c = getchar())) || c == '.')
while (isdigit((c = getch())) || c == '.')
*bufptr++ = c;
}

// need to put back the last character
ungetchar(c);
ungetch(c);

// make sure string is asciiz
*bufptr = '\0';
Expand All @@ -4530,7 +4530,7 @@ int backslash(int c)
if (c != '\\')
return c;

c = getchar();
c = getch();
if (islower(c) && strchr(translation_tab, c))
return strchr(translation_tab, c)[1];

Expand All @@ -4545,15 +4545,15 @@ int getString(int delim)
int c;
char buf[BUF_SIZE], *cptr = buf;

c = getchar();
c = getch();

while (c != delim && cptr < &buf[sizeof(buf)])
{
if (c == '\n' || c == EOF)
yyerror("missing end quote");

*cptr++ = backslash(c);
c = getchar();
c = getch();
}

*cptr = 0;
Expand Down Expand Up @@ -4600,7 +4600,7 @@ int yylex()

yylex01:
// skip leading whitespace
while ((c = getchar()) == ' ' || c == '\t');
while ((c = getch()) == ' ' || c == '\t');

// see if input is empty
if (c == EOF)
Expand All @@ -4624,14 +4624,14 @@ int yylex()
// look for char literals
if (c == '\'')
{
c = getchar();
c = getch();
if (follow('\'', 1, 0))
{
yylval.ival = backslash(c);
return CHAR;
}

ungetchar(c);
ungetch(c);
return getString('\'');
}

Expand All @@ -4646,14 +4646,14 @@ int yylex()
{
if (c == '-' || c == '+')
{
int n = getchar();
ungetchar(n);
int n = getch();
ungetch(n);

if (n != '$' && !isdigit(n))
return c;
}

ungetchar(c);
ungetch(c);
return getNumber();
}

Expand All @@ -4664,10 +4664,10 @@ int yylex()

do {
*p++ = c;
} while ((c=getchar()) != EOF && (c == '_' || isalnum(c)));
} while ((c=getch()) != EOF && (c == '_' || isalnum(c)));

// put back the last character!
ungetchar(c);
ungetch(c);

// be sure to null terminate the string
*p = 0;
Expand Down

0 comments on commit 4b778f8

Please sign in to comment.