From: "Göran Halfvarson" Newsgroups: comp.os.msdos.djgpp Subject: Re: Bison optionality Date: 11 Feb 1997 03:12:35 GMT Organization: IGL Lines: 41 Message-ID: <01bc17c8$79608d00$7e58f482@nic.swip.net> References: <5dgqht$nu3 AT news00 DOT btx DOT dtag DOT de> NNTP-Posting-Host: dialup112-4-15.swipnet.se NNTP-Posting-User: s-12716 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp I am not very experienced in Bison or Yacc programming but this works fine for me: ... | circle expression expression expression opt_radius {circle($2, $3, $4, $5);} opt_radius: /* empty is OK */ { return NULL; } | expression { return $1; } ; .... I think this is a standard technique. If anyone has a better approach I would be happy to learn. Hope this helps! /Göran goran AT igl DOT se Gunnar Beushausen wrote in article <5dgqht$nu3 AT news00 DOT btx DOT dtag DOT de>... > Hi there! > > Does anyone know how to implement optionality into a bison script? > I'm creating a command that's called "circle" with the arguments > x_position, y_position, radius and color. But i want color to be an > optional argumend. My current code looks like this > > | circle expression expression expression expression {circle();} > > But when i execute the code i can't leave out the last expression, > otherwise there would be a parse error. > > Can somebody help me please? > > --- > Gunnar Beushausen > GBeushausen AT t-online DOT de > http://www.hof.de/~gbasic >