Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %{
- void yyerror (char *s);
- #include <stdio.h>
- #include <stdlib.h>
- yydebug=1;
- %}
- %token BEGINT ENDT PROGRAM OUTPUT INPUT IDENTIFIER INT
- %%
- program : PROGRAM declaration_s BEGINT statement_s ENDT ';' {printf("This is a valid program.\n");
- exit(0);
- }
- ;
- declaration_s : type ':' IDENTIFIER declaration
- ;
- type : INT
- ;
- declaration : ',' IDENTIFIER declaration
- | ';'
- ;
- statement_s : assign_statement
- | output_statement
- | input_statement
- ;
- assign_statement : IDENTIFIER '=' expression ';'
- ;
- output_statement : OUTPUT IDENTIFIER declaration
- ;
- input_statement : INPUT IDENTIFIER declaration
- ;
- expression : expression '+' IDENTIFIER
- | IDENTIFIER
- ;
- %%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement