Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  btoi.y
Language: C/C++
Code:

%{ 
  /* Definition section */
  #include<stdio.h> 
  #include<stdlib.h> 
  void yyerror(char *s); 
%} 
%token ZERO ONE 
  
/* Rule Section */
%% 
N: L {printf("\n%d", $$);} 
L: L B {$$=$1*2+$2;} 
| B {$$=$1;} 
B:ZERO {$$=$1;} 
|ONE {$$=$1;}; 
%% 
  
//driver code  
int main() 

 while(yyparse()); 

  
yyerror(char *s) 

 fprintf(stdout, "\n%s", s); 

  
Comments: