🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #753

cutting down shift/reduce conflicts in expread.y

#753
From: alverson
Date: Fri, 14 Apr 1989 20:54
97 lines
2818 bytes
You can cut the S/R conflicts in expread.y down to 1 (and leave the
reduce/reduce conflicts at 1) by adding a few precedence rules.
Here are diffs from expread.y in gdb 3.1.2

Bob Alverson (alverson@decwrl.dec.com)

*** src/expread.y	Tue Jan 17 11:30:36 1989
--- expread.y	Fri Apr 14 13:33:05 1989
***************
*** 139,144
  %left ','
  %left ABOVE_COMMA
  %right '=' ASSIGN_MODIFY
  %left OR
  %left AND
  %left '|'

--- 139,145 -----
  %left ','
  %left ABOVE_COMMA
  %right '=' ASSIGN_MODIFY
+ %right '?'
  %left OR
  %left AND
  %left '|'
***************
*** 151,157
  %left '*' '/' '%'
  %left '@'
  %right UNARY INCREMENT DECREMENT
! %right ARROW '.' '['
  %left COLONCOLON
  
  %%

--- 152,158 -----
  %left '*' '/' '%'
  %left '@'
  %right UNARY INCREMENT DECREMENT
! %right ARROW '.' '[' '('
  %left COLONCOLON
  
  %%
***************
*** 232,238
  			/* This is to save the value of arglist_len
  			   being accumulated by an outer function call.  */
  			{ start_arglist (); }
! 		arglist ')'
  			{ write_exp_elt_opcode (OP_FUNCALL);
  			  write_exp_elt_longcst (end_arglist ());
  			  write_exp_elt_opcode (OP_FUNCALL); }

--- 233,239 -----
  			/* This is to save the value of arglist_len
  			   being accumulated by an outer function call.  */
  			{ start_arglist (); }
! 		arglist ')'	%prec ARROW
  			{ write_exp_elt_opcode (OP_FUNCALL);
  			  write_exp_elt_longcst (end_arglist ());
  			  write_exp_elt_opcode (OP_FUNCALL); }
***************
*** 343,349
  			{ write_exp_elt_opcode (BINOP_OR); }
  	;
  
! exp	:	exp '?' exp ':' exp
  			{ write_exp_elt_opcode (TERNOP_COND); }
  	;
  			  

--- 344,350 -----
  			{ write_exp_elt_opcode (BINOP_OR); }
  	;
  
! exp	:	exp '?' exp ':' exp	%prec '?'
  			{ write_exp_elt_opcode (TERNOP_COND); }
  	;
  			  
***************
*** 399,405
  			  write_exp_elt_opcode (OP_INTERNALVAR); }
  	;
  
! exp	:	SIZEOF '(' type ')'
  			{ write_exp_elt_opcode (OP_LONG);
  			  write_exp_elt_type (builtin_type_int);
  			  write_exp_elt_longcst ((long) TYPE_LENGTH ($3));

--- 400,406 -----
  			  write_exp_elt_opcode (OP_INTERNALVAR); }
  	;
  
! exp	:	SIZEOF '(' type ')'	%prec UNARY
  			{ write_exp_elt_opcode (OP_LONG);
  			  write_exp_elt_type (builtin_type_int);
  			  write_exp_elt_longcst ((long) TYPE_LENGTH ($3));
Technical Details
Message-ID: <ALVERSON.89Apr14135408@mopar.stars.flab.Fujitsu.JUNET>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!alverson

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!alverson
From: alverson@decwrl.dec.com (alverson)
Newsgroups: gnu.gdb.bug
Subject: cutting down shift/reduce conflicts in expread.y
Message-ID: <ALVERSON.89Apr14135408@mopar.stars.flab.Fujitsu.JUNET>
Date: 14 Apr 89 20:54:08 GMT
Sender: alverson@decwrl.dec.com
Distribution: gnu
Organization: DEC Western Research Lab
Lines: 97