home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pccts.zip / pccts / antlr / dialog.c < prev    next >
C/C++ Source or Header  |  1994-03-31  |  3KB  |  132 lines

  1. /*
  2.  * dialog.c
  3.  *
  4.  * $Id: dialog.c,v 1.2 1993/12/14 20:17:08 parrt Exp parrt $
  5.  * $Revision: 1.2 $
  6.  *
  7.  * dialog manager for -ai (antlr interactive) mode
  8.  *
  9.  * SOFTWARE RIGHTS
  10.  *
  11.  * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
  12.  * Set (PCCTS) -- PCCTS is in the public domain.  An individual or
  13.  * company may do whatever they wish with source code distributed with
  14.  * PCCTS or the code generated by PCCTS, including the incorporation of
  15.  * PCCTS, or its output, into commerical software.
  16.  * 
  17.  * We encourage users to develop software with PCCTS.  However, we do ask
  18.  * that credit is given to us for developing PCCTS.  By "credit",
  19.  * we mean that if you incorporate our source code into one of your
  20.  * programs (commercial product, research project, or otherwise) that you
  21.  * acknowledge this fact somewhere in the documentation, research report,
  22.  * etc...  If you like PCCTS and have developed a nice tool with the
  23.  * output, please mention that you developed it using PCCTS.  In
  24.  * addition, we ask that this header remain intact in our source code.
  25.  * As long as these guidelines are kept, we expect to continue enhancing
  26.  * this system and expect to make other tools available as they are
  27.  * completed.
  28.  *
  29.  * ANTLR 1.20
  30.  * Terence Parr
  31.  * Purdue University
  32.  * With AHPCRC, University of Minnesota
  33.  * 1989-1994
  34.  */
  35. #include <stdio.h>
  36. #ifdef __cplusplus
  37. #ifndef __STDC__
  38. #define __STDC__
  39. #endif
  40. #endif
  41. #include "set.h"
  42. #include "syn.h"
  43. #include "hash.h"
  44. #include "generic.h"
  45. #include "dlgdef.h"
  46.  
  47. #ifdef NOT_USED
  48.  
  49. void
  50. #ifdef __STDC__
  51. AmbiguityDialog( Junction *j, int jtype, Junction *alt1, Junction *alt2, int *CLL_k, int *LL_k)
  52. #else
  53. AmbiguityDialog( j, jtype, alt1, alt2, CLL_k, LL_k )
  54. Junction *j;
  55. int jtype;
  56. Junction *alt1;
  57. Junction *alt2;
  58. int *CLL_k;
  59. int *LL_k;
  60. #endif
  61. {
  62.     int i;
  63.     set *fset;
  64.  
  65.     fset = (set *) calloc( *CLL_k+1, sizeof(set));
  66.     require(fset!=NULL, "cannot allocate fset");
  67.     for (i=1; i<= *CLL_k; i++)
  68.     {
  69.         fset[i] = set_and(alt1->fset[i], alt2->fset[i]);
  70.     }
  71.  
  72.     fprintf(stdout, "\n");
  73.     pLevel = 0;
  74.     pAlt1 = alt1->altnum;
  75.     pAlt2 = alt2->altnum;
  76.  
  77.     if ( jtype==aLoopBlk )
  78.     {
  79.         pLevel = 1;
  80.         if ( pAlt1==1 ) printf("=>");
  81.         printf("\t");
  82.     }
  83.  
  84. #ifdef DUM
  85.     if ( jtype==aLoopBlk )
  86.     {
  87.         pLevel++;
  88.         if ( pLevel==1 )
  89.         {
  90.             if ( pAlt1==1 ) printf("=>");
  91.             printf("\t");
  92.         }
  93.         else printf(" ");
  94.         printf("(");
  95.         if ( pLevel==1 ) printf(" ");
  96.         pJunc(j);
  97.         if ( pLevel>1 ) printf(" ");
  98.         else printf("\n\t");
  99.         printf(")*");
  100.         pLevel--;
  101.         if ( j->end->p1 != NULL ) PRINT(j->end->p1);
  102.     }
  103.     else
  104. #endif
  105.  
  106.     pJunc(j);
  107.     fprintf(stdout, "\n");
  108.  
  109.     fprintf(stdout, ErrHdr, FileStr[alt1->file], alt1->line);
  110.     if ( jtype == aLoopBegin )
  111.         fprintf(stdout, " warning: optional path and alt(s) of (..)* ambiguous upon");
  112.     else
  113.         fprintf(stdout, " warning: alts %d and %d ambiguous upon",
  114.                     alt1->altnum, alt2->altnum);
  115. /*    if ( elevel == 3 )
  116.     {
  117.         preorder(ambig);
  118.         fprintf(stderr, "\n");
  119.         Tfree(ambig);
  120.         return;
  121.     }*/
  122.  
  123.     dumpAmbigMsg(fset, stdout, 1);
  124.  
  125.     fprintf(stdout, "> ");
  126.     getchar();
  127.     for (i=1; i<= *CLL_k; i++) set_free( fset[i] );
  128.     free(fset);
  129. }
  130.  
  131. #endif
  132.