OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [lcc/] [lburg/] [lburg.h] - Blame information for rev 18

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 hellwig
#ifndef BURG_INCLUDED
2
 
3
#define BURG_INCLUDED
4
 
5
 
6
 
7
/* $Id: lburg.h,v 2.1 1994/11/30 21:53:18 drh Exp $ */
8
 
9
/* iburg.c: */
10
 
11
extern void *alloc(int nbytes);
12
 
13
 
14
 
15
typedef enum { TERM=1, NONTERM } Kind;
16
 
17
typedef struct rule *Rule;
18
 
19
typedef struct term *Term;
20
 
21
struct term {           /* terminals: */
22
 
23
        char *name;             /* terminal name */
24
 
25
        Kind kind;              /* TERM */
26
 
27
        int esn;                /* external symbol number */
28
 
29
        int arity;              /* operator arity */
30
 
31
        Term link;              /* next terminal in esn order */
32
 
33
        Rule rules;             /* rules whose pattern starts with term */
34
 
35
};
36
 
37
 
38
 
39
typedef struct nonterm *Nonterm;
40
 
41
struct nonterm {        /* nonterminals: */
42
 
43
        char *name;             /* nonterminal name */
44
 
45
        Kind kind;              /* NONTERM */
46
 
47
        int number;             /* identifying number */
48
 
49
        int lhscount;           /* # times nt appears in a rule lhs */
50
 
51
        int reached;            /* 1 iff reached from start nonterminal */
52
 
53
        Rule rules;             /* rules w/nonterminal on lhs */
54
 
55
        Rule chain;             /* chain rules w/nonterminal on rhs */
56
 
57
        Nonterm link;           /* next terminal in number order */
58
 
59
};
60
 
61
extern Nonterm nonterm(char *id);
62
 
63
extern Term term(char *id, int esn);
64
 
65
 
66
 
67
typedef struct tree *Tree;
68
 
69
struct tree {           /* tree patterns: */
70
 
71
        void *op;               /* a terminal or nonterminal */
72
 
73
        Tree left, right;       /* operands */
74
 
75
        int nterms;             /* number of terminal nodes in this tree */
76
 
77
};
78
 
79
extern Tree tree(char *op, Tree left, Tree right);
80
 
81
 
82
 
83
struct rule {           /* rules: */
84
 
85
        Nonterm lhs;            /* lefthand side nonterminal */
86
 
87
        Tree pattern;           /* rule pattern */
88
 
89
        int ern;                /* external rule number */
90
 
91
        int packed;             /* packed external rule number */
92
 
93
        int cost;               /* cost, if a constant */
94
 
95
        char *code;             /* cost, if an expression */
96
 
97
        char *template;         /* assembler template */
98
 
99
        Rule link;              /* next rule in ern order */
100
 
101
        Rule next;              /* next rule with same pattern root */
102
 
103
        Rule chain;             /* next chain rule with same rhs */
104
 
105
        Rule decode;            /* next rule with same lhs */
106
 
107
        Rule kids;              /* next rule with same _kids pattern */
108
 
109
};
110
 
111
extern Rule rule(char *id, Tree pattern, char *template, char *code);
112
 
113
 
114
 
115
/* gram.y: */
116
 
117
void yyerror(char *fmt, ...);
118
 
119
int yyparse(void);
120
 
121
void yywarn(char *fmt, ...);
122
 
123
extern int errcnt;
124
 
125
extern FILE *infp;
126
 
127
extern FILE *outfp;
128
 
129
 
130
 
131
#endif
132
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.