[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GNU-COBOL] grammar



   From: Tim Underwood <TimU@hightouchinc.com>
   Date: Tue, 29 Jun 1999 12:07:25 -0500

   > I did a quick comparison between bison, byacc and btyacc, 
   > using the same
   > input grammar.
   > 
   > Byacc fared the best(not always, usually), with bison in second. The
   > problem with btyacc seems to be that while byacc and bison will output
   > errors then stop, btyacc will seg fault and core dump. 
   > 
   > As to specifically why it as a tendency to that, I do not 
   > know. At the time
   > I had no wish to track down the problem.
   > 

   It's got to be a stack problem.  From what I read about btyacc, it starts
   "hunting" other possible solutions, probably through recursion.  There isn't
   a test to make sure it isn't going too deep.  I have NOT looked at the code,
   but it should probably have a counter/check and not go more than <n> levels
   deep.  It continues, and chews up the stack, thus causing the seg fault.

   BTW, we had some problems here with power, and I seem to have lost the email
   someone sent that gave the location of the source, etc.  Could someone
   resend this please?

   Thanx. 

You just need to tell BtYacc where to stop when doing trial parse.
YYVALID embedded in [] rule is used for this.

If BtYacc is not told to stop, it is possible that overflow would
occur.

This is how it's done in our grammar:

            // Conflict #1: 2 SR.
            // lookahead 1 is not enough to distuinguish between
            // PERFORM a OF b TIMES     and
            // PERFORM a OF b MOVE
            // Fixed by backtracking.
          | RW_PERFORM proc_name_thru_name perform_tail [YYVALID; /*conflict #1*/] 
            { $$ = new SctExprOper(STMT_PERFORM_PROC,$2,$3); }

            // ANSI-85
          | RW_PERFORM perform_tail [YYVALID; /*conflict #1*/]
            { $$ = new SctExprOper(STMT_PERFORM_BLOCK);
	      $$->SetArg(PRFB_REPEATERS, $2);
	    }
            _statements_inside 
            end_perform
            { $$ = $3;
	      $$->SetArg(PRFB_STATEMENTS,$4);
	      $$->SetArg(PRFB_END_PERFORM,$5);
	    }
  
............

perform_tail:  
              {$$ = new SctNullNode();}
            | ident_liter RW_TIMES 
              {$$ = new SctExprOper(EX_PERF_TIMES,$1);}
            | perform_test RW_UNTIL condition
              {$$ = new SctExprOper(EX_PERF_UNTIL,$1,$3);}
            | perform_test RW_VARYING variations
              {$$ = new SctExprOper(EX_PERF_VARYING,$1,$3);}
            ;

Regards,
Vadim Maslov

--
This message was sent through the gnu-cobol mailing list.  To remove yourself
from this mailing list, send a message to majordomo@acm.cs.umr.edu with the
words "unsubscribe gnu-cobol" in the message body.  For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@acm.cs.umr.edu.