summaryrefslogtreecommitdiff
path: root/support/rail/rail.h
blob: 941a1b819fd033bdad1e541c07f64ed47f539695 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * rail.h - global definitions for rail program
 *
 */

#define RIGHT_ARROW 'r'         /* right arrowhead (prefix for LaTeX macros)*/
#define LEFT_ARROW  'l'         /* right arrowhead (prefix for LaTeX macros)*/
#define NO_ARROW    ' '         /* no arrowhead (prefix for LaTeX macros)*/

#define	UNKNOWN	'?'		/* unknown */
#define	TOKEN	'o'		/* terminal or nonterminal */
#define	TERM	't'		/* terminal */
#define	NTERM	'n'		/* nonterminal */

typedef struct id {
	char *name;		/* identifier */
	struct id *next;	/* link to next entry */
	int kind;		/* UNKNOWN, TOKEN, TERM, NTERM */
} IDTYPE;

#define	EMPTY	'e'
#define	CAT	';'
#define	BAR	'|'
#define	PLUS	'+'
#define	ANNOTE	'a'
#define	IDENT	'i'
#define	STRNG	's'
#define	CR	'c'

#define	MAXLIST	50

typedef struct body {
	int kind;			/* kind */
	struct body *list[MAXLIST];	/* sub-bodies */
	int nlist;			/* number of bodies */
	int entry,exit;			/* entry, exit */
	int ystart;			/* starting y coordinate */
	int ynext;			/* next y coordinate */
	int done;			/* done flag */
	IDTYPE *id;			/* identifier */
	char *text;			/* text */
	char *annot;			/* annotation */
} BODYTYPE;

#define	NULLBODY	((BODYTYPE *)NULL)

typedef struct rule {
	IDTYPE *id;
	BODYTYPE *body;
	struct rule *next;
} RULETYPE;

typedef union {
	IDTYPE *id;	/* identifier */
	int num;	/* number */
	char *text;	/* text */
	BODYTYPE *body;	/* body */
	RULETYPE *rule;	/* rule */
} YYSTYPE;

extern unsigned line;
extern int copy;

extern FILE *outf;

extern int altstar;
extern int anonymous;

extern IDTYPE *errorid;

extern char *mcheck();

extern BODYTYPE *newbody();
extern freebody();
extern int isemptybody();
extern BODYTYPE *addbody();
extern BODYTYPE *revbody();

extern RULETYPE *newrule();
extern freerule();
extern RULETYPE *addrule();
extern outrule();

extern IDTYPE *lookup();
extern delete();

extern undef();
extern redef();
extern error();