fset2.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/*
* fset2.c
*
* Compute FIRST sets for full LL(k)
*
* SOFTWARE RIGHTS
*
* We reserve no LEGAL rights to the Purdue Compiler Construction Tool
* Set (PCCTS) -- PCCTS is in the public domain. An individual or
* company may do whatever they wish with source code distributed with
* PCCTS or the code generated by PCCTS, including the incorporation of
* PCCTS, or its output, into commerical software.
*
* We encourage users to develop software with PCCTS. However, we do ask
* that credit is given to us for developing PCCTS. By "credit",
* we mean that if you incorporate our source code into one of your
* programs (commercial product, research project, or otherwise) that you
* acknowledge this fact somewhere in the documentation, research report,
* etc... If you like PCCTS and have developed a nice tool with the
* output, please mention that you developed it using PCCTS. In
* addition, we ask that this header remain intact in our source code.
* As long as these guidelines are kept, we expect to continue enhancing
* this system and expect to make other tools available as they are
* completed.
*
* ANTLR 1.33
* Terence Parr
* Parr Research Corporation
* with Purdue University and AHPCRC, University of Minnesota
* 1989-2001
*/
#include <stdio.h>
#include "pcctscfg.h"
#include <stdlib.h>
#ifdef PCCTS_USE_STDARG
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include "set.h"
#include "syn.h"
#include "hash.h"
#include "generic.h"
#include "dlgdef.h"
/* ick! globals. Used by permute() to track which elements of a set have been used */
static int *findex;
static unsigned **ftbl;
int ConstrainSearch;
int maxk; /* set to initial k upon tree construction request */
/* MR11 make global */
#ifdef __USE_PROTOS
#else
static int tmember_of_context();
#endif
#if TREE_DEBUG
#endif
/* Do root
* Then each sibling
*/
void
#ifdef __USE_PROTOS
#else
#endif
{
}
#ifdef __USE_PROTOS
#else
int MR_tree_matches_constraints(k,constrain,t)
int k;
Tree * t;
#endif
{
int i;
Tree *u;
if (k == 0) return 1;
/* for testing guard predicates: if the guard tree is shorter
than the constraint then it is a match. The reason is that
a guard of (A B) should be equivalent to a guard of (A B . . .)
where "." matches every token. Thus a match which runs out
of tree before constraint is a match.
*/
if (t == NULL) return 1;
"MR_tree_matches_constraints: set_deg != 1");
if (t->token != i) return 0;
if (k-1 == 0) return 1;
return 1;
};
};
return 0;
}
/* check the depth of each primary sibling to see that it is exactly
* k deep. e.g.;
*
* ALT
* |
* A ------- B
* | |
* C -- D E
*
* Remove all branches <= k deep.
*
* Added by TJP 9-23-92 to make the LL(k) constraint mechanism to work.
*/
static int pruneCount=0;
static int prunePeak=200;
Tree *
#ifdef __USE_PROTOS
#else
prune( t, k )
Tree *t;
int k;
#endif
{
pruneCount++;
#if 0
/*** preorder(t); ***/
#endif
};
if ( t == NULL ) {
pruneCount--;
return NULL;
};
if ( k>1 )
{
{
Tfree(t);
pruneCount--;
return r;
}
}
pruneCount--;
return t;
}
/* build a tree (root child1 child2 ... NULL) */
#ifdef PCCTS_USE_STDARG
#else
#endif
{
Tree *w;
#ifndef PCCTS_USE_STDARG
#endif
#ifdef PCCTS_USE_STDARG
#else
#endif
{
#ifdef DUM
/* added "find end of child" thing TJP March 1994 */
#else
w = child;
#endif
}
/* was "root->down = sibling;" */
return root;
}
Tree *
#ifdef __USE_PROTOS
#else
int tok;
#endif
{
static int n=0;
{
/*fprintf(stderr, "tnode: %d more nodes\n", TreeBlockAllocSize);*/
if ( TreeResourceLimit > 0 )
{
if ( (n+TreeBlockAllocSize) >= TreeResourceLimit )
{
}
}
{
}
n += TreeBlockAllocSize;
{
FreeList = p;
}
}
p = FreeList;
TnodesAllocated++; /* MR10 */
TnodesInUse++; /* MR10 */
#ifdef TREE_DEBUG
p->in_use = 1;
p->seq=TnodesAllocated;
if (stop_on_tnode_seq_number == p->seq) {
};
#endif
return p;
}
static Tree *
#ifdef __USE_PROTOS
eofnode( int k )
#else
eofnode( k )
int k;
#endif
{
int i;
for (i=1; i<=k; i++)
{
}
return t;
}
void
#ifdef __USE_PROTOS
#else
_Tfree( t )
Tree *t;
#endif
{
if ( t!=NULL )
{
#ifdef TREE_DEBUG
if (t->seq == stop_on_tnode_seq_number) {
};
t->in_use = 0;
#endif
FreeList = t;
TnodesInUse--; /* MR10 */
}
}
/* tree duplicate */
Tree *
#ifdef __USE_PROTOS
#else
tdup( t )
Tree *t;
#endif
{
Tree *u;
return u;
}
/* tree duplicate (assume tree is a chain downwards) */
Tree *
#ifdef __USE_PROTOS
tdup_chain( Tree *t )
#else
tdup_chain( t )
Tree *t;
#endif
{
Tree *u;
return u;
}
Tree *
#ifdef __USE_PROTOS
#else
tappend( t, u )
Tree *t;
Tree *u;
#endif
{
Tree *w;
/*** fprintf(stderr, "tappend(");
*** preorder(t); fprintf(stderr, ",");
*** preorder(u); fprintf(stderr, " )\n");
*/
if ( t == NULL ) return u;
w->right = u;
return t;
}
/* dealloc all nodes in a tree */
void
#ifdef __USE_PROTOS
#else
Tfree( t )
Tree *t;
#endif
{
if ( t == NULL ) return;
_Tfree( t );
}
/* find all children (alts) of t that require remaining_k nodes to be LL_k
* tokens long.
*
* t-->o
* |
* a1--a2--...--an <-- LL(1) tokens
* | | |
* b1 b2 ... bn <-- LL(2) tokens
* | | |
* . . .
* . . .
* z1 z2 ... zn <-- LL(LL_k) tokens
*
* We look for all [Ep] needing remaining_k nodes and replace with u.
* u is not destroyed or actually used by the tree (a copy is made).
*/
Tree *
#ifdef __USE_PROTOS
#else
tlink( t, u, remaining_k )
Tree *t;
Tree *u;
int remaining_k;
#endif
{
Tree *p;
/*fprintf(stderr, "tlink: u is:"); preorder(u); fprintf(stderr, "\n");*/
{
if ( u == NULL ) {
/* MR10 */ _Tfree(t);
/* MR10 */ return tt;
};
p = tdup( u );
_Tfree( t );
return p;
}
return t;
}
/* remove as many ALT nodes as possible while still maintaining semantics */
Tree *
#ifdef __USE_PROTOS
#else
tshrink( t )
Tree *t;
#endif
{
{
{
_Tfree(t);
return u; /* remove useless alts */
}
return t;
}
/* (? (ALT (? ...)) s) ==> (? (? ...) s) where s = sibling, ? = match any */
{
_Tfree( t );
return u;
}
/* (? (A (ALT t)) s) ==> (? (A t) s) where A is a token; s,t siblings */
{
t->down = u;
return t;
}
return t;
}
Tree *
#ifdef __USE_PROTOS
#else
tflatten( t )
Tree *t;
#endif
{
{
Tree *u;
/* find tail of children */
u = t->down;
_Tfree( t );
return u;
}
return t;
}
Tree *
#ifdef __USE_PROTOS
#else
Junction *p;
int k;
#endif
{
#ifdef DBG_TRAV
#endif
/* MR14 */ warnFL(
/* MR14 */ "not possible to compute follow set for alpha in an \"(alpha)? beta\" block. ",
/* MR14 */ MR_alphaBetaTraceReport();
/* MR14 */ };
/* MR14 */ if (p->alpha_beta_guess_end) {
/* MR14 */ return NULL;
/* MR14 */ }
{
}
/* MR10 */ if (MR_MaintainBackTrace) {
/* MR10 */ };
/* MR10 */ if (MR_MaintainBackTrace) {
/* MR10 */ };
{
/* if this is one of the added optional alts for (...)+ then break */
else
{
/* MR10 */ if (MR_MaintainBackTrace) {
/* MR10 */ };
/* MR10 */ if (MR_MaintainBackTrace) {
/* MR10 */ };
}
}
#ifdef DBG_TREES
#endif
return r;
}
{
if ( p->halt ) /* don't want FOLLOW here? */
{
/**** if ( ContextGuardTRAV ) return NULL; ****/
t->v.rk = k;
return t;
}
/* if no FOLLOW assume k EOF's */
}
/* MR14 */ }
/* MR14 */ }
{
/* MR10 */ if (MR_MaintainBackTrace) {
/* MR10 */ };
/* M14 */ } else {
/* M14 */ }
/* MR10 */ if (MR_MaintainBackTrace) {
/* MR10 */ };
return t;
}
/* MR10 */ if (MR_MaintainBackTrace) {
/* MR10 */ };
/* M14 */ } else {
/* M14 */ }
/* MR10 */ if (MR_MaintainBackTrace) {
/* MR10 */ };
}
Tree *
#ifdef __USE_PROTOS
#else
RuleRefNode *p;
int k;
#endif
{
int k2;
Junction *r;
int save_halt;
#ifdef DBG_TRAV
#endif
if ( q == NULL )
{
return t;
}
/* MR10 */ if (MR_MaintainBackTrace) {
/* MR10 */ };
/* MR10 */ if (MR_MaintainBackTrace) {
/* MR10 */ };
#ifdef DBG_TREES
#endif
t = tshrink( t );
/* MR10 */ if (MR_MaintainBackTrace) {
/* MR10 */ };
/* MR10 */ if (MR_MaintainBackTrace) {
/* MR10 */ };
Tfree(u); /* MR10 */
}
return t;
}
Tree *
#ifdef __USE_PROTOS
#else
TokNode *p;
int k;
#endif
{
if (ConstrainSearch) {
if (MR_AmbSourceSearch) {
} else {
};
}
#ifdef DBG_TRAV
if ( ConstrainSearch ) {
}
#endif
/* is it a meta token (set of tokens)? */
{
unsigned e=0;
set a;
if ( ConstrainSearch ) {
if (set_nil(a)) { /* MR10 */
set_free(a); /* MR11 */
return NULL; /* MR10 */
}; /* MR10 */
} else {
};
{
e = set_int(a);
n = tnode(e);
}
set_free( a );
}
{
/* fprintf(stderr, "ignoring token %s(%d)\n", TerminalString(p->token),
k);*/
return NULL;
}
else {
};
/* MR10 */ if (MR_MaintainBackTrace) {
/* MR10 */ if (k == 1) {
/* MR13 */ if (MR_SuppressSearch) {
/* MR13 */ MR_suppressSearchReport();
/* MR13 */ } else {
/* MR10 */ MR_backTraceReport();
/* MR13 */ };
/* MR11 */ return NULL;
/* MR10 */ };
/* MR10 */ };
if ( k == 1 ) return tset;
if (MR_MaintainBackTrace) {
};
if (MR_MaintainBackTrace) {
Tfree(t);
return NULL;
};
/* here, we are positive that, at least, this tree will not contribute
* to the LL(2) tree since it will be too shallow, IF t==NULL.
* If doing a context guard walk, then don't prune.
*/
{
return NULL;
}
#ifdef DBG_TREES
#endif
/* if single token root, then just make new tree and return */
/* MR10 - set_nil(p->tset) isn't a good test because of ConstraintSearch */
/* here we must make a copy of t as a child of each element of the tset;
* e.g., "T1..T3 A" would yield ( nil ( T1 A ) ( T2 A ) ( T3 A ) )
*/
{
/* make a copy of t and hook it onto bottom of u */
}
Tfree( t );
#ifdef DBG_TREES
#endif
return tset;
}
Tree *
#ifdef __USE_PROTOS
#else
ActionNode *p;
int k;
#endif
{
int i;
/* fprintf(stderr, "tAction\n"); */
/* An MR_SuppressSearch is looking for things that can be
reached even when the predicate is false.
There are three kinds of predicates:
plain: r1: <<p>>? r2
guarded: r1: (A)? => <<p>>? r2
ampersand style: r1: (A)? && <<p>>? r2
Of the three kinds of predicates, only a guard predicate
has things which are reachable even when the predicate
is false. To be reachable the constraint must *not*
match the guard.
*/
if (p->is_predicate && MR_SuppressSearch) {
t=NULL;
goto EXIT;
};
if (pred->k == 1) {
t=NULL;
goto EXIT;
};
} else {
t=NULL;
goto EXIT;
};
}
};
/* The ampersand predicate differs from the
other predicates because its first set
is a subset of the first set behind the predicate
r1: (A)? && <<p>>? r2 ;
r2: A | B;
In this case first[1] of r1 is A, even
though first[1] of r2 is {A B}.
*/
if (k <= pred->k) {
return t;
} else {
if (ConstrainSearch) {
if (MR_AmbSourceSearch) {
"tToken: constrain is not a valid set");
} else {
"tToken: constrain is not a valid set");
};
for (i=1; i <= CLL_k ; i++) {
};
if (pred->k == 1) {
t=NULL;
goto EXIT;
};
} else {
t=NULL;
goto EXIT;
}; /* end loop on i */
}; /* end if on k > pred->k */
}; /* end if on constrain search */
if (t != NULL) {
t=tshrink(t);
t=tflatten(t);
t=tleft_factor(t);
} else {
};
Tfree(t);
t=tAND;
};
goto EXIT;
}; /* end if on ampersand predicate */
EXIT:
for (i=1 ; i <= CLL_k ; i++) {
};
};
return t;
}
/* see if e exists in s as a possible input permutation (e is always a chain) */
int
#ifdef __USE_PROTOS
#else
tmember( e, s )
Tree *e;
Tree *s;
#endif
{
/** fprintf(stderr, "tmember(");
*** preorder(e); fprintf(stderr, ",");
*** preorder(s); fprintf(stderr, " )\n");
*/
{
}
}
/* see if e exists in s as a possible input permutation (e is always a chain);
* Only check s to the depth of e. In other words, 'e' can be a shorter
* sequence than s.
*/
int
#ifdef __USE_PROTOS
#else
tmember_constrained( e, s )
Tree *e;
Tree *s;
#endif
{
/** fprintf(stderr, "tmember_constrained(");
*** preorder(e); fprintf(stderr, ",");
*** preorder(s); fprintf(stderr, " )\n");
**/
return tmember_constrained(e, s->down);
{
return tmember_constrained(e, s->right);
}
return tmember_constrained(e, s->right);
}
/* combine (? (A t) ... (A u) ...) into (? (A t u)) */
Tree *
#ifdef __USE_PROTOS
tleft_factor( Tree *t )
#else
tleft_factor( t )
Tree *t;
#endif
{
/* left-factor what is at this level */
{
trail = u;
v=u->right;
while ( v!=NULL )
{
{
{
}
_Tfree( v );
}
}
}
/* left-factor what is below */
return t;
}
/* remove the permutation p from t if present */
Tree *
#ifdef __USE_PROTOS
#else
trm_perm( t, p )
Tree *t;
Tree *p;
#endif
{
/*
fprintf(stderr, "trm_perm(");
preorder(t); fprintf(stderr, ",");
preorder(p); fprintf(stderr, " )\n");
*/
{
{
_Tfree( t );
return trm_perm(u, p);
}
return t;
}
{
return t;
}
{
_Tfree( t );
return trm_perm(u, p);
}
return t;
}
/* add the permutation 'perm' to the LL_k sets in 'fset' */
void
#ifdef __USE_PROTOS
#else
#endif
{
}
/* for each element of ftbl[k], make it the root of a tree with permute(ftbl[k+1])
* as a child.
*/
Tree *
#ifdef __USE_PROTOS
#else
int k, max_k;
#endif
{
Tree *t, *u;
{
findex[k+1] = 0;
(findex[k])++; /* try next token at this k */
}
return u;
}
/* Compute LL(k) trees for alts alt1 and alt2 of p.
* function result is tree of ambiguous input permutations
*
* ALGORITHM may change to look for something other than LL_k size
* trees ==> maxk will have to change.
*/
Tree *
#ifdef __USE_PROTOS
VerifyAmbig( Junction *alt1, Junction *alt2, unsigned **ft, set *fs, Tree **t, Tree **u, int *numAmbig )
#else
unsigned **ft;
Tree **t;
Tree **u;
int *numAmbig;
#endif
{
Junction *p;
int k;
int tnodes_at_end;
int tnodes_used;
int j;
{
}
*t = tshrink( *t );
*t = tflatten( *t );
*t = tleft_factor( *t ); /* MR10 */
*t = tleft_factor( *t );
/*** fprintf(stderr, "after shrink&flatten&prune&left_factor:"); preorder(*t); fprintf(stderr, "\n");*/
if ( *t == NULL )
{
/*** fprintf(stderr, "TreeIncomplete --> no LL(%d) ambiguity\n", LL_k);*/
Tfree( *t ); /* kill if impossible to have ambig */
*t = NULL;
}
*u = tshrink( *u );
*u = tflatten( *u );
*t = tleft_factor( *t ); /* MR10 */
*u = tleft_factor( *u );
/* fprintf(stderr, "after shrink&flatten&prune&lfactor:"); preorder(*u); fprintf(stderr, "\n");*/
if ( *u == NULL )
{
/* fprintf(stderr, "TreeIncomplete --> no LL(%d) ambiguity\n", LL_k);*/
Tfree( *u );
*u = NULL;
}
k = 0;
{
{
/* fprintf(stderr, "chk perm:"); preorder(perm); fprintf(stderr, "\n");*/
{
/* fprintf(stderr, "ambig upon"); preorder(perm); fprintf(stderr, "\n");*/
k++;
}
}
}
for (j=1; j <= CLL_k ; j++) {
};
};
*numAmbig = k;
/* fprintf(stderr, "final ambig:"); preorder(ambig); fprintf(stderr, "\n");*/
return ambig;
}
static Tree *
#ifdef __USE_PROTOS
bottom_of_chain( Tree *t )
#else
bottom_of_chain( t )
Tree *t;
#endif
{
return t;
}
/*
* Make a tree from k sets where the degree of the first k-1 sets is 1.
*/
Tree *
#ifdef __USE_PROTOS
#else
#endif
{
int i;
unsigned *p,*q;
/* do the degree 1 sets first */
{
}
/* now add the chain of tokens at depth k */
u = bottom_of_chain(t);
/* first one is linked to bottom, then others are sibling linked */
n = tnode(*p++);
u->down = n;
u = u->down;
while ( *p != nil )
{
n = tnode(*p);
u->right = n;
u = u->right;
p++;
}
free((char *)q);
return t;
}
/* create and return the tree of lookahead k-sequences that are in t, but not
* in the context of predicates in predicate list p.
*/
Tree *
#ifdef __USE_PROTOS
#else
Predicate *p;
#endif
{
unsigned **ft;
set b;
int i,k;
for (i=1; i<=CLL_k; i++)
{
set_free(b);
}
{
fatal_internal("out of memory in tdif while checking predicates");
}
#ifdef DBG_TRAV
#endif
{
#ifdef DBG_TRAV
#endif
!tmember_of_context(perm, p) )
{
#ifdef DBG_TRAV
#endif
k++;
else
{
}
}
}
#ifdef DBG_TRAV
#endif
return dif;
}
/* is lookahead sequence t a member of any context tree for any
* predicate in p?
*/
static int
#ifdef __USE_PROTOS
#else
tmember_of_context( t, p )
Tree *t;
Predicate *p;
#endif
{
{
return tmember_of_context(t, p->down);
}
return 0;
}
int
#ifdef __USE_PROTOS
is_single_tuple( Tree *t )
#else
is_single_tuple( t )
Tree *t;
#endif
{
if ( t == NULL ) return 0;
return is_single_tuple(t->down);
}
/* MR10 Check that a context guard contains only allowed things */
/* MR10 (mainly token references). */
#ifdef __USE_PROTOS
#else
int contextGuardOK(p,h,hmax)
Node *p;
int h;
int *hmax;
#endif
{
Junction *j;
if (p == NULL) return 1;
h++;
};
goto Fail;
goto Fail;
} else {
j=(Junction *) p;
/**** j->jtype != aOptBlk && ****/ /* pretty sure this one is allowed */ /* MR11 not any more ! */
errFL("A context guard may not contain an option block: {...} or looping block: (...)* or (...)+",
return 0;
};
/* do both p1 and p2 so use | rather than || */
};
Fail:
errFL("A context guard may contain only Token references - guard will be ignored",
return 0;
}
/*
* Look at a (...)? generalized-predicate context-guard and compute
* either a lookahead set (k==1) or a lookahead tree for k>1. The
* k level is determined by the guard itself rather than the LL_k
* variable. For example, ( A B )? is an LL(2) guard and ( ID )?
* is an LL(1) guard. For the moment, you can only have a single
* tuple in the guard. Physically, the block must look like this
* --o-->TOKEN-->o-->o-->TOKEN-->o-- ... -->o-->TOKEN-->o--
* An error is printed for any other type.
*/
#ifdef __USE_PROTOS
#else
int *msgDone; /* MR10 */
#endif
{
int ok;
int hmax=0;
/* MR10 Check for anything other than Tokens and generic junctions */
*msgDone=0; /* MR10 */
if (! ok) { /* MR10 */
return NULL; /* MR10 */
}; /* MR10 */
if (hmax == 0) {
*msgDone=1;
return NULL;
};
return NULL; /* MR10 */
}; /* MR10 */
p = junc;
{
ConstrainSearch = 0;
ContextGuardTRAV = 1;
ContextGuardTRAV = 0;
t = tshrink( t );
t = tflatten( t );
t = tleft_factor( t );
/*
fprintf(stderr, "ctx guard:");
preorder(t);
fprintf(stderr, "\n");
*/
}
else
{
/*
fprintf(stderr, "LL(1) ctx guard is:");
s_fprT(stderr, scontext);
fprintf(stderr, "\n");
*/
}
return pred;
}
/* MR13
When the context guard is originally computed the
meta-tokens are not known.
*/
#ifdef __USE_PROTOS
#else
void recomputeContextGuard(pred)
#endif
{
Junction * p;
p=actionNode->guardNodes;
if (pred->k > 1 )
{
ConstrainSearch = 0;
ContextGuardTRAV = 1;
ContextGuardTRAV = 0;
t = tshrink( t );
t = tflatten( t );
t = tleft_factor( t );
}
else
{
}
}
/* MR11 - had enough of flags yet ? */
int MR_AmbSourceSearch=0;
int MR_AmbSourceSearchGroup=0;
int MR_AmbSourceSearchChoice=0;
int MR_AmbSourceSearchLimit=0;
int MR_matched_AmbAidRule=0;
static int *tokensInChain=NULL;
void MR_traceAmbSourceKclient()
{
int i;
int save_ConstrainSearch;
Tree *t;
};
for (i=1 ; i <= MR_AmbSourceSearchLimit ; i++) {
set_orel( (unsigned) tokensInChain[i],
&matchSets[0][i]);
set_orel( (unsigned) tokensInChain[i],
&matchSets[1][i]);
};
for (i=0 ; i < 2 ; i++) {
#if 0
** for (j=1 ; j <= MR_AmbSourceSearchLimit ; j++) {
** };
#endif
t=NULL;
Tfree(t);
};
}
#ifdef __USE_PROTOS
#else
Tree *t;
#endif
{
Tree *u;
} else {
};
return u;
}
#ifdef __USE_PROTOS
#else
void MR_iterateOverTree(t,chain)
Tree *t;
int chain[];
#endif
{
if (t == NULL) return;
} else {
};
chain[0]=0;
}
#ifdef __USE_PROTOS
#else
Tree *t;
#endif
{
int i;
int depth;
int maxDepth;
if (MR_AmbAidRule == NULL) return;
if ( ! (
)
) return;
/* there are no token sets in trees, only in TokNodes */
if (tokensInChain == NULL) {
};
(MR_AmbAidDepth <= LL_k ?
"(-k %d -aa %s %s -aad %d)\n\n" :
"(-k %d -aa %s %s [-k value limits -aad %d])\n\n"),
LL_k,
for (i=0 ; i < 2 ; i++) {
(i+1),
MR_AmbSourceSearchJ[i]->line,
};
if (MR_AmbAidDepth < LL_k) {
} else {
};
} else {
};
};
}
/* this if for k=1 grammars only
this is approximate only because of the limitations of linear
approximation lookahead. Don't want to do a k=3 search when
the user only specified a ck=3 grammar
*/
#ifdef __USE_PROTOS
#else
#endif
{
Junction *p[2];
int i;
int j;
int depth;
if (MR_AmbAidRule == NULL) return;
if ( ! (
)
) return;
(MR_AmbAidDepth <= CLL_k ?
"(-ck %d -aa %s %s -aad %d)\n\n" :
"(-ck %d -aa %s %s [-ck value limits -aad %d])\n\n"),
for (i=0 ; i < 2 ; i++) {
(i+1),
MR_ruleNamePlusOffset( (Node *) p[i]),
};
for (j=1; j <= CLL_k ; j++) {
};
"illegal MR_AmbAidDepth");
for (i=0 ; i < 2 ; i++) {
/*** fprintf(stdout," Choice:%d Depth:%d\n\n",i+1,depth); ***/
};
};
free ( (char *) dup_matchSets);
}
static int itemCount;
void MR_backTraceDumpItemReset() {
itemCount=0;
}
#ifdef __USE_PROTOS
#else
void MR_backTraceDumpItem(f,skip,n)
FILE *f;
int skip;
Node *n;
#endif
{
Junction *j;
ActionNode *a;
switch (n->ntype) {
case nToken:
} else {
};
break;
case nRuleRef:
rrn=(RuleRefNode *)n;
break;
case nAction:
a=(ActionNode *)n;
goto EXIT;
case nJunction:
j=(Junction *)n;
switch (j->jtype) {
case aSubBlk:
if (j->guess) {
break;
};
/****** fprintf(f," %2d %-32s",itemCount,"in (...) block at"); *******/
/****** break; *******/
goto EXIT;
case aOptBlk:
break;
case aLoopBlk:
break;
case EndBlk:
if (j->alpha_beta_guess_end) {
break;
};
goto EXIT;
/****** fprintf(f," %2d %-32s",itemCount,"end of a block at"); *****/
/****** break; *****/
case RuleBlk:
break;
case Generic:
goto EXIT;
case EndRule:
break;
case aPlusBlk:
break;
case aLoopBegin:
goto EXIT;
};
break;
};
EXIT:
return;
}
#ifdef __USE_PROTOS
void MR_backTraceReport(void)
#else
void MR_backTraceReport()
#endif
{
int i;
int match = 0;
int limitMatch;
Node *p;
int depth;
/* Even when doing a k=2 search this routine can get
called when there is only 1 token on the stack.
This is because something like rRuleRef can change
the search value of k from 2 to 1 temporarily.
It does this because the it wants to know the k=1
first set before it does a k=2 search
*/
depth=0;
for (i=0; i < MR_BackTraceStack.count ; i++) {
};
/* MR14 */ if (MR_AmbSourceSearch) {
/* MR14 */ }
/* MR23 THM - Traceback report was being called at the wrong time for -alpha reports */
/* Reported by Arpad Beszedes (beszedes@inf.u-szeged.hu) */
return;
};
};
break;
};
};
/* not sure at the moment why there would be duplicates */
depth=0;
for (i=0; i < MR_BackTraceStack.count ; i++) {
depth++;
if (! MR_AmbAidMultiple) {
} else {
};
};
};
for (i=0; i < MR_BackTraceStack.count ; i++) {
};
for (i=0; i < MR_BackTraceStack.count ; i++) {
};
};
}
#ifdef __USE_PROTOS
#else
#endif
{
}