ack/util/LLgen/src/extern.h
George Koehler 8bb395b147 LLgen: use size_t, reduce warnings, other small changes
Use C89 size_t for sizes from sizeof() or to malloc() or realloc().
Remove obsolete (unsigned) casts.  Sizes were unsigned int in
traditional C but are size_t in C89.

Silence some clang warnings.  Add the second pair of round brackets in
`while ((ff = ff->ff_next))` to silence -Wparentheses.  Change
`if (nc_first(...))/*nothing*/;` to `(void)nc_first(...);` to silence
-Wempty-body.  The code in compute.c nc_first() had the form
`if (x) if (y) s; else t;`.  The old indentation (before 10717cc)
suggests that the "else" belongs to the 2nd "if", so add braces like
`if (x) { if (y) s; else t; }` to silence -Wdangling-else.

Shuffle extern function declarations.  Add missing declaration for
LLparse().  Stop declaring RENAME(); it doesn't exist.  Move some
declarations from main.c to extern.h, so the C compiler may check that
the declarations are compatible with the function definitions.

Assume that standard C89 remove() is available and doesn't need the
UNLINK() wrapper.

In lib/incl, don't need to include <stdio.h> nor <stdlib.h> to use
assert().

Remove alloc.h.  If you don't clean your build, then an outdated
BUILDDIR/obj/util/LLgen/headers/alloc.h will survive but should not
cause harm, because nothing includes it.  Don't need to remove alloc.h
from util/LLgen/distr.sh, because it isn't there.

Run the bootstrap to rebuild LLgen.c, Lpars.c, tokens.c.
2019-10-22 15:32:23 -04:00

133 lines
3.4 KiB
C

/* Copyright (c) 1991 by the Vrije Universiteit, Amsterdam, the Netherlands.
* For full copyright and restrictions on use see the file COPYING in the top
* level of the LLgen tree.
*/
#ifndef EXTERN_H_
#define EXTERN_H_
/*
* L L G E N
*
* An Extended LL(1) Parser Generator
*
* Author : Ceriel J.H. Jacobs
*/
/*
* $Id$
* Miscellanious constants and
* some variables that are visible in more than one file
*/
# include "types.h"
# define LTEXTSZ 256 /* Size of longest token */
/*
* options for the identifier search routine
*/
# define ENTERING 1
# define BOTH 2
/*
* Now for some declarations
*/
extern char ltext[]; /* input buffer */
extern int nnonterms; /* number of nonterminals */
extern int ntokens; /* number of terminals */
extern int nterms; /* number of terms */
extern int nalts; /* number of alternatives */
extern p_start start; /* will contain startsymbols */
#ifdef NON_CORRECTING
extern int nsubstarts; /* number of subparserstarts */
extern p_set start_firsts; /* Will contain the union of first sets of
startsymbols when -n -s option is on */
#endif
extern int linecount; /* line number */
extern int assval; /* to create difference between literals
* and other terminals
*/
extern p_nont nonterms; /* the nonterminal array */
extern p_nont maxnt; /* is filled up until here */
extern p_token tokens; /* the token array */
extern p_token maxt; /* is filled up until here */
extern int norder, torder;
/* order of nonterminals in the grammar,
* important because actions are copied to
* a temporary file in the order in which they
* were read
*/
extern string e_noopen; /* Error message string used often */
extern int verbose; /* Level of verbosity */
extern int wflag; /* warnings? */
extern string lexical; /* name of lexical analyser */
extern string prefix; /* prefix of externals */
extern string onerror; /* name of user error handler */
extern int ntneeded; /* ntneeded = 1 if nonterminals are included
* in the sets.
*/
extern int ntprint; /* ntprint = 1 if they must be printed too in
* the LL.output file (-x option)
*/
# ifndef NDEBUG
extern int debug;
# endif /* not NDEBUG */
extern p_file files,pfile; /* pointers to file structure.
* "files" points to the start of the
* list */
extern p_file maxfiles;
extern string LLgenid; /* LLgen identification string */
extern t_token lextoken; /* the current token */
extern int nerrors;
extern string rec_file, incl_file;
#ifdef NON_CORRECTING
extern string nc_rec_file, nc_incl_file;
#endif
extern int low_percentage, high_percentage;
extern int min_cases_for_jmptable;
extern int jmptable_option;
#ifdef NON_CORRECTING
extern int non_corr;
extern int subpars_sim;
extern p_gram illegal_gram;
#endif
extern int strip_grammar;
extern int in_production;
/* LLgen.g */
void LLparse(void);
/* check.c */
void conflchecks(void);
/* compute.c */
void do_compute(void);
int empty(p_gram);
int t_safety(int, int, int, int);
int t_after(int, int, int);
/* gencode.c */
void gencode(int);
/* machdep.c */
void TMPNAM(string);
string libpath(string);
/* main.c */
void error(int lineno,string s,string t);
void warning(int lineno,string s,string t);
void fatal(int lineno,string s,string t);
void copyfile(string);
void install(string, string);
/* name.c */
void name_init(void);
string store(string);
p_gram search(int, string, int);
/* reach.c */
void co_reach(void);
#endif /* EXTERN_H_ */