Next batch of changes!

This commit is contained in:
Godzil
2013-03-20 01:58:06 +01:00
committed by Manoël Trapier
parent a05a174f40
commit 1c4e04de3a
29 changed files with 129 additions and 78 deletions

View File

@@ -13,6 +13,7 @@
# include "tunable.h"
# include "token.h"
# include "Lpars.h"
# include "main.h"
struct token dot; /* current token */
static struct token aside; /* to put currrent token aside, when a token

View File

@@ -14,6 +14,8 @@
#include <string.h>
#include "misc.h"
struct hlist { /* linear list of pattern numbers */
int h_patno;
struct hlist *h_next;
@@ -76,7 +78,7 @@ void printhashtable()
* pointers to them
*/
int i;
struct hlist *p;
/*struct hlist *p;*/
for (i = 1; i <= 128; i++) {
fprintf(genc,"int hash%d[] = { ",i);

13
util/topgen/hash.h Normal file
View File

@@ -0,0 +1,13 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef UTIL_TOPGEN_HASH_H
#define UTIL_TOPGEN_HASH_H
/* util/topgen/hash.c */
void addtohashtable(char *s, int n);
void printhashtable(void);
#endif /* UTIL_TOPGEN_HASH_H */

View File

@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
extern int lineno, newline;
@@ -19,6 +20,9 @@ static int nerrors;
char *linedir = "#line %d \"%s\"\n"; /* format of line directive */
char *inpfile;
/* From Lexer */
void LLparse(void);
int main(int argc, char *argv[])
{
newline = 1;
@@ -44,11 +48,14 @@ int main(int argc, char *argv[])
}
/* VARARGS1 */
void error(char *s, char *s1)
void error(char *s, ...)
{
va_list va;
nerrors++;
fprintf(stderr,"\"%s\", line %d: ",inpfile,lineno);
fprintf(stderr,s,s1);
va_start(va, s);
vfprintf(stderr, s, va);
va_end(va);
putc('\n',stderr);
}

14
util/topgen/main.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef UTIL_TOPGEN_MAIN_H
#define UTIL_TOPGEN_MAIN_H
/* util/topgen/main.c */
int main(int argc, char *argv[]);
void error(char *s, ...);
int onlyspace(char *s);
#endif /* UTIL_TOPGEN_MAIN_H */

13
util/topgen/pattern.h Normal file
View File

@@ -0,0 +1,13 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef UTIL_TOPGEN_PATTERN_H
#define UTIL_TOPGEN_PATTERN_H
/* util/topgen/pattern.c */
void addpattern(char *str, int l, int np, int nr);
void printpatterns(void);
#endif /* UTIL_TOPGEN_PATTERN_H */

View File

@@ -12,19 +12,20 @@
#include <stdlib.h>
#include <string.h>
#include "symtab.h"
#include "main.h"
struct symtab *idtable, *deftable;
struct symtab *
findident(s, mode, table) char *s; struct symtab **table; {
struct symtab *findident(char *s, int mode, struct symtab **table)
{
/*
* Look for identifier s in the symboltable referred to by *table.
* If mode = LOOKING, no new entry's will be made.
* If mode = ENTERING, a new entry will be made if s is not in the
* table yet, otherwise an error results
*/
register struct symtab *p;
register n;
struct symtab *p;
int n;
if (!*table) { /* No entry for this symbol */
if (mode == LOOKING) return (struct symtab *) 0;

View File

@@ -21,6 +21,9 @@
#include "token.h"
#include "symtab.h"
#include "misc.h"
#include "main.h"
#include "pattern.h"
#include "hash.h"
char idbuf[BUFSIZ], buf[BUFSIZ];
int countid; /* # of variables */