home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pccts1.zip / ANTLR / DIALOG.C < prev    next >
C/C++ Source or Header  |  1993-09-02  |  3KB  |  127 lines

  1. /*
  2.  * dialog.c
  3.  *
  4.  * $Id: dialog.c,v 1.3 1993/08/10 17:10:00 pccts Exp pccts $
  5.  * $Revision: 1.3 $
  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.10
  30.  * Terence Parr
  31.  * Purdue University
  32.  * 1989-1993
  33.  */
  34. #include <stdio.h>
  35. #ifdef __cplusplus
  36. #ifndef __STDC__
  37. #define __STDC__
  38. #endif
  39. #endif
  40. #include "set.h"
  41. #include "syn.h"
  42. #include "hash.h"
  43. #include "generic.h"
  44. #include "dlgdef.h"
  45.  
  46. void
  47. #ifdef __STDC__
  48. AmbiguityDialog( Junction *j, int jtype, Junction *alt1, Junction *alt2, int *CLL_k, int *LL_k)
  49. #else
  50. AmbiguityDialog( j, jtype, alt1, alt2, CLL_k, LL_k )
  51. Junction *j;
  52. int jtype;
  53. Junction *alt1;
  54. Junction *alt2;
  55. int *CLL_k;
  56. int *LL_k;
  57. #endif
  58. {
  59.     int i;
  60.     set *fset;
  61.  
  62.     fset = (set *) calloc( *CLL_k+1, sizeof(set));
  63.     require(fset!=NULL, "cannot allocate fset");
  64.     for (i=1; i<= *CLL_k; i++)
  65.     {
  66.         fset[i] = set_and(alt1->fset[i], alt2->fset[i]);
  67.     }
  68.  
  69.     fprintf(stdout, "\n");
  70.     pLevel = 0;
  71.     pAlt1 = alt1->altnum;
  72.     pAlt2 = alt2->altnum;
  73.  
  74.     if ( jtype==aLoopBlk )
  75.     {
  76.         pLevel = 1;
  77.         if ( pAlt1==1 ) printf("=>");
  78.         printf("\t");
  79.     }
  80.  
  81. #ifdef DUM
  82.     if ( jtype==aLoopBlk )
  83.     {
  84.         pLevel++;
  85.         if ( pLevel==1 )
  86.         {
  87.             if ( pAlt1==1 ) printf("=>");
  88.             printf("\t");
  89.         }
  90.         else printf(" ");
  91.         printf("(");
  92.         if ( pLevel==1 ) printf(" ");
  93.         pJunc(j);
  94.         if ( pLevel>1 ) printf(" ");
  95.         else printf("\n\t");
  96.         printf(")*");
  97.         pLevel--;
  98.         if ( j->end->p1 != NULL ) PRINT(j->end->p1);
  99.     }
  100.     else
  101. #endif
  102.  
  103.     pJunc(j);
  104.     fprintf(stdout, "\n");
  105.  
  106.     fprintf(stdout, ErrHdr, FileStr[alt1->file], alt1->line);
  107.     if ( jtype == aLoopBegin )
  108.         fprintf(stdout, " warning: optional path and alt(s) of (..)* ambiguous upon");
  109.     else
  110.         fprintf(stdout, " warning: alts %d and %d ambiguous upon",
  111.                     alt1->altnum, alt2->altnum);
  112. /*    if ( elevel == 3 )
  113.     {
  114.         preorder(ambig);
  115.         fprintf(stderr, "\n");
  116.         Tfree(ambig);
  117.         return;
  118.     }*/
  119.  
  120.     dumpAmbigMsg(fset, stdout, 1);
  121.  
  122.     fprintf(stdout, "> ");
  123.     getchar();
  124.     for (i=1; i<= *CLL_k; i++) set_free( fset[i] );
  125.     free(fset);
  126. }
  127.