and the name is looked up in the symbol table using symtab.c;
symval is set to a pointer to the entry found. */
-#include <stdio.h>
#include "system.h"
+#include "getargs.h"
#include "files.h"
#include "getopt.h" /* for optarg */
#include "symtab.h"
#include "alloc.h"
#include "complain.h"
-/* flags set by % directives */
-extern int definesflag; /* for -d */
-extern int toknumflag; /* for -k */
-extern int noparserflag; /* for -n */
-extern int fixed_outfiles; /* for -y */
-extern int nolinesflag; /* for -l */
-extern int rawtoknumflag; /* for -r */
-extern int verboseflag; /* for -v */
-extern int debugflag; /* for -t */
-extern char *spec_name_prefix; /* for -p */
-extern char *spec_file_prefix; /* for -b */
/*spec_outfile is declared in files.h, for -o */
extern int translations;
-void init_lex PARAMS((void));
-char *grow_token_buffer PARAMS((char *));
-int skip_white_space PARAMS((void));
-int safegetc PARAMS((FILE *));
-int literalchar PARAMS((char **, int *, char));
-void unlex PARAMS((int));
-int lex PARAMS((void));
-int parse_percent_token PARAMS((void));
+extern void init_lex PARAMS((void));
+extern char *grow_token_buffer PARAMS((char *));
+extern int skip_white_space PARAMS((void));
+extern void unlex PARAMS((int));
+extern int lex PARAMS((void));
+extern int parse_percent_token PARAMS((void));
+
+static int safegetc PARAMS((FILE *));
+static int literalchar PARAMS((char **, int *, char));
/* functions from main.c */
extern char *printable_version PARAMS((int));
break;
default:
- return (c);
+ return c;
}
}
}
/* do a getc, but give error message if EOF encountered */
-int
+static int
safegetc (FILE *f)
{
register int c = getc(f);
return 1 unless the character is an unescaped `term' or \n
report error for \n
*/
-int
+static int
literalchar (char **pp, int *pcode, char term)
{
register int c;
symval = unlexed_symval;
c = unlexed;
unlexed = -1;
- return (c);
+ return c;
}
c = skip_white_space();
{
case EOF:
strcpy(token_buffer, "EOF");
- return (ENDFILE);
+ return ENDFILE;
case 'A': case 'B': case 'C': case 'D': case 'E':
case 'F': case 'G': case 'H': case 'I': case 'J':
*p = 0;
ungetc(c, finput);
symval = getsym(token_buffer);
- return (IDENTIFIER);
+ return IDENTIFIER;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
}
*p = 0;
ungetc(c, finput);
- return (NUMBER);
+ return NUMBER;
}
case '\'':
symval->class = STOKEN;
if (! symval->user_token_number)
symval->user_token_number = code;
- return (IDENTIFIER);
+ return IDENTIFIER;
}
case '\"':
symval = getsym(token_buffer);
symval->class = STOKEN;
- return (IDENTIFIER);
+ return IDENTIFIER;
}
case ',':
- return (COMMA);
+ return COMMA;
case ':':
- return (COLON);
+ return COLON;
case ';':
- return (SEMICOLON);
+ return SEMICOLON;
case '|':
- return (BAR);
+ return BAR;
case '{':
- return (LEFT_CURLY);
+ return LEFT_CURLY;
case '=':
do
if (c == '{')
{
strcpy(token_buffer, "={");
- return(LEFT_CURLY);
+ return LEFT_CURLY;
}
else
{
ungetc(c, finput);
- return(ILLEGAL);
+ return ILLEGAL;
}
case '<':
c = getc(finput);
}
*p = 0;
- return (TYPENAME);
+ return TYPENAME;
case '%':
- return (parse_percent_token());
+ return parse_percent_token();
default:
- return (ILLEGAL);
+ return ILLEGAL;
}
}
set. A retval action returns the code.
*/
struct percent_table_struct {
- char *name;
+ const char *name;
void *setflag;
int retval;
} percent_table[] =
switch (c)
{
case '%':
- return (TWO_PERCENTS);
+ return TWO_PERCENTS;
case '{':
- return (PERCENT_LEFT_CURLY);
+ return PERCENT_LEFT_CURLY;
case '<':
- return (LEFT);
+ return LEFT;
case '>':
- return (RIGHT);
+ return RIGHT;
case '2':
- return (NONASSOC);
+ return NONASSOC;
case '0':
- return (TOKEN);
+ return TOKEN;
case '=':
- return (PREC);
+ return PREC;
}
if (!isalpha(c))
- return (ILLEGAL);
+ return ILLEGAL;
p = token_buffer;
*p++ = '%';