home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pccts1.zip / BUGS100 < prev    next >
Text File  |  1993-03-30  |  13KB  |  498 lines

  1.  
  2.  
  3.  
  4.                C u r r e n t  B U G  L i s t
  5.  
  6.                       December 1, 1992
  7.  
  8.  
  9. (1)  Only lexical class START could have over 100 tokens.
  10.  
  11.  
  12. (2)  Ambiguity messages were printing junk when the  grammar  did  not
  13.      end  up in lexclass START at the end of the file. (fix is too big
  14.      for this posting)
  15.  
  16.  
  17. (3)  This bug causes antlr to suffer  segmentation  faults/bus  errors
  18.      when  processing a grammar that has multiple lexical classes (say
  19.      7) and over 200 token definitions.  This is the same as bug (1).
  20.  
  21. The bug is in misc.c at lines 58-64:
  22.  
  23. for (i=0; i<NumLexClasses; i++)
  24. {
  25.   lclass[i].exprs = (char **)
  26.             realloc(lclass[i].exprs, tsize*sizeof(char *));
  27.   require(lclass[i].exprs != NULL, "Ttrack: can't extend ExprStr");
  28.   for (p= &lclass[i].exprs[tsize-more],i=1; i<=more; i++) *p++ = NULL;
  29. }
  30.  
  31. Here is the fix (thanks to Mark Scheevel):
  32.  
  33. for (i=0; i<NumLexClasses; i++)
  34. {
  35.   int j;
  36.   lclass[i].exprs = (char **)
  37.             realloc(lclass[i].exprs, tsize*sizeof(char *));
  38.   require(lclass[i].exprs != NULL, "Ttrack: can't extend ExprStr");
  39.   for (p= &lclass[i].exprs[tsize-more],j=1; j<=more; j++) *p++ =NULL;
  40. }
  41.  
  42. Thanks to Mark Scheevel and  Tom  Reyes  (unisql!treyes@cs.utexas.edu)
  43. for this bug report and fix.
  44.  
  45.  
  46. (4)  When one.c encountered  an  error,  it  printed  random  garbage.
  47.      one.c:  The line in the 'extract()' routine which reads:
  48.  
  49. fprintf(stderr,"unbag: line %d: bad file format: %s\n", stop, line);
  50.  
  51. should read:
  52.  
  53. fprintf(stderr,"unbag: line %d: bad file format: %s\n", line, text);
  54.  
  55. Thanks to Fred Scholldorf (scholldorf@nuclear.physics.sunysb.edu).
  56.  
  57.  
  58.  
  59.  
  60.  
  61.                                                                 Page 1
  62.  
  63.                                                                  PCCTS
  64.  
  65.  
  66. (5)  When compiling antlr on a MC 680x0 system with  gnus  gcc  (2.1),
  67.      you  have  to add -fwriteable-strings to CFLAGS. Otherwise, antlr
  68.      will dump core.
  69.  
  70. From: pia@hotmama.toppoint.de
  71.  
  72.  
  73. (6)  Regarding the C front-end example provided with ANTLR,  line  299
  74.      must be removed from main.c:
  75.  
  76. fprintf(" %s\n", a->data.s.name);
  77.  
  78. which is obviously wrong without a stream parameter and is a duplicate
  79. of the line after it anyway.  Another cut-n-paste error, I guess.
  80.  
  81. (7)  A bug in set.c allowed malloc() and friends to be called  with  a
  82.      size  argument  of 0 which caused problems on some machines.  The
  83.      fix causes malloc() to be called less resulting in  slight  speed
  84.      improvements to DLG, and ANTLR.
  85.  
  86.  
  87. file set.c INSERT
  88.  
  89.     if ( n == 0 ) return t;     /* TJP 4-27-92 fixed for empty set */
  90.  
  91. in func set_and() in context:
  92.  
  93.     n = (b.n > c.n) ? c.n : b.n;
  94. --->[INSERT]
  95.     set_ext(&t, n);
  96.  
  97. and in func set_dif() in context:
  98.  
  99.     n = (b.n <= c.n) ? b.n : c.n ;
  100. --->[INSERT]
  101.     set_ext(&t, b.n);
  102.  
  103. in func set_ex() INSERT
  104.  
  105.         if ( n == 0 ) return;
  106.  
  107. in context:
  108.  
  109.     if ( a->n == 0 )
  110.     {
  111. ------->[INSERT]
  112.         a->setword = (unsigned *) calloc(n, BytesPerWord);
  113.  
  114. Also note that an extra, slightly different copy of set.c was included
  115. in  the  DLG bag.  This version is not used by the makefile in the DLG
  116. directory and can be ignored.
  117.  
  118. (8)  ANTLR generates unknown escape  sequences  in  scan.c  and  err.c
  119.      because  it  dumps  your token definitions verbatim to the output
  120.  
  121.  
  122.  
  123.                                                                 Page 2
  124.  
  125.                                                                  PCCTS
  126.  
  127.  
  128.      files.  You get messages like:
  129.  
  130. err.c:113: warning: unknown escape sequence `\+'
  131.  
  132. One user, ggf@saifr00.cfsat.honeywell.com (Gary  Frederick),  overcame
  133. this by:
  134.  
  135. > I 'escaped' the above lines by doing this to err.c
  136. >      /* 04 */        "\\*/",
  137. >      /* 05 */        "\\>\\>",
  138.  
  139. These are only warnings, but give you "+" instead  of  "\+"  when  you
  140. print a token in your program.
  141.  
  142. (9)  In order to compile with gcc version 1.37.1 you will need  a  new
  143.      version  of  proto.h called proto.h.new which can be obtained via
  144.      this mail server.  In addition, I had to do the following things:
  145.  
  146. o    Use the -fwritable-strings gcc option.
  147.  
  148. o    In file fset2.c at line 25, add
  149.  
  150. #ifdef __STDC__
  151. Tree *tmake(Tree *root, ...);
  152. #else
  153. Tree *tmake();
  154. #endif
  155.  
  156. o    Remove the definition of scarfPAction():
  157.  
  158. char *scarfPAction();
  159.  
  160. from the top of files: antlr.c and scan.c (right  before  #include  of
  161. attrib.h).
  162.  
  163. o    In file trax.h, change
  164.  
  165. #ifdef ANSI
  166.  
  167. to
  168.  
  169. #ifdef __STDC__
  170.  
  171. Also, change the definition of mFree to:
  172.  
  173. void mFree(void *, char *, int);
  174.  
  175. o    In file lexhelp.c, change line 41 to read
  176.  
  177. int begin, end;
  178.  
  179. which changes them from chars to ints.
  180.  
  181.  
  182.  
  183.  
  184.  
  185.                                                                 Page 3
  186.  
  187.                                                                  PCCTS
  188.  
  189.  
  190. o    In file bits.c, line 295 change eMsg1 to eMsgd:
  191.  
  192. require(j<NumLexClasses, eMsgd("No label or expr for token %d",i));
  193.  
  194. o    In file, gen.c, change line 56 to
  195.  
  196. static void dumpRetValAssign(char *, char *);
  197.  
  198. And, add
  199.  
  200. static dumpAfterActions(FILE *output);
  201.  
  202. right after on line 57.  Add the non-ANSI version at line 60
  203.  
  204. static dumpAfterActions();
  205.  
  206. o    In file misc.c, change line 313 to read:
  207.  
  208. void *e;
  209.  
  210. o    In file trax.c in the support/trax directory, change line 401  to
  211.      read:
  212.  
  213. pChk( (char *)p+sizeof(Trax) );
  214.  
  215. Also, change line 232 to read:
  216.  
  217. void *p;
  218.  
  219. I think that that includes everything.  Good luck.
  220.  
  221. (10) The manual references a set of memory allocation  debugging  rou-
  222.      tines called "trax.h".  It indicates that they are in the support
  223.      directory.  This is not the case.  If you are interested, mail to
  224.      'parrt@ecn.purdue.edu' (a human) for a copy.
  225.  
  226. (11) As per the manual, PCCTS had a problem with multiple ANTLR  macro
  227.      invocations.   This has been fixed (we think).  In file dlgauto.h
  228.      in the pccts/h directory make the following additions:
  229.  
  230. zzrdstream( f )
  231. FILE *f;
  232. {
  233.     zzline = 1;
  234.     zzstream_in = f;
  235.     zzfunc_in = NULL;
  236.     zzcharfull = 0;     /* TJP added May 1992 */ <-------- ADD
  237. }
  238.  
  239. zzrdfunc( f )
  240. int (*f)();
  241. {
  242.     zzline = 1;
  243.     zzstream_in = NULL;
  244.  
  245.  
  246.  
  247.                                                                 Page 4
  248.  
  249.                                                                  PCCTS
  250.  
  251.  
  252.     zzfunc_in = f;
  253.     zzcharfull = 0;     /* TJP added May 1992 */ <-------- ADD
  254. }
  255.  
  256. You should be able to do this:
  257.  
  258. parse(f1,f2)
  259. FILE *f1, *f2;
  260. {
  261.      ANTLR(grammar(), f1);
  262.      ANTLR(grammar(), f2);
  263. }
  264.  
  265. Before, the second invocation of the ANTLR macro did not know that  it
  266. needed to get another character before beginning.  Let us know if this
  267. screws up anything  else.   Be  aware  that  switching  between  input
  268. streams  will not work because characters are lost when switching to a
  269. new stream.
  270.  
  271. (12) Character delimiters within ANTLR actions cause problems: e.g.
  272.  
  273.     << '"' >>
  274.  
  275.  
  276. (13) Marlin Prowell found a bug in the parameter passing code  genera-
  277.      tion.  He reports:
  278.      I traced the error to the strmember() routine  (in  lex.c)  which
  279.      uses  too  simple an algorithm to test if one string is contained
  280.      within another.  The routine is only used  to  determine  if  the
  281.      var-part of $var is contained in the parameter or result strings,
  282.      as in:
  283.  
  284.     strmember ("int x, int y", "i");
  285.  
  286. The strmember function will return true if "i" matches any letter, not
  287. just  when "i" matches an entire word.  It should return true when the
  288. second parameter is a *word* in the first parameter.  I include  below
  289. a  revised (and overly cautious) version of strmember.  This fixes the
  290. problem I described above, and PCCTS now produces correct code for the
  291. example.
  292.  
  293.     /* check to see if string e is a word in string s */
  294.     int
  295.     strmember(s, e)
  296.     char *s, *e;
  297.     {
  298.         register char *p;
  299.         require(s!=NULL&&e!=NULL, "strmember: NULL string");
  300.  
  301.         if ( *e==' ' ) return 1;   /* empty string is always member */
  302.         do {
  303.             while ( *s!=' ' && !isalnum(*s) && *s!='_' )
  304.                 ++s;
  305.             p = e;
  306.  
  307.  
  308.  
  309.                                                                 Page 5
  310.  
  311.                                                                  PCCTS
  312.  
  313.  
  314.             while ( *p!=' ' && *p==*s ) {p++; s++;}
  315.             if ( *p==' ' ) {
  316.                 if ( *s==' ' ) return 1;
  317.                 if ( !isalnum (*s) && *s != '_' ) return 1;
  318.             }
  319.             while ( isalnum(*s) || *s == '_' )
  320.                 ++s;
  321.         } while ( *s!=' ' );
  322.         return 0;
  323.     }
  324.  
  325. Marlin Prowell
  326. mbp@nyssa.wa7ipx.ampr.org
  327.  
  328.  
  329. (14) A bug in ANTLR code generation for k>=2 was found.  The  bug  was
  330.      due  to  the grammar analysis phase's inability to detect invalid
  331.      LL(k) FIRST trees.  For example,
  332.  
  333. a   :   A A
  334.     |   b B
  335.     ;
  336.  
  337. b   :   {C} A
  338.     ;
  339.  
  340. generated invalid code:
  341.  
  342.         ...
  343.         if ( (LA(1)==A) && (LA(2)==A) && !(LA(1)==A) ) {
  344.                 zzmatch(A); zzCONSUME;
  345.                 zzmatch(A); zzCONSUME;
  346.         }
  347.         else if ( (LA(1)==A || LA(1)==C) && (LA(2)==A || LA(2)==B) ) {
  348.                 b();
  349.                 zzmatch(B); zzCONSUME;
  350.         }
  351.         ...
  352.  
  353. This has been corrected to generate (in my latest version):
  354.  
  355.         ...
  356.         if ( (LA(1)==A) && (LA(2)==A) ) {
  357.                 zzmatch(A); zzCONSUME;
  358.                 zzmatch(A); zzCONSUME;
  359.         }
  360.         else if ( (LA(1)==A || LA(1)==C) && (LA(2)==A || LA(2)==B) ) {
  361.                 b();
  362.                 zzmatch(B); zzCONSUME;
  363.         }
  364.         ...
  365.  
  366. Terence Parr
  367.  
  368.  
  369.  
  370.  
  371.                                                                 Page 6
  372.  
  373.                                                                  PCCTS
  374.  
  375.  
  376. (15) ANTLR attempts to read from a closed file  sometimes.   This  was
  377.      caused  by  ANTLR's  insistence  upon  always  getting the next k
  378.      tokens of lookahead  instead  of  upon  demand.   Upon  EOF,  the
  379.      current  input  file was closed during the EOF lexical action and
  380.      then ANTLR tried to fill its  lookahead  queue.   This  has  been
  381.      fixed in our version, but appears not to be much trouble for any-
  382.      one since we haven't heard anything.  Next release will have many
  383.      fixes.
  384.  
  385.  
  386. (16) In charptr.h, the macro zzdef0 was incorrect.  The correct  macro
  387.      is:
  388.  
  389. #define zzdef0(a)               {*(a)=NULL;}
  390.  
  391. Also, the zzcr_attr() function didn't check for the out of memory con-
  392. dition.  Add
  393.  
  394.     if ( *a == NULL ) {fprintf(stderr, "zzcr_attr: out of memory!\n"); exit(-1);}
  395.  
  396. right after the call to malloc().
  397.  
  398.  
  399. (17) The PASCAL example expression grammar was incorrect.  Rules expr,
  400.      simpleExpr,  and  term use {...} optional braces when (...)* clo-
  401.      sure should be used; e.g.
  402.  
  403. term    : factor {("|"/"| Div | Mod | And ) factor} ;
  404.  
  405. should be
  406.  
  407. term    : factor (("|"/"| Div | Mod | And ) factor)* ;
  408.  
  409.  
  410. (18) Chris Song, dsong@ncsa.uiuc.edu, National Center for Supercomput-
  411.      ing Applications; found this bug:
  412.  
  413. line 797 of antlr/misc.c:
  414.         p->ntype<=NumJuncTypes ...
  415. should be         NumNodeTypes
  416.  
  417.  
  418. (19) Chris Song, dsong@ncsa.uiuc.edu, National Center for Supercomput-
  419.      ing Applications; found this bug:
  420.  
  421. antlr/lex.c: line 52-57 of genLexDescr
  422. The first node in the link list LexActions is a sentinal (see
  423. list_add()). So it should be skipped. The correction is as follows:
  424.     if (LexActions != NULL)
  425.     {
  426.         for (p = LexActions->next; p!=NULL; p=p->next)
  427.         {
  428.         ...
  429.         }
  430.  
  431.  
  432.  
  433.                                                                 Page 7
  434.  
  435.                                                                  PCCTS
  436.  
  437.  
  438.     }
  439.  
  440.  
  441. (20) Chris Song, dsong@ncsa.uiuc.edu, National Center for Supercomput-
  442.      ing Applications; found this bug:
  443.  
  444. dlg/automata.c: line 124
  445.         last_done = NFA_NO(d_state);
  446. The NFA_NO should be DFA_NO?
  447.  
  448.  
  449. (21) LL(k) grammar analysis didn't make mucho copies of  EOF  when  it
  450.      needed to:
  451.  
  452. type    :   type_name
  453.     |   {class_name} type_name
  454.     ;
  455.  
  456. type_name: ID ;
  457.  
  458. class_name: ID ;
  459.  
  460. First alternative should see ( ID ( @ @ ) ), not ( ID @ ).
  461.  
  462. Also, bug in left_factor: ID ( ID ( @ @ ) became ID not ( ID ( @  @  )
  463. ).
  464.  
  465. Terence
  466.  
  467.  
  468. (22) DLG generated spurious crap upon bad argument lists such as  "DLG
  469.      -j".
  470.  
  471.  
  472. (23) ANTLR's -p option to print out a grammar without  actions  had  a
  473.      bug  that  did  not  print  alternative  '|'  operators for {...}
  474.      subrules.  In addition, this option  has  been  improved  to  not
  475.      print an extra level of (...) for rules.
  476.  
  477.  
  478. (24) A bug in set_dif() of set.c  caused  DLG  to  generate  incorrect
  479.      scanners.   When  set_dif()  had  the empty set subtracted from a
  480.      non-empty set,  it  incorrectly  returned  an  empty  set.   This
  481.      prevented the DLG generating correct code for [] and ~[].
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.                                                                 Page 8
  496.  
  497.  
  498.