Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grammar bison(yacc) question

Status
Not open for further replies.

homeless

Programmer
Nov 6, 2001
20
CH
i try to catch the error position, and give out in an error File:


stmnts: primary_terminal exp '\n' {/* read something...*/ }
| primary_terminal error '\n' {/* give out the eror line for exp */; yyerrok;}
| primary_terminal exp error {/* give out the eror line for newline */; yyerrok;}

if i try to give out the errorline for primary_terminal by adding a new opition: error exp '\n' {/* give out the eror line for primary_terminal */; yyerrok;},
so caused the rule stmnts conflicts.

how will that be agreed?
 
You need to break it down further
Code:
stmnts:   primary_terminal experr '\n'      {/* read something...*/ }

experr: exp |
        error |
        exp error
I'm not sure if that will work - you may need to break that down even further.
 
thx xwb,

but this was not the answer of my question. think about an input statement like this one:
Code:
   if(x>y){...}
with the primary_terminal "if" and
Code:
   while(x>y){...}
with the primary_terminal "else"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top