spaces replaced by tabs
This commit is contained in:
parent
7f6d1911e2
commit
e35b40b793
|
@ -38,15 +38,15 @@ static p_order order,
|
||||||
maxorder;
|
maxorder;
|
||||||
static p_term t_list;
|
static p_term t_list;
|
||||||
static int t_cnt;
|
static int t_cnt;
|
||||||
static p_gram alt_table;
|
static p_gram alt_table;
|
||||||
static int n_alts;
|
static int n_alts;
|
||||||
static int max_alts;
|
static int max_alts;
|
||||||
#define ALTINCR 32
|
#define ALTINCR 32
|
||||||
|
|
||||||
static p_gram rule_table;
|
static p_gram rule_table;
|
||||||
static int n_rules;
|
static int n_rules;
|
||||||
static int max_rules;
|
static int max_rules;
|
||||||
#define RULEINCR 32
|
#define RULEINCR 32
|
||||||
|
|
||||||
/* Here are defined : */
|
/* Here are defined : */
|
||||||
STATIC p_order neworder();
|
STATIC p_order neworder();
|
||||||
|
@ -76,12 +76,12 @@ neworder(index) {
|
||||||
|
|
||||||
p_init()
|
p_init()
|
||||||
{
|
{
|
||||||
alt_table = (p_gram )alloc(ALTINCR*sizeof(t_gram));
|
alt_table = (p_gram )alloc(ALTINCR*sizeof(t_gram));
|
||||||
n_alts = 0;
|
n_alts = 0;
|
||||||
max_alts = ALTINCR;
|
max_alts = ALTINCR;
|
||||||
rule_table = (p_gram )alloc(RULEINCR*sizeof(t_gram));
|
rule_table = (p_gram )alloc(RULEINCR*sizeof(t_gram));
|
||||||
n_rules = 0;
|
n_rules = 0;
|
||||||
max_rules = RULEINCR;
|
max_rules = RULEINCR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ def { register string p; }
|
||||||
* A token declaration
|
* A token declaration
|
||||||
*/
|
*/
|
||||||
| C_START C_IDENT
|
| C_START C_IDENT
|
||||||
{ p = store(lextoken.t_string); }
|
{ p = store(lextoken.t_string); }
|
||||||
',' C_IDENT ';'
|
',' C_IDENT ';'
|
||||||
/*
|
/*
|
||||||
* A start symbol declaration
|
* A start symbol declaration
|
||||||
|
@ -168,7 +168,7 @@ rule { register p_nont p;
|
||||||
* grammar for a production rule
|
* grammar for a production rule
|
||||||
*/
|
*/
|
||||||
C_IDENT { temp = search(NONTERM,lextoken.t_string,BOTH);
|
C_IDENT { temp = search(NONTERM,lextoken.t_string,BOTH);
|
||||||
p = &nonterms[g_getcont(temp)];
|
p = &nonterms[g_getcont(temp)];
|
||||||
if (p->n_rule) {
|
if (p->n_rule) {
|
||||||
error(linecount,
|
error(linecount,
|
||||||
"Nonterminal %s already defined", lextoken.t_string);
|
"Nonterminal %s already defined", lextoken.t_string);
|
||||||
|
@ -183,7 +183,7 @@ rule { register p_nont p;
|
||||||
p->n_count = acount;
|
p->n_count = acount;
|
||||||
acount = 0;
|
acount = 0;
|
||||||
p->n_lineno = linecount;
|
p->n_lineno = linecount;
|
||||||
}
|
}
|
||||||
[ params(2) { p->n_flags |= PARAMS;
|
[ params(2) { p->n_flags |= PARAMS;
|
||||||
if (nparams > 15) {
|
if (nparams > 15) {
|
||||||
error(linecount,"Too many parameters");
|
error(linecount,"Too many parameters");
|
||||||
|
@ -198,7 +198,7 @@ rule { register p_nont p;
|
||||||
* Do not use p->n_rule now! The nonterms array
|
* Do not use p->n_rule now! The nonterms array
|
||||||
* might have been re-allocated.
|
* might have been re-allocated.
|
||||||
*/
|
*/
|
||||||
{ nonterms[g_getcont(temp)].n_rule = rr;}
|
{ nonterms[g_getcont(temp)].n_rule = rr;}
|
||||||
;
|
;
|
||||||
|
|
||||||
action(int n;)
|
action(int n;)
|
||||||
|
@ -218,7 +218,7 @@ productions(p_gram *p;)
|
||||||
int conflres = 0;
|
int conflres = 0;
|
||||||
int t = 0;
|
int t = 0;
|
||||||
int haddefault = 0;
|
int haddefault = 0;
|
||||||
int altcnt = 0;
|
int altcnt = 0;
|
||||||
int o_lc, n_lc;
|
int o_lc, n_lc;
|
||||||
} :
|
} :
|
||||||
{ o_lc = linecount; }
|
{ o_lc = linecount; }
|
||||||
|
@ -227,11 +227,11 @@ productions(p_gram *p;)
|
||||||
[
|
[
|
||||||
[ '|' { n_lc = linecount; }
|
[ '|' { n_lc = linecount; }
|
||||||
simpleproduction(&prod,&t)
|
simpleproduction(&prod,&t)
|
||||||
{ if (n_alts >= max_alts-2) {
|
{ if (n_alts >= max_alts-2) {
|
||||||
alt_table = (p_gram ) ralloc(
|
alt_table = (p_gram ) ralloc(
|
||||||
(p_mem) alt_table,
|
(p_mem) alt_table,
|
||||||
(max_alts+=ALTINCR)*sizeof(t_gram));
|
(max_alts+=ALTINCR)*sizeof(t_gram));
|
||||||
}
|
}
|
||||||
if (t & DEF) {
|
if (t & DEF) {
|
||||||
if (haddefault) {
|
if (haddefault) {
|
||||||
error(n_lc,
|
error(n_lc,
|
||||||
|
@ -240,7 +240,7 @@ productions(p_gram *p;)
|
||||||
haddefault = 1;
|
haddefault = 1;
|
||||||
}
|
}
|
||||||
mkalt(*p,conflres,o_lc,&alt_table[n_alts++]);
|
mkalt(*p,conflres,o_lc,&alt_table[n_alts++]);
|
||||||
altcnt++;
|
altcnt++;
|
||||||
o_lc = n_lc;
|
o_lc = n_lc;
|
||||||
conflres = t;
|
conflres = t;
|
||||||
t = 0;
|
t = 0;
|
||||||
|
@ -250,11 +250,11 @@ productions(p_gram *p;)
|
||||||
error(n_lc,
|
error(n_lc,
|
||||||
"Resolver on last alternative not allowed");
|
"Resolver on last alternative not allowed");
|
||||||
}
|
}
|
||||||
mkalt(*p,conflres,n_lc,&alt_table[n_alts++]);
|
mkalt(*p,conflres,n_lc,&alt_table[n_alts++]);
|
||||||
altcnt++;
|
altcnt++;
|
||||||
g_settype((&alt_table[n_alts]),EORULE);
|
g_settype((&alt_table[n_alts]),EORULE);
|
||||||
*p = copyrule(&alt_table[n_alts-altcnt],altcnt+1);
|
*p = copyrule(&alt_table[n_alts-altcnt],altcnt+1);
|
||||||
}
|
}
|
||||||
|
|
|
|
||||||
{ if (conflres & ~DEF) {
|
{ if (conflres & ~DEF) {
|
||||||
error(o_lc,
|
error(o_lc,
|
||||||
|
@ -308,15 +308,15 @@ simpleproduction(p_gram *p; register int *conflres;)
|
||||||
/*
|
/*
|
||||||
* Optional conflict reslover
|
* Optional conflict reslover
|
||||||
*/
|
*/
|
||||||
C_IF expr { *conflres |= COND; }
|
C_IF expr { *conflres |= COND; }
|
||||||
| C_PREFER { *conflres |= PREFERING; }
|
| C_PREFER { *conflres |= PREFERING; }
|
||||||
| C_AVOID { *conflres |= AVOIDING; }
|
| C_AVOID { *conflres |= AVOIDING; }
|
||||||
]?
|
]?
|
||||||
[ %persistent elem(&elem)
|
[ %persistent elem(&elem)
|
||||||
{ if (n_rules >= max_rules-2) {
|
{ if (n_rules >= max_rules-2) {
|
||||||
rule_table = (p_gram) ralloc(
|
rule_table = (p_gram) ralloc(
|
||||||
(p_mem) rule_table,
|
(p_mem) rule_table,
|
||||||
(max_rules+=RULEINCR)*sizeof(t_gram));
|
(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||||
}
|
}
|
||||||
kind = FIXED;
|
kind = FIXED;
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
|
@ -324,8 +324,8 @@ simpleproduction(p_gram *p; register int *conflres;)
|
||||||
[ repeats(&kind, &cnt)
|
[ repeats(&kind, &cnt)
|
||||||
{ if (g_gettype(&elem) != TERM) {
|
{ if (g_gettype(&elem) != TERM) {
|
||||||
rule_table[n_rules] = elem;
|
rule_table[n_rules] = elem;
|
||||||
g_settype((&rule_table[n_rules+1]),EORULE);
|
g_settype((&rule_table[n_rules+1]),EORULE);
|
||||||
mkterm(copyrule(&rule_table[n_rules],2),
|
mkterm(copyrule(&rule_table[n_rules],2),
|
||||||
0,
|
0,
|
||||||
elem.g_lineno,
|
elem.g_lineno,
|
||||||
&elem);
|
&elem);
|
||||||
|
@ -340,19 +340,19 @@ simpleproduction(p_gram *p; register int *conflres;)
|
||||||
g_gettype(q->t_rule) != EORULE) {
|
g_gettype(q->t_rule) != EORULE) {
|
||||||
while (g_gettype(q->t_rule) != EORULE) {
|
while (g_gettype(q->t_rule) != EORULE) {
|
||||||
rule_table[n_rules++] = *q->t_rule++;
|
rule_table[n_rules++] = *q->t_rule++;
|
||||||
elmcnt++;
|
elmcnt++;
|
||||||
if (n_rules >= max_rules-2) {
|
if (n_rules >= max_rules-2) {
|
||||||
rule_table = (p_gram) ralloc(
|
rule_table = (p_gram) ralloc(
|
||||||
(p_mem) rule_table,
|
(p_mem) rule_table,
|
||||||
(max_rules+=RULEINCR)*sizeof(t_gram));
|
(max_rules+=RULEINCR)*sizeof(t_gram));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elem = *--(q->t_rule);
|
elem = *--(q->t_rule);
|
||||||
n_rules--;
|
n_rules--;
|
||||||
elmcnt--;
|
elmcnt--;
|
||||||
if (q == t_list - 1) {
|
if (q == t_list - 1) {
|
||||||
t_list--;
|
t_list--;
|
||||||
nterms--;
|
nterms--;
|
||||||
t_cnt++;
|
t_cnt++;
|
||||||
}
|
}
|
||||||
termdeleted = 1;
|
termdeleted = 1;
|
||||||
|
@ -383,24 +383,24 @@ simpleproduction(p_gram *p; register int *conflres;)
|
||||||
}
|
}
|
||||||
termdeleted = 0;
|
termdeleted = 0;
|
||||||
elmcnt++;
|
elmcnt++;
|
||||||
rule_table[n_rules++] = elem;
|
rule_table[n_rules++] = elem;
|
||||||
}
|
}
|
||||||
]* { register p_term q;
|
]* { register p_term q;
|
||||||
|
|
||||||
g_settype((&rule_table[n_rules]),EORULE);
|
g_settype((&rule_table[n_rules]),EORULE);
|
||||||
*p = 0;
|
*p = 0;
|
||||||
n_rules -= elmcnt;
|
n_rules -= elmcnt;
|
||||||
if (g_gettype(&rule_table[n_rules]) == TERM &&
|
if (g_gettype(&rule_table[n_rules]) == TERM &&
|
||||||
elmcnt == 1) {
|
elmcnt == 1) {
|
||||||
q = g_getterm(&rule_table[n_rules]);
|
q = g_getterm(&rule_table[n_rules]);
|
||||||
if (r_getkind(q) == FIXED &&
|
if (r_getkind(q) == FIXED &&
|
||||||
r_getnum(q) == 0) {
|
r_getnum(q) == 0) {
|
||||||
*p = q->t_rule;
|
*p = q->t_rule;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!*p) *p = copyrule(&rule_table[n_rules],
|
if (!*p) *p = copyrule(&rule_table[n_rules],
|
||||||
elmcnt+1);
|
elmcnt+1);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -441,12 +441,12 @@ elem (register p_gram pres;)
|
||||||
]?
|
]?
|
||||||
productions(&p1)
|
productions(&p1)
|
||||||
']' {
|
']' {
|
||||||
mkterm(p1,t,ln,pres);
|
mkterm(p1,t,ln,pres);
|
||||||
}
|
}
|
||||||
|
|
|
|
||||||
C_IDENT { pe = search(UNKNOWN,lextoken.t_string,BOTH);
|
C_IDENT { pe = search(UNKNOWN,lextoken.t_string,BOTH);
|
||||||
*pres = *pe;
|
*pres = *pe;
|
||||||
}
|
}
|
||||||
[ params(0) { if (nparams > 14) {
|
[ params(0) { if (nparams > 14) {
|
||||||
error(linecount,"Too many parameters");
|
error(linecount,"Too many parameters");
|
||||||
} else g_setnpar(pres,nparams+1);
|
} else g_setnpar(pres,nparams+1);
|
||||||
|
@ -497,12 +497,12 @@ number(int *t;)
|
||||||
if (*t <= 0 || *t >= 8192) {
|
if (*t <= 0 || *t >= 8192) {
|
||||||
error(linecount,"Illegal number");
|
error(linecount,"Illegal number");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
firsts { register string p; }
|
firsts { register string p; }
|
||||||
: C_FIRST C_IDENT
|
: C_FIRST C_IDENT
|
||||||
{ p = store(lextoken.t_string); }
|
{ p = store(lextoken.t_string); }
|
||||||
',' C_IDENT ';'
|
',' C_IDENT ';'
|
||||||
{ /*
|
{ /*
|
||||||
* Store this %first in the list belonging
|
* Store this %first in the list belonging
|
||||||
|
|
Loading…
Reference in a new issue